aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Cullmann <cullmann@kde.org>2014-01-23 11:33:31 (GMT)
committerChristoph Cullmann <cullmann@kde.org>2014-01-23 11:33:31 (GMT)
commit5ca1a06dc50572d0ac44d71a1d9a0ea084f58bd6 (patch)
tree28412f50691aeae9acca7e5e19e8fc0529046e71
parentbaf33965718f20785f3ed073a910b5fe6e51d281 (diff)
kdelibs coding style, like ktexteditor, astyle-kdelibs for the win
-rw-r--r--kate/app/kateapp.cpp546
-rw-r--r--kate/app/kateapp.h143
-rw-r--r--kate/app/kateappadaptor.cpp92
-rw-r--r--kate/app/kateappadaptor.h41
-rw-r--r--kate/app/kateappcommands.cpp97
-rw-r--r--kate/app/kateappcommands.h26
-rw-r--r--kate/app/kateconfigdialog.cpp616
-rw-r--r--kate/app/kateconfigdialog.h40
-rw-r--r--kate/app/kateconfigplugindialogpage.cpp105
-rw-r--r--kate/app/kateconfigplugindialogpage.h21
-rw-r--r--kate/app/katedocmanager.cpp888
-rw-r--r--kate/app/katedocmanager.h110
-rw-r--r--kate/app/katemainwindow.cpp1379
-rw-r--r--kate/app/katemainwindow.h328
-rw-r--r--kate/app/katemdi.cpp1219
-rw-r--r--kate/app/katemdi.h768
-rw-r--r--kate/app/katemwmodonhddialog.cpp477
-rw-r--r--kate/app/katemwmodonhddialog.h21
-rw-r--r--kate/app/katepluginmanager.cpp442
-rw-r--r--kate/app/katepluginmanager.h48
-rw-r--r--kate/app/katequickopen.cpp237
-rw-r--r--kate/app/katequickopen.h59
-rw-r--r--kate/app/katerunninginstanceinfo.cpp68
-rw-r--r--kate/app/katerunninginstanceinfo.h79
-rw-r--r--kate/app/katesavemodifieddialog.cpp368
-rw-r--r--kate/app/katesavemodifieddialog.h15
-rw-r--r--kate/app/katetabbar.cpp18
-rw-r--r--kate/app/katetabbar.h1
-rw-r--r--kate/app/katetabbutton.cpp2
-rw-r--r--kate/app/katetabbutton.h2
-rw-r--r--kate/app/kateviewmanager.cpp1423
-rw-r--r--kate/app/kateviewmanager.h180
-rw-r--r--kate/app/kateviewspace.cpp475
-rw-r--r--kate/app/kateviewspace.h46
-rw-r--r--kate/app/katewaiter.h40
-rw-r--r--kate/app/main.cpp702
-rw-r--r--kate/autotests/session_manager_test.cpp127
-rw-r--r--kate/autotests/session_manager_test.h7
-rw-r--r--kate/autotests/session_test.cpp131
-rw-r--r--kate/autotests/session_test.h7
-rw-r--r--kate/autotests/sessions_action_test.cpp71
-rw-r--r--kate/autotests/sessions_action_test.h7
-rw-r--r--kate/session/katesession.cpp81
-rw-r--r--kate/session/katesession.h27
-rw-r--r--kate/session/katesessionchooser.cpp218
-rw-r--r--kate/session/katesessionchooser.h31
-rw-r--r--kate/session/katesessionchooseritem.h18
-rw-r--r--kate/session/katesessionmanagedialog.cpp211
-rw-r--r--kate/session/katesessionmanagedialog.h25
-rw-r--r--kate/session/katesessionmanager.cpp655
-rw-r--r--kate/session/katesessionmanager.h29
-rw-r--r--kate/session/katesessionopendialog.cpp98
-rw-r--r--kate/session/katesessionopendialog.h21
-rw-r--r--kate/session/katesessionsaction.cpp55
-rw-r--r--kate/session/katesessionsaction.h12
55 files changed, 6466 insertions, 6487 deletions
diff --git a/kate/app/kateapp.cpp b/kate/app/kateapp.cpp
index f4010c4..99b2ae5 100644
--- a/kate/app/kateapp.cpp
+++ b/kate/app/kateapp.cpp
@@ -46,389 +46,385 @@ KateApp *KateApp::s_self = 0;
Q_LOGGING_CATEGORY(LOG_KATE, "kate")
KateApp::KateApp(const QCommandLineParser &args)
- : m_args (args)
- , m_wrapper (new KTextEditor::Application (this))
+ : m_args(args)
+ , m_wrapper(new KTextEditor::Application(this))
{
- s_self = this;
-
- // doc man
- m_docManager = new KateDocManager (this);
-
- // init all normal plugins
- m_pluginManager = new KatePluginManager (this);
-
- // session manager up
- m_sessionManager = new KateSessionManager (this);
-
- // dbus
- m_adaptor = new KateAppAdaptor( this );
-
- m_appCommands = KateAppCommands::self();
-
- /**
- * re-route some signals to application wrapper
- */
- connect (m_docManager, SIGNAL(documentCreated(KTextEditor::Document*)), m_wrapper, SIGNAL(documentCreated(KTextEditor::Document*)));
- connect (m_docManager, SIGNAL(documentWillBeDeleted(KTextEditor::Document*)), m_wrapper, SIGNAL(documentWillBeDeleted(KTextEditor::Document*)));
- connect (m_docManager, SIGNAL(documentDeleted(KTextEditor::Document*)), m_wrapper, SIGNAL(documentDeleted(KTextEditor::Document*)));
- connect (m_docManager, SIGNAL(aboutToCreateDocuments()), m_wrapper, SIGNAL(aboutToCreateDocuments()));
- connect (m_docManager, SIGNAL(documentsCreated(QList<KTextEditor::Document*>)), m_wrapper, SIGNAL(documentsCreated(QList<KTextEditor::Document*>)));
+ s_self = this;
+
+ // doc man
+ m_docManager = new KateDocManager(this);
+
+ // init all normal plugins
+ m_pluginManager = new KatePluginManager(this);
+
+ // session manager up
+ m_sessionManager = new KateSessionManager(this);
+
+ // dbus
+ m_adaptor = new KateAppAdaptor(this);
+
+ m_appCommands = KateAppCommands::self();
+
+ /**
+ * re-route some signals to application wrapper
+ */
+ connect(m_docManager, SIGNAL(documentCreated(KTextEditor::Document*)), m_wrapper, SIGNAL(documentCreated(KTextEditor::Document*)));
+ connect(m_docManager, SIGNAL(documentWillBeDeleted(KTextEditor::Document*)), m_wrapper, SIGNAL(documentWillBeDeleted(KTextEditor::Document*)));
+ connect(m_docManager, SIGNAL(documentDeleted(KTextEditor::Document*)), m_wrapper, SIGNAL(documentDeleted(KTextEditor::Document*)));
+ connect(m_docManager, SIGNAL(aboutToCreateDocuments()), m_wrapper, SIGNAL(aboutToCreateDocuments()));
+ connect(m_docManager, SIGNAL(documentsCreated(QList<KTextEditor::Document*>)), m_wrapper, SIGNAL(documentsCreated(QList<KTextEditor::Document*>)));
}
-KateApp::~KateApp ()
+KateApp::~KateApp()
{
- // unregister...
- m_adaptor->emitExiting ();
- QDBusConnection::sessionBus().unregisterObject( QStringLiteral("/MainApplication") );
- delete m_adaptor;
+ // unregister...
+ m_adaptor->emitExiting();
+ QDBusConnection::sessionBus().unregisterObject(QStringLiteral("/MainApplication"));
+ delete m_adaptor;
- // l8r, app commands
- delete m_appCommands;
+ // l8r, app commands
+ delete m_appCommands;
- // cu session manager
- delete m_sessionManager;
+ // cu session manager
+ delete m_sessionManager;
- // cu plugin manager
- delete m_pluginManager;
+ // cu plugin manager
+ delete m_pluginManager;
- // delete this now, or we crash
- delete m_docManager;
+ // delete this now, or we crash
+ delete m_docManager;
}
-KateApp *KateApp::self ()
+KateApp *KateApp::self()
{
- return s_self;
+ return s_self;
}
-bool KateApp::init ()
+bool KateApp::init()
{
- qCDebug(LOG_KATE) << "Setting KATE_PID: '" << QCoreApplication::applicationPid() << "'";
- ::setenv( "KATE_PID", QString::fromLatin1("%1").arg(QCoreApplication::applicationPid()).toLatin1().constData(), 1 );
-
- // handle restore different
- if (qApp->isSessionRestored())
- {
- restoreKate ();
- }
- else
- {
- // let us handle our command line args and co ;)
- // we can exit here if session chooser decides
- if (!startupKate ())
- {
- qCDebug(LOG_KATE) << "startupKate returned false";
- return false;
+ qCDebug(LOG_KATE) << "Setting KATE_PID: '" << QCoreApplication::applicationPid() << "'";
+ ::setenv("KATE_PID", QString::fromLatin1("%1").arg(QCoreApplication::applicationPid()).toLatin1().constData(), 1);
+
+ // handle restore different
+ if (qApp->isSessionRestored()) {
+ restoreKate();
+ } else {
+ // let us handle our command line args and co ;)
+ // we can exit here if session chooser decides
+ if (!startupKate()) {
+ qCDebug(LOG_KATE) << "startupKate returned false";
+ return false;
+ }
}
- }
- // application dbus interface
- QDBusConnection::sessionBus().registerObject( QStringLiteral("/MainApplication"), this );
- return true;
+ // application dbus interface
+ QDBusConnection::sessionBus().registerObject(QStringLiteral("/MainApplication"), this);
+ return true;
}
-void KateApp::restoreKate ()
+void KateApp::restoreKate()
{
- KConfig *sessionConfig = KConfigGui::sessionConfig();
-
- // activate again correct session!!!
- QString lastSession (sessionConfig->group("General").readEntry ("Last Session", QString()));
- sessionManager()->activateSession(lastSession, false, false);
-
- // plugins
- KatePluginManager::self ()->loadConfig (sessionConfig);
-
- // restore the files we need
- m_docManager->restoreDocumentList (sessionConfig);
-
- // restore all windows ;)
- for (int n = 1; KMainWindow::canBeRestored(n); n++)
- newMainWindow(sessionConfig, QString::number(n));
-
- // oh, no mainwindow, create one, should not happen, but make sure ;)
- if (mainWindowsCount() == 0)
- newMainWindow ();
+ KConfig *sessionConfig = KConfigGui::sessionConfig();
+
+ // activate again correct session!!!
+ QString lastSession(sessionConfig->group("General").readEntry("Last Session", QString()));
+ sessionManager()->activateSession(lastSession, false, false);
+
+ // plugins
+ KatePluginManager::self()->loadConfig(sessionConfig);
+
+ // restore the files we need
+ m_docManager->restoreDocumentList(sessionConfig);
+
+ // restore all windows ;)
+ for (int n = 1; KMainWindow::canBeRestored(n); n++) {
+ newMainWindow(sessionConfig, QString::number(n));
+ }
+
+ // oh, no mainwindow, create one, should not happen, but make sure ;)
+ if (mainWindowsCount() == 0) {
+ newMainWindow();
+ }
}
-bool KateApp::startupKate ()
+bool KateApp::startupKate()
{
- // user specified session to open
- if (m_args.isSet (QStringLiteral("start")))
- {
- sessionManager()->activateSession (m_args.value(QStringLiteral("start")), false);
- }
- else if (m_args.isSet(QStringLiteral("startanon")))
- {
- sessionManager()->activateAnonymousSession();
- }
- else if (!m_args.isSet( QStringLiteral("stdin") ) && (m_args.positionalArguments().count() == 0)) // only start session if no files specified
- {
- // let the user choose session if possible
- if (!sessionManager()->chooseSession ())
- {
- qCDebug(LOG_KATE) << "chooseSession returned false, exiting";
- // we will exit kate now, notify the rest of the world we are done
+ // user specified session to open
+ if (m_args.isSet(QStringLiteral("start"))) {
+ sessionManager()->activateSession(m_args.value(QStringLiteral("start")), false);
+ } else if (m_args.isSet(QStringLiteral("startanon"))) {
+ sessionManager()->activateAnonymousSession();
+ } else if (!m_args.isSet(QStringLiteral("stdin")) && (m_args.positionalArguments().count() == 0)) { // only start session if no files specified
+ // let the user choose session if possible
+ if (!sessionManager()->chooseSession()) {
+ qCDebug(LOG_KATE) << "chooseSession returned false, exiting";
+ // we will exit kate now, notify the rest of the world we are done
#ifdef Q_WS_X11
- KStartupInfo::appStarted (startupId());
+ KStartupInfo::appStarted(startupId());
#endif
- return false;
+ return false;
+ }
+ } else {
+ sessionManager()->activateAnonymousSession();
+ }
+
+ // oh, no mainwindow, create one, should not happen, but make sure ;)
+ if (mainWindowsCount() == 0) {
+ newMainWindow();
}
- }
- else
- {
- sessionManager()->activateAnonymousSession();
- }
-
- // oh, no mainwindow, create one, should not happen, but make sure ;)
- if (mainWindowsCount() == 0)
- newMainWindow ();
-
- // notify about start
+
+ // notify about start
#ifdef Q_WS_X11
- KStartupInfo::setNewStartupId( activeKateMainWindow(), startupId());
+ KStartupInfo::setNewStartupId(activeKateMainWindow(), startupId());
#endif
-
- QTextCodec *codec = m_args.isSet(QStringLiteral("encoding")) ? QTextCodec::codecForName(m_args.value(QStringLiteral("encoding")).toUtf8()) : 0;
- bool tempfileSet = m_args.isSet(QStringLiteral("tempfile"));
-
- KTextEditor::Document *doc = 0;
- const QString codec_name = codec ? QString::fromLatin1(codec->name()) : QString();
-
- QList<QUrl> urls;
- Q_FOREACH (const QString positionalArgument, m_args.positionalArguments())
- {
- QUrl url;
-
- // convert to an url
- QRegExp withProtocol(QStringLiteral("^[a-zA-Z]+:")); // TODO: remove after Qt supports this on its own
- if (withProtocol.indexIn(positionalArgument) == 0) {
- url = QUrl::fromUserInput(positionalArgument);
- } else {
- const QString path = QDir::current().absoluteFilePath(positionalArgument);
- url = QUrl::fromLocalFile(path);
+
+ QTextCodec *codec = m_args.isSet(QStringLiteral("encoding")) ? QTextCodec::codecForName(m_args.value(QStringLiteral("encoding")).toUtf8()) : 0;
+ bool tempfileSet = m_args.isSet(QStringLiteral("tempfile"));
+
+ KTextEditor::Document *doc = 0;
+ const QString codec_name = codec ? QString::fromLatin1(codec->name()) : QString();
+
+ QList<QUrl> urls;
+ Q_FOREACH(const QString positionalArgument, m_args.positionalArguments()) {
+ QUrl url;
+
+ // convert to an url
+ QRegExp withProtocol(QStringLiteral("^[a-zA-Z]+:")); // TODO: remove after Qt supports this on its own
+ if (withProtocol.indexIn(positionalArgument) == 0) {
+ url = QUrl::fromUserInput(positionalArgument);
+ } else {
+ const QString path = QDir::current().absoluteFilePath(positionalArgument);
+ url = QUrl::fromLocalFile(path);
+ }
+
+ // this file is no local dir, open it, else warn
+ bool noDir = !url.isLocalFile() || !QFileInfo(url.toLocalFile()).isDir();
+
+ if (noDir) {
+ urls << url;
+ } else {
+ KMessageBox::sorry(activeKateMainWindow(),
+ i18n("The file '%1' could not be opened: it is not a normal file, it is a folder.", url.toString()));
+ }
}
- // this file is no local dir, open it, else warn
- bool noDir = !url.isLocalFile() || !QFileInfo (url.toLocalFile()).isDir();
+ doc = activeKateMainWindow()->viewManager()->openUrls(urls, codec_name, tempfileSet);
- if (noDir) {
- urls << url;
- } else {
- KMessageBox::sorry( activeKateMainWindow(),
- i18n("The file '%1' could not be opened: it is not a normal file, it is a folder.", url.toString()) );
+ // handle stdin input
+ if (m_args.isSet(QStringLiteral("stdin"))) {
+ QTextStream input(stdin, QIODevice::ReadOnly);
+
+ // set chosen codec
+ if (codec) {
+ input.setCodec(codec);
+ }
+
+ QString line;
+ QString text;
+
+ do {
+ line = input.readLine();
+ text.append(line + QLatin1Char('\n'));
+ } while (!line.isNull());
+
+ openInput(text);
+ } else if (doc) {
+ activeKateMainWindow()->viewManager()->activateView(doc);
}
- }
- doc = activeKateMainWindow()->viewManager()->openUrls(urls, codec_name, tempfileSet);
+ if (activeKateMainWindow()->viewManager()->viewCount() == 0) {
+ activeKateMainWindow()->viewManager()->activateView(m_docManager->document(0));
+ }
- // handle stdin input
- if( m_args.isSet( QStringLiteral("stdin") ) )
- {
- QTextStream input(stdin, QIODevice::ReadOnly);
+ int line = 0;
+ int column = 0;
+ bool nav = false;
- // set chosen codec
- if (codec)
- input.setCodec (codec);
+ if (m_args.isSet(QStringLiteral("line"))) {
+ line = m_args.value(QStringLiteral("line")).toInt() - 1;
+ nav = true;
+ }
- QString line;
- QString text;
+ if (m_args.isSet(QStringLiteral("column"))) {
+ column = m_args.value(QStringLiteral("column")).toInt() - 1;
+ nav = true;
+ }
- do
- {
- line = input.readLine();
- text.append( line + QLatin1Char('\n') );
+ if (nav && activeKateMainWindow()->viewManager()->activeView()) {
+ activeKateMainWindow()->viewManager()->activeView()->setCursorPosition(KTextEditor::Cursor(line, column));
}
- while( !line.isNull() );
-
- openInput (text);
- }
- else if ( doc )
- activeKateMainWindow()->viewManager()->activateView( doc );
-
- if ( activeKateMainWindow()->viewManager()->viewCount () == 0 )
- activeKateMainWindow()->viewManager()->activateView(m_docManager->document (0));
-
- int line = 0;
- int column = 0;
- bool nav = false;
-
- if (m_args.isSet (QStringLiteral("line")))
- {
- line = m_args.value (QStringLiteral("line")).toInt() - 1;
- nav = true;
- }
-
- if (m_args.isSet (QStringLiteral("column")))
- {
- column = m_args.value (QStringLiteral("column")).toInt() - 1;
- nav = true;
- }
-
- if (nav && activeKateMainWindow()->viewManager()->activeView ())
- activeKateMainWindow()->viewManager()->activeView ()->setCursorPosition (KTextEditor::Cursor (line, column));
-
- activeKateMainWindow()->setAutoSaveSettings();
-
- qCDebug(LOG_KATE) << "KateApplication::init finished successful";
- return true;
+
+ activeKateMainWindow()->setAutoSaveSettings();
+
+ qCDebug(LOG_KATE) << "KateApplication::init finished successful";
+ return true;
}
-void KateApp::shutdownKate (KateMainWindow *win)
+void KateApp::shutdownKate(KateMainWindow *win)
{
- if (!win->queryClose_internal())
- return;
+ if (!win->queryClose_internal()) {
+ return;
+ }
- sessionManager()->saveActiveSession(true);
+ sessionManager()->saveActiveSession(true);
- // cu main windows
- while (!m_mainWindows.isEmpty())
- {
- // mainwindow itself calls KateApp::removeMainWindow(this)
- delete m_mainWindows[0];
- }
+ // cu main windows
+ while (!m_mainWindows.isEmpty()) {
+ // mainwindow itself calls KateApp::removeMainWindow(this)
+ delete m_mainWindows[0];
+ }
- QApplication::quit ();
+ QApplication::quit();
}
KatePluginManager *KateApp::pluginManager()
{
- return m_pluginManager;
+ return m_pluginManager;
}
-KateDocManager *KateApp::documentManager ()
+KateDocManager *KateApp::documentManager()
{
- return m_docManager;
+ return m_docManager;
}
-KateSessionManager *KateApp::sessionManager ()
+KateSessionManager *KateApp::sessionManager()
{
- return m_sessionManager;
+ return m_sessionManager;
}
-bool KateApp::openUrl (const QUrl &url, const QString &encoding, bool isTempFile)
+bool KateApp::openUrl(const QUrl &url, const QString &encoding, bool isTempFile)
{
- return openDocUrl(url,encoding,isTempFile);
+ return openDocUrl(url, encoding, isTempFile);
}
-KTextEditor::Document* KateApp::openDocUrl (const QUrl &url, const QString &encoding, bool isTempFile)
+KTextEditor::Document *KateApp::openDocUrl(const QUrl &url, const QString &encoding, bool isTempFile)
{
- KateMainWindow *mainWindow = activeKateMainWindow ();
+ KateMainWindow *mainWindow = activeKateMainWindow();
- if (!mainWindow)
- return 0;
+ if (!mainWindow) {
+ return 0;
+ }
+
+ QTextCodec *codec = encoding.isEmpty() ? 0 : QTextCodec::codecForName(encoding.toLatin1());
+
+ // this file is no local dir, open it, else warn
+ bool noDir = !url.isLocalFile() || !QFileInfo(url.toLocalFile()).isDir();
- QTextCodec *codec = encoding.isEmpty() ? 0 : QTextCodec::codecForName(encoding.toLatin1());
-
- // this file is no local dir, open it, else warn
- bool noDir = !url.isLocalFile() || !QFileInfo (url.toLocalFile()).isDir();
-
- KTextEditor::Document *doc=0;
-
- if (noDir)
- {
- // open a normal file
- if (codec)
- doc=mainWindow->viewManager()->openUrl( url, QString::fromLatin1(codec->name()), true, isTempFile);
- else
- doc=mainWindow->viewManager()->openUrl( url, QString(), true, isTempFile );
- }
- else
- KMessageBox::sorry( mainWindow,
- i18n("The file '%1' could not be opened: it is not a normal file, it is a folder.", url.url()) );
-
- return doc;
+ KTextEditor::Document *doc = 0;
+
+ if (noDir) {
+ // open a normal file
+ if (codec) {
+ doc = mainWindow->viewManager()->openUrl(url, QString::fromLatin1(codec->name()), true, isTempFile);
+ } else {
+ doc = mainWindow->viewManager()->openUrl(url, QString(), true, isTempFile);
+ }
+ } else
+ KMessageBox::sorry(mainWindow,
+ i18n("The file '%1' could not be opened: it is not a normal file, it is a folder.", url.url()));
+
+ return doc;
}
-bool KateApp::setCursor (int line, int column)
+bool KateApp::setCursor(int line, int column)
{
- KateMainWindow *mainWindow = activeKateMainWindow ();
+ KateMainWindow *mainWindow = activeKateMainWindow();
- if (!mainWindow)
- return false;
+ if (!mainWindow) {
+ return false;
+ }
- if (mainWindow->viewManager()->activeView ())
- mainWindow->viewManager()->activeView ()->setCursorPosition (KTextEditor::Cursor (line, column));
+ if (mainWindow->viewManager()->activeView()) {
+ mainWindow->viewManager()->activeView()->setCursorPosition(KTextEditor::Cursor(line, column));
+ }
- return true;
+ return true;
}
-bool KateApp::openInput (const QString &text)
+bool KateApp::openInput(const QString &text)
{
- activeKateMainWindow()->viewManager()->openUrl( QUrl(), QString(), true );
+ activeKateMainWindow()->viewManager()->openUrl(QUrl(), QString(), true);
- if (!activeKateMainWindow()->viewManager()->activeView ())
- return false;
+ if (!activeKateMainWindow()->viewManager()->activeView()) {
+ return false;
+ }
- KTextEditor::Document *doc = activeKateMainWindow()->viewManager()->activeView ()->document();
+ KTextEditor::Document *doc = activeKateMainWindow()->viewManager()->activeView()->document();
- if (!doc)
- return false;
+ if (!doc) {
+ return false;
+ }
- return doc->setText (text);
+ return doc->setText(text);
}
-KateMainWindow *KateApp::newMainWindow (KConfig *sconfig_, const QString &sgroup_)
+KateMainWindow *KateApp::newMainWindow(KConfig *sconfig_, const QString &sgroup_)
{
- KConfig *sconfig = sconfig_ ? sconfig_ : KSharedConfig::openConfig().data();
- QString sgroup = !sgroup_.isEmpty() ? sgroup_ : QStringLiteral("MainWindow0");
+ KConfig *sconfig = sconfig_ ? sconfig_ : KSharedConfig::openConfig().data();
+ QString sgroup = !sgroup_.isEmpty() ? sgroup_ : QStringLiteral("MainWindow0");
- KateMainWindow *mainWindow = new KateMainWindow (sconfig, sgroup);
- mainWindow->show ();
+ KateMainWindow *mainWindow = new KateMainWindow(sconfig, sgroup);
+ mainWindow->show();
- return mainWindow;
+ return mainWindow;
}
-void KateApp::addMainWindow (KateMainWindow *mainWindow)
+void KateApp::addMainWindow(KateMainWindow *mainWindow)
{
- m_mainWindows.push_back (mainWindow);
+ m_mainWindows.push_back(mainWindow);
}
-void KateApp::removeMainWindow (KateMainWindow *mainWindow)
+void KateApp::removeMainWindow(KateMainWindow *mainWindow)
{
- m_mainWindows.removeAll(mainWindow);
+ m_mainWindows.removeAll(mainWindow);
}
-KateMainWindow *KateApp::activeKateMainWindow ()
+KateMainWindow *KateApp::activeKateMainWindow()
{
- if (m_mainWindows.isEmpty())
- return 0;
+ if (m_mainWindows.isEmpty()) {
+ return 0;
+ }
- int n = m_mainWindows.indexOf (static_cast<KateMainWindow *>((static_cast<QApplication *>(QCoreApplication::instance ())->activeWindow())));
+ int n = m_mainWindows.indexOf(static_cast<KateMainWindow *>((static_cast<QApplication *>(QCoreApplication::instance())->activeWindow())));
- if (n < 0)
- n = 0;
+ if (n < 0) {
+ n = 0;
+ }
- return m_mainWindows[n];
+ return m_mainWindows[n];
}
-int KateApp::mainWindowsCount () const
+int KateApp::mainWindowsCount() const
{
- return m_mainWindows.size();
+ return m_mainWindows.size();
}
int KateApp::mainWindowID(KateMainWindow *window)
{
- for (int i = 0;i < m_mainWindows.size();i++)
- if (window == m_mainWindows[i]) return i;
- return -1;
+ for (int i = 0; i < m_mainWindows.size(); i++)
+ if (window == m_mainWindows[i]) {
+ return i;
+ }
+ return -1;
}
-KateMainWindow *KateApp::mainWindow (int n)
+KateMainWindow *KateApp::mainWindow(int n)
{
- if (n < m_mainWindows.size())
- return m_mainWindows[n];
+ if (n < m_mainWindows.size()) {
+ return m_mainWindows[n];
+ }
- return 0;
+ return 0;
}
-void KateApp::emitDocumentClosed(const QString& token)
+void KateApp::emitDocumentClosed(const QString &token)
{
- m_adaptor->emitDocumentClosed(token);
+ m_adaptor->emitDocumentClosed(token);
}
-KTextEditor::Plugin *KateApp::plugin (const QString &name)
+KTextEditor::Plugin *KateApp::plugin(const QString &name)
{
- return m_pluginManager->plugin (name);
+ return m_pluginManager->plugin(name);
}
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/app/kateapp.h b/kate/app/kateapp.h
index 5478b66..beb6b1f 100644
--- a/kate/app/kateapp.h
+++ b/kate/app/kateapp.h
@@ -39,7 +39,7 @@ class QCommandLineParser;
namespace KTextEditor
{
- class Document;
+class Document;
}
/**
@@ -53,67 +53,66 @@ class KATE_TESTS_EXPORT KateApp : public QObject
/**
* constructors & accessor to app object + plugin interface for it
*/
- public:
+public:
/**
* application constructor
*/
- KateApp (const QCommandLineParser &args);
-
+ KateApp(const QCommandLineParser &args);
+
/**
* get kate inited
* @return false, if application should exit
*/
- bool init ();
+ bool init();
/**
* application destructor
*/
- ~KateApp ();
+ ~KateApp();
/**
* static accessor to avoid casting ;)
* @return app instance
*/
- static KateApp *self ();
-
+ static KateApp *self();
+
/**
* KTextEditor::Application wrapper
* @return KTextEditor::Application wrapper.
*/
- KTextEditor::Application *wrapper ()
- {
- return m_wrapper;
+ KTextEditor::Application *wrapper() {
+ return m_wrapper;
}
/**
* kate init
*/
- private:
+private:
/**
* restore a old kate session
*/
- void restoreKate ();
+ void restoreKate();
/**
* try to start kate
* @return success, if false, kate should exit
*/
- bool startupKate ();
+ bool startupKate();
/**
* kate shutdown
*/
- public:
+public:
/**
* shutdown kate application
* @param win mainwindow which is used for dialogs
*/
- void shutdownKate (KateMainWindow *win);
+ void shutdownKate(KateMainWindow *win);
/**
* other accessors for global unique instances
*/
- public:
+public:
/**
* accessor to plugin manager
* @return plugin manager instance
@@ -124,66 +123,66 @@ class KATE_TESTS_EXPORT KateApp : public QObject
* accessor to document manager
* @return document manager instance
*/
- KateDocManager *documentManager ();
+ KateDocManager *documentManager();
/**
* accessor to session manager
* @return session manager instance
*/
- KateSessionManager *sessionManager ();
+ KateSessionManager *sessionManager();
/**
* window management
*/
- public:
+public:
/**
* create a new main window, use given config if any for restore
* @param sconfig session config object
* @param sgroup session group for this window
* @return new constructed main window
*/
- KateMainWindow *newMainWindow (KConfig *sconfig = 0, const QString &sgroup = QString());
+ KateMainWindow *newMainWindow(KConfig *sconfig = 0, const QString &sgroup = QString());
/**
* add the mainwindow given
* should be called in mainwindow constructor
* @param mainWindow window to remove
*/
- void addMainWindow (KateMainWindow *mainWindow);
+ void addMainWindow(KateMainWindow *mainWindow);
/**
* removes the mainwindow given, DOES NOT DELETE IT
* should be called in mainwindow destructor
* @param mainWindow window to remove
*/
- void removeMainWindow (KateMainWindow *mainWindow);
+ void removeMainWindow(KateMainWindow *mainWindow);
/**
* give back current active main window
* can only be 0 at app start or exit
* @return current active main window
*/
- KateMainWindow *activeKateMainWindow ();
+ KateMainWindow *activeKateMainWindow();
/**
* give back number of existing main windows
* @return number of main windows
*/
- int mainWindowsCount () const;
+ int mainWindowsCount() const;
/**
* give back the window you want
* @param n window index
* @return requested main window
*/
- KateMainWindow *mainWindow (int n);
+ KateMainWindow *mainWindow(int n);
int mainWindowID(KateMainWindow *window);
/**
* some stuff for the dcop API
*/
- public:
+public:
/**
* open url with given encoding
* used by kate if --use given
@@ -191,19 +190,19 @@ class KATE_TESTS_EXPORT KateApp : public QObject
* @param encoding encoding name
* @return success
*/
- bool openUrl (const QUrl &url, const QString &encoding, bool isTempFile);
+ bool openUrl(const QUrl &url, const QString &encoding, bool isTempFile);
+
+ KTextEditor::Document *openDocUrl(const QUrl &url, const QString &encoding, bool isTempFile);
+
+ void emitDocumentClosed(const QString &token);
- KTextEditor::Document* openDocUrl (const QUrl &url, const QString &encoding, bool isTempFile);
-
- void emitDocumentClosed(const QString& token);
-
/**
* position cursor in current active view
* @param line line to set
* @param column column to set
* @return success
*/
- bool setCursor (int line, int column);
+ bool setCursor(int line, int column);
/**
* helper to handle stdin input
@@ -211,45 +210,44 @@ class KATE_TESTS_EXPORT KateApp : public QObject
* @param text text to fill in the new doc/view
* @return success
*/
- bool openInput (const QString &text);
-
- //
- // KTextEditor::Application interface, called by wrappers via invokeMethod
- //
- public Q_SLOTS:
+ bool openInput(const QString &text);
+
+ //
+ // KTextEditor::Application interface, called by wrappers via invokeMethod
+ //
+public Q_SLOTS:
/**
* Get a list of all main windows.
* @return all main windows
*/
- QList<KTextEditor::MainWindow *> mainWindows ()
- {
- // assemble right list
- QList<KTextEditor::MainWindow *> windows;
- for (int i = 0; i < m_mainWindows.size(); ++i)
- windows.push_back (m_mainWindows[i]->wrapper());
- return windows;
+ QList<KTextEditor::MainWindow *> mainWindows() {
+ // assemble right list
+ QList<KTextEditor::MainWindow *> windows;
+ for (int i = 0; i < m_mainWindows.size(); ++i) {
+ windows.push_back(m_mainWindows[i]->wrapper());
+ }
+ return windows;
}
-
+
/**
* Accessor to the active main window.
* \return a pointer to the active mainwindow
*/
- KTextEditor::MainWindow *activeMainWindow ()
- {
- // either return wrapper or nullptr
- if (KateMainWindow *a = activeKateMainWindow ())
- return a->wrapper ();
- return nullptr;
+ KTextEditor::MainWindow *activeMainWindow() {
+ // either return wrapper or nullptr
+ if (KateMainWindow *a = activeKateMainWindow()) {
+ return a->wrapper();
+ }
+ return nullptr;
}
-
+
/**
* Get a list of all documents that are managed by the application.
* This might contain less documents than the editor has in his documents () list.
* @return all documents the application manages
*/
- QList<KTextEditor::Document *> documents ()
- {
- return m_docManager->documentList ();
+ QList<KTextEditor::Document *> documents() {
+ return m_docManager->documentList();
}
/**
@@ -258,9 +256,8 @@ class KATE_TESTS_EXPORT KateApp : public QObject
* \param url the document's URL
* \return the document with the given \p url or NULL, if none found
*/
- KTextEditor::Document *findUrl (const QUrl &url)
- {
- return m_docManager->findDocument (url);
+ KTextEditor::Document *findUrl(const QUrl &url) {
+ return m_docManager->findDocument(url);
}
/**
@@ -271,9 +268,8 @@ class KATE_TESTS_EXPORT KateApp : public QObject
* encoding will be guessed or the default encoding will be used.
* \return a pointer to the created document
*/
- KTextEditor::Document *openUrl (const QUrl &url, const QString &encoding = QString())
- {
- return m_docManager->openUrl (url, encoding);
+ KTextEditor::Document *openUrl(const QUrl &url, const QString &encoding = QString()) {
+ return m_docManager->openUrl(url, encoding);
}
/**
@@ -281,9 +277,8 @@ class KATE_TESTS_EXPORT KateApp : public QObject
* \param document the document to be closed
* \return \e true on success, otherwise \e false
*/
- bool closeDocument (KTextEditor::Document *document)
- {
- return m_docManager->closeDocument (document);
+ bool closeDocument(KTextEditor::Document *document) {
+ return m_docManager->closeDocument(document);
}
/**
@@ -293,9 +288,8 @@ class KATE_TESTS_EXPORT KateApp : public QObject
* \param documents list of documents to be closed
* \return \e true on success, otherwise \e false
*/
- bool closeDocuments (const QList<KTextEditor::Document *> &documents)
- {
- return m_docManager->closeDocumentList (documents);
+ bool closeDocuments(const QList<KTextEditor::Document *> &documents) {
+ return m_docManager->closeDocumentList(documents);
}
/**
@@ -303,14 +297,14 @@ class KATE_TESTS_EXPORT KateApp : public QObject
* \param name the plugin's name
* \return pointer to the plugin if a plugin with \p name is loaded, otherwise nullptr
*/
- KTextEditor::Plugin *plugin (const QString &name);
+ KTextEditor::Plugin *plugin(const QString &name);
- private:
+private:
/**
* Singleton instance
*/
static KateApp *s_self;
-
+
/**
* kate's command line args
*/
@@ -339,11 +333,11 @@ class KATE_TESTS_EXPORT KateApp : public QObject
/**
* known main windows
*/
- QList<KateMainWindow*> m_mainWindows;
+ QList<KateMainWindow *> m_mainWindows;
// various vim-inspired command line commands
KateAppCommands *m_appCommands;
-
+
/**
* Wrapper of application for KTextEditor
*/
@@ -352,5 +346,4 @@ class KATE_TESTS_EXPORT KateApp : public QObject
};
#endif
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/app/kateappadaptor.cpp b/kate/app/kateappadaptor.cpp
index 38b29a6..f589480 100644
--- a/kate/app/kateappadaptor.cpp
+++ b/kate/app/kateappadaptor.cpp
@@ -1,15 +1,15 @@
/* This file is part of the KDE project
Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
-
+
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
-
+
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
-
+
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
@@ -26,83 +26,87 @@
#include "katedebug.h"
#include <KWindowSystem>
-KateAppAdaptor::KateAppAdaptor (KateApp *app)
- : QDBusAbstractAdaptor( app )
- , m_app (app)
+KateAppAdaptor::KateAppAdaptor(KateApp *app)
+ : QDBusAbstractAdaptor(app)
+ , m_app(app)
{}
-void KateAppAdaptor::activate ()
+void KateAppAdaptor::activate()
{
- KateMainWindow *win = m_app->activeKateMainWindow();
- if (!win)
- return;
-
- win->show();
- win->activateWindow();
- win->raise();
-
- KWindowSystem::forceActiveWindow (win->winId ());
- KWindowSystem::raiseWindow (win->winId ());
- KWindowSystem::demandAttention (win->winId ());
+ KateMainWindow *win = m_app->activeKateMainWindow();
+ if (!win) {
+ return;
+ }
+
+ win->show();
+ win->activateWindow();
+ win->raise();
+
+ KWindowSystem::forceActiveWindow(win->winId());
+ KWindowSystem::raiseWindow(win->winId());
+ KWindowSystem::demandAttention(win->winId());
}
-bool KateAppAdaptor::openUrl (QString url, QString encoding)
+bool KateAppAdaptor::openUrl(QString url, QString encoding)
{
- return m_app->openUrl (QUrl(url), encoding, false);
+ return m_app->openUrl(QUrl(url), encoding, false);
}
-bool KateAppAdaptor::openUrl (QString url, QString encoding, bool isTempFile)
+bool KateAppAdaptor::openUrl(QString url, QString encoding, bool isTempFile)
{
- qCDebug(LOG_KATE) << "openURL";
+ qCDebug(LOG_KATE) << "openURL";
- return m_app->openUrl (QUrl(url), encoding, isTempFile);
+ return m_app->openUrl(QUrl(url), encoding, isTempFile);
}
//-----------
-QString KateAppAdaptor::tokenOpenUrl (QString url, QString encoding)
+QString KateAppAdaptor::tokenOpenUrl(QString url, QString encoding)
{
- KTextEditor::Document *doc=m_app->openDocUrl (QUrl(url), encoding, false);
- if (!doc) return QStringLiteral("ERROR");
- return QString::fromLatin1("%1").arg((qptrdiff)doc);
+ KTextEditor::Document *doc = m_app->openDocUrl(QUrl(url), encoding, false);
+ if (!doc) {
+ return QStringLiteral("ERROR");
+ }
+ return QString::fromLatin1("%1").arg((qptrdiff)doc);
}
-QString KateAppAdaptor::tokenOpenUrl (QString url, QString encoding, bool isTempFile)
+QString KateAppAdaptor::tokenOpenUrl(QString url, QString encoding, bool isTempFile)
{
- qCDebug(LOG_KATE) << "openURL";
- KTextEditor::Document *doc=m_app->openDocUrl (QUrl(url), encoding, isTempFile);
- if (!doc) return QStringLiteral("ERROR");
- return QString::fromLatin1("%1").arg((qptrdiff)doc);
+ qCDebug(LOG_KATE) << "openURL";
+ KTextEditor::Document *doc = m_app->openDocUrl(QUrl(url), encoding, isTempFile);
+ if (!doc) {
+ return QStringLiteral("ERROR");
+ }
+ return QString::fromLatin1("%1").arg((qptrdiff)doc);
}
//--------
-bool KateAppAdaptor::setCursor (int line, int column)
+bool KateAppAdaptor::setCursor(int line, int column)
{
- return m_app->setCursor (line, column);
+ return m_app->setCursor(line, column);
}
-bool KateAppAdaptor::openInput (QString text)
+bool KateAppAdaptor::openInput(QString text)
{
- return m_app->openInput (text);
+ return m_app->openInput(text);
}
-bool KateAppAdaptor::activateSession (QString session)
+bool KateAppAdaptor::activateSession(QString session)
{
- return m_app->sessionManager()->activateSession(session);
+ return m_app->sessionManager()->activateSession(session);
}
QString KateAppAdaptor::activeSession()
{
- return m_app->sessionManager()->activeSession()->name();
+ return m_app->sessionManager()->activeSession()->name();
}
-void KateAppAdaptor::emitExiting ()
+void KateAppAdaptor::emitExiting()
{
- emit exiting ();
+ emit exiting();
}
-void KateAppAdaptor::emitDocumentClosed(const QString& token)
+void KateAppAdaptor::emitDocumentClosed(const QString &token)
{
- documentClosed(token);
+ documentClosed(token);
}
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/app/kateappadaptor.h b/kate/app/kateappadaptor.h
index 02715e5..dd7ad10 100644
--- a/kate/app/kateappadaptor.h
+++ b/kate/app/kateappadaptor.h
@@ -29,16 +29,16 @@ class KateAppAdaptor : public QDBusAbstractAdaptor
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.kde.Kate.Application")
Q_PROPERTY(QString activeSession READ activeSession)
- public:
- KateAppAdaptor (KateApp *app);
+public:
+ KateAppAdaptor(KateApp *app);
/**
* emit the exiting signal
*/
- void emitExiting ();
- void emitDocumentClosed(const QString& token);
-
- public Q_SLOTS:
+ void emitExiting();
+ void emitDocumentClosed(const QString &token);
+
+public Q_SLOTS:
/**
* open a file with given url and encoding
* will get view created
@@ -46,8 +46,8 @@ class KateAppAdaptor : public QDBusAbstractAdaptor
* @param encoding encoding name
* @return success
*/
- bool openUrl (QString url, QString encoding);
-
+ bool openUrl(QString url, QString encoding);
+
/**
* open a file with given url and encoding
* will get view created
@@ -55,7 +55,7 @@ class KateAppAdaptor : public QDBusAbstractAdaptor
* @param encoding encoding name
* @return token or ERROR
*/
- QString tokenOpenUrl (QString url, QString encoding);
+ QString tokenOpenUrl(QString url, QString encoding);
/**
* Like the above, but adds an option to let the documentManager know
@@ -66,14 +66,14 @@ class KateAppAdaptor : public QDBusAbstractAdaptor
bool openUrl(QString url, QString encoding, bool isTempFile);
QString tokenOpenUrl(QString url, QString encoding, bool isTempFile);
-
+
/**
* set cursor of active view in active main window
* @param line line for cursor
* @param column column for cursor
* @return success
*/
- bool setCursor (int line, int column);
+ bool setCursor(int line, int column);
/**
* helper to handle stdin input
@@ -81,33 +81,32 @@ class KateAppAdaptor : public QDBusAbstractAdaptor
* @param text text to fill in the new doc/view
* @return success
*/
- bool openInput (QString text);
+ bool openInput(QString text);
/**
* activate a given session
* @param session session name
* @return success
*/
- bool activateSession (QString session);
+ bool activateSession(QString session);
/**
* activate this kate instance
*/
- void activate ();
-
- Q_SIGNALS:
+ void activate();
+
+Q_SIGNALS:
/**
* Notify the world that this kate instance is exiting.
* All apps should stop using the dbus interface of this instance after this signal got emitted.
*/
- void exiting ();
- void documentClosed(const QString& token);
- public:
+ void exiting();
+ void documentClosed(const QString &token);
+public:
QString activeSession();
- private:
+private:
KateApp *m_app;
};
#endif
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/app/kateappcommands.cpp b/kate/app/kateappcommands.cpp
index 8ed3c8b..1b19335 100644
--- a/kate/app/kateappcommands.cpp
+++ b/kate/app/kateappcommands.cpp
@@ -2,7 +2,6 @@
Copyright (C) 2009 Erlend Hamberg <ehamberg@gmail.com>
Copyright (C) 2011 Svyatoslav Kuzmich <svatoslav1@gmail.com>
-
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
@@ -28,12 +27,12 @@
#include "katedocmanager.h"
#include "kateviewmanager.h"
-KateAppCommands* KateAppCommands::m_instance = 0;
+KateAppCommands *KateAppCommands::m_instance = 0;
KateAppCommands::KateAppCommands()
: KTextEditor::Command()
{
- KTextEditor::CommandInterface *iface = qobject_cast<KTextEditor::CommandInterface*>(KTextEditor::Editor::instance());
+ KTextEditor::CommandInterface *iface = qobject_cast<KTextEditor::CommandInterface *>(KTextEditor::Editor::instance());
if (iface) {
iface->registerCommand(this);
@@ -52,7 +51,7 @@ KateAppCommands::KateAppCommands()
KateAppCommands::~KateAppCommands()
{
- KTextEditor::CommandInterface *iface = qobject_cast<KTextEditor::CommandInterface*>(KTextEditor::Editor::instance());
+ KTextEditor::CommandInterface *iface = qobject_cast<KTextEditor::CommandInterface *>(KTextEditor::Editor::instance());
if (iface) {
iface->unregisterCommand(this);
@@ -61,7 +60,7 @@ KateAppCommands::~KateAppCommands()
m_instance = 0;
}
-const QStringList& KateAppCommands::cmds()
+const QStringList &KateAppCommands::cmds()
{
static QStringList l;
@@ -78,8 +77,8 @@ const QStringList& KateAppCommands::cmds()
bool KateAppCommands::exec(KTextEditor::View *view, const QString &cmd, QString &msg)
{
- QStringList args(cmd.split( QRegExp(QStringLiteral("\\s+")), QString::SkipEmptyParts)) ;
- QString command( args.takeFirst() );
+ QStringList args(cmd.split(QRegExp(QStringLiteral("\\s+")), QString::SkipEmptyParts)) ;
+ QString command(args.takeFirst());
KateMainWindow *mainWin = KateApp::self()->activeKateMainWindow();
@@ -95,37 +94,41 @@ bool KateAppCommands::exec(KTextEditor::View *view, const QString &cmd, QString
// Other buffer commands are implemented by the KateFileTree plugin
else if (re_close.exactMatch(command)) {
QTimer::singleShot(0, mainWin, SLOT(slotFileClose()));
- }
- else if (re_quit.exactMatch(command)) {
+ } else if (re_quit.exactMatch(command)) {
const bool save = !re_quit.cap(1).isEmpty(); // :[w]q
const bool allDocuments = !re_quit.cap(2).isEmpty(); // :q[all]
const bool doNotPromptForSave = !re_quit.cap(3).isEmpty(); // :q[!]
if (allDocuments) {
- if (save)
+ if (save) {
KateDocManager::self()->saveAll();
+ }
if (doNotPromptForSave) {
- foreach ( KTextEditor::Document *doc, KateDocManager::self()->documentList() )
- if ( doc->isModified() )
- doc->setModified(false);
+ foreach(KTextEditor::Document * doc, KateDocManager::self()->documentList())
+ if (doc->isModified()) {
+ doc->setModified(false);
+ }
}
QTimer::singleShot(0, mainWin, SLOT(slotFileQuit()));
} else {
- if (save && view->document()->isModified())
+ if (save && view->document()->isModified()) {
view->document()->documentSave();
+ }
- if (doNotPromptForSave)
+ if (doNotPromptForSave) {
view->document()->setModified(false);
+ }
if (mainWin->viewManager()->count() > 1) {
- QTimer::singleShot(0, mainWin->viewManager(), SLOT(slotCloseCurrentViewSpace()));
+ QTimer::singleShot(0, mainWin->viewManager(), SLOT(slotCloseCurrentViewSpace()));
} else {
- if (KateDocManager::self()->documents() > 1)
- QTimer::singleShot(0, mainWin, SLOT(slotFileClose()));
- else
- QTimer::singleShot(0, mainWin, SLOT(slotFileQuit()));
+ if (KateDocManager::self()->documents() > 1) {
+ QTimer::singleShot(0, mainWin, SLOT(slotFileClose()));
+ } else {
+ QTimer::singleShot(0, mainWin, SLOT(slotFileQuit()));
+ }
}
}
} else if (re_exit.exactMatch(command)) {
@@ -137,14 +140,14 @@ bool KateAppCommands::exec(KTextEditor::View *view, const QString &cmd, QString
view->document()->documentSave();
}
- if (KateDocManager::self()->documents() > 1)
+ if (KateDocManager::self()->documents() > 1) {
QTimer::singleShot(0, mainWin, SLOT(slotFileClose()));
- else
+ } else {
QTimer::singleShot(0, mainWin, SLOT(slotFileQuit()));
+ }
}
QTimer::singleShot(0, mainWin, SLOT(slotFileQuit()));
- }
- else if (re_edit.exactMatch(command)) {
+ } else if (re_edit.exactMatch(command)) {
QString argument = args.join(QLatin1Char(' '));
if (argument.isEmpty() || argument == QStringLiteral("!")) {
view->document()->documentReload();
@@ -153,39 +156,35 @@ bool KateAppCommands::exec(KTextEditor::View *view, const QString &cmd, QString
QUrl url;
QUrl arg2path(argument);
if (base.isValid()) { // first try to use the same path as the current open document has
- url = QUrl(base.resolved(arg2path)); //resolved handles the case where the args is a relative path, and is the same as using QUrl(args) elsewise
+ url = QUrl(base.resolved(arg2path)); //resolved handles the case where the args is a relative path, and is the same as using QUrl(args) elsewise
} else { // else use the cwd
- url = QUrl(QUrl(QDir::currentPath() + QStringLiteral("/")).resolved(arg2path)); // + "/" is needed because of http://lists.qt.nokia.com/public/qt-interest/2011-May/033913.html
+ url = QUrl(QUrl(QDir::currentPath() + QStringLiteral("/")).resolved(arg2path)); // + "/" is needed because of http://lists.qt.nokia.com/public/qt-interest/2011-May/033913.html
}
- QFileInfo file( url.toLocalFile() );
- KTextEditor::Document *doc = KateDocManager::self()->findDocument( url );
+ QFileInfo file(url.toLocalFile());
+ KTextEditor::Document *doc = KateDocManager::self()->findDocument(url);
if (doc) {
- mainWin->viewManager()->activateView( doc );
+ mainWin->viewManager()->activateView(doc);
} else if (file.exists()) {
- mainWin->viewManager()->openUrl( url, QString(), true );
+ mainWin->viewManager()->openUrl(url, QString(), true);
} else {
- mainWin->viewManager()->openUrl( QUrl(), QString(), true )->saveAs ( url );
+ mainWin->viewManager()->openUrl(QUrl(), QString(), true)->saveAs(url);
}
}
- }
- else if (re_new.exactMatch(command)) {
+ } else if (re_new.exactMatch(command)) {
if (re_new.cap(1) == QStringLiteral("v")) { // vertical split
mainWin->viewManager()->slotSplitViewSpaceVert();
} else { // horizontal split
mainWin->viewManager()->slotSplitViewSpaceHoriz();
}
mainWin->viewManager()->slotDocumentNew();
- }
- else if (command == QStringLiteral("enew")) {
+ } else if (command == QStringLiteral("enew")) {
mainWin->viewManager()->slotDocumentNew();
- }
- else if (re_split.exactMatch(command)) {
+ } else if (re_split.exactMatch(command)) {
mainWin->viewManager()->slotSplitViewSpaceHoriz();
- }
- else if (re_vsplit.exactMatch(command)) {
+ } else if (re_vsplit.exactMatch(command)) {
mainWin->viewManager()->slotSplitViewSpaceVert();
} else if (re_only.exactMatch(command)) {
- mainWin->viewManager()->slotCloseOtherViews();
+ mainWin->viewManager()->slotCloseOtherViews();
}
return true;
@@ -205,8 +204,7 @@ bool KateAppCommands::help(KTextEditor::View *view, const QString &cmd, QString
"<p>If no file name is associated with the document, "
"a file dialog will be shown.</p>");
return true;
- }
- else if (re_quit.exactMatch(cmd)) {
+ } else if (re_quit.exactMatch(cmd)) {
msg = i18n("<p><b>q/qa/wq/wqa &mdash; [write and] quit</b></p>"
"<p>Usage: <tt><b>[w]q[a]</b></tt></p>"
"<p>Quits the application. If <tt>w</tt> is prepended, it also writes"
@@ -220,8 +218,7 @@ bool KateAppCommands::help(KTextEditor::View *view, const QString &cmd, QString
"If no file name is associated with the document and it should be written to disk, "
"a file dialog will be shown.</p>");
return true;
- }
- else if (re_exit.exactMatch(cmd)) {
+ } else if (re_exit.exactMatch(cmd)) {
msg = i18n("<p><b>x/xa &mdash; write and quit</b></p>"
"<p>Usage: <tt><b>x[a]</b></tt></p>"
"<p>Saves document(s) and quits (e<b>x</b>its). This command "
@@ -234,20 +231,17 @@ bool KateAppCommands::help(KTextEditor::View *view, const QString &cmd, QString
"<p>Unlike the 'w' commands, this command only writes the document if it is modified."
"</p>");
return true;
- }
- else if (re_split.exactMatch(cmd)) {
+ } else if (re_split.exactMatch(cmd)) {
msg = i18n("<p><b>sp,split&mdash; Split horizontally the current view into two</b></p>"
"<p>Usage: <tt><b>sp[lit]</b></tt></p>"
"<p>The result is two views on the same document.</p>");
return true;
- }
- else if (re_vsplit.exactMatch(cmd)) {
+ } else if (re_vsplit.exactMatch(cmd)) {
msg = i18n("<p><b>vs,vsplit&mdash; Split vertically the current view into two</b></p>"
"<p>Usage: <tt><b>vs[plit]</b></tt></p>"
"<p>The result is two views on the same document.</p>");
return true;
- }
- else if (re_new.exactMatch(cmd)) {
+ } else if (re_new.exactMatch(cmd)) {
msg = i18n("<p><b>[v]new &mdash; split view and create new document</b></p>"
"<p>Usage: <tt><b>[v]new</b></tt></p>"
"<p>Splits the current view and opens a new document in the new view."
@@ -256,8 +250,7 @@ bool KateAppCommands::help(KTextEditor::View *view, const QString &cmd, QString
" <tt>vnew</tt> &mdash; splits the view vertically and opens a new document.<br />"
"</p>");
return true;
- }
- else if (re_edit.exactMatch(cmd)) {
+ } else if (re_edit.exactMatch(cmd)) {
msg = i18n("<p><b>e[dit] &mdash; reload current document</b></p>"
"<p>Usage: <tt><b>e[dit]</b></tt></p>"
"<p>Starts <b>e</b>diting the current document again. This is useful to re-edit"
diff --git a/kate/app/kateappcommands.h b/kate/app/kateappcommands.h
index a53c5f7..8b47c6b 100644
--- a/kate/app/kateappcommands.h
+++ b/kate/app/kateappcommands.h
@@ -25,23 +25,23 @@
class KateAppCommands : public KTextEditor::Command
{
- KateAppCommands();
- static KateAppCommands* m_instance;
+ KateAppCommands();
+ static KateAppCommands *m_instance;
- public:
+public:
virtual ~KateAppCommands();
- virtual const QStringList &cmds ();
- virtual bool exec (KTextEditor::View *view, const QString &cmd, QString &msg);
- virtual bool help (KTextEditor::View *view, const QString &cmd, QString &msg);
-
- static KateAppCommands* self() {
- if (m_instance == 0) {
- m_instance = new KateAppCommands();
- }
- return m_instance;
+ virtual const QStringList &cmds();
+ virtual bool exec(KTextEditor::View *view, const QString &cmd, QString &msg);
+ virtual bool help(KTextEditor::View *view, const QString &cmd, QString &msg);
+
+ static KateAppCommands *self() {
+ if (m_instance == 0) {
+ m_instance = new KateAppCommands();
+ }
+ return m_instance;
}
- private:
+private:
QRegExp re_write;
QRegExp re_close;
QRegExp re_quit;
diff --git a/kate/app/kateconfigdialog.cpp b/kate/app/kateconfigdialog.cpp
index 45ed7f6..784b18f 100644
--- a/kate/app/kateconfigdialog.cpp
+++ b/kate/app/kateconfigdialog.cpp
@@ -47,350 +47,358 @@
#include <QSpinBox>
#include <QVBoxLayout>
-KateConfigDialog::KateConfigDialog ( KateMainWindow *parent, KTextEditor::View *view )
- : KPageDialog( parent )
- , m_mainWindow( parent )
- , m_view( view )
+KateConfigDialog::KateConfigDialog(KateMainWindow *parent, KTextEditor::View *view)
+ : KPageDialog(parent)
+ , m_mainWindow(parent)
+ , m_view(view)
{
- setFaceType( Tree );
- setWindowTitle( i18n("Configure") );
- setStandardButtons( QDialogButtonBox::Ok | QDialogButtonBox::Apply | QDialogButtonBox::Cancel | QDialogButtonBox::Help );
- setObjectName(QStringLiteral("configdialog"));
-
- KSharedConfig::Ptr config = KSharedConfig::openConfig();
- KConfigGroup cgGeneral = KConfigGroup( config, "General" );
-
- buttonBox()->button(QDialogButtonBox::Apply)->setEnabled(false);
-
- KPageWidgetItem *applicationItem = addPage( new QWidget, i18n("Application") );
- applicationItem->setIcon( QIcon::fromTheme( QStringLiteral("preferences-other") ) );
- applicationItem->setHeader( i18n("Application Options") );
- m_applicationPage = applicationItem;
-
- //BEGIN General page
- QFrame* generalFrame = new QFrame;
- KPageWidgetItem *item = addSubPage( applicationItem, generalFrame, i18n("General") );
- item->setHeader( i18n("General Options") );
- item->setIcon( QIcon::fromTheme( QStringLiteral("go-home") ) );
- setCurrentPage (item);
-
- QVBoxLayout *layout = new QVBoxLayout( generalFrame );
- layout->setMargin(0);
-
- // GROUP with the one below: "Behavior"
- QGroupBox *buttonGroup = new QGroupBox( i18n("&Behavior"), generalFrame );
- QVBoxLayout *vbox = new QVBoxLayout;
- layout->addWidget( buttonGroup );
-
- // modified files notification
- m_modNotifications = new QCheckBox(
- i18n("Wa&rn about files modified by foreign processes"), buttonGroup );
- m_modNotifications->setChecked( parent->modNotificationEnabled() );
- m_modNotifications->setWhatsThis( i18n(
- "If enabled, when Kate receives focus you will be asked what to do with "
- "files that have been modified on the hard disk. If not enabled, you will "
- "be asked what to do with a file that has been modified on the hard disk only "
- "when that file is tried to be saved.") );
- connect( m_modNotifications, SIGNAL(toggled(bool)),
- this, SLOT(slotChanged()) );
-
- vbox->addWidget(m_modNotifications);
- buttonGroup->setLayout(vbox);
-
- // GROUP with the one below: "Meta-information"
- buttonGroup = new QGroupBox( i18n("Meta-Information"), generalFrame );
- vbox = new QVBoxLayout;
- layout->addWidget( buttonGroup );
-
- // save meta infos
- m_saveMetaInfos = new QCheckBox( buttonGroup );
- m_saveMetaInfos->setText(i18n("Keep &meta-information past sessions"));
- m_saveMetaInfos->setChecked(KateDocManager::self()->getSaveMetaInfos());
- m_saveMetaInfos->setWhatsThis( i18n(
- "Check this if you want document configuration like for example "
- "bookmarks to be saved past editor sessions. The configuration will be "
- "restored if the document has not changed when reopened."));
- connect( m_saveMetaInfos, SIGNAL(toggled(bool)), this, SLOT(slotChanged()) );
-
- vbox->addWidget(m_saveMetaInfos);
-
- // meta infos days
- QFrame *metaInfos = new QFrame( buttonGroup );
- QHBoxLayout *hlayout = new QHBoxLayout(metaInfos);
-
- metaInfos->setEnabled(KateDocManager::self()->getSaveMetaInfos());
- QLabel *label = new QLabel( i18n("&Delete unused meta-information after:"), metaInfos );
- hlayout->addWidget(label);
- m_daysMetaInfos = new QSpinBox( metaInfos );
- m_daysMetaInfos->setMaximum( 180 );
- m_daysMetaInfos->setSpecialValueText(i18n("(never)"));
- m_daysMetaInfos->setValue( KateDocManager::self()->getDaysMetaInfos() );
- hlayout->addWidget(m_daysMetaInfos);
- label->setBuddy( m_daysMetaInfos );
- connect( m_saveMetaInfos, SIGNAL(toggled(bool)), metaInfos, SLOT(setEnabled(bool)) );
- connect( m_daysMetaInfos, SIGNAL(valueChanged(int)), this, SLOT(slotChanged()) );
-
- vbox->addWidget(metaInfos);
- buttonGroup->setLayout(vbox);
-
- layout->addStretch(1); // :-] works correct without autoadd
- //END General page
-
-
- //BEGIN Session page
- QFrame* sessionsFrame = new QFrame;
- item = addSubPage( applicationItem, sessionsFrame, i18n("Sessions") );
- item->setHeader( i18n("Session Management") );
- item->setIcon( QIcon::fromTheme( QStringLiteral("view-history") ) );
-
- layout = new QVBoxLayout( sessionsFrame );
- layout->setMargin(0);
-
- // GROUP with the one below: "Startup"
- buttonGroup = new QGroupBox( i18n("Elements of Sessions"), sessionsFrame );
- vbox = new QVBoxLayout;
- layout->addWidget( buttonGroup );
-
- // restore view config
- m_restoreVC = new QCheckBox( buttonGroup );
- m_restoreVC->setText(i18n("Include &window configuration"));
- m_restoreVC->setChecked( cgGeneral.readEntry("Restore Window Configuration", true) );
- m_restoreVC->setWhatsThis( i18n("Check this if you want all your views and frames restored each time you open Kate"));
- connect( m_restoreVC, SIGNAL(toggled(bool)), this, SLOT(slotChanged()) );
-
- vbox->addWidget(m_restoreVC);
- buttonGroup->setLayout(vbox);
-
- QGroupBox* sessionsStart = new QGroupBox( i18n("Behavior on Application Startup"), sessionsFrame );
- vbox = new QVBoxLayout;
- layout->addWidget(sessionsStart);
-
- m_startNewSessionRadioButton = new QRadioButton( i18n("&Start new session"), sessionsStart );
- m_loadLastUserSessionRadioButton = new QRadioButton( i18n("&Load last-used session"), sessionsStart );
- m_manuallyChooseSessionRadioButton = new QRadioButton( i18n("&Manually choose a session"), sessionsStart );
-
- QString sesStart (cgGeneral.readEntry ("Startup Session", "manual"));
- if (sesStart == QStringLiteral("new"))
- m_startNewSessionRadioButton->setChecked (true);
- else if (sesStart == QStringLiteral("last"))
- m_loadLastUserSessionRadioButton->setChecked (true);
- else
- m_manuallyChooseSessionRadioButton->setChecked (true);
-
- connect(m_startNewSessionRadioButton, SIGNAL(toggled(bool)), this, SLOT(slotChanged()));
- connect(m_loadLastUserSessionRadioButton, SIGNAL(toggled(bool)), this, SLOT(slotChanged()));
- connect(m_manuallyChooseSessionRadioButton, SIGNAL(toggled(bool)), this, SLOT(slotChanged()));
-
- vbox->addWidget(m_startNewSessionRadioButton);
- vbox->addWidget(m_loadLastUserSessionRadioButton);
- vbox->addWidget(m_manuallyChooseSessionRadioButton);
- sessionsStart->setLayout(vbox);
-
- layout->addStretch(1); // :-] works correct without autoadd
- //END Session page
-
- //BEGIN Plugins page
- QFrame *page = new QFrame(this);
- QVBoxLayout *vlayout = new QVBoxLayout(page);
- vlayout->setMargin(0);
- vlayout->setSpacing(0);
-
- KateConfigPluginPage *configPluginPage = new KateConfigPluginPage(page, this);
- vlayout->addWidget(configPluginPage);
- connect( configPluginPage, SIGNAL(changed()), this, SLOT(slotChanged()) );
-
- item = addSubPage( applicationItem, page, i18n("Plugins") );
- item->setHeader( i18n("Plugin Manager") );
- item->setIcon( QIcon::fromTheme( QStringLiteral("preferences-plugin") ) );
-
- KatePluginList &pluginList (KatePluginManager::self()->pluginList());
- foreach (const KatePluginInfo &plugin, pluginList)
- {
- if ( plugin.load
- && qobject_cast<KTextEditor::ConfigPageInterface*>(plugin.plugin) )
- addPluginPage (plugin.plugin);
- }
- //END Plugins page
+ setFaceType(Tree);
+ setWindowTitle(i18n("Configure"));
+ setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Apply | QDialogButtonBox::Cancel | QDialogButtonBox::Help);
+ setObjectName(QStringLiteral("configdialog"));
+
+ KSharedConfig::Ptr config = KSharedConfig::openConfig();
+ KConfigGroup cgGeneral = KConfigGroup(config, "General");
+
+ buttonBox()->button(QDialogButtonBox::Apply)->setEnabled(false);
+
+ KPageWidgetItem *applicationItem = addPage(new QWidget, i18n("Application"));
+ applicationItem->setIcon(QIcon::fromTheme(QStringLiteral("preferences-other")));
+ applicationItem->setHeader(i18n("Application Options"));
+ m_applicationPage = applicationItem;
+
+ //BEGIN General page
+ QFrame *generalFrame = new QFrame;
+ KPageWidgetItem *item = addSubPage(applicationItem, generalFrame, i18n("General"));
+ item->setHeader(i18n("General Options"));
+ item->setIcon(QIcon::fromTheme(QStringLiteral("go-home")));
+ setCurrentPage(item);
+
+ QVBoxLayout *layout = new QVBoxLayout(generalFrame);
+ layout->setMargin(0);
+
+ // GROUP with the one below: "Behavior"
+ QGroupBox *buttonGroup = new QGroupBox(i18n("&Behavior"), generalFrame);
+ QVBoxLayout *vbox = new QVBoxLayout;
+ layout->addWidget(buttonGroup);
+
+ // modified files notification
+ m_modNotifications = new QCheckBox(
+ i18n("Wa&rn about files modified by foreign processes"), buttonGroup);
+ m_modNotifications->setChecked(parent->modNotificationEnabled());
+ m_modNotifications->setWhatsThis(i18n(
+ "If enabled, when Kate receives focus you will be asked what to do with "
+ "files that have been modified on the hard disk. If not enabled, you will "
+ "be asked what to do with a file that has been modified on the hard disk only "
+ "when that file is tried to be saved."));
+ connect(m_modNotifications, SIGNAL(toggled(bool)),
+ this, SLOT(slotChanged()));
+
+ vbox->addWidget(m_modNotifications);
+ buttonGroup->setLayout(vbox);
+
+ // GROUP with the one below: "Meta-information"
+ buttonGroup = new QGroupBox(i18n("Meta-Information"), generalFrame);
+ vbox = new QVBoxLayout;
+ layout->addWidget(buttonGroup);
+
+ // save meta infos
+ m_saveMetaInfos = new QCheckBox(buttonGroup);
+ m_saveMetaInfos->setText(i18n("Keep &meta-information past sessions"));
+ m_saveMetaInfos->setChecked(KateDocManager::self()->getSaveMetaInfos());
+ m_saveMetaInfos->setWhatsThis(i18n(
+ "Check this if you want document configuration like for example "
+ "bookmarks to be saved past editor sessions. The configuration will be "
+ "restored if the document has not changed when reopened."));
+ connect(m_saveMetaInfos, SIGNAL(toggled(bool)), this, SLOT(slotChanged()));
+
+ vbox->addWidget(m_saveMetaInfos);
+
+ // meta infos days
+ QFrame *metaInfos = new QFrame(buttonGroup);
+ QHBoxLayout *hlayout = new QHBoxLayout(metaInfos);
+
+ metaInfos->setEnabled(KateDocManager::self()->getSaveMetaInfos());
+ QLabel *label = new QLabel(i18n("&Delete unused meta-information after:"), metaInfos);
+ hlayout->addWidget(label);
+ m_daysMetaInfos = new QSpinBox(metaInfos);
+ m_daysMetaInfos->setMaximum(180);
+ m_daysMetaInfos->setSpecialValueText(i18n("(never)"));
+ m_daysMetaInfos->setValue(KateDocManager::self()->getDaysMetaInfos());
+ hlayout->addWidget(m_daysMetaInfos);
+ label->setBuddy(m_daysMetaInfos);
+ connect(m_saveMetaInfos, SIGNAL(toggled(bool)), metaInfos, SLOT(setEnabled(bool)));
+ connect(m_daysMetaInfos, SIGNAL(valueChanged(int)), this, SLOT(slotChanged()));
+
+ vbox->addWidget(metaInfos);
+ buttonGroup->setLayout(vbox);
+
+ layout->addStretch(1); // :-] works correct without autoadd
+ //END General page
+
+ //BEGIN Session page
+ QFrame *sessionsFrame = new QFrame;
+ item = addSubPage(applicationItem, sessionsFrame, i18n("Sessions"));
+ item->setHeader(i18n("Session Management"));
+ item->setIcon(QIcon::fromTheme(QStringLiteral("view-history")));
+
+ layout = new QVBoxLayout(sessionsFrame);
+ layout->setMargin(0);
+
+ // GROUP with the one below: "Startup"
+ buttonGroup = new QGroupBox(i18n("Elements of Sessions"), sessionsFrame);
+ vbox = new QVBoxLayout;
+ layout->addWidget(buttonGroup);
+
+ // restore view config
+ m_restoreVC = new QCheckBox(buttonGroup);
+ m_restoreVC->setText(i18n("Include &window configuration"));
+ m_restoreVC->setChecked(cgGeneral.readEntry("Restore Window Configuration", true));
+ m_restoreVC->setWhatsThis(i18n("Check this if you want all your views and frames restored each time you open Kate"));
+ connect(m_restoreVC, SIGNAL(toggled(bool)), this, SLOT(slotChanged()));
+
+ vbox->addWidget(m_restoreVC);
+ buttonGroup->setLayout(vbox);
+
+ QGroupBox *sessionsStart = new QGroupBox(i18n("Behavior on Application Startup"), sessionsFrame);
+ vbox = new QVBoxLayout;
+ layout->addWidget(sessionsStart);
+
+ m_startNewSessionRadioButton = new QRadioButton(i18n("&Start new session"), sessionsStart);
+ m_loadLastUserSessionRadioButton = new QRadioButton(i18n("&Load last-used session"), sessionsStart);
+ m_manuallyChooseSessionRadioButton = new QRadioButton(i18n("&Manually choose a session"), sessionsStart);
+
+ QString sesStart(cgGeneral.readEntry("Startup Session", "manual"));
+ if (sesStart == QStringLiteral("new")) {
+ m_startNewSessionRadioButton->setChecked(true);
+ } else if (sesStart == QStringLiteral("last")) {
+ m_loadLastUserSessionRadioButton->setChecked(true);
+ } else {
+ m_manuallyChooseSessionRadioButton->setChecked(true);
+ }
+
+ connect(m_startNewSessionRadioButton, SIGNAL(toggled(bool)), this, SLOT(slotChanged()));
+ connect(m_loadLastUserSessionRadioButton, SIGNAL(toggled(bool)), this, SLOT(slotChanged()));
+ connect(m_manuallyChooseSessionRadioButton, SIGNAL(toggled(bool)), this, SLOT(slotChanged()));
+
+ vbox->addWidget(m_startNewSessionRadioButton);
+ vbox->addWidget(m_loadLastUserSessionRadioButton);
+ vbox->addWidget(m_manuallyChooseSessionRadioButton);
+ sessionsStart->setLayout(vbox);
+
+ layout->addStretch(1); // :-] works correct without autoadd
+ //END Session page
+
+ //BEGIN Plugins page
+ QFrame *page = new QFrame(this);
+ QVBoxLayout *vlayout = new QVBoxLayout(page);
+ vlayout->setMargin(0);
+ vlayout->setSpacing(0);
+
+ KateConfigPluginPage *configPluginPage = new KateConfigPluginPage(page, this);
+ vlayout->addWidget(configPluginPage);
+ connect(configPluginPage, SIGNAL(changed()), this, SLOT(slotChanged()));
+
+ item = addSubPage(applicationItem, page, i18n("Plugins"));
+ item->setHeader(i18n("Plugin Manager"));
+ item->setIcon(QIcon::fromTheme(QStringLiteral("preferences-plugin")));
+
+ KatePluginList &pluginList(KatePluginManager::self()->pluginList());
+ foreach(const KatePluginInfo & plugin, pluginList) {
+ if (plugin.load
+ && qobject_cast<KTextEditor::ConfigPageInterface *>(plugin.plugin)) {
+ addPluginPage(plugin.plugin);
+ }
+ }
+ //END Plugins page
// editor widgets from kwrite/kwdialog
- m_editorPage = addPage( new QWidget, i18n("Editor Component") );
- m_editorPage->setIcon( QIcon::fromTheme( QStringLiteral("accessories-text-editor") ) );
- m_editorPage->setHeader( i18n("Editor Component Options") );
+ m_editorPage = addPage(new QWidget, i18n("Editor Component"));
+ m_editorPage->setIcon(QIcon::fromTheme(QStringLiteral("accessories-text-editor")));
+ m_editorPage->setHeader(i18n("Editor Component Options"));
- addEditorPages();
+ addEditorPages();
- connect(this, SIGNAL(accepted()), this, SLOT(slotApply()));
- connect(buttonBox()->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(slotApply()));
- connect(buttonBox()->button(QDialogButtonBox::Help), SIGNAL(clicked()), this, SLOT(slotHelp()));
- connect(this, SIGNAL(currentPageChanged(KPageWidgetItem*,KPageWidgetItem*)),
- this, SLOT(slotCurrentPageChanged(KPageWidgetItem*,KPageWidgetItem*)));
- m_dataChanged = false;
+ connect(this, SIGNAL(accepted()), this, SLOT(slotApply()));
+ connect(buttonBox()->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(slotApply()));
+ connect(buttonBox()->button(QDialogButtonBox::Help), SIGNAL(clicked()), this, SLOT(slotHelp()));
+ connect(this, SIGNAL(currentPageChanged(KPageWidgetItem*,KPageWidgetItem*)),
+ this, SLOT(slotCurrentPageChanged(KPageWidgetItem*,KPageWidgetItem*)));
+ m_dataChanged = false;
- resize(minimumSizeHint());
+ resize(minimumSizeHint());
}
KateConfigDialog::~KateConfigDialog()
{}
+void KateConfigDialog::addEditorPages()
+{
-void KateConfigDialog::addEditorPages() {
-
- for (int i = 0; i < KTextEditor::Editor::instance()->configPages (); ++i)
- {
- KTextEditor::ConfigPage *page = KTextEditor::Editor::instance()->configPage(i, this);
- connect( page, SIGNAL(changed()), this, SLOT(slotChanged()) );
- m_editorPages.push_back (page);
- KPageWidgetItem *item=addSubPage( m_editorPage, page, KTextEditor::Editor::instance()->configPageName(i) );
- item->setHeader( KTextEditor::Editor::instance()->configPageFullName(i) );
- item->setIcon( KTextEditor::Editor::instance()->configPageIcon(i) );
- }
+ for (int i = 0; i < KTextEditor::Editor::instance()->configPages(); ++i) {
+ KTextEditor::ConfigPage *page = KTextEditor::Editor::instance()->configPage(i, this);
+ connect(page, SIGNAL(changed()), this, SLOT(slotChanged()));
+ m_editorPages.push_back(page);
+ KPageWidgetItem *item = addSubPage(m_editorPage, page, KTextEditor::Editor::instance()->configPageName(i));
+ item->setHeader(KTextEditor::Editor::instance()->configPageFullName(i));
+ item->setIcon(KTextEditor::Editor::instance()->configPageIcon(i));
+ }
}
-void KateConfigDialog::addPluginPage (KTextEditor::Plugin *plugin)
+void KateConfigDialog::addPluginPage(KTextEditor::Plugin *plugin)
{
- if (!qobject_cast<KTextEditor::ConfigPageInterface*>(plugin))
- return;
-
- for (int i = 0; i < qobject_cast<KTextEditor::ConfigPageInterface*>(plugin)->configPages(); i++)
- {
- QFrame *page = new QFrame();
- QVBoxLayout *layout = new QVBoxLayout(page);
- layout->setSpacing(0);
- layout->setMargin(0);
+ if (!qobject_cast<KTextEditor::ConfigPageInterface *>(plugin)) {
+ return;
+ }
- KPageWidgetItem *item = addSubPage( m_applicationPage, page, qobject_cast<KTextEditor::ConfigPageInterface*>(plugin)->configPageName(i) );
- item->setHeader( qobject_cast<KTextEditor::ConfigPageInterface*>(plugin)->configPageFullName(i) );
- item->setIcon( qobject_cast<KTextEditor::ConfigPageInterface*>(plugin)->configPageIcon(i));
-
- PluginPageListItem *info = new PluginPageListItem;
- info->plugin = plugin;
- info->configPageInterface=qobject_cast<KTextEditor::ConfigPageInterface*>(plugin);
- info->pageParent=page;
- info->pluginPage = 0; //info->configPageInterface->configPage (i, page);
- info->idInPlugin=i;
- info->pageWidgetItem = item;
- //connect( info->page, SIGNAL(changed()), this, SLOT(slotChanged()) );
- m_pluginPages.insert(item,info);
- }
+ for (int i = 0; i < qobject_cast<KTextEditor::ConfigPageInterface *>(plugin)->configPages(); i++) {
+ QFrame *page = new QFrame();
+ QVBoxLayout *layout = new QVBoxLayout(page);
+ layout->setSpacing(0);
+ layout->setMargin(0);
+
+ KPageWidgetItem *item = addSubPage(m_applicationPage, page, qobject_cast<KTextEditor::ConfigPageInterface *>(plugin)->configPageName(i));
+ item->setHeader(qobject_cast<KTextEditor::ConfigPageInterface *>(plugin)->configPageFullName(i));
+ item->setIcon(qobject_cast<KTextEditor::ConfigPageInterface *>(plugin)->configPageIcon(i));
+
+ PluginPageListItem *info = new PluginPageListItem;
+ info->plugin = plugin;
+ info->configPageInterface = qobject_cast<KTextEditor::ConfigPageInterface *>(plugin);
+ info->pageParent = page;
+ info->pluginPage = 0; //info->configPageInterface->configPage (i, page);
+ info->idInPlugin = i;
+ info->pageWidgetItem = item;
+ //connect( info->page, SIGNAL(changed()), this, SLOT(slotChanged()) );
+ m_pluginPages.insert(item, info);
+ }
}
-void KateConfigDialog::slotCurrentPageChanged( KPageWidgetItem *current, KPageWidgetItem * /*before*/ )
+void KateConfigDialog::slotCurrentPageChanged(KPageWidgetItem *current, KPageWidgetItem * /*before*/)
{
- PluginPageListItem *info=m_pluginPages[current];
- if (!info) return;
- if (info->pluginPage) return;
- qCDebug(LOG_KATE)<<"creating config page";
- info->pluginPage=info->configPageInterface->configPage(info->idInPlugin,info->pageParent);
- info->pageParent->layout()->addWidget(info->pluginPage);
- info->pluginPage->show();
- connect( info->pluginPage, SIGNAL(changed()), this, SLOT(slotChanged()) );
+ PluginPageListItem *info = m_pluginPages[current];
+ if (!info) {
+ return;
+ }
+ if (info->pluginPage) {
+ return;
+ }
+ qCDebug(LOG_KATE) << "creating config page";
+ info->pluginPage = info->configPageInterface->configPage(info->idInPlugin, info->pageParent);
+ info->pageParent->layout()->addWidget(info->pluginPage);
+ info->pluginPage->show();
+ connect(info->pluginPage, SIGNAL(changed()), this, SLOT(slotChanged()));
}
-void KateConfigDialog::removePluginPage (KTextEditor::Plugin *plugin)
+void KateConfigDialog::removePluginPage(KTextEditor::Plugin *plugin)
{
- if (!qobject_cast<KTextEditor::ConfigPageInterface*>(plugin))
- return;
-
- QList<KPageWidgetItem*> remove;
- for (QHash<KPageWidgetItem*,PluginPageListItem*>::const_iterator it=m_pluginPages.constBegin();it!=m_pluginPages.constEnd();++it) {
- PluginPageListItem *pli=it.value();
- if (!pli) continue;
- if (pli->plugin==plugin)
- remove.append(it.key());
- }
-
- qCDebug(LOG_KATE)<<remove.count();
- while (!remove.isEmpty()) {
- KPageWidgetItem *wItem=remove.takeLast();
- PluginPageListItem *pItem=m_pluginPages.take(wItem);
- delete pItem->pluginPage;
- delete pItem->pageParent;
- removePage(wItem);
- delete pItem;
- }
+ if (!qobject_cast<KTextEditor::ConfigPageInterface *>(plugin)) {
+ return;
+ }
+
+ QList<KPageWidgetItem *> remove;
+ for (QHash<KPageWidgetItem *, PluginPageListItem *>::const_iterator it = m_pluginPages.constBegin(); it != m_pluginPages.constEnd(); ++it) {
+ PluginPageListItem *pli = it.value();
+ if (!pli) {
+ continue;
+ }
+ if (pli->plugin == plugin) {
+ remove.append(it.key());
+ }
+ }
+
+ qCDebug(LOG_KATE) << remove.count();
+ while (!remove.isEmpty()) {
+ KPageWidgetItem *wItem = remove.takeLast();
+ PluginPageListItem *pItem = m_pluginPages.take(wItem);
+ delete pItem->pluginPage;
+ delete pItem->pageParent;
+ removePage(wItem);
+ delete pItem;
+ }
}
void KateConfigDialog::slotApply()
{
- KSharedConfig::Ptr config = KSharedConfig::openConfig();
-
- // if data changed apply the kate app stuff
- if( m_dataChanged )
- {
- KConfigGroup cg = KConfigGroup( config, "General" );
-
- cg.writeEntry("Restore Window Configuration", m_restoreVC->isChecked());
-
- if (m_startNewSessionRadioButton->isChecked())
- cg.writeEntry ("Startup Session", "new");
- else if (m_loadLastUserSessionRadioButton->isChecked())
- cg.writeEntry ("Startup Session", "last");
- else
- cg.writeEntry ("Startup Session", "manual");
-
- cg.writeEntry("Save Meta Infos", m_saveMetaInfos->isChecked());
- KateDocManager::self()->setSaveMetaInfos(m_saveMetaInfos->isChecked());
-
- cg.writeEntry("Days Meta Infos", m_daysMetaInfos->value() );
- KateDocManager::self()->setDaysMetaInfos(m_daysMetaInfos->value());
-
- cg.writeEntry("Modified Notification", m_modNotifications->isChecked());
- m_mainWindow->setModNotificationEnabled (m_modNotifications->isChecked());
-
- // patch document modified warn state
- const QList<KTextEditor::Document*> &docs = KateDocManager::self()->documentList ();
- foreach (KTextEditor::Document *doc, docs)
- if (qobject_cast<KTextEditor::ModificationInterface *>(doc))
- qobject_cast<KTextEditor::ModificationInterface *>(doc)->setModifiedOnDiskWarning (!m_modNotifications->isChecked());
-
- m_mainWindow->saveOptions ();
-
- // save plugin config !!
- KateSessionManager *sessionmanager = KateSessionManager::self();
- KConfig *sessionConfig = sessionmanager->activeSession()->config();
- KateApp::self()->pluginManager()->writeConfig (sessionConfig);
- }
-
- foreach (PluginPageListItem *plugin, m_pluginPages.values())
- {
- if (!plugin) continue;
- if (plugin->pluginPage)
- plugin->pluginPage->apply();
- }
-
- // apply ktexteditor pages
- foreach (KTextEditor::ConfigPage *page, m_editorPages)
+ KSharedConfig::Ptr config = KSharedConfig::openConfig();
+
+ // if data changed apply the kate app stuff
+ if (m_dataChanged) {
+ KConfigGroup cg = KConfigGroup(config, "General");
+
+ cg.writeEntry("Restore Window Configuration", m_restoreVC->isChecked());
+
+ if (m_startNewSessionRadioButton->isChecked()) {
+ cg.writeEntry("Startup Session", "new");
+ } else if (m_loadLastUserSessionRadioButton->isChecked()) {
+ cg.writeEntry("Startup Session", "last");
+ } else {
+ cg.writeEntry("Startup Session", "manual");
+ }
+
+ cg.writeEntry("Save Meta Infos", m_saveMetaInfos->isChecked());
+ KateDocManager::self()->setSaveMetaInfos(m_saveMetaInfos->isChecked());
+
+ cg.writeEntry("Days Meta Infos", m_daysMetaInfos->value());
+ KateDocManager::self()->setDaysMetaInfos(m_daysMetaInfos->value());
+
+ cg.writeEntry("Modified Notification", m_modNotifications->isChecked());
+ m_mainWindow->setModNotificationEnabled(m_modNotifications->isChecked());
+
+ // patch document modified warn state
+ const QList<KTextEditor::Document *> &docs = KateDocManager::self()->documentList();
+ foreach(KTextEditor::Document * doc, docs)
+ if (qobject_cast<KTextEditor::ModificationInterface *>(doc)) {
+ qobject_cast<KTextEditor::ModificationInterface *>(doc)->setModifiedOnDiskWarning(!m_modNotifications->isChecked());
+ }
+
+ m_mainWindow->saveOptions();
+
+ // save plugin config !!
+ KateSessionManager *sessionmanager = KateSessionManager::self();
+ KConfig *sessionConfig = sessionmanager->activeSession()->config();
+ KateApp::self()->pluginManager()->writeConfig(sessionConfig);
+ }
+
+ foreach(PluginPageListItem * plugin, m_pluginPages.values()) {
+ if (!plugin) {
+ continue;
+ }
+ if (plugin->pluginPage) {
+ plugin->pluginPage->apply();
+ }
+ }
+
+ // apply ktexteditor pages
+ foreach(KTextEditor::ConfigPage * page, m_editorPages)
page->apply();
- // write back the editor config
- KTextEditor::Editor::instance()->writeConfig(config.data());
+ // write back the editor config
+ KTextEditor::Editor::instance()->writeConfig(config.data());
- config->sync();
+ config->sync();
- m_dataChanged = false;
- buttonBox()->button(QDialogButtonBox::Apply)->setEnabled(false);
+ m_dataChanged = false;
+ buttonBox()->button(QDialogButtonBox::Apply)->setEnabled(false);
}
void KateConfigDialog::slotChanged()
{
- m_dataChanged = true;
- buttonBox()->button(QDialogButtonBox::Apply)->setEnabled(true);
- m_daysMetaInfos->setSuffix(i18ncp("The suffix of 'Delete unused meta-information after'", " day", " days", m_daysMetaInfos->value()));
+ m_dataChanged = true;
+ buttonBox()->button(QDialogButtonBox::Apply)->setEnabled(true);
+ m_daysMetaInfos->setSuffix(i18ncp("The suffix of 'Delete unused meta-information after'", " day", " days", m_daysMetaInfos->value()));
}
-void KateConfigDialog::showAppPluginPage(KTextEditor::ConfigPageInterface *configpageinterface,uint id)
+void KateConfigDialog::showAppPluginPage(KTextEditor::ConfigPageInterface *configpageinterface, uint id)
{
- foreach (PluginPageListItem *plugin, m_pluginPages.values())
- {
- if ((plugin->configPageInterface==configpageinterface) && (id==plugin->idInPlugin))
- {
- setCurrentPage(plugin->pageWidgetItem);
- break;
+ foreach(PluginPageListItem * plugin, m_pluginPages.values()) {
+ if ((plugin->configPageInterface == configpageinterface) && (id == plugin->idInPlugin)) {
+ setCurrentPage(plugin->pageWidgetItem);
+ break;
+ }
}
- }
}
void KateConfigDialog::slotHelp()
{
- QDesktopServices::openUrl(QUrl(QStringLiteral("help:/")));
+ QDesktopServices::openUrl(QUrl(QStringLiteral("help:/")));
}
diff --git a/kate/app/kateconfigdialog.h b/kate/app/kateconfigdialog.h
index 9953ff8..b09e27c 100644
--- a/kate/app/kateconfigdialog.h
+++ b/kate/app/kateconfigdialog.h
@@ -37,39 +37,38 @@ class QSpinBox;
class QRadioButton;
class KateMainWindow;
-struct PluginPageListItem
-{
- KTextEditor::Plugin *plugin;
- KTextEditor::ConfigPageInterface *configPageInterface;
- uint idInPlugin;
- KTextEditor::ConfigPage *pluginPage;
- QWidget *pageParent;
- KPageWidgetItem *pageWidgetItem;
+struct PluginPageListItem {
+ KTextEditor::Plugin *plugin;
+ KTextEditor::ConfigPageInterface *configPageInterface;
+ uint idInPlugin;
+ KTextEditor::ConfigPage *pluginPage;
+ QWidget *pageParent;
+ KPageWidgetItem *pageWidgetItem;
};
class KateConfigDialog : public KPageDialog
{
Q_OBJECT
- public:
- KateConfigDialog (KateMainWindow *parent, KTextEditor::View *view);
- ~KateConfigDialog ();
+public:
+ KateConfigDialog(KateMainWindow *parent, KTextEditor::View *view);
+ ~KateConfigDialog();
- public:
- void addPluginPage (KTextEditor::Plugin *plugin);
- void removePluginPage (KTextEditor::Plugin *plugin);
- void showAppPluginPage(KTextEditor::ConfigPageInterface *configpageinterface,uint id);
- protected Q_SLOTS:
+public:
+ void addPluginPage(KTextEditor::Plugin *plugin);
+ void removePluginPage(KTextEditor::Plugin *plugin);
+ void showAppPluginPage(KTextEditor::ConfigPageInterface *configpageinterface, uint id);
+protected Q_SLOTS:
void slotApply();
void slotChanged();
void slotHelp();
- void slotCurrentPageChanged( KPageWidgetItem *current, KPageWidgetItem *before );
+ void slotCurrentPageChanged(KPageWidgetItem *current, KPageWidgetItem *before);
- private:
+private:
KateMainWindow *m_mainWindow;
- KTextEditor::View* m_view;
+ KTextEditor::View *m_view;
bool m_dataChanged;
QCheckBox *m_modNotifications;
@@ -82,7 +81,7 @@ class KateConfigDialog : public KPageDialog
QRadioButton *m_loadLastUserSessionRadioButton;
QRadioButton *m_manuallyChooseSessionRadioButton;
- QHash<KPageWidgetItem*, PluginPageListItem*> m_pluginPages;
+ QHash<KPageWidgetItem *, PluginPageListItem *> m_pluginPages;
QList<KTextEditor::ConfigPage *> m_editorPages;
KPageWidgetItem *m_applicationPage;
KPageWidgetItem *m_editorPage;
@@ -91,5 +90,4 @@ class KateConfigDialog : public KPageDialog
};
#endif
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/app/kateconfigplugindialogpage.cpp b/kate/app/kateconfigplugindialogpage.cpp
index 7743977..ec2460d 100644
--- a/kate/app/kateconfigplugindialogpage.cpp
+++ b/kate/app/kateconfigplugindialogpage.cpp
@@ -2,16 +2,16 @@
Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
Copyright (C) 2002 Joseph Wenninger <jowenn@kde.org>
Copyright (C) 2007 Mirko Stocker <me@misto.ch>
-
+
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
-
+
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
-
+
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
@@ -28,18 +28,17 @@
class KatePluginListItem : public QTreeWidgetItem
{
- public:
+public:
KatePluginListItem(bool checked, KatePluginInfo *info);
- KatePluginInfo *info() const
- {
- return mInfo;
+ KatePluginInfo *info() const {
+ return mInfo;
}
- protected:
+protected:
void stateChange(bool);
-
- private:
+
+private:
KatePluginInfo *mInfo;
};
@@ -47,78 +46,80 @@ KatePluginListItem::KatePluginListItem(bool checked, KatePluginInfo *info)
: QTreeWidgetItem()
, mInfo(info)
{
- setCheckState(0, checked ? Qt::Checked : Qt::Unchecked);
- // skip plugins that will be loaded always!
- setDisabled (info->alwaysLoad);
+ setCheckState(0, checked ? Qt::Checked : Qt::Unchecked);
+ // skip plugins that will be loaded always!
+ setDisabled(info->alwaysLoad);
}
KatePluginListView::KatePluginListView(QWidget *parent)
: QTreeWidget(parent)
{
- setRootIsDecorated(false);
- connect(this, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(stateChanged(QTreeWidgetItem*)));
+ setRootIsDecorated(false);
+ connect(this, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(stateChanged(QTreeWidgetItem*)));
}
void KatePluginListView::stateChanged(QTreeWidgetItem *item)
{
- emit stateChange(static_cast<KatePluginListItem *>(item), item->checkState(0) == Qt::Checked);
+ emit stateChange(static_cast<KatePluginListItem *>(item), item->checkState(0) == Qt::Checked);
}
KateConfigPluginPage::KateConfigPluginPage(QWidget *parent, KateConfigDialog *dialog)
: QFrame(parent)
, myDialog(dialog)
{
- QVBoxLayout *layout = new QVBoxLayout(this);
- layout->setSpacing(0);
- layout->setMargin(0);
+ QVBoxLayout *layout = new QVBoxLayout(this);
+ layout->setSpacing(0);
+ layout->setMargin(0);
- KatePluginListView* listView = new KatePluginListView(this);
- layout->addWidget(listView);
+ KatePluginListView *listView = new KatePluginListView(this);
+ layout->addWidget(listView);
- QStringList headers;
+ QStringList headers;
headers << i18n("Name") << i18n("Comment");
- listView->setHeaderLabels(headers);
- listView->setWhatsThis(i18n("Here you can see all available Kate plugins. Those with a check mark are loaded, and will be loaded again the next time Kate is started."));
-
- KatePluginList &pluginList (KatePluginManager::self()->pluginList());
- for (KatePluginList::iterator it = pluginList.begin();it != pluginList.end(); ++it) {
- if (it->alwaysLoad) continue;
- QTreeWidgetItem *item = new KatePluginListItem(it->load, &(*it));
- item->setText(0, it->service->name());
- item->setText(1, it->service->comment());
- listView->addTopLevelItem(item);
- }
-
- listView->resizeColumnToContents(0);
- listView->sortByColumn(0, Qt::AscendingOrder);
- connect(listView, SIGNAL(stateChange(KatePluginListItem*,bool)), this, SLOT(stateChange(KatePluginListItem*,bool)));
+ listView->setHeaderLabels(headers);
+ listView->setWhatsThis(i18n("Here you can see all available Kate plugins. Those with a check mark are loaded, and will be loaded again the next time Kate is started."));
+
+ KatePluginList &pluginList(KatePluginManager::self()->pluginList());
+ for (KatePluginList::iterator it = pluginList.begin(); it != pluginList.end(); ++it) {
+ if (it->alwaysLoad) {
+ continue;
+ }
+ QTreeWidgetItem *item = new KatePluginListItem(it->load, &(*it));
+ item->setText(0, it->service->name());
+ item->setText(1, it->service->comment());
+ listView->addTopLevelItem(item);
+ }
+
+ listView->resizeColumnToContents(0);
+ listView->sortByColumn(0, Qt::AscendingOrder);
+ connect(listView, SIGNAL(stateChange(KatePluginListItem*,bool)), this, SLOT(stateChange(KatePluginListItem*,bool)));
}
void KateConfigPluginPage::stateChange(KatePluginListItem *item, bool b)
{
- if(b)
- loadPlugin(item);
- else
- unloadPlugin(item);
+ if (b) {
+ loadPlugin(item);
+ } else {
+ unloadPlugin(item);
+ }
- emit changed();
+ emit changed();
}
-void KateConfigPluginPage::loadPlugin (KatePluginListItem *item)
+void KateConfigPluginPage::loadPlugin(KatePluginListItem *item)
{
- KatePluginManager::self()->loadPlugin (item->info());
- KatePluginManager::self()->enablePluginGUI (item->info());
- myDialog->addPluginPage (item->info()->plugin);
+ KatePluginManager::self()->loadPlugin(item->info());
+ KatePluginManager::self()->enablePluginGUI(item->info());
+ myDialog->addPluginPage(item->info()->plugin);
- item->setCheckState(0, Qt::Checked);
+ item->setCheckState(0, Qt::Checked);
}
-void KateConfigPluginPage::unloadPlugin (KatePluginListItem *item)
+void KateConfigPluginPage::unloadPlugin(KatePluginListItem *item)
{
- myDialog->removePluginPage (item->info()->plugin);
- KatePluginManager::self()->unloadPlugin (item->info());
+ myDialog->removePluginPage(item->info()->plugin);
+ KatePluginManager::self()->unloadPlugin(item->info());
- item->setCheckState(0, Qt::Unchecked);
+ item->setCheckState(0, Qt::Unchecked);
}
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/app/kateconfigplugindialogpage.h b/kate/app/kateconfigplugindialogpage.h
index 0602c7b..94db2ad 100644
--- a/kate/app/kateconfigplugindialogpage.h
+++ b/kate/app/kateconfigplugindialogpage.h
@@ -31,13 +31,13 @@ class KatePluginListView : public QTreeWidget
{
Q_OBJECT
- public:
- KatePluginListView (QWidget *parent = 0);
+public:
+ KatePluginListView(QWidget *parent = 0);
- Q_SIGNALS:
+Q_SIGNALS:
void stateChange(KatePluginListItem *, bool);
- private Q_SLOTS:
+private Q_SLOTS:
void stateChanged(QTreeWidgetItem *);
};
@@ -45,22 +45,21 @@ class KateConfigPluginPage: public QFrame
{
Q_OBJECT
- public:
+public:
KateConfigPluginPage(QWidget *parent, class KateConfigDialog *dialog);
- private:
+private:
class KateConfigDialog *myDialog;
- Q_SIGNALS:
+Q_SIGNALS:
void changed();
- private Q_SLOTS:
+private Q_SLOTS:
void stateChange(KatePluginListItem *, bool);
- void loadPlugin (KatePluginListItem *);
- void unloadPlugin (KatePluginListItem *);
+ void loadPlugin(KatePluginListItem *);
+ void unloadPlugin(KatePluginListItem *);
};
#endif
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/app/katedocmanager.cpp b/kate/app/katedocmanager.cpp
index c7229f0..0228f0b 100644
--- a/kate/app/katedocmanager.cpp
+++ b/kate/app/katedocmanager.cpp
@@ -49,532 +49,521 @@
#include <QListView>
#include <QProgressDialog>
-KateDocManager::KateDocManager (QObject *parent)
+KateDocManager::KateDocManager(QObject *parent)
: QObject(parent)
, m_saveMetaInfos(true)
, m_daysMetaInfos(0)
- , m_documentStillToRestore (0)
+ , m_documentStillToRestore(0)
{
- // set our application wrapper
- KTextEditor::Editor::instance()->setApplication (KateApp::self()->wrapper());
-
- // read in editor config
- KTextEditor::Editor::instance()->readConfig(KSharedConfig::openConfig().data());
+ // set our application wrapper
+ KTextEditor::Editor::instance()->setApplication(KateApp::self()->wrapper());
- m_metaInfos = new KConfig(QStringLiteral("metainfos"), KConfig::NoGlobals, QStandardPaths::DataLocation );
+ // read in editor config
+ KTextEditor::Editor::instance()->readConfig(KSharedConfig::openConfig().data());
- createDoc ();
+ m_metaInfos = new KConfig(QStringLiteral("metainfos"), KConfig::NoGlobals, QStandardPaths::DataLocation);
+
+ createDoc();
}
-KateDocManager::~KateDocManager ()
+KateDocManager::~KateDocManager()
{
- // write editor config
- KTextEditor::Editor::instance()->writeConfig(KSharedConfig::openConfig().data());
+ // write editor config
+ KTextEditor::Editor::instance()->writeConfig(KSharedConfig::openConfig().data());
- // write metainfos?
- if (m_saveMetaInfos)
- {
- // saving meta-infos when file is saved is not enough, we need to do it once more at the end
- saveMetaInfos( m_docList );
+ // write metainfos?
+ if (m_saveMetaInfos) {
+ // saving meta-infos when file is saved is not enough, we need to do it once more at the end
+ saveMetaInfos(m_docList);
- // purge saved filesessions
- if (m_daysMetaInfos > 0)
- {
- const QStringList groups = m_metaInfos->groupList();
- QDateTime def(QDate(1970, 1, 1));
- for (QStringList::const_iterator it = groups.begin(); it != groups.end(); ++it)
- {
- QDateTime last = m_metaInfos->group(*it).readEntry("Time", def);
- if (last.daysTo(QDateTime::currentDateTime()) > m_daysMetaInfos)
- m_metaInfos->deleteGroup(*it);
- }
+ // purge saved filesessions
+ if (m_daysMetaInfos > 0) {
+ const QStringList groups = m_metaInfos->groupList();
+ QDateTime def(QDate(1970, 1, 1));
+ for (QStringList::const_iterator it = groups.begin(); it != groups.end(); ++it) {
+ QDateTime last = m_metaInfos->group(*it).readEntry("Time", def);
+ if (last.daysTo(QDateTime::currentDateTime()) > m_daysMetaInfos) {
+ m_metaInfos->deleteGroup(*it);
+ }
+ }
+ }
}
- }
- qDeleteAll( m_docInfos );
- delete m_metaInfos;
+ qDeleteAll(m_docInfos);
+ delete m_metaInfos;
}
-KateDocManager *KateDocManager::self ()
+KateDocManager *KateDocManager::self()
{
- return KateApp::self()->documentManager ();
+ return KateApp::self()->documentManager();
}
-KTextEditor::Document *KateDocManager::createDoc (const KateDocumentInfo& docInfo)
+KTextEditor::Document *KateDocManager::createDoc(const KateDocumentInfo &docInfo)
{
- qCDebug(LOG_KATE)<<"createDoc"<<endl;
+ qCDebug(LOG_KATE) << "createDoc" << endl;
+
+ KTextEditor::Document *doc = KTextEditor::Editor::instance()->createDocument(this);
- KTextEditor::Document *doc = KTextEditor::Editor::instance()->createDocument(this);
-
- // turn of the editorpart's own modification dialog, we have our own one, too!
- const KConfigGroup generalGroup(KSharedConfig::openConfig(), "General");
- bool ownModNotification = generalGroup.readEntry("Modified Notification", false);
- if (qobject_cast<KTextEditor::ModificationInterface *>(doc))
- qobject_cast<KTextEditor::ModificationInterface *>(doc)->setModifiedOnDiskWarning (!ownModNotification);
+ // turn of the editorpart's own modification dialog, we have our own one, too!
+ const KConfigGroup generalGroup(KSharedConfig::openConfig(), "General");
+ bool ownModNotification = generalGroup.readEntry("Modified Notification", false);
+ if (qobject_cast<KTextEditor::ModificationInterface *>(doc)) {
+ qobject_cast<KTextEditor::ModificationInterface *>(doc)->setModifiedOnDiskWarning(!ownModNotification);
+ }
- m_docList.append(doc);
- m_docInfos.insert (doc, new KateDocumentInfo (docInfo));
+ m_docList.append(doc);
+ m_docInfos.insert(doc, new KateDocumentInfo(docInfo));
- // connect internal signals...
- connect(doc, SIGNAL(modifiedChanged(KTextEditor::Document*)), this, SLOT(slotModChanged1(KTextEditor::Document*)));
- connect(doc, SIGNAL(modifiedOnDisk(KTextEditor::Document*,bool,KTextEditor::ModificationInterface::ModifiedOnDiskReason)),
- this, SLOT(slotModifiedOnDisc(KTextEditor::Document*,bool,KTextEditor::ModificationInterface::ModifiedOnDiskReason)));
+ // connect internal signals...
+ connect(doc, SIGNAL(modifiedChanged(KTextEditor::Document*)), this, SLOT(slotModChanged1(KTextEditor::Document*)));
+ connect(doc, SIGNAL(modifiedOnDisk(KTextEditor::Document*,bool,KTextEditor::ModificationInterface::ModifiedOnDiskReason)),
+ this, SLOT(slotModifiedOnDisc(KTextEditor::Document*,bool,KTextEditor::ModificationInterface::ModifiedOnDiskReason)));
- // we have a new document, show it the world
- emit documentCreated (doc);
- emit documentCreatedViewManager (doc);
+ // we have a new document, show it the world
+ emit documentCreated(doc);
+ emit documentCreatedViewManager(doc);
- // return our new document
- return doc;
+ // return our new document
+ return doc;
}
-void KateDocManager::deleteDoc (KTextEditor::Document *doc)
+void KateDocManager::deleteDoc(KTextEditor::Document *doc)
{
- KateApp::self()->emitDocumentClosed(QString::number((qptrdiff)doc));
- qCDebug(LOG_KATE)<<"deleting document with name:"<<doc->documentName();
+ KateApp::self()->emitDocumentClosed(QString::number((qptrdiff)doc));
+ qCDebug(LOG_KATE) << "deleting document with name:" << doc->documentName();
+
+ // document will be deleted, soon
+ emit documentWillBeDeleted(doc);
- // document will be deleted, soon
- emit documentWillBeDeleted (doc);
+ // really delete the document and its infos
+ delete m_docInfos.take(doc);
+ delete m_docList.takeAt(m_docList.indexOf(doc));
- // really delete the document and its infos
- delete m_docInfos.take (doc);
- delete m_docList.takeAt (m_docList.indexOf(doc));
-
- // document is gone, emit our signals
- emit documentDeleted (doc);
+ // document is gone, emit our signals
+ emit documentDeleted(doc);
}
-KTextEditor::Document *KateDocManager::document (uint n)
+KTextEditor::Document *KateDocManager::document(uint n)
{
- return m_docList.at(n);
+ return m_docList.at(n);
}
-KateDocumentInfo *KateDocManager::documentInfo (KTextEditor::Document *doc)
+KateDocumentInfo *KateDocManager::documentInfo(KTextEditor::Document *doc)
{
- return m_docInfos.contains(doc) ? m_docInfos[doc] : 0;
+ return m_docInfos.contains(doc) ? m_docInfos[doc] : 0;
}
-int KateDocManager::findDocument (KTextEditor::Document *doc)
+int KateDocManager::findDocument(KTextEditor::Document *doc)
{
- return m_docList.indexOf (doc);
+ return m_docList.indexOf(doc);
}
-uint KateDocManager::documents ()
+uint KateDocManager::documents()
{
- return m_docList.count ();
+ return m_docList.count();
}
-KTextEditor::Document *KateDocManager::findDocument (const QUrl &url) const
+KTextEditor::Document *KateDocManager::findDocument(const QUrl &url) const
{
- QUrl u( url.adjusted(QUrl::NormalizePathSegments) );
+ QUrl u(url.adjusted(QUrl::NormalizePathSegments));
- foreach (KTextEditor::Document* it, m_docList)
- {
- if ( it->url() == u)
- return it;
- }
+ foreach(KTextEditor::Document * it, m_docList) {
+ if (it->url() == u) {
+ return it;
+ }
+ }
- return 0;
+ return 0;
}
bool KateDocManager::isOpen(QUrl url)
{
- // return just if we found some document with this url
- return findDocument (url) != 0;
+ // return just if we found some document with this url
+ return findDocument(url) != 0;
}
-QList<KTextEditor::Document *> KateDocManager::openUrls(const QList<QUrl> &urls, const QString &encoding, bool isTempFile, const KateDocumentInfo& docInfo)
+QList<KTextEditor::Document *> KateDocManager::openUrls(const QList<QUrl> &urls, const QString &encoding, bool isTempFile, const KateDocumentInfo &docInfo)
{
- QList<KTextEditor::Document *> docs;
+ QList<KTextEditor::Document *> docs;
- emit aboutToCreateDocuments();
+ emit aboutToCreateDocuments();
- foreach (const QUrl &url, urls) {
- docs << openUrl(url, encoding, isTempFile, docInfo);
- }
+ foreach(const QUrl & url, urls) {
+ docs << openUrl(url, encoding, isTempFile, docInfo);
+ }
- emit documentsCreated(docs);
+ emit documentsCreated(docs);
- return docs;
+ return docs;
}
-KTextEditor::Document *KateDocManager::openUrl (const QUrl& url, const QString &encoding, bool isTempFile, const KateDocumentInfo& docInfo)
+KTextEditor::Document *KateDocManager::openUrl(const QUrl &url, const QString &encoding, bool isTempFile, const KateDocumentInfo &docInfo)
{
- // special handling: if only one unmodified empty buffer in the list,
- // keep this buffer in mind to close it after opening the new url
- KTextEditor::Document * untitledDoc = 0;
- if ((documentList().count() == 1) && (!documentList().at(0)->isModified()
- && documentList().at(0)->url().isEmpty()))
- {
- untitledDoc = documentList().first();
- }
+ // special handling: if only one unmodified empty buffer in the list,
+ // keep this buffer in mind to close it after opening the new url
+ KTextEditor::Document *untitledDoc = 0;
+ if ((documentList().count() == 1) && (!documentList().at(0)->isModified()
+ && documentList().at(0)->url().isEmpty())) {
+ untitledDoc = documentList().first();
+ }
- //
- // create new document
- //
- QUrl u( url.adjusted(QUrl::NormalizePathSegments) );
- KTextEditor::Document *doc = 0;
+ //
+ // create new document
+ //
+ QUrl u(url.adjusted(QUrl::NormalizePathSegments));
+ KTextEditor::Document *doc = 0;
- // always new document if url is empty...
- if (!u.isEmpty())
- doc = findDocument (u);
+ // always new document if url is empty...
+ if (!u.isEmpty()) {
+ doc = findDocument(u);
+ }
- if ( !doc )
- {
- doc = createDoc (docInfo);
+ if (!doc) {
+ doc = createDoc(docInfo);
- doc->setEncoding(encoding);
+ doc->setEncoding(encoding);
- if (!u.isEmpty())
- {
- if (!loadMetaInfos(doc, u))
- doc->openUrl (u);
+ if (!u.isEmpty()) {
+ if (!loadMetaInfos(doc, u)) {
+ doc->openUrl(u);
+ }
+ }
}
- }
- //
- // if needed, register as temporary file
- //
- if ( isTempFile && u.isLocalFile() ) {
- QFileInfo fi( u.toLocalFile() );
- if ( fi.exists() ) {
- m_tempFiles[doc] = qMakePair(u, fi.lastModified());
- qCDebug(LOG_KATE) << "temporary file will be deleted after use unless modified: " << u;
+ //
+ // if needed, register as temporary file
+ //
+ if (isTempFile && u.isLocalFile()) {
+ QFileInfo fi(u.toLocalFile());
+ if (fi.exists()) {
+ m_tempFiles[doc] = qMakePair(u, fi.lastModified());
+ qCDebug(LOG_KATE) << "temporary file will be deleted after use unless modified: " << u;
+ }
}
- }
- //
- // close untitled document, as it is not wanted
- //
- if (untitledDoc)
- closeDocument(untitledDoc);
+ //
+ // close untitled document, as it is not wanted
+ //
+ if (untitledDoc) {
+ closeDocument(untitledDoc);
+ }
- return doc;
+ return doc;
}
bool KateDocManager::closeDocuments(const QList<KTextEditor::Document *> &documents, bool closeUrl)
{
- if (documents.isEmpty()) return false;
+ if (documents.isEmpty()) {
+ return false;
+ }
- saveMetaInfos( documents );
+ saveMetaInfos(documents);
- emit aboutToDeleteDocuments(documents);
+ emit aboutToDeleteDocuments(documents);
- int last = 0;
- foreach(KTextEditor::Document *doc, documents)
- {
- if (closeUrl && !doc->closeUrl())
- return false; // get out on first error
+ int last = 0;
+ foreach(KTextEditor::Document * doc, documents) {
+ if (closeUrl && !doc->closeUrl()) {
+ return false; // get out on first error
+ }
- for (int i = 0; i < KateApp::self()->mainWindowsCount (); i++ ) {
- KateApp::self()->mainWindow(i)->viewManager()->closeViews(doc);
- }
+ for (int i = 0; i < KateApp::self()->mainWindowsCount(); i++) {
+ KateApp::self()->mainWindow(i)->viewManager()->closeViews(doc);
+ }
- if ( closeUrl && m_tempFiles.contains( doc ) )
- {
- QFileInfo fi( m_tempFiles[ doc ].first.toLocalFile() );
- if ( fi.lastModified() <= m_tempFiles[ doc ].second ||
- KMessageBox::questionYesNo( KateApp::self()->activeKateMainWindow(),
- i18n("The supposedly temporary file %1 has been modified. "
- "Do you want to delete it anyway?", m_tempFiles[ doc ].first.url(QUrl::PreferLocalFile)),
- i18n("Delete File?") ) == KMessageBox::Yes )
- {
- KIO::del( m_tempFiles[ doc ].first, KIO::HideProgressInfo );
- qCDebug(LOG_KATE) << "Deleted temporary file " << m_tempFiles[ doc ].first;
- m_tempFiles.remove( doc );
- }
- else
- {
- m_tempFiles.remove(doc);
- qCDebug(LOG_KATE) << "The supposedly temporary file " << m_tempFiles[ doc ].first.url() << " have been modified since loaded, and has not been deleted.";
- }
- }
+ if (closeUrl && m_tempFiles.contains(doc)) {
+ QFileInfo fi(m_tempFiles[ doc ].first.toLocalFile());
+ if (fi.lastModified() <= m_tempFiles[ doc ].second ||
+ KMessageBox::questionYesNo(KateApp::self()->activeKateMainWindow(),
+ i18n("The supposedly temporary file %1 has been modified. "
+ "Do you want to delete it anyway?", m_tempFiles[ doc ].first.url(QUrl::PreferLocalFile)),
+ i18n("Delete File?")) == KMessageBox::Yes) {
+ KIO::del(m_tempFiles[ doc ].first, KIO::HideProgressInfo);
+ qCDebug(LOG_KATE) << "Deleted temporary file " << m_tempFiles[ doc ].first;
+ m_tempFiles.remove(doc);
+ } else {
+ m_tempFiles.remove(doc);
+ qCDebug(LOG_KATE) << "The supposedly temporary file " << m_tempFiles[ doc ].first.url() << " have been modified since loaded, and has not been deleted.";
+ }
+ }
- deleteDoc (doc);
- last++;
- }
+ deleteDoc(doc);
+ last++;
+ }
- emit documentsDeleted(documents.mid(last));
+ emit documentsDeleted(documents.mid(last));
- // never ever empty the whole document list
- if (m_docList.isEmpty())
- createDoc ();
+ // never ever empty the whole document list
+ if (m_docList.isEmpty()) {
+ createDoc();
+ }
- return true;
+ return true;
}
bool KateDocManager::closeDocument(KTextEditor::Document *doc, bool closeUrl)
{
- if (!doc) return false;
+ if (!doc) {
+ return false;
+ }
- QList<KTextEditor::Document *> documents;
- documents.append( doc );
+ QList<KTextEditor::Document *> documents;
+ documents.append(doc);
- return closeDocuments( documents, closeUrl );
+ return closeDocuments(documents, closeUrl);
}
bool KateDocManager::closeOtherDocuments(uint n)
{
- return closeOtherDocuments (document(n));
+ return closeOtherDocuments(document(n));
}
-bool KateDocManager::closeDocumentList(QList<KTextEditor::Document*> documents)
+bool KateDocManager::closeDocumentList(QList<KTextEditor::Document *> documents)
{
- bool res = true;
+ bool res = true;
- for (int i = 0; i < KateApp::self()->mainWindowsCount (); i++ )
- KateApp::self()->mainWindow(i)->viewManager()->setViewActivationBlocked(true);
+ for (int i = 0; i < KateApp::self()->mainWindowsCount(); i++) {
+ KateApp::self()->mainWindow(i)->viewManager()->setViewActivationBlocked(true);
+ }
- QList<KTextEditor::Document*> modifiedDocuments;
- foreach(KTextEditor::Document* document, documents) {
- if (document->isModified()) {
- modifiedDocuments.append(document);
+ QList<KTextEditor::Document *> modifiedDocuments;
+ foreach(KTextEditor::Document * document, documents) {
+ if (document->isModified()) {
+ modifiedDocuments.append(document);
+ }
}
- }
- if(modifiedDocuments.size() > 0 && !KateSaveModifiedDialog::queryClose(0, modifiedDocuments)) {
- return false;
- }
+ if (modifiedDocuments.size() > 0 && !KateSaveModifiedDialog::queryClose(0, modifiedDocuments)) {
+ return false;
+ }
- res = closeDocuments( documents, false ); // Do not show save/discard dialog
+ res = closeDocuments(documents, false); // Do not show save/discard dialog
- for (int i = 0; i < KateApp::self()->mainWindowsCount (); i++ )
- {
- KateApp::self()->mainWindow(i)->viewManager()->setViewActivationBlocked(false);
- if (!KateApp::self()->mainWindow(i)->viewManager()->activeView())
- KateApp::self()->mainWindow(i)->viewManager()->activateView (m_docList.at(0));
- else
- KateApp::self()->mainWindow(i)->viewManager()->reactivateActiveView();
- }
+ for (int i = 0; i < KateApp::self()->mainWindowsCount(); i++) {
+ KateApp::self()->mainWindow(i)->viewManager()->setViewActivationBlocked(false);
+ if (!KateApp::self()->mainWindow(i)->viewManager()->activeView()) {
+ KateApp::self()->mainWindow(i)->viewManager()->activateView(m_docList.at(0));
+ } else {
+ KateApp::self()->mainWindow(i)->viewManager()->reactivateActiveView();
+ }
+ }
- return res;
+ return res;
}
bool KateDocManager::closeAllDocuments(bool closeUrl)
{
- bool res = true;
+ bool res = true;
- QList<KTextEditor::Document*> docs = m_docList;
+ QList<KTextEditor::Document *> docs = m_docList;
- for (int i = 0; i < KateApp::self()->mainWindowsCount (); i++ )
- KateApp::self()->mainWindow(i)->viewManager()->setViewActivationBlocked(true);
+ for (int i = 0; i < KateApp::self()->mainWindowsCount(); i++) {
+ KateApp::self()->mainWindow(i)->viewManager()->setViewActivationBlocked(true);
+ }
- res = closeDocuments( docs, closeUrl );
+ res = closeDocuments(docs, closeUrl);
- for (int i = 0; i < KateApp::self()->mainWindowsCount (); i++ )
- {
- KateApp::self()->mainWindow(i)->viewManager()->setViewActivationBlocked(false);
- KateApp::self()->mainWindow(i)->viewManager()->activateView (m_docList.at(0));
- }
+ for (int i = 0; i < KateApp::self()->mainWindowsCount(); i++) {
+ KateApp::self()->mainWindow(i)->viewManager()->setViewActivationBlocked(false);
+ KateApp::self()->mainWindow(i)->viewManager()->activateView(m_docList.at(0));
+ }
- return res;
+ return res;
}
-bool KateDocManager::closeOtherDocuments(KTextEditor::Document* doc)
+bool KateDocManager::closeOtherDocuments(KTextEditor::Document *doc)
{
- bool res = true;
+ bool res = true;
- QList<KTextEditor::Document*> documents = m_docList;
+ QList<KTextEditor::Document *> documents = m_docList;
- for (int i = 0; i < KateApp::self()->mainWindowsCount (); i++ )
- KateApp::self()->mainWindow(i)->viewManager()->setViewActivationBlocked(true);
+ for (int i = 0; i < KateApp::self()->mainWindowsCount(); i++) {
+ KateApp::self()->mainWindow(i)->viewManager()->setViewActivationBlocked(true);
+ }
- documents.removeOne( doc );
+ documents.removeOne(doc);
- res = closeDocuments( documents );
+ res = closeDocuments(documents);
- for (int i = 0; i < KateApp::self()->mainWindowsCount (); i++ )
- {
- KateApp::self()->mainWindow(i)->viewManager()->setViewActivationBlocked(false);
- KateApp::self()->mainWindow(i)->viewManager()->activateView (m_docList.at(0));
- }
+ for (int i = 0; i < KateApp::self()->mainWindowsCount(); i++) {
+ KateApp::self()->mainWindow(i)->viewManager()->setViewActivationBlocked(false);
+ KateApp::self()->mainWindow(i)->viewManager()->activateView(m_docList.at(0));
+ }
- return res;
+ return res;
}
/**
* Find all modified documents.
* @return Return the list of all modified documents.
*/
-QList<KTextEditor::Document*> KateDocManager::modifiedDocumentList()
+QList<KTextEditor::Document *> KateDocManager::modifiedDocumentList()
{
- QList<KTextEditor::Document*> modified;
- foreach (KTextEditor::Document* doc, m_docList)
- {
- if (doc->isModified())
- {
- modified.append(doc);
+ QList<KTextEditor::Document *> modified;
+ foreach(KTextEditor::Document * doc, m_docList) {
+ if (doc->isModified()) {
+ modified.append(doc);
+ }
}
- }
- return modified;
+ return modified;
}
-
bool KateDocManager::queryCloseDocuments(KateMainWindow *w)
{
- int docCount = m_docList.count();
- foreach (KTextEditor::Document *doc, m_docList)
- {
- if (doc->url().isEmpty() && doc->isModified())
- {
- int msgres = KMessageBox::warningYesNoCancel( w,
- i18n("<p>The document '%1' has been modified, but not saved.</p>"
- "<p>Do you want to save your changes or discard them?</p>", doc->documentName() ),
- i18n("Close Document"), KStandardGuiItem::save(), KStandardGuiItem::discard() );
-
- if (msgres == KMessageBox::Cancel)
- return false;
-
- if (msgres == KMessageBox::Yes)
- {
- KEncodingFileDialog::Result r = KEncodingFileDialog::getSaveUrlAndEncoding( doc->encoding(), QUrl(), QString(), w, i18n("Save As"));
-
- doc->setEncoding( r.encoding );
-
- if (!r.URLs.isEmpty())
- {
- QUrl tmp = r.URLs.first();
-
- if ( !doc->saveAs( tmp ) )
- return false;
+ int docCount = m_docList.count();
+ foreach(KTextEditor::Document * doc, m_docList) {
+ if (doc->url().isEmpty() && doc->isModified()) {
+ int msgres = KMessageBox::warningYesNoCancel(w,
+ i18n("<p>The document '%1' has been modified, but not saved.</p>"
+ "<p>Do you want to save your changes or discard them?</p>", doc->documentName()),
+ i18n("Close Document"), KStandardGuiItem::save(), KStandardGuiItem::discard());
+
+ if (msgres == KMessageBox::Cancel) {
+ return false;
+ }
+
+ if (msgres == KMessageBox::Yes) {
+ KEncodingFileDialog::Result r = KEncodingFileDialog::getSaveUrlAndEncoding(doc->encoding(), QUrl(), QString(), w, i18n("Save As"));
+
+ doc->setEncoding(r.encoding);
+
+ if (!r.URLs.isEmpty()) {
+ QUrl tmp = r.URLs.first();
+
+ if (!doc->saveAs(tmp)) {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+ } else {
+ if (!doc->queryClose()) {
+ return false;
+ }
}
- else
- return false;
- }
}
- else
- {
- if (!doc->queryClose())
+
+ // document count changed while queryClose, abort and notify user
+ if (m_docList.count() > docCount) {
+ KMessageBox::information(w,
+ i18n("New file opened while trying to close Kate, closing aborted."),
+ i18n("Closing Aborted"));
return false;
}
- }
- // document count changed while queryClose, abort and notify user
- if (m_docList.count() > docCount)
- {
- KMessageBox::information (w,
- i18n ("New file opened while trying to close Kate, closing aborted."),
- i18n ("Closing Aborted"));
- return false;
- }
-
- return true;
+ return true;
}
-
void KateDocManager::saveAll()
{
- foreach ( KTextEditor::Document *doc, m_docList )
- if ( doc->isModified() )
- doc->documentSave();
+ foreach(KTextEditor::Document * doc, m_docList)
+ if (doc->isModified()) {
+ doc->documentSave();
+ }
}
-void KateDocManager::saveSelected(const QList<KTextEditor::Document*> &docList)
+void KateDocManager::saveSelected(const QList<KTextEditor::Document *> &docList)
{
- foreach(KTextEditor::Document* doc, docList)
- {
- if ( doc->isModified() )
- doc->documentSave();
- }
+ foreach(KTextEditor::Document * doc, docList) {
+ if (doc->isModified()) {
+ doc->documentSave();
+ }
+ }
}
void KateDocManager::reloadAll()
{
- // reload all docs that are NOT modified on disk
- foreach ( KTextEditor::Document *doc, m_docList ) {
- if ( ! documentInfo( doc )->modifiedOnDisc )
- doc->documentReload();
- }
+ // reload all docs that are NOT modified on disk
+ foreach(KTextEditor::Document * doc, m_docList) {
+ if (! documentInfo(doc)->modifiedOnDisc) {
+ doc->documentReload();
+ }
+ }
- // take care of all documents that ARE modified on disk
- KateApp::self()->activeKateMainWindow()->showModOnDiskPrompt();
+ // take care of all documents that ARE modified on disk
+ KateApp::self()->activeKateMainWindow()->showModOnDiskPrompt();
}
void KateDocManager::closeOrphaned()
{
- QList<KTextEditor::Document *> documents;
+ QList<KTextEditor::Document *> documents;
- foreach ( KTextEditor::Document *doc, m_docList )
- {
- KateDocumentInfo* info = documentInfo( doc );
- if (info && !info->openSuccess)
- documents.append( doc );
- }
+ foreach(KTextEditor::Document * doc, m_docList) {
+ KateDocumentInfo *info = documentInfo(doc);
+ if (info && !info->openSuccess) {
+ documents.append(doc);
+ }
+ }
- closeDocuments( documents );
+ closeDocuments(documents);
}
-void KateDocManager::saveDocumentList (KConfig* config)
+void KateDocManager::saveDocumentList(KConfig *config)
{
- KConfigGroup openDocGroup(config, "Open Documents");
+ KConfigGroup openDocGroup(config, "Open Documents");
- openDocGroup.writeEntry ("Count", m_docList.count());
+ openDocGroup.writeEntry("Count", m_docList.count());
- int i = 0;
- foreach ( KTextEditor::Document *doc, m_docList)
- {
- KConfigGroup cg( config, QString::fromLatin1("Document %1").arg(i) );
- if (KTextEditor::ParameterizedSessionConfigInterface *iface =
- qobject_cast<KTextEditor::ParameterizedSessionConfigInterface*>(doc))
- {
- iface->writeParameterizedSessionConfig(cg, KTextEditor::ParameterizedSessionConfigInterface::SkipNone);
- }
+ int i = 0;
+ foreach(KTextEditor::Document * doc, m_docList) {
+ KConfigGroup cg(config, QString::fromLatin1("Document %1").arg(i));
+ if (KTextEditor::ParameterizedSessionConfigInterface *iface =
+ qobject_cast<KTextEditor::ParameterizedSessionConfigInterface *>(doc)) {
+ iface->writeParameterizedSessionConfig(cg, KTextEditor::ParameterizedSessionConfigInterface::SkipNone);
+ }
- i++;
- }
+ i++;
+ }
}
-void KateDocManager::restoreDocumentList (KConfig* config)
+void KateDocManager::restoreDocumentList(KConfig *config)
{
- KConfigGroup openDocGroup(config, "Open Documents");
- unsigned int count = openDocGroup.readEntry("Count", 0);
-
- if (count == 0)
- {
- return;
- }
+ KConfigGroup openDocGroup(config, "Open Documents");
+ unsigned int count = openDocGroup.readEntry("Count", 0);
- QProgressDialog progress;
- progress.setWindowTitle(i18n("Starting Up"));
- progress.setLabelText(i18n("Reopening files from the last session..."));
- progress.setModal(true);
- progress.setCancelButton(0);
- progress.setRange(0, count);
+ if (count == 0) {
+ return;
+ }
- m_documentStillToRestore = count;
- m_openingErrors.clear();
- for (unsigned int i = 0; i < count; i++)
- {
- KConfigGroup cg( config, QString::fromLatin1("Document %1").arg(i));
- KTextEditor::Document *doc = 0;
+ QProgressDialog progress;
+ progress.setWindowTitle(i18n("Starting Up"));
+ progress.setLabelText(i18n("Reopening files from the last session..."));
+ progress.setModal(true);
+ progress.setCancelButton(0);
+ progress.setRange(0, count);
+
+ m_documentStillToRestore = count;
+ m_openingErrors.clear();
+ for (unsigned int i = 0; i < count; i++) {
+ KConfigGroup cg(config, QString::fromLatin1("Document %1").arg(i));
+ KTextEditor::Document *doc = 0;
+
+ if (i == 0) {
+ doc = document(0);
+ } else {
+ doc = createDoc();
+ }
- if (i == 0) {
- doc = document (0);
- }
- else
- doc = createDoc ();
+ connect(doc, SIGNAL(completed()), this, SLOT(documentOpened()));
+ connect(doc, SIGNAL(canceled(QString)), this, SLOT(documentOpened()));
- connect(doc, SIGNAL(completed()), this, SLOT(documentOpened()));
- connect(doc, SIGNAL(canceled(QString)), this, SLOT(documentOpened()));
+ if (KTextEditor::ParameterizedSessionConfigInterface *iface =
+ qobject_cast<KTextEditor::ParameterizedSessionConfigInterface *>(doc)) {
+ iface->readParameterizedSessionConfig(cg, KTextEditor::ParameterizedSessionConfigInterface::SkipNone);
+ }
- if (KTextEditor::ParameterizedSessionConfigInterface *iface =
- qobject_cast<KTextEditor::ParameterizedSessionConfigInterface *>(doc))
- {
- iface->readParameterizedSessionConfig(cg, KTextEditor::ParameterizedSessionConfigInterface::SkipNone);
+ progress.setValue(i);
}
-
- progress.setValue(i);
- }
}
-void KateDocManager::slotModifiedOnDisc (KTextEditor::Document *doc, bool b, KTextEditor::ModificationInterface::ModifiedOnDiskReason reason)
+void KateDocManager::slotModifiedOnDisc(KTextEditor::Document *doc, bool b, KTextEditor::ModificationInterface::ModifiedOnDiskReason reason)
{
- if (m_docInfos.contains(doc))
- {
- m_docInfos[doc]->modifiedOnDisc = b;
- m_docInfos[doc]->modifiedOnDiscReason = reason;
- slotModChanged1(doc);
- }
+ if (m_docInfos.contains(doc)) {
+ m_docInfos[doc]->modifiedOnDisc = b;
+ m_docInfos[doc]->modifiedOnDiscReason = reason;
+ slotModChanged1(doc);
+ }
}
/**
@@ -582,43 +571,40 @@ void KateDocManager::slotModifiedOnDisc (KTextEditor::Document *doc, bool b, KTe
*/
bool KateDocManager::loadMetaInfos(KTextEditor::Document *doc, const QUrl &url)
{
- if (!m_saveMetaInfos)
- return false;
-
- if (!m_metaInfos->hasGroup(url.toDisplayString()))
- return false;
-
- QByteArray md5;
- bool ok = true;
-
- if (computeUrlMD5(url, md5))
- {
- KConfigGroup urlGroup( m_metaInfos, url.toDisplayString() );
- const QString old_md5 = urlGroup.readEntry("MD5");
-
- if (QString::fromLatin1(md5) == old_md5)
- {
- if (KTextEditor::ParameterizedSessionConfigInterface *iface =
- qobject_cast<KTextEditor::ParameterizedSessionConfigInterface *>(doc))
- {
- KTextEditor::ParameterizedSessionConfigInterface::SessionConfigParameter flags =
- KTextEditor::ParameterizedSessionConfigInterface::SkipNone;
- if (documentInfo(doc)->openedByUser) {
- flags = KTextEditor::ParameterizedSessionConfigInterface::SkipEncoding;
- }
- iface->readParameterizedSessionConfig(urlGroup, flags);
- }
+ if (!m_saveMetaInfos) {
+ return false;
}
- else
- {
- urlGroup.deleteGroup();
- ok = false;
+
+ if (!m_metaInfos->hasGroup(url.toDisplayString())) {
+ return false;
}
- m_metaInfos->sync();
- }
+ QByteArray md5;
+ bool ok = true;
+
+ if (computeUrlMD5(url, md5)) {
+ KConfigGroup urlGroup(m_metaInfos, url.toDisplayString());
+ const QString old_md5 = urlGroup.readEntry("MD5");
+
+ if (QString::fromLatin1(md5) == old_md5) {
+ if (KTextEditor::ParameterizedSessionConfigInterface *iface =
+ qobject_cast<KTextEditor::ParameterizedSessionConfigInterface *>(doc)) {
+ KTextEditor::ParameterizedSessionConfigInterface::SessionConfigParameter flags =
+ KTextEditor::ParameterizedSessionConfigInterface::SkipNone;
+ if (documentInfo(doc)->openedByUser) {
+ flags = KTextEditor::ParameterizedSessionConfigInterface::SkipEncoding;
+ }
+ iface->readParameterizedSessionConfig(urlGroup, flags);
+ }
+ } else {
+ urlGroup.deleteGroup();
+ ok = false;
+ }
- return ok && doc->url() == url;
+ m_metaInfos->sync();
+ }
+
+ return ok && doc->url() == url;
}
/**
@@ -627,105 +613,103 @@ bool KateDocManager::loadMetaInfos(KTextEditor::Document *doc, const QUrl &url)
void KateDocManager::saveMetaInfos(const QList<KTextEditor::Document *> &documents)
{
- if (!m_saveMetaInfos)
- return;
+ if (!m_saveMetaInfos) {
+ return;
+ }
- QByteArray md5;
- QDateTime now = QDateTime::currentDateTime();
+ QByteArray md5;
+ QDateTime now = QDateTime::currentDateTime();
- foreach(const KTextEditor::Document *doc, documents)
- {
- if (doc->isModified())
- continue;
+ foreach(const KTextEditor::Document * doc, documents) {
+ if (doc->isModified()) {
+ continue;
+ }
- if (computeUrlMD5(doc->url(), md5))
- {
- KConfigGroup urlGroup( m_metaInfos, doc->url().toString() );
+ if (computeUrlMD5(doc->url(), md5)) {
+ KConfigGroup urlGroup(m_metaInfos, doc->url().toString());
- if (KTextEditor::SessionConfigInterface *iface = qobject_cast<KTextEditor::SessionConfigInterface *>(doc))
- iface->writeSessionConfig(urlGroup);
+ if (KTextEditor::SessionConfigInterface *iface = qobject_cast<KTextEditor::SessionConfigInterface *>(doc)) {
+ iface->writeSessionConfig(urlGroup);
+ }
- urlGroup.writeEntry("MD5", md5.constData());
- urlGroup.writeEntry("Time", now);
+ urlGroup.writeEntry("MD5", md5.constData());
+ urlGroup.writeEntry("Time", now);
+ }
}
- }
- m_metaInfos->sync();
+ m_metaInfos->sync();
}
// TODO: KDE 5: KateDocument computes the md5 digest when loading a file, and
// when saving a file. Maybe add "QString KTextEditor::Document::md5sum()" const?
bool KateDocManager::computeUrlMD5(const QUrl &url, QByteArray &result)
{
- QFile f(url.toLocalFile());
+ QFile f(url.toLocalFile());
- if (f.exists() && f.open(QIODevice::ReadOnly))
- {
- QCryptographicHash crypto(QCryptographicHash::Md5);
- while(!f.atEnd())
- crypto.addData (f.read(256 * 1024));
- result = crypto.result();
- f.close();
- }
- else
- return false;
+ if (f.exists() && f.open(QIODevice::ReadOnly)) {
+ QCryptographicHash crypto(QCryptographicHash::Md5);
+ while (!f.atEnd()) {
+ crypto.addData(f.read(256 * 1024));
+ }
+ result = crypto.result();
+ f.close();
+ } else {
+ return false;
+ }
- return true;
+ return true;
}
-void KateDocManager::slotModChanged(KTextEditor::Document * doc)
+void KateDocManager::slotModChanged(KTextEditor::Document *doc)
{
- QList<KTextEditor::Document *> documents;
- documents.append( doc );
- saveMetaInfos( documents );
+ QList<KTextEditor::Document *> documents;
+ documents.append(doc);
+ saveMetaInfos(documents);
}
-void KateDocManager::slotModChanged1(KTextEditor::Document * doc)
+void KateDocManager::slotModChanged1(KTextEditor::Document *doc)
{
- const KateDocumentInfo *info = documentInfo(doc);
+ const KateDocumentInfo *info = documentInfo(doc);
- if (info && info->modifiedOnDisc)
- {
- QMetaObject::invokeMethod(KateApp::self()->activeKateMainWindow(), "queueModifiedOnDisc",
- Qt::QueuedConnection, Q_ARG(KTextEditor::Document *, doc));
- }
+ if (info && info->modifiedOnDisc) {
+ QMetaObject::invokeMethod(KateApp::self()->activeKateMainWindow(), "queueModifiedOnDisc",
+ Qt::QueuedConnection, Q_ARG(KTextEditor::Document *, doc));
+ }
}
void KateDocManager::documentOpened()
{
- KColorScheme colors(QPalette::Active);
+ KColorScheme colors(QPalette::Active);
- KTextEditor::Document *doc = qobject_cast<KTextEditor::Document*>(sender());
- if (!doc) return; // should never happen, but who knows
- disconnect(doc, SIGNAL(completed()), this, SLOT(documentOpened()));
- disconnect(doc, SIGNAL(canceled(QString)), this, SLOT(documentOpened()));
- if (doc->openingError())
- {
- m_openingErrors += QLatin1Char('\n') + doc->openingErrorMessage() + QStringLiteral("\n\n");
- KateDocumentInfo* info = documentInfo(doc);
- if (info) {
- info->openSuccess = false;
+ KTextEditor::Document *doc = qobject_cast<KTextEditor::Document *>(sender());
+ if (!doc) {
+ return; // should never happen, but who knows
+ }
+ disconnect(doc, SIGNAL(completed()), this, SLOT(documentOpened()));
+ disconnect(doc, SIGNAL(canceled(QString)), this, SLOT(documentOpened()));
+ if (doc->openingError()) {
+ m_openingErrors += QLatin1Char('\n') + doc->openingErrorMessage() + QStringLiteral("\n\n");
+ KateDocumentInfo *info = documentInfo(doc);
+ if (info) {
+ info->openSuccess = false;
+ }
}
- }
- --m_documentStillToRestore;
+ --m_documentStillToRestore;
- if (m_documentStillToRestore == 0)
- QTimer::singleShot(0, this, SLOT(showRestoreErrors()));
+ if (m_documentStillToRestore == 0) {
+ QTimer::singleShot(0, this, SLOT(showRestoreErrors()));
+ }
}
-void KateDocManager::showRestoreErrors ()
+void KateDocManager::showRestoreErrors()
{
- if (!m_openingErrors.isEmpty())
- {
- KMessageBox::information (0,
- m_openingErrors,
- i18n ("Errors/Warnings while opening documents"));
+ if (!m_openingErrors.isEmpty()) {
+ KMessageBox::information(0,
+ m_openingErrors,
+ i18n("Errors/Warnings while opening documents"));
- // clear errors
- m_openingErrors.clear ();
- }
+ // clear errors
+ m_openingErrors.clear();
+ }
}
-// kate: space-indent on; indent-width 2; replace-tabs on;
-
-
diff --git a/kate/app/katedocmanager.h b/kate/app/katedocmanager.h
index a0e3c10..0b54970 100644
--- a/kate/app/katedocmanager.h
+++ b/kate/app/katedocmanager.h
@@ -37,13 +37,13 @@ class KateMainWindow;
class KateDocumentInfo
{
- public:
+public:
enum CustomRoles {RestoreOpeningFailedRole };
- public:
- KateDocumentInfo ()
- : modifiedOnDisc (false)
- , modifiedOnDiscReason (KTextEditor::ModificationInterface::OnDiskUnmodified)
+public:
+ KateDocumentInfo()
+ : modifiedOnDisc(false)
+ , modifiedOnDiscReason(KTextEditor::ModificationInterface::OnDiskUnmodified)
, openedByUser(false)
, openSuccess(true)
{}
@@ -59,75 +59,70 @@ class KateDocManager : public QObject
{
Q_OBJECT
- public:
- KateDocManager (QObject *parent);
- ~KateDocManager ();
+public:
+ KateDocManager(QObject *parent);
+ ~KateDocManager();
- static KateDocManager *self ();
+ static KateDocManager *self();
- KTextEditor::Document *createDoc (const KateDocumentInfo& docInfo = KateDocumentInfo());
-
- void deleteDoc (KTextEditor::Document *doc);
+ KTextEditor::Document *createDoc(const KateDocumentInfo &docInfo = KateDocumentInfo());
- KTextEditor::Document *document (uint n);
+ void deleteDoc(KTextEditor::Document *doc);
- KateDocumentInfo *documentInfo (KTextEditor::Document *doc);
+ KTextEditor::Document *document(uint n);
- int findDocument (KTextEditor::Document *doc);
+ KateDocumentInfo *documentInfo(KTextEditor::Document *doc);
+
+ int findDocument(KTextEditor::Document *doc);
/** Returns the documentNumber of the doc with url URL or -1 if no such doc is found */
- KTextEditor::Document *findDocument (const QUrl &url) const;
+ KTextEditor::Document *findDocument(const QUrl &url) const;
bool isOpen(QUrl url);
- uint documents ();
+ uint documents();
- const QList<KTextEditor::Document*> &documentList () const
- {
- return m_docList;
+ const QList<KTextEditor::Document *> &documentList() const {
+ return m_docList;
}
- KTextEditor::Document *openUrl(const QUrl&,
+ KTextEditor::Document *openUrl(const QUrl &,
const QString &encoding = QString(),
bool isTempFile = false,
- const KateDocumentInfo& docInfo = KateDocumentInfo());
+ const KateDocumentInfo &docInfo = KateDocumentInfo());
- QList<KTextEditor::Document *> openUrls(const QList<QUrl>&,
+ QList<KTextEditor::Document *> openUrls(const QList<QUrl> &,
const QString &encoding = QString(),
bool isTempFile = false,
- const KateDocumentInfo& docInfo = KateDocumentInfo());
+ const KateDocumentInfo &docInfo = KateDocumentInfo());
bool closeDocument(KTextEditor::Document *, bool closeUrl = true);
bool closeDocuments(const QList<KTextEditor::Document *> &documents, bool closeUrl = true);
- bool closeDocumentList(QList<KTextEditor::Document*> documents);
+ bool closeDocumentList(QList<KTextEditor::Document *> documents);
bool closeAllDocuments(bool closeUrl = true);
- bool closeOtherDocuments(KTextEditor::Document*);
+ bool closeOtherDocuments(KTextEditor::Document *);
bool closeOtherDocuments(uint);
- QList<KTextEditor::Document*> modifiedDocumentList();
+ QList<KTextEditor::Document *> modifiedDocumentList();
bool queryCloseDocuments(KateMainWindow *w);
- void saveDocumentList (KConfig *config);
- void restoreDocumentList (KConfig *config);
+ void saveDocumentList(KConfig *config);
+ void restoreDocumentList(KConfig *config);
- inline bool getSaveMetaInfos()
- {
- return m_saveMetaInfos;
+ inline bool getSaveMetaInfos() {
+ return m_saveMetaInfos;
}
- inline void setSaveMetaInfos(bool b)
- {
- m_saveMetaInfos = b;
+ inline void setSaveMetaInfos(bool b) {
+ m_saveMetaInfos = b;
}
- inline int getDaysMetaInfos()
- {
- return m_daysMetaInfos;
+ inline int getDaysMetaInfos() {
+ return m_daysMetaInfos;
}
- inline void setDaysMetaInfos(int i)
- {
- m_daysMetaInfos = i;
+ inline void setDaysMetaInfos(int i) {
+ m_daysMetaInfos = i;
}
- public Q_SLOTS:
+public Q_SLOTS:
/**
* saves all documents that has at least one view.
* documents with no views are ignored :P
@@ -148,36 +143,36 @@ class KateDocManager : public QObject
/**
* save selected documents from the File List
*/
- void saveSelected(const QList<KTextEditor::Document*>&);
+ void saveSelected(const QList<KTextEditor::Document *> &);
- Q_SIGNALS:
+Q_SIGNALS:
/**
* This signal is emitted when the \p document was created.
*/
- void documentCreated (KTextEditor::Document *document);
+ void documentCreated(KTextEditor::Document *document);
/**
* This signal is emitted when the \p document was created.
* This is emited after the initial documentCreated for internal use in view manager
*/
- void documentCreatedViewManager (KTextEditor::Document *document);
+ void documentCreatedViewManager(KTextEditor::Document *document);
/**
* This signal is emitted before a \p document which should be closed is deleted
* The document is still accessible and usable, but it will be deleted
* after this signal was send.
- *
+ *
* @param document document that will be deleted
*/
- void documentWillBeDeleted (KTextEditor::Document *document);
+ void documentWillBeDeleted(KTextEditor::Document *document);
/**
* This signal is emitted when the \p document has been deleted.
- *
+ *
* Warning !!! DO NOT ACCESS THE DATA REFERENCED BY THE POINTER, IT IS ALREADY INVALID
* Use the pointer only to remove mappings in hash or maps
*/
- void documentDeleted (KTextEditor::Document *document);
+ void documentDeleted(KTextEditor::Document *document);
/**
* This signal is emitted before the batch of documents is being created.
@@ -209,19 +204,19 @@ class KateDocManager : public QObject
*/
void documentsDeleted(const QList<KTextEditor::Document *> &documents);
- private Q_SLOTS:
- void slotModifiedOnDisc (KTextEditor::Document *doc, bool b, KTextEditor::ModificationInterface::ModifiedOnDiskReason reason);
+private Q_SLOTS:
+ void slotModifiedOnDisc(KTextEditor::Document *doc, bool b, KTextEditor::ModificationInterface::ModifiedOnDiskReason reason);
void slotModChanged(KTextEditor::Document *doc);
void slotModChanged1(KTextEditor::Document *doc);
- void showRestoreErrors ();
- private:
+ void showRestoreErrors();
+private:
bool loadMetaInfos(KTextEditor::Document *doc, const QUrl &url);
void saveMetaInfos(const QList<KTextEditor::Document *> &docs);
bool computeUrlMD5(const QUrl &url, QByteArray &result);
- QList<KTextEditor::Document*> m_docList;
- QHash<KTextEditor::Document*, KateDocumentInfo*> m_docInfos;
+ QList<KTextEditor::Document *> m_docList;
+ QHash<KTextEditor::Document *, KateDocumentInfo *> m_docInfos;
KConfig *m_metaInfos;
bool m_saveMetaInfos;
@@ -232,9 +227,8 @@ class KateDocManager : public QObject
QString m_openingErrors;
int m_documentStillToRestore;
- private Q_SLOTS:
+private Q_SLOTS:
void documentOpened();
};
#endif
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/app/katemainwindow.cpp b/kate/app/katemainwindow.cpp
index 249514b..f01bd3e 100644
--- a/kate/app/katemainwindow.cpp
+++ b/kate/app/katemainwindow.cpp
@@ -79,385 +79,384 @@
//END
uint KateMainWindow::uniqueID = 1;
-KateMwModOnHdDialog *KateMainWindow::s_modOnHdDialog=0;
+KateMwModOnHdDialog *KateMainWindow::s_modOnHdDialog = 0;
-KateContainerStackedLayout::KateContainerStackedLayout(QWidget* parent)
- : QStackedLayout(parent)
+KateContainerStackedLayout::KateContainerStackedLayout(QWidget *parent)
+ : QStackedLayout(parent)
{}
QSize KateContainerStackedLayout::sizeHint() const
{
- if (currentWidget())
- return currentWidget()->sizeHint();
- return QStackedLayout::sizeHint();
+ if (currentWidget()) {
+ return currentWidget()->sizeHint();
+ }
+ return QStackedLayout::sizeHint();
}
QSize KateContainerStackedLayout::minimumSize() const
{
- if (currentWidget())
- return currentWidget()->minimumSize();
- return QStackedLayout::minimumSize();
+ if (currentWidget()) {
+ return currentWidget()->minimumSize();
+ }
+ return QStackedLayout::minimumSize();
}
-
-KateMainWindow::KateMainWindow (KConfig *sconfig, const QString &sgroup)
- : KateMDI::MainWindow (0)
- , m_wrapper (new KTextEditor::MainWindow (this))
+KateMainWindow::KateMainWindow(KConfig *sconfig, const QString &sgroup)
+ : KateMDI::MainWindow(0)
+ , m_wrapper(new KTextEditor::MainWindow(this))
{
- setObjectName(QString::fromLatin1("__KateMainWindow#%1").arg(uniqueID));
- // first the very important id
- myID = uniqueID;
- uniqueID++;
-
- m_modignore = false;
-
- int scnum = QApplication::desktop()->screenNumber(parentWidget());
- QRect desk = QApplication::desktop()->screenGeometry(scnum);
-
- QSize size;
-
- // try to load size
- if (sconfig)
- {
- KConfigGroup cg( sconfig, sgroup );
- size.setWidth (cg.readEntry( QString::fromLatin1("Width %1").arg(desk.width()), 0 ));
- size.setHeight (cg.readEntry( QString::fromLatin1("Height %1").arg(desk.height()), 0 ));
- }
-
- // if thats fails, try to reuse size
- if (size.isEmpty())
- {
- // first try to reuse size known from current or last created main window ;=)
- if (KateApp::self()->mainWindowsCount () > 0)
- {
- KateMainWindow *win = KateApp::self()->activeKateMainWindow ();
-
- if (!win)
- win = KateApp::self()->mainWindow (KateApp::self()->mainWindowsCount () - 1);
-
- size = win->size();
- }
- else // now fallback to hard defaults ;)
- {
- // first try global app config
- KConfigGroup cg( KSharedConfig::openConfig(), "MainWindow" );
- size.setWidth (cg.readEntry( QString::fromLatin1("Width %1").arg(desk.width()), 0 ));
- size.setHeight (cg.readEntry( QString::fromLatin1("Height %1").arg(desk.height()), 0 ));
-
- if (size.isEmpty())
- size = QSize (qMin (700, desk.width()), qMin(480, desk.height()));
+ setObjectName(QString::fromLatin1("__KateMainWindow#%1").arg(uniqueID));
+ // first the very important id
+ myID = uniqueID;
+ uniqueID++;
+
+ m_modignore = false;
+
+ int scnum = QApplication::desktop()->screenNumber(parentWidget());
+ QRect desk = QApplication::desktop()->screenGeometry(scnum);
+
+ QSize size;
+
+ // try to load size
+ if (sconfig) {
+ KConfigGroup cg(sconfig, sgroup);
+ size.setWidth(cg.readEntry(QString::fromLatin1("Width %1").arg(desk.width()), 0));
+ size.setHeight(cg.readEntry(QString::fromLatin1("Height %1").arg(desk.height()), 0));
}
- resize (size);
- }
+ // if thats fails, try to reuse size
+ if (size.isEmpty()) {
+ // first try to reuse size known from current or last created main window ;=)
+ if (KateApp::self()->mainWindowsCount() > 0) {
+ KateMainWindow *win = KateApp::self()->activeKateMainWindow();
+
+ if (!win) {
+ win = KateApp::self()->mainWindow(KateApp::self()->mainWindowsCount() - 1);
+ }
+
+ size = win->size();
+ } else { // now fallback to hard defaults ;)
+ // first try global app config
+ KConfigGroup cg(KSharedConfig::openConfig(), "MainWindow");
+ size.setWidth(cg.readEntry(QString::fromLatin1("Width %1").arg(desk.width()), 0));
+ size.setHeight(cg.readEntry(QString::fromLatin1("Height %1").arg(desk.height()), 0));
+
+ if (size.isEmpty()) {
+ size = QSize(qMin(700, desk.width()), qMin(480, desk.height()));
+ }
+ }
+
+ resize(size);
+ }
- // start session restore if needed
- startRestore (sconfig, sgroup);
+ // start session restore if needed
+ startRestore(sconfig, sgroup);
- // setup most important actions first, needed by setupMainWindow
- setupImportantActions ();
+ // setup most important actions first, needed by setupMainWindow
+ setupImportantActions();
- // setup the most important widgets
- setupMainWindow();
+ // setup the most important widgets
+ setupMainWindow();
- // setup the actions
- setupActions();
+ // setup the actions
+ setupActions();
- setStandardToolBarMenuEnabled( true );
- setXMLFile( QStringLiteral("kateui.rc") );
- createShellGUI ( true );
+ setStandardToolBarMenuEnabled(true);
+ setXMLFile(QStringLiteral("kateui.rc"));
+ createShellGUI(true);
- //qCDebug(LOG_KATE) << "****************************************************************************" << sconfig;
+ //qCDebug(LOG_KATE) << "****************************************************************************" << sconfig;
- // register mainwindow in app
- KateApp::self()->addMainWindow (this);
+ // register mainwindow in app
+ KateApp::self()->addMainWindow(this);
- // enable plugin guis
- KatePluginManager::self()->enableAllPluginsGUI (this, sconfig);
+ // enable plugin guis
+ KatePluginManager::self()->enableAllPluginsGUI(this, sconfig);
- // caption update
- for (uint i = 0; i < KateDocManager::self()->documents(); i++)
- slotDocumentCreated (KateDocManager::self()->document(i));
+ // caption update
+ for (uint i = 0; i < KateDocManager::self()->documents(); i++) {
+ slotDocumentCreated(KateDocManager::self()->document(i));
+ }
- connect(KateDocManager::self(), SIGNAL(documentCreated(KTextEditor::Document*)), this, SLOT(slotDocumentCreated(KTextEditor::Document*)));
+ connect(KateDocManager::self(), SIGNAL(documentCreated(KTextEditor::Document*)), this, SLOT(slotDocumentCreated(KTextEditor::Document*)));
- readOptions();
+ readOptions();
- if (sconfig)
- m_viewManager->restoreViewConfiguration (KConfigGroup(sconfig, sgroup) );
+ if (sconfig) {
+ m_viewManager->restoreViewConfiguration(KConfigGroup(sconfig, sgroup));
+ }
- finishRestore ();
+ finishRestore();
- m_fileOpenRecent->loadEntries( KConfigGroup(sconfig, "Recent Files" ) );
+ m_fileOpenRecent->loadEntries(KConfigGroup(sconfig, "Recent Files"));
- setAcceptDrops(true);
+ setAcceptDrops(true);
- connect(KateSessionManager::self(), SIGNAL(sessionChanged()), this, SLOT(updateCaption()));
+ connect(KateSessionManager::self(), SIGNAL(sessionChanged()), this, SLOT(updateCaption()));
- connect(this,SIGNAL(sigShowPluginConfigPage(KTextEditor::ConfigPageInterface *,uint)),this,SLOT(showPluginConfigPage(KTextEditor::ConfigPageInterface *,uint)));
+ connect(this, SIGNAL(sigShowPluginConfigPage(KTextEditor::ConfigPageInterface*,uint)), this, SLOT(showPluginConfigPage(KTextEditor::ConfigPageInterface*,uint)));
}
KateMainWindow::~KateMainWindow()
{
- // first, save our fallback window size ;)
- KConfigGroup cfg(KSharedConfig::openConfig(), "MainWindow");
- KWindowConfig::saveWindowSize(windowHandle(), cfg);
-
- // save other options ;=)
- saveOptions();
-
- // unregister mainwindow in app
- KateApp::self()->removeMainWindow (this);
-
- // disable all plugin guis, delete all pluginViews
- KatePluginManager::self()->disableAllPluginsGUI (this);
-
- // delete the view manager, before KateMainWindow's wrapper is dead
- delete m_viewManager;
- m_viewManager = 0;
-
- // kill the wrapper object, now that all views are dead
- delete m_wrapper;
- m_wrapper = 0;
+ // first, save our fallback window size ;)
+ KConfigGroup cfg(KSharedConfig::openConfig(), "MainWindow");
+ KWindowConfig::saveWindowSize(windowHandle(), cfg);
+
+ // save other options ;=)
+ saveOptions();
+
+ // unregister mainwindow in app
+ KateApp::self()->removeMainWindow(this);
+
+ // disable all plugin guis, delete all pluginViews
+ KatePluginManager::self()->disableAllPluginsGUI(this);
+
+ // delete the view manager, before KateMainWindow's wrapper is dead
+ delete m_viewManager;
+ m_viewManager = 0;
+
+ // kill the wrapper object, now that all views are dead
+ delete m_wrapper;
+ m_wrapper = 0;
}
-void KateMainWindow::setupImportantActions ()
+void KateMainWindow::setupImportantActions()
{
- // settings
- m_paShowStatusBar = KStandardAction::showStatusbar(this, SLOT(toggleShowStatusBar()), actionCollection());
- m_paShowStatusBar->setWhatsThis(i18n("Use this command to show or hide the view's statusbar"));
-
- m_paShowPath = new KToggleAction( i18n("Sho&w Path in Titlebar"), this );
- actionCollection()->addAction( QStringLiteral("settings_show_full_path"), m_paShowPath );
- connect( m_paShowPath, SIGNAL(toggled(bool)), this, SLOT(updateCaption()) );
- m_paShowPath->setWhatsThis(i18n("Show the complete document path in the window caption"));
+ // settings
+ m_paShowStatusBar = KStandardAction::showStatusbar(this, SLOT(toggleShowStatusBar()), actionCollection());
+ m_paShowStatusBar->setWhatsThis(i18n("Use this command to show or hide the view's statusbar"));
+
+ m_paShowPath = new KToggleAction(i18n("Sho&w Path in Titlebar"), this);
+ actionCollection()->addAction(QStringLiteral("settings_show_full_path"), m_paShowPath);
+ connect(m_paShowPath, SIGNAL(toggled(bool)), this, SLOT(updateCaption()));
+ m_paShowPath->setWhatsThis(i18n("Show the complete document path in the window caption"));
}
-void KateMainWindow::setupMainWindow ()
+void KateMainWindow::setupMainWindow()
{
- setToolViewStyle( KMultiTabBar::KDEV3ICON );
+ setToolViewStyle(KMultiTabBar::KDEV3ICON);
- /**
- * create central stacked widget with its children
- */
- m_mainStackedWidget = new QStackedWidget (centralWidget());
- centralWidget()->layout()->addWidget(m_mainStackedWidget);
- (static_cast<QBoxLayout*>(centralWidget()->layout()))->setStretchFactor(m_mainStackedWidget,100);
+ /**
+ * create central stacked widget with its children
+ */
+ m_mainStackedWidget = new QStackedWidget(centralWidget());
+ centralWidget()->layout()->addWidget(m_mainStackedWidget);
+ (static_cast<QBoxLayout *>(centralWidget()->layout()))->setStretchFactor(m_mainStackedWidget, 100);
- m_quickOpen = new KateQuickOpen (m_mainStackedWidget, this);
- m_mainStackedWidget->addWidget (m_quickOpen);
+ m_quickOpen = new KateQuickOpen(m_mainStackedWidget, this);
+ m_mainStackedWidget->addWidget(m_quickOpen);
- m_viewManager = new KateViewManager (m_mainStackedWidget, this);
- m_mainStackedWidget->addWidget (m_viewManager);
+ m_viewManager = new KateViewManager(m_mainStackedWidget, this);
+ m_mainStackedWidget->addWidget(m_viewManager);
- // make view manager default visible!
- m_mainStackedWidget->setCurrentWidget (m_viewManager);
+ // make view manager default visible!
+ m_mainStackedWidget->setCurrentWidget(m_viewManager);
- m_bottomViewBarContainer = new QWidget(centralWidget());
- centralWidget()->layout()->addWidget(m_bottomViewBarContainer);
- m_bottomContainerStack = new KateContainerStackedLayout(m_bottomViewBarContainer);
+ m_bottomViewBarContainer = new QWidget(centralWidget());
+ centralWidget()->layout()->addWidget(m_bottomViewBarContainer);
+ m_bottomContainerStack = new KateContainerStackedLayout(m_bottomViewBarContainer);
}
void KateMainWindow::setupActions()
{
- QAction *a;
-
- actionCollection()->addAction( KStandardAction::New, QStringLiteral("file_new"), m_viewManager, SLOT(slotDocumentNew()) )
- ->setWhatsThis(i18n("Create a new document"));
- actionCollection()->addAction( KStandardAction::Open, QStringLiteral("file_open"), m_viewManager, SLOT(slotDocumentOpen()) )
- ->setWhatsThis(i18n("Open an existing document for editing"));
-
- m_fileOpenRecent = KStandardAction::openRecent (m_viewManager, SLOT(openUrl(QUrl)), this);
- actionCollection()->addAction(m_fileOpenRecent->objectName(), m_fileOpenRecent);
- m_fileOpenRecent->setWhatsThis(i18n("This lists files which you have opened recently, and allows you to easily open them again."));
-
- a = actionCollection()->addAction( QStringLiteral("file_save_all") );
- a->setIcon( QIcon::fromTheme(QStringLiteral("document-save-all")) );
- a->setText( i18n("Save A&ll") );
- a->setShortcut( QKeySequence(Qt::CTRL + Qt::Key_L) );
- connect( a, SIGNAL(triggered()), KateDocManager::self(), SLOT(saveAll()) );
- a->setWhatsThis(i18n("Save all open, modified documents to disk."));
-
- a = actionCollection()->addAction( QStringLiteral("file_reload_all") );
- a->setText( i18n("&Reload All") );
- connect( a, SIGNAL(triggered()), KateDocManager::self(), SLOT(reloadAll()) );
- a->setWhatsThis(i18n("Reload all open documents."));
-
- a = actionCollection()->addAction( QStringLiteral("file_close_orphaned") );
- a->setText( i18n("Close Orphaned") );
- connect( a, SIGNAL(triggered()), KateDocManager::self(), SLOT(closeOrphaned()) );
- a->setWhatsThis(i18n("Close all documents in the file list that could not be reopened, because they are not accessible anymore."));
-
- actionCollection()->addAction( KStandardAction::Close, QStringLiteral("file_close"), m_viewManager, SLOT(slotDocumentClose()) )
- ->setWhatsThis(i18n("Close the current document."));
-
- a = actionCollection()->addAction( QStringLiteral("file_close_other") );
- a->setText( i18n( "Close Other" ) );
- connect( a, SIGNAL(triggered()), this, SLOT(slotDocumentCloseOther()) );
- a->setWhatsThis(i18n("Close other open documents."));
-
- a = actionCollection()->addAction( QStringLiteral("file_close_all") );
- a->setText( i18n( "Clos&e All" ) );
- connect( a, SIGNAL(triggered()), this, SLOT(slotDocumentCloseAll()) );
- a->setWhatsThis(i18n("Close all open documents."));
-
- a = actionCollection()->addAction( KStandardAction::Quit, QStringLiteral("file_quit") );
- // Qt::QueuedConnection: delay real shutdown, as we are inside menu action handling (bug #185708)
- connect( a, SIGNAL(triggered()), this, SLOT(slotFileQuit()), Qt::QueuedConnection );
- a->setWhatsThis(i18n("Close this window"));
-
- a = actionCollection()->addAction( QStringLiteral("view_new_view") );
- a->setIcon( QIcon::fromTheme(QStringLiteral("window-new")) );
- a->setText( i18n("&New Window") );
- connect( a, SIGNAL(triggered()), this, SLOT(newWindow()) );
- a->setWhatsThis(i18n("Create a new Kate view (a new window with the same document list)."));
-
- a = actionCollection()->addAction( QStringLiteral("view_quick_open") );
- a->setIcon( QIcon::fromTheme(QStringLiteral("fork")) );
- a->setText( i18n("&Quick Open") );
- QList<QKeySequence> scuts;
- scuts << QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_O)
- << QKeySequence(Qt::CTRL + Qt::Key_Tab);
- a->setShortcuts(scuts);
- connect( a, SIGNAL(triggered()), this, SLOT(slotQuickOpen()) );
- a->setWhatsThis(i18n("Open a form to quick open documents."));
-
- KToggleAction* showFullScreenAction = KStandardAction::fullScreen( 0, 0, this, this);
- actionCollection()->addAction( showFullScreenAction->objectName(), showFullScreenAction );
- connect( showFullScreenAction, SIGNAL(toggled(bool)), this, SLOT(slotFullScreen(bool)));
-
- documentOpenWith = new KActionMenu(i18n("Open W&ith"), this);
- actionCollection()->addAction(QStringLiteral("file_open_with"), documentOpenWith);
- documentOpenWith->setWhatsThis(i18n("Open the current document using another application registered for its file type, or an application of your choice."));
- connect(documentOpenWith->menu(), SIGNAL(aboutToShow()), this, SLOT(mSlotFixOpenWithMenu()));
- connect(documentOpenWith->menu(), SIGNAL(triggered(QAction*)), this, SLOT(slotOpenWithMenuAction(QAction*)));
-
- a = KStandardAction::keyBindings(this, SLOT(editKeys()), actionCollection());
- a->setWhatsThis(i18n("Configure the application's keyboard shortcut assignments."));
-
- a = KStandardAction::configureToolbars(this, SLOT(slotEditToolbars()), actionCollection());
- a->setWhatsThis(i18n("Configure which items should appear in the toolbar(s)."));
-
- QAction* settingsConfigure = KStandardAction::preferences(this, SLOT(slotConfigure()), actionCollection());
- settingsConfigure->setWhatsThis(i18n("Configure various aspects of this application and the editing component."));
-
- if (KatePluginManager::self()->pluginList().count() > 0)
- {
- a = actionCollection()->addAction( QStringLiteral("help_plugins_contents") );
- a->setText( i18n("&Plugins Handbook") );
- connect( a, SIGNAL(triggered()), this, SLOT(pluginHelp()) );
- a->setWhatsThis(i18n("This shows help files for various available plugins."));
- }
-
- a = actionCollection()->addAction( QStringLiteral("help_about_editor") );
- a->setText( i18n("&About Editor Component") );
- connect( a, SIGNAL(triggered()), this, SLOT(aboutEditor()) );
-
- connect(m_viewManager, SIGNAL(viewChanged(KTextEditor::View*)), this, SLOT(slotWindowActivated()));
- connect(m_viewManager, SIGNAL(viewChanged(KTextEditor::View*)), this, SLOT(slotUpdateOpenWith()));
- connect(m_viewManager, SIGNAL(viewChanged(KTextEditor::View*)), this, SLOT(slotUpdateBottomViewBar()));
-
- // re-route signals to our wrapper
- connect (m_viewManager, SIGNAL(viewChanged(KTextEditor::View*)), m_wrapper, SIGNAL(viewChanged(KTextEditor::View*)));
- connect (m_viewManager, SIGNAL(viewCreated(KTextEditor::View*)), m_wrapper, SIGNAL(viewCreated(KTextEditor::View*)));
- connect (this, SIGNAL(unhandledShortcutOverride(QEvent*)), m_wrapper, SIGNAL(unhandledShortcutOverride(QEvent*)));
-
- slotWindowActivated ();
-
- // session actions
- a = actionCollection()->addAction( QStringLiteral("sessions_new") );
- a->setIcon( QIcon::fromTheme(QStringLiteral("document-new")) );
- a->setText( i18nc("Menu entry Session->New", "&New") );
- // Qt::QueuedConnection to avoid deletion of code that is executed when reducing the amount of mainwindows. (bug #227008)
- connect( a, SIGNAL(triggered()), KateSessionManager::self(), SLOT(sessionNew()), Qt::QueuedConnection );
- a = actionCollection()->addAction( QStringLiteral("sessions_open") );
- a->setIcon( QIcon::fromTheme(QStringLiteral("document-open")) );
- a->setText( i18n("&Open Session") );
- // Qt::QueuedConnection to avoid deletion of code that is executed when reducing the amount of mainwindows. (bug #227008)
- connect( a, SIGNAL(triggered()), KateSessionManager::self(), SLOT(sessionOpen()), Qt::QueuedConnection );
- a = actionCollection()->addAction( QStringLiteral("sessions_save") );
- a->setIcon( QIcon::fromTheme(QStringLiteral("document-save")) );
- a->setText( i18n("&Save Session") );
- connect( a, SIGNAL(triggered()), KateSessionManager::self(), SLOT(sessionSave()) );
- a = actionCollection()->addAction( QStringLiteral("sessions_save_as") );
- a->setIcon( QIcon::fromTheme(QStringLiteral("document-save-as")) );
- a->setText( i18n("Save Session &As...") );
- connect( a, SIGNAL(triggered()), KateSessionManager::self(), SLOT(sessionSaveAs()) );
- a = actionCollection()->addAction( QStringLiteral("sessions_manage") );
- a->setIcon( QIcon::fromTheme(QStringLiteral("view-choose")) );
- a->setText( i18n("&Manage Sessions...") );
- // Qt::QueuedConnection to avoid deletion of code that is executed when reducing the amount of mainwindows. (bug #227008)
- connect( a, SIGNAL(triggered()), KateSessionManager::self(), SLOT(sessionManage()), Qt::QueuedConnection );
-
- // quick open menu ;)
- a = new KateSessionsAction (i18n("&Quick Open Session"), this);
- actionCollection()->addAction(QStringLiteral("sessions_list"), a);
+ QAction *a;
+
+ actionCollection()->addAction(KStandardAction::New, QStringLiteral("file_new"), m_viewManager, SLOT(slotDocumentNew()))
+ ->setWhatsThis(i18n("Create a new document"));
+ actionCollection()->addAction(KStandardAction::Open, QStringLiteral("file_open"), m_viewManager, SLOT(slotDocumentOpen()))
+ ->setWhatsThis(i18n("Open an existing document for editing"));
+
+ m_fileOpenRecent = KStandardAction::openRecent(m_viewManager, SLOT(openUrl(QUrl)), this);
+ actionCollection()->addAction(m_fileOpenRecent->objectName(), m_fileOpenRecent);
+ m_fileOpenRecent->setWhatsThis(i18n("This lists files which you have opened recently, and allows you to easily open them again."));
+
+ a = actionCollection()->addAction(QStringLiteral("file_save_all"));
+ a->setIcon(QIcon::fromTheme(QStringLiteral("document-save-all")));
+ a->setText(i18n("Save A&ll"));
+ a->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_L));
+ connect(a, SIGNAL(triggered()), KateDocManager::self(), SLOT(saveAll()));
+ a->setWhatsThis(i18n("Save all open, modified documents to disk."));
+
+ a = actionCollection()->addAction(QStringLiteral("file_reload_all"));
+ a->setText(i18n("&Reload All"));
+ connect(a, SIGNAL(triggered()), KateDocManager::self(), SLOT(reloadAll()));
+ a->setWhatsThis(i18n("Reload all open documents."));
+
+ a = actionCollection()->addAction(QStringLiteral("file_close_orphaned"));
+ a->setText(i18n("Close Orphaned"));
+ connect(a, SIGNAL(triggered()), KateDocManager::self(), SLOT(closeOrphaned()));
+ a->setWhatsThis(i18n("Close all documents in the file list that could not be reopened, because they are not accessible anymore."));
+
+ actionCollection()->addAction(KStandardAction::Close, QStringLiteral("file_close"), m_viewManager, SLOT(slotDocumentClose()))
+ ->setWhatsThis(i18n("Close the current document."));
+
+ a = actionCollection()->addAction(QStringLiteral("file_close_other"));
+ a->setText(i18n("Close Other"));
+ connect(a, SIGNAL(triggered()), this, SLOT(slotDocumentCloseOther()));
+ a->setWhatsThis(i18n("Close other open documents."));
+
+ a = actionCollection()->addAction(QStringLiteral("file_close_all"));
+ a->setText(i18n("Clos&e All"));
+ connect(a, SIGNAL(triggered()), this, SLOT(slotDocumentCloseAll()));
+ a->setWhatsThis(i18n("Close all open documents."));
+
+ a = actionCollection()->addAction(KStandardAction::Quit, QStringLiteral("file_quit"));
+ // Qt::QueuedConnection: delay real shutdown, as we are inside menu action handling (bug #185708)
+ connect(a, SIGNAL(triggered()), this, SLOT(slotFileQuit()), Qt::QueuedConnection);
+ a->setWhatsThis(i18n("Close this window"));
+
+ a = actionCollection()->addAction(QStringLiteral("view_new_view"));
+ a->setIcon(QIcon::fromTheme(QStringLiteral("window-new")));
+ a->setText(i18n("&New Window"));
+ connect(a, SIGNAL(triggered()), this, SLOT(newWindow()));
+ a->setWhatsThis(i18n("Create a new Kate view (a new window with the same document list)."));
+
+ a = actionCollection()->addAction(QStringLiteral("view_quick_open"));
+ a->setIcon(QIcon::fromTheme(QStringLiteral("fork")));
+ a->setText(i18n("&Quick Open"));
+ QList<QKeySequence> scuts;
+ scuts << QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_O)
+ << QKeySequence(Qt::CTRL + Qt::Key_Tab);
+ a->setShortcuts(scuts);
+ connect(a, SIGNAL(triggered()), this, SLOT(slotQuickOpen()));
+ a->setWhatsThis(i18n("Open a form to quick open documents."));
+
+ KToggleAction *showFullScreenAction = KStandardAction::fullScreen(0, 0, this, this);
+ actionCollection()->addAction(showFullScreenAction->objectName(), showFullScreenAction);
+ connect(showFullScreenAction, SIGNAL(toggled(bool)), this, SLOT(slotFullScreen(bool)));
+
+ documentOpenWith = new KActionMenu(i18n("Open W&ith"), this);
+ actionCollection()->addAction(QStringLiteral("file_open_with"), documentOpenWith);
+ documentOpenWith->setWhatsThis(i18n("Open the current document using another application registered for its file type, or an application of your choice."));
+ connect(documentOpenWith->menu(), SIGNAL(aboutToShow()), this, SLOT(mSlotFixOpenWithMenu()));
+ connect(documentOpenWith->menu(), SIGNAL(triggered(QAction*)), this, SLOT(slotOpenWithMenuAction(QAction*)));
+
+ a = KStandardAction::keyBindings(this, SLOT(editKeys()), actionCollection());
+ a->setWhatsThis(i18n("Configure the application's keyboard shortcut assignments."));
+
+ a = KStandardAction::configureToolbars(this, SLOT(slotEditToolbars()), actionCollection());
+ a->setWhatsThis(i18n("Configure which items should appear in the toolbar(s)."));
+
+ QAction *settingsConfigure = KStandardAction::preferences(this, SLOT(slotConfigure()), actionCollection());
+ settingsConfigure->setWhatsThis(i18n("Configure various aspects of this application and the editing component."));
+
+ if (KatePluginManager::self()->pluginList().count() > 0) {
+ a = actionCollection()->addAction(QStringLiteral("help_plugins_contents"));
+ a->setText(i18n("&Plugins Handbook"));
+ connect(a, SIGNAL(triggered()), this, SLOT(pluginHelp()));
+ a->setWhatsThis(i18n("This shows help files for various available plugins."));
+ }
+
+ a = actionCollection()->addAction(QStringLiteral("help_about_editor"));
+ a->setText(i18n("&About Editor Component"));
+ connect(a, SIGNAL(triggered()), this, SLOT(aboutEditor()));
+
+ connect(m_viewManager, SIGNAL(viewChanged(KTextEditor::View*)), this, SLOT(slotWindowActivated()));
+ connect(m_viewManager, SIGNAL(viewChanged(KTextEditor::View*)), this, SLOT(slotUpdateOpenWith()));
+ connect(m_viewManager, SIGNAL(viewChanged(KTextEditor::View*)), this, SLOT(slotUpdateBottomViewBar()));
+
+ // re-route signals to our wrapper
+ connect(m_viewManager, SIGNAL(viewChanged(KTextEditor::View*)), m_wrapper, SIGNAL(viewChanged(KTextEditor::View*)));
+ connect(m_viewManager, SIGNAL(viewCreated(KTextEditor::View*)), m_wrapper, SIGNAL(viewCreated(KTextEditor::View*)));
+ connect(this, SIGNAL(unhandledShortcutOverride(QEvent*)), m_wrapper, SIGNAL(unhandledShortcutOverride(QEvent*)));
+
+ slotWindowActivated();
+
+ // session actions
+ a = actionCollection()->addAction(QStringLiteral("sessions_new"));
+ a->setIcon(QIcon::fromTheme(QStringLiteral("document-new")));
+ a->setText(i18nc("Menu entry Session->New", "&New"));
+ // Qt::QueuedConnection to avoid deletion of code that is executed when reducing the amount of mainwindows. (bug #227008)
+ connect(a, SIGNAL(triggered()), KateSessionManager::self(), SLOT(sessionNew()), Qt::QueuedConnection);
+ a = actionCollection()->addAction(QStringLiteral("sessions_open"));
+ a->setIcon(QIcon::fromTheme(QStringLiteral("document-open")));
+ a->setText(i18n("&Open Session"));
+ // Qt::QueuedConnection to avoid deletion of code that is executed when reducing the amount of mainwindows. (bug #227008)
+ connect(a, SIGNAL(triggered()), KateSessionManager::self(), SLOT(sessionOpen()), Qt::QueuedConnection);
+ a = actionCollection()->addAction(QStringLiteral("sessions_save"));
+ a->setIcon(QIcon::fromTheme(QStringLiteral("document-save")));
+ a->setText(i18n("&Save Session"));
+ connect(a, SIGNAL(triggered()), KateSessionManager::self(), SLOT(sessionSave()));
+ a = actionCollection()->addAction(QStringLiteral("sessions_save_as"));
+ a->setIcon(QIcon::fromTheme(QStringLiteral("document-save-as")));
+ a->setText(i18n("Save Session &As..."));
+ connect(a, SIGNAL(triggered()), KateSessionManager::self(), SLOT(sessionSaveAs()));
+ a = actionCollection()->addAction(QStringLiteral("sessions_manage"));
+ a->setIcon(QIcon::fromTheme(QStringLiteral("view-choose")));
+ a->setText(i18n("&Manage Sessions..."));
+ // Qt::QueuedConnection to avoid deletion of code that is executed when reducing the amount of mainwindows. (bug #227008)
+ connect(a, SIGNAL(triggered()), KateSessionManager::self(), SLOT(sessionManage()), Qt::QueuedConnection);
+
+ // quick open menu ;)
+ a = new KateSessionsAction(i18n("&Quick Open Session"), this);
+ actionCollection()->addAction(QStringLiteral("sessions_list"), a);
}
void KateMainWindow::slotDocumentCloseAll()
{
- if ( KateDocManager::self()->documents() >= 1 && KMessageBox::warningContinueCancel(this,
- i18n ("This will close all open documents. Are you sure you want to continue?"),
- i18n ("Close all documents"),
- KStandardGuiItem::cont(),
- KStandardGuiItem::cancel(),
- QStringLiteral("closeAll")) != KMessageBox::Cancel)
- {
- if (queryClose_internal())
- KateDocManager::self()->closeAllDocuments(false);
- }
+ if (KateDocManager::self()->documents() >= 1 && KMessageBox::warningContinueCancel(this,
+ i18n("This will close all open documents. Are you sure you want to continue?"),
+ i18n("Close all documents"),
+ KStandardGuiItem::cont(),
+ KStandardGuiItem::cancel(),
+ QStringLiteral("closeAll")) != KMessageBox::Cancel) {
+ if (queryClose_internal()) {
+ KateDocManager::self()->closeAllDocuments(false);
+ }
+ }
}
-
void KateMainWindow::slotDocumentCloseOther(KTextEditor::Document *document)
{
- if (queryClose_internal(document))
- KateDocManager::self()->closeOtherDocuments(document);
+ if (queryClose_internal(document)) {
+ KateDocManager::self()->closeOtherDocuments(document);
+ }
}
-void KateMainWindow::slotDocumentCloseSelected(const QList<KTextEditor::Document*> &docList)
+void KateMainWindow::slotDocumentCloseSelected(const QList<KTextEditor::Document *> &docList)
{
- QList<KTextEditor::Document *> documents;
- foreach(KTextEditor::Document *doc, docList)
- {
- if(queryClose_internal(doc))
- documents.append(doc);
- }
-
- KateDocManager::self()->closeDocuments(documents);
+ QList<KTextEditor::Document *> documents;
+ foreach(KTextEditor::Document * doc, docList) {
+ if (queryClose_internal(doc)) {
+ documents.append(doc);
+ }
+ }
+
+ KateDocManager::self()->closeDocuments(documents);
}
void KateMainWindow::slotDocumentCloseOther()
{
- if (queryClose_internal(m_viewManager->activeView()->document()))
- KateDocManager::self()->closeOtherDocuments(m_viewManager->activeView()->document());
+ if (queryClose_internal(m_viewManager->activeView()->document())) {
+ KateDocManager::self()->closeOtherDocuments(m_viewManager->activeView()->document());
+ }
}
-bool KateMainWindow::queryClose_internal(KTextEditor::Document* doc)
+bool KateMainWindow::queryClose_internal(KTextEditor::Document *doc)
{
- uint documentCount = KateDocManager::self()->documents();
+ uint documentCount = KateDocManager::self()->documents();
- if ( ! showModOnDiskPrompt() )
- return false;
+ if (! showModOnDiskPrompt()) {
+ return false;
+ }
- QList<KTextEditor::Document*> modifiedDocuments = KateDocManager::self()->modifiedDocumentList();
- modifiedDocuments.removeAll(doc);
- bool shutdown = (modifiedDocuments.count() == 0);
+ QList<KTextEditor::Document *> modifiedDocuments = KateDocManager::self()->modifiedDocumentList();
+ modifiedDocuments.removeAll(doc);
+ bool shutdown = (modifiedDocuments.count() == 0);
- if (!shutdown)
- {
- shutdown = KateSaveModifiedDialog::queryClose(this, modifiedDocuments);
- }
+ if (!shutdown) {
+ shutdown = KateSaveModifiedDialog::queryClose(this, modifiedDocuments);
+ }
- if ( KateDocManager::self()->documents() > documentCount )
- {
- KMessageBox::information (this,
- i18n ("New file opened while trying to close Kate, closing aborted."),
- i18n ("Closing Aborted"));
- shutdown = false;
- }
+ if (KateDocManager::self()->documents() > documentCount) {
+ KMessageBox::information(this,
+ i18n("New file opened while trying to close Kate, closing aborted."),
+ i18n("Closing Aborted"));
+ shutdown = false;
+ }
- return shutdown;
+ return shutdown;
}
/**
@@ -465,581 +464,587 @@ bool KateMainWindow::queryClose_internal(KTextEditor::Document* doc)
*/
bool KateMainWindow::queryClose()
{
- // session saving, can we close all views ?
- // just test, not close them actually
- if (qApp->isSavingSession())
- {
- return queryClose_internal();
- }
-
- // normal closing of window
- // allow to close all windows until the last without restrictions
- if ( KateApp::self()->mainWindowsCount () > 1 )
- return true;
+ // session saving, can we close all views ?
+ // just test, not close them actually
+ if (qApp->isSavingSession()) {
+ return queryClose_internal();
+ }
- // last one: check if we can close all documents, try run
- // and save docs if we really close down !
- if ( queryClose_internal () )
- {
- KateApp::self()->sessionManager()->saveActiveSession(true);
- return true;
- }
+ // normal closing of window
+ // allow to close all windows until the last without restrictions
+ if (KateApp::self()->mainWindowsCount() > 1) {
+ return true;
+ }
- return false;
+ // last one: check if we can close all documents, try run
+ // and save docs if we really close down !
+ if (queryClose_internal()) {
+ KateApp::self()->sessionManager()->saveActiveSession(true);
+ return true;
+ }
+
+ return false;
}
-void KateMainWindow::newWindow ()
+void KateMainWindow::newWindow()
{
- KateApp::self()->newMainWindow (KateApp::self()->sessionManager()->activeSession()->config());
+ KateApp::self()->newMainWindow(KateApp::self()->sessionManager()->activeSession()->config());
}
void KateMainWindow::slotEditToolbars()
{
- KConfigGroup cfg(KSharedConfig::openConfig(), "MainWindow");
- saveMainWindowSettings(cfg);
+ KConfigGroup cfg(KSharedConfig::openConfig(), "MainWindow");
+ saveMainWindowSettings(cfg);
- KEditToolBar dlg( factory() );
+ KEditToolBar dlg(factory());
- connect( &dlg, SIGNAL(newToolBarConfig()), this, SLOT(slotNewToolbarConfig()) );
- dlg.exec();
+ connect(&dlg, SIGNAL(newToolBarConfig()), this, SLOT(slotNewToolbarConfig()));
+ dlg.exec();
}
void KateMainWindow::slotNewToolbarConfig()
{
- applyMainWindowSettings(KConfigGroup(KSharedConfig::openConfig(), "MainWindow"));
+ applyMainWindowSettings(KConfigGroup(KSharedConfig::openConfig(), "MainWindow"));
}
void KateMainWindow::slotFileQuit()
{
- KateApp::self()->shutdownKate (this);
+ KateApp::self()->shutdownKate(this);
}
void KateMainWindow::slotFileClose()
{
- m_viewManager->slotDocumentClose();
+ m_viewManager->slotDocumentClose();
}
void KateMainWindow::slotOpenDocument(QUrl url)
{
- m_viewManager->openUrl(url,
- QString(),
- true,
- false);
+ m_viewManager->openUrl(url,
+ QString(),
+ true,
+ false);
}
-void KateMainWindow::readOptions ()
+void KateMainWindow::readOptions()
{
- KSharedConfig::Ptr config = KSharedConfig::openConfig();
+ KSharedConfig::Ptr config = KSharedConfig::openConfig();
- const KConfigGroup generalGroup(config, "General");
- m_modNotification = generalGroup.readEntry("Modified Notification", false);
- KateDocManager::self()->setSaveMetaInfos(generalGroup.readEntry("Save Meta Infos", true));
- KateDocManager::self()->setDaysMetaInfos(generalGroup.readEntry("Days Meta Infos", 30));
+ const KConfigGroup generalGroup(config, "General");
+ m_modNotification = generalGroup.readEntry("Modified Notification", false);
+ KateDocManager::self()->setSaveMetaInfos(generalGroup.readEntry("Save Meta Infos", true));
+ KateDocManager::self()->setDaysMetaInfos(generalGroup.readEntry("Days Meta Infos", 30));
- m_paShowPath->setChecked (generalGroup.readEntry("Show Full Path in Title", false));
- m_paShowStatusBar->setChecked (generalGroup.readEntry("Show Status Bar", true));
+ m_paShowPath->setChecked(generalGroup.readEntry("Show Full Path in Title", false));
+ m_paShowStatusBar->setChecked(generalGroup.readEntry("Show Status Bar", true));
- // emit signal to hide/show statusbars
- toggleShowStatusBar ();
+ // emit signal to hide/show statusbars
+ toggleShowStatusBar();
}
-void KateMainWindow::saveOptions ()
+void KateMainWindow::saveOptions()
{
- KSharedConfig::Ptr config = KSharedConfig::openConfig();
+ KSharedConfig::Ptr config = KSharedConfig::openConfig();
- KConfigGroup generalGroup(config, "General");
+ KConfigGroup generalGroup(config, "General");
- generalGroup.writeEntry("Save Meta Infos", KateDocManager::self()->getSaveMetaInfos());
+ generalGroup.writeEntry("Save Meta Infos", KateDocManager::self()->getSaveMetaInfos());
- generalGroup.writeEntry("Days Meta Infos", KateDocManager::self()->getDaysMetaInfos());
+ generalGroup.writeEntry("Days Meta Infos", KateDocManager::self()->getDaysMetaInfos());
- generalGroup.writeEntry("Show Full Path in Title", m_paShowPath->isChecked());
- generalGroup.writeEntry("Show Status Bar", m_paShowStatusBar->isChecked());
+ generalGroup.writeEntry("Show Full Path in Title", m_paShowPath->isChecked());
+ generalGroup.writeEntry("Show Status Bar", m_paShowStatusBar->isChecked());
}
-void KateMainWindow::toggleShowStatusBar ()
+void KateMainWindow::toggleShowStatusBar()
{
- emit statusBarToggled ();
+ emit statusBarToggled();
}
-bool KateMainWindow::showStatusBar ()
+bool KateMainWindow::showStatusBar()
{
- return m_paShowStatusBar->isChecked ();
+ return m_paShowStatusBar->isChecked();
}
-void KateMainWindow::slotWindowActivated ()
+void KateMainWindow::slotWindowActivated()
{
- if (m_viewManager->activeView())
- updateCaption (m_viewManager->activeView()->document());
+ if (m_viewManager->activeView()) {
+ updateCaption(m_viewManager->activeView()->document());
+ }
- // show view manager in any case
- if (m_mainStackedWidget->currentWidget () != m_viewManager)
- m_mainStackedWidget->setCurrentWidget (m_viewManager);
+ // show view manager in any case
+ if (m_mainStackedWidget->currentWidget() != m_viewManager) {
+ m_mainStackedWidget->setCurrentWidget(m_viewManager);
+ }
- // update proxy
- centralWidget()->setFocusProxy (m_viewManager->activeView());
+ // update proxy
+ centralWidget()->setFocusProxy(m_viewManager->activeView());
}
void KateMainWindow::slotUpdateOpenWith()
{
- if (m_viewManager->activeView())
- documentOpenWith->setEnabled(!m_viewManager->activeView()->document()->url().isEmpty());
- else
- documentOpenWith->setEnabled(false);
+ if (m_viewManager->activeView()) {
+ documentOpenWith->setEnabled(!m_viewManager->activeView()->document()->url().isEmpty());
+ } else {
+ documentOpenWith->setEnabled(false);
+ }
}
-void KateMainWindow::dragEnterEvent( QDragEnterEvent *event )
+void KateMainWindow::dragEnterEvent(QDragEnterEvent *event)
{
- if (!event->mimeData()) return;
- const bool accept = event->mimeData()->hasUrls() || event->mimeData()->hasText();
- event->setAccepted(accept);
+ if (!event->mimeData()) {
+ return;
+ }
+ const bool accept = event->mimeData()->hasUrls() || event->mimeData()->hasText();
+ event->setAccepted(accept);
}
-void KateMainWindow::dropEvent( QDropEvent *event )
+void KateMainWindow::dropEvent(QDropEvent *event)
{
- slotDropEvent(event);
+ slotDropEvent(event);
}
-void KateMainWindow::slotDropEvent( QDropEvent * event )
+void KateMainWindow::slotDropEvent(QDropEvent *event)
{
- if (event->mimeData() == 0) return;
-
- //
- // are we dropping files?
- //
-
- if ( event->mimeData()->hasUrls() )
- {
- QList<QUrl> textlist = event->mimeData()->urls();
-
- // Try to get the KTextEditor::View that sent this, and activate it, so that the file opens in the
- // view where it was dropped
- KTextEditor::View *kVsender = qobject_cast<KTextEditor::View *>(QObject::sender());
- if (kVsender != 0) {
- QWidget *parent = kVsender->parentWidget();
- if (parent != 0) {
- KateViewSpace* vs = qobject_cast<KateViewSpace *>(parent->parentWidget());
- if (vs != 0) m_viewManager->setActiveSpace(vs);
- }
+ if (event->mimeData() == 0) {
+ return;
}
- foreach ( const QUrl &url, textlist )
- {
- // if url has no file component, try and recursively scan dir
- KFileItem kitem(url);
- kitem.setDelayedMimeTypes(true);
- if( kitem.isDir() ) {
- KIO::ListJob *list_job = KIO::listRecursive(url, KIO::DefaultFlags, false);
- connect(list_job, SIGNAL(entries(KIO::Job*,KIO::UDSEntryList)),
- this, SLOT(slotListRecursiveEntries(KIO::Job*,KIO::UDSEntryList)));
- }
- else {
- m_viewManager->openUrl (url);
- }
+ //
+ // are we dropping files?
+ //
+
+ if (event->mimeData()->hasUrls()) {
+ QList<QUrl> textlist = event->mimeData()->urls();
+
+ // Try to get the KTextEditor::View that sent this, and activate it, so that the file opens in the
+ // view where it was dropped
+ KTextEditor::View *kVsender = qobject_cast<KTextEditor::View *>(QObject::sender());
+ if (kVsender != 0) {
+ QWidget *parent = kVsender->parentWidget();
+ if (parent != 0) {
+ KateViewSpace *vs = qobject_cast<KateViewSpace *>(parent->parentWidget());
+ if (vs != 0) {
+ m_viewManager->setActiveSpace(vs);
+ }
+ }
+ }
+
+ foreach(const QUrl & url, textlist) {
+ // if url has no file component, try and recursively scan dir
+ KFileItem kitem(url);
+ kitem.setDelayedMimeTypes(true);
+ if (kitem.isDir()) {
+ KIO::ListJob *list_job = KIO::listRecursive(url, KIO::DefaultFlags, false);
+ connect(list_job, SIGNAL(entries(KIO::Job*,KIO::UDSEntryList)),
+ this, SLOT(slotListRecursiveEntries(KIO::Job*,KIO::UDSEntryList)));
+ } else {
+ m_viewManager->openUrl(url);
+ }
+ }
+ }
+ //
+ // or are we dropping text?
+ //
+ else if (event->mimeData()->hasText()) {
+ KTextEditor::Document *doc =
+ KateDocManager::self()->createDoc();
+ doc->setText(event->mimeData()->text());
+ m_viewManager->activateView(doc);
}
- }
- //
- // or are we dropping text?
- //
- else if (event->mimeData()->hasText()) {
- KTextEditor::Document * doc =
- KateDocManager::self()->createDoc();
- doc->setText(event->mimeData()->text());
- m_viewManager->activateView(doc);
- }
}
void KateMainWindow::slotListRecursiveEntries(KIO::Job *job, const KIO::UDSEntryList &list)
{
- const QUrl dir = static_cast<KIO::SimpleJob*>( job )->url();
- foreach( const KIO::UDSEntry &entry, list )
- {
- QUrl currentUrl = dir.resolved( QUrl(entry.stringValue( KIO::UDSEntry::UDS_NAME )) );
-
- if( !entry.isDir() )
- {
- m_viewManager->openUrl(currentUrl);
- }
- }
+ const QUrl dir = static_cast<KIO::SimpleJob *>(job)->url();
+ foreach(const KIO::UDSEntry & entry, list) {
+ QUrl currentUrl = dir.resolved(QUrl(entry.stringValue(KIO::UDSEntry::UDS_NAME)));
+
+ if (!entry.isDir()) {
+ m_viewManager->openUrl(currentUrl);
+ }
+ }
}
void KateMainWindow::editKeys()
{
- KShortcutsDialog dlg ( KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this );
+ KShortcutsDialog dlg(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this);
- QList<KXMLGUIClient*> clients = guiFactory()->clients();
+ QList<KXMLGUIClient *> clients = guiFactory()->clients();
- foreach(KXMLGUIClient *client, clients) {
- // FIXME there appear to be invalid clients after session switching
+ foreach(KXMLGUIClient * client, clients) {
+ // FIXME there appear to be invalid clients after session switching
// qCDebug(LOG_KATE)<<"adding client to shortcut editor";
// qCDebug(LOG_KATE)<<client;
// qCDebug(LOG_KATE)<<client->actionCollection();
// qCDebug(LOG_KATE)<<client->componentData().aboutData();
// qCDebug(LOG_KATE)<<client->componentData().aboutData()->programName();
- dlg.addCollection ( client->actionCollection(), client->componentName() );
- }
- dlg.configure();
+ dlg.addCollection(client->actionCollection(), client->componentName());
+ }
+ dlg.configure();
- QList<KTextEditor::Document*> l = KateDocManager::self()->documentList();
- for (int i = 0;i < l.count();i++)
- {
+ QList<KTextEditor::Document *> l = KateDocManager::self()->documentList();
+ for (int i = 0; i < l.count(); i++) {
// qCDebug(LOG_KATE)<<"reloading Keysettings for document "<<i;
- l.at(i)->reloadXML();
- QList<KTextEditor::View *> l1 = l.at(i)->views ();
- for (int i1 = 0;i1 < l1.count();i1++)
- {
- l1.at(i1)->reloadXML();
+ l.at(i)->reloadXML();
+ QList<KTextEditor::View *> l1 = l.at(i)->views();
+ for (int i1 = 0; i1 < l1.count(); i1++) {
+ l1.at(i1)->reloadXML();
// qCDebug(LOG_KATE)<<"reloading Keysettings for view "<<i<<"/"<<i1;
+ }
}
- }
}
-void KateMainWindow::openUrl (const QString &name)
+void KateMainWindow::openUrl(const QString &name)
{
- m_viewManager->openUrl (QUrl(name));
+ m_viewManager->openUrl(QUrl(name));
}
void KateMainWindow::slotConfigure()
{
- showPluginConfigPage(0,0);
+ showPluginConfigPage(0, 0);
}
-void KateMainWindow::showPluginConfigPage(KTextEditor::ConfigPageInterface *configpageinterface,uint id)
+void KateMainWindow::showPluginConfigPage(KTextEditor::ConfigPageInterface *configpageinterface, uint id)
{
- if (!m_viewManager->activeView())
- return;
+ if (!m_viewManager->activeView()) {
+ return;
+ }
- KateConfigDialog* dlg = new KateConfigDialog (this, m_viewManager->activeView());
- if (configpageinterface) {
- dlg->showAppPluginPage(configpageinterface,id);
- }
- dlg->exec();
+ KateConfigDialog *dlg = new KateConfigDialog(this, m_viewManager->activeView());
+ if (configpageinterface) {
+ dlg->showAppPluginPage(configpageinterface, id);
+ }
+ dlg->exec();
- delete dlg;
+ delete dlg;
- m_viewManager->reactivateActiveView(); // gui (toolbars...) needs to be updated, because
- // of possible changes that the configure dialog
- // could have done on it, specially for plugins.
+ m_viewManager->reactivateActiveView(); // gui (toolbars...) needs to be updated, because
+ // of possible changes that the configure dialog
+ // could have done on it, specially for plugins.
}
QUrl KateMainWindow::activeDocumentUrl()
{
- // anders: i make this one safe, as it may be called during
- // startup (by the file selector)
- KTextEditor::View *v = m_viewManager->activeView();
- if ( v )
- return v->document()->url();
- return QUrl();
+ // anders: i make this one safe, as it may be called during
+ // startup (by the file selector)
+ KTextEditor::View *v = m_viewManager->activeView();
+ if (v) {
+ return v->document()->url();
+ }
+ return QUrl();
}
void KateMainWindow::mSlotFixOpenWithMenu()
{
- // dh: in bug #307699, this slot is called when launching the Kate application
- // unfortunately, noone ever could reproduce except users.
- KTextEditor::View *activeView = m_viewManager->activeView();
- if (! activeView)
- return;
-
- // cleanup menu
- QMenu *menu = documentOpenWith->menu();
- menu->clear();
-
- // get a list of appropriate services.
- QMimeDatabase db;
- QMimeType mime = db.mimeTypeForName( activeView->document()->mimeType() );
- //qCDebug(LOG_KATE) << "mime type: " << mime.name();
-
- QAction *a = 0;
- KService::List offers = KMimeTypeTrader::self()->query(mime.name(), QStringLiteral("Application"));
- // add all default open-with-actions except "Kate"
- for(KService::List::Iterator it = offers.begin(); it != offers.end(); ++it)
- {
- KService::Ptr service = *it;
- if (service->name() == QStringLiteral("Kate")) continue;
- a = menu->addAction(QIcon::fromTheme(service->icon()), service->name());
- a->setData(service->entryPath());
- }
- // append "Other..." to call the KDE "open with" dialog.
- a = documentOpenWith->menu()->addAction(i18n("&Other..."));
- a->setData(QString());
+ // dh: in bug #307699, this slot is called when launching the Kate application
+ // unfortunately, noone ever could reproduce except users.
+ KTextEditor::View *activeView = m_viewManager->activeView();
+ if (! activeView) {
+ return;
+ }
+
+ // cleanup menu
+ QMenu *menu = documentOpenWith->menu();
+ menu->clear();
+
+ // get a list of appropriate services.
+ QMimeDatabase db;
+ QMimeType mime = db.mimeTypeForName(activeView->document()->mimeType());
+ //qCDebug(LOG_KATE) << "mime type: " << mime.name();
+
+ QAction *a = 0;
+ KService::List offers = KMimeTypeTrader::self()->query(mime.name(), QStringLiteral("Application"));
+ // add all default open-with-actions except "Kate"
+ for (KService::List::Iterator it = offers.begin(); it != offers.end(); ++it) {
+ KService::Ptr service = *it;
+ if (service->name() == QStringLiteral("Kate")) {
+ continue;
+ }
+ a = menu->addAction(QIcon::fromTheme(service->icon()), service->name());
+ a->setData(service->entryPath());
+ }
+ // append "Other..." to call the KDE "open with" dialog.
+ a = documentOpenWith->menu()->addAction(i18n("&Other..."));
+ a->setData(QString());
}
-void KateMainWindow::slotOpenWithMenuAction(QAction* a)
+void KateMainWindow::slotOpenWithMenuAction(QAction *a)
{
- QList<QUrl> list;
- list.append( m_viewManager->activeView()->document()->url() );
-
- const QString openWith = a->data().toString();
- if (openWith.isEmpty())
- {
- // display "open with" dialog
- KOpenWithDialog dlg(list);
- if (dlg.exec())
- KRun::run(*dlg.service(), list, this);
- return;
- }
-
- KService::Ptr app = KService::serviceByDesktopPath(openWith);
- if (app)
- {
- KRun::run(*app, list, this);
- }
- else
- {
- KMessageBox::error(this, i18n("Application '%1' not found.", openWith), i18n("Application not found"));
- }
+ QList<QUrl> list;
+ list.append(m_viewManager->activeView()->document()->url());
+
+ const QString openWith = a->data().toString();
+ if (openWith.isEmpty()) {
+ // display "open with" dialog
+ KOpenWithDialog dlg(list);
+ if (dlg.exec()) {
+ KRun::run(*dlg.service(), list, this);
+ }
+ return;
+ }
+
+ KService::Ptr app = KService::serviceByDesktopPath(openWith);
+ if (app) {
+ KRun::run(*app, list, this);
+ } else {
+ KMessageBox::error(this, i18n("Application '%1' not found.", openWith), i18n("Application not found"));
+ }
}
void KateMainWindow::pluginHelp()
{
- KHelpClient::invokeHelp (QString(), QStringLiteral("kate-plugins"));
+ KHelpClient::invokeHelp(QString(), QStringLiteral("kate-plugins"));
}
void KateMainWindow::aboutEditor()
{
- KAboutApplicationDialog ad(KTextEditor::Editor::instance()->aboutData(),this);
- ad.exec();
+ KAboutApplicationDialog ad(KTextEditor::Editor::instance()->aboutData(), this);
+ ad.exec();
}
void KateMainWindow::slotFullScreen(bool t)
{
- KToggleFullScreenAction::setFullScreen(this, t);
+ KToggleFullScreenAction::setFullScreen(this, t);
}
bool KateMainWindow::showModOnDiskPrompt()
{
- KTextEditor::Document *doc;
-
- DocVector list;
- list.reserve( KateDocManager::self()->documents() );
- foreach( doc, KateDocManager::self()->documentList())
- {
- if ( KateDocManager::self()->documentInfo( doc )->modifiedOnDisc )
- {
- list.append( doc );
+ KTextEditor::Document *doc;
+
+ DocVector list;
+ list.reserve(KateDocManager::self()->documents());
+ foreach(doc, KateDocManager::self()->documentList()) {
+ if (KateDocManager::self()->documentInfo(doc)->modifiedOnDisc) {
+ list.append(doc);
+ }
}
- }
- if ( !list.isEmpty() && !m_modignore )
- {
- KateMwModOnHdDialog mhdlg( list, this );
- m_modignore = true;
- bool res = mhdlg.exec();
- m_modignore = false;
+ if (!list.isEmpty() && !m_modignore) {
+ KateMwModOnHdDialog mhdlg(list, this);
+ m_modignore = true;
+ bool res = mhdlg.exec();
+ m_modignore = false;
- return res;
- }
- return true;
+ return res;
+ }
+ return true;
}
-void KateMainWindow::slotDocumentCreated (KTextEditor::Document *doc)
+void KateMainWindow::slotDocumentCreated(KTextEditor::Document *doc)
{
- connect(doc, SIGNAL(modifiedChanged(KTextEditor::Document*)), this, SLOT(updateCaption(KTextEditor::Document*)));
- connect(doc, SIGNAL(readWriteChanged(KTextEditor::Document*)), this, SLOT(updateCaption(KTextEditor::Document*)));
- connect(doc, SIGNAL(documentNameChanged(KTextEditor::Document*)), this, SLOT(updateCaption(KTextEditor::Document*)));
- connect(doc, SIGNAL(documentNameChanged(KTextEditor::Document*)), this, SLOT(slotUpdateOpenWith()));
+ connect(doc, SIGNAL(modifiedChanged(KTextEditor::Document*)), this, SLOT(updateCaption(KTextEditor::Document*)));
+ connect(doc, SIGNAL(readWriteChanged(KTextEditor::Document*)), this, SLOT(updateCaption(KTextEditor::Document*)));
+ connect(doc, SIGNAL(documentNameChanged(KTextEditor::Document*)), this, SLOT(updateCaption(KTextEditor::Document*)));
+ connect(doc, SIGNAL(documentNameChanged(KTextEditor::Document*)), this, SLOT(slotUpdateOpenWith()));
- updateCaption (doc);
+ updateCaption(doc);
}
-void KateMainWindow::updateCaption ()
+void KateMainWindow::updateCaption()
{
- if (m_viewManager->activeView())
- updateCaption(m_viewManager->activeView()->document());
+ if (m_viewManager->activeView()) {
+ updateCaption(m_viewManager->activeView()->document());
+ }
}
-void KateMainWindow::updateCaption (KTextEditor::Document *doc)
+void KateMainWindow::updateCaption(KTextEditor::Document *doc)
{
- if (!m_viewManager->activeView())
- {
- setCaption (QString(), false);
- return;
- }
-
- // block signals from inactive docs
- if (!((KTextEditor::Document*)m_viewManager->activeView()->document() == doc))
- return;
-
- QString c;
- if (m_viewManager->activeView()->document()->url().isEmpty() || (!m_paShowPath || !m_paShowPath->isChecked()))
- {
- c = ((KTextEditor::Document*)m_viewManager->activeView()->document())->documentName();
- }
- else
- {
- c = m_viewManager->activeView()->document()->url().toString();
- }
-
- QString sessName = KateApp::self()->sessionManager()->activeSession()->name();
- if ( !sessName.isEmpty() )
- sessName = QString::fromLatin1("%1: ").arg( sessName );
-
- QString readOnlyCaption;
- if (!m_viewManager->activeView()->document()->isReadWrite())
- readOnlyCaption=i18n(" [read only]");
-
- setCaption( sessName + c+readOnlyCaption+QStringLiteral(" [*]"),
- m_viewManager->activeView()->document()->isModified());
+ if (!m_viewManager->activeView()) {
+ setCaption(QString(), false);
+ return;
+ }
+
+ // block signals from inactive docs
+ if (!((KTextEditor::Document *)m_viewManager->activeView()->document() == doc)) {
+ return;
+ }
+
+ QString c;
+ if (m_viewManager->activeView()->document()->url().isEmpty() || (!m_paShowPath || !m_paShowPath->isChecked())) {
+ c = ((KTextEditor::Document *)m_viewManager->activeView()->document())->documentName();
+ } else {
+ c = m_viewManager->activeView()->document()->url().toString();
+ }
+
+ QString sessName = KateApp::self()->sessionManager()->activeSession()->name();
+ if (!sessName.isEmpty()) {
+ sessName = QString::fromLatin1("%1: ").arg(sessName);
+ }
+
+ QString readOnlyCaption;
+ if (!m_viewManager->activeView()->document()->isReadWrite()) {
+ readOnlyCaption = i18n(" [read only]");
+ }
+
+ setCaption(sessName + c + readOnlyCaption + QStringLiteral(" [*]"),
+ m_viewManager->activeView()->document()->isModified());
}
-void KateMainWindow::saveProperties(KConfigGroup& config)
+void KateMainWindow::saveProperties(KConfigGroup &config)
{
- saveSession(config);
-
- // store all plugin view states
- int id = KateApp::self()->mainWindowID (this);
- foreach(const KatePluginInfo &item, KatePluginManager::self()->pluginList()) {
- if (item.plugin && pluginViews().contains(item.plugin)) {
- if (auto interface = qobject_cast<KTextEditor::SessionConfigInterface *> (pluginViews().value(item.plugin))) {
- KConfigGroup group (config.config(), QString::fromLatin1("Plugin:%1:MainWindow:%2").arg(item.saveName()).arg(id));
- interface->writeSessionConfig (group);
- }
+ saveSession(config);
+
+ // store all plugin view states
+ int id = KateApp::self()->mainWindowID(this);
+ foreach(const KatePluginInfo & item, KatePluginManager::self()->pluginList()) {
+ if (item.plugin && pluginViews().contains(item.plugin)) {
+ if (auto interface = qobject_cast<KTextEditor::SessionConfigInterface *> (pluginViews().value(item.plugin))) {
+ KConfigGroup group(config.config(), QString::fromLatin1("Plugin:%1:MainWindow:%2").arg(item.saveName()).arg(id));
+ interface->writeSessionConfig(group);
+ }
+ }
}
- }
- m_fileOpenRecent->saveEntries( KConfigGroup(config.config(), "Recent Files" ) );
- m_viewManager->saveViewConfiguration (config);
+ m_fileOpenRecent->saveEntries(KConfigGroup(config.config(), "Recent Files"));
+ m_viewManager->saveViewConfiguration(config);
}
-void KateMainWindow::readProperties(const KConfigGroup& config)
+void KateMainWindow::readProperties(const KConfigGroup &config)
{
- // KDE5: TODO startRestore should take a const KConfigBase*, or even just a const KConfigGroup&,
- // but this propagates down to interfaces/kate/plugin.h so all plugins have to be ported
- KConfigBase* configBase = const_cast<KConfig *>(config.config());
- startRestore(configBase, config.name());
+ // KDE5: TODO startRestore should take a const KConfigBase*, or even just a const KConfigGroup&,
+ // but this propagates down to interfaces/kate/plugin.h so all plugins have to be ported
+ KConfigBase *configBase = const_cast<KConfig *>(config.config());
+ startRestore(configBase, config.name());
- // perhaps enable plugin guis
- KatePluginManager::self()->enableAllPluginsGUI (this, configBase);
+ // perhaps enable plugin guis
+ KatePluginManager::self()->enableAllPluginsGUI(this, configBase);
- finishRestore ();
+ finishRestore();
- m_fileOpenRecent->loadEntries( KConfigGroup(config.config(), "Recent Files" ) );
- m_viewManager->restoreViewConfiguration (config);
+ m_fileOpenRecent->loadEntries(KConfigGroup(config.config(), "Recent Files"));
+ m_viewManager->restoreViewConfiguration(config);
}
-void KateMainWindow::saveGlobalProperties( KConfig* sessionConfig )
+void KateMainWindow::saveGlobalProperties(KConfig *sessionConfig)
{
- KateDocManager::self()->saveDocumentList (sessionConfig);
+ KateDocManager::self()->saveDocumentList(sessionConfig);
- KConfigGroup cg( sessionConfig, "General");
- cg.writeEntry ("Last Session", KateApp::self()->sessionManager()->activeSession()->name());
+ KConfigGroup cg(sessionConfig, "General");
+ cg.writeEntry("Last Session", KateApp::self()->sessionManager()->activeSession()->name());
- // save plugin config !!
- KateApp::self()->pluginManager()->writeConfig (sessionConfig);
+ // save plugin config !!
+ KateApp::self()->pluginManager()->writeConfig(sessionConfig);
}
void KateMainWindow::saveWindowConfig(const KConfigGroup &_config)
{
- KConfigGroup config( _config );
- saveMainWindowSettings(config);
- KWindowConfig::saveWindowSize(windowHandle(), config);
- config.writeEntry("WindowState", int(((KParts::MainWindow*)this)->windowState()));
- config.sync();
+ KConfigGroup config(_config);
+ saveMainWindowSettings(config);
+ KWindowConfig::saveWindowSize(windowHandle(), config);
+ config.writeEntry("WindowState", int(((KParts::MainWindow *)this)->windowState()));
+ config.sync();
}
void KateMainWindow::restoreWindowConfig(const KConfigGroup &config)
{
- setWindowState(Qt::WindowNoState);
- applyMainWindowSettings(config);
- KWindowConfig::restoreWindowSize(windowHandle(), config);
- setWindowState( QFlags<Qt::WindowState>(config.readEntry("WindowState", int(Qt::WindowActive))) );
+ setWindowState(Qt::WindowNoState);
+ applyMainWindowSettings(config);
+ KWindowConfig::restoreWindowSize(windowHandle(), config);
+ setWindowState(QFlags<Qt::WindowState>(config.readEntry("WindowState", int(Qt::WindowActive))));
}
void KateMainWindow::slotUpdateBottomViewBar()
{
- //qCDebug(LOG_KATE)<<"slotUpdateHorizontalViewBar()"<<endl;
- KTextEditor::View *view=m_viewManager->activeView();
- BarState bs=m_bottomViewBarMapping[view];
- if (bs.bar() && bs.state()) {
- m_bottomContainerStack->setCurrentWidget(bs.bar());
- m_bottomContainerStack->currentWidget()->show();
- m_bottomViewBarContainer->show();
- } else {
- QWidget *wid=m_bottomContainerStack->currentWidget();
- if (wid) wid->hide();
- //qCDebug(LOG_KATE)<<wid<<"hiding container"<<endl;
- m_bottomViewBarContainer->hide();
- }
+ //qCDebug(LOG_KATE)<<"slotUpdateHorizontalViewBar()"<<endl;
+ KTextEditor::View *view = m_viewManager->activeView();
+ BarState bs = m_bottomViewBarMapping[view];
+ if (bs.bar() && bs.state()) {
+ m_bottomContainerStack->setCurrentWidget(bs.bar());
+ m_bottomContainerStack->currentWidget()->show();
+ m_bottomViewBarContainer->show();
+ } else {
+ QWidget *wid = m_bottomContainerStack->currentWidget();
+ if (wid) {
+ wid->hide();
+ }
+ //qCDebug(LOG_KATE)<<wid<<"hiding container"<<endl;
+ m_bottomViewBarContainer->hide();
+ }
}
void KateMainWindow::queueModifiedOnDisc(KTextEditor::Document *doc)
{
- if (!m_modNotification) return;
-
- if (s_modOnHdDialog==0) {
- DocVector list;
- list.append(doc);
+ if (!m_modNotification) {
+ return;
+ }
- s_modOnHdDialog= new KateMwModOnHdDialog( list, this );
- m_modignore = true;
- KWindowSystem::setOnAllDesktops( s_modOnHdDialog->winId(), true);
- s_modOnHdDialog->exec();
- delete s_modOnHdDialog; // s_modOnHdDialog is set to 0 in destructor of KateMwModOnHdDialog (jowenn!!!)
- m_modignore = false;
- } else {
- s_modOnHdDialog->addDocument(doc);
- }
+ if (s_modOnHdDialog == 0) {
+ DocVector list;
+ list.append(doc);
+
+ s_modOnHdDialog = new KateMwModOnHdDialog(list, this);
+ m_modignore = true;
+ KWindowSystem::setOnAllDesktops(s_modOnHdDialog->winId(), true);
+ s_modOnHdDialog->exec();
+ delete s_modOnHdDialog; // s_modOnHdDialog is set to 0 in destructor of KateMwModOnHdDialog (jowenn!!!)
+ m_modignore = false;
+ } else {
+ s_modOnHdDialog->addDocument(doc);
+ }
}
-bool KateMainWindow::event( QEvent *e )
+bool KateMainWindow::event(QEvent *e)
{
- if (e->type() == QEvent::ShortcutOverride) {
- QKeyEvent *k = static_cast<QKeyEvent *>(e);
- emit unhandledShortcutOverride (k);
- }
- return KateMDI::MainWindow::event(e);
+ if (e->type() == QEvent::ShortcutOverride) {
+ QKeyEvent *k = static_cast<QKeyEvent *>(e);
+ emit unhandledShortcutOverride(k);
+ }
+ return KateMDI::MainWindow::event(e);
}
-QObject *KateMainWindow::pluginView (const QString &name)
+QObject *KateMainWindow::pluginView(const QString &name)
{
- KTextEditor::Plugin *plugin = KateApp::self()->pluginManager()->plugin (name);
- if (!plugin)
- return 0;
+ KTextEditor::Plugin *plugin = KateApp::self()->pluginManager()->plugin(name);
+ if (!plugin) {
+ return 0;
+ }
- return m_pluginViews.contains(plugin) ? m_pluginViews.value (plugin) : 0;
+ return m_pluginViews.contains(plugin) ? m_pluginViews.value(plugin) : 0;
}
-void KateMainWindow::slotQuickOpen ()
+void KateMainWindow::slotQuickOpen()
{
- /**
- * show quick open and pass focus to it
- */
- m_quickOpen->update ();
- m_mainStackedWidget->setCurrentWidget (m_quickOpen);
- centralWidget()->setFocusProxy (m_quickOpen);
- m_quickOpen->setFocus ();
+ /**
+ * show quick open and pass focus to it
+ */
+ m_quickOpen->update();
+ m_mainStackedWidget->setCurrentWidget(m_quickOpen);
+ centralWidget()->setFocusProxy(m_quickOpen);
+ m_quickOpen->setFocus();
}
-QWidget *KateMainWindow::createToolView (KTextEditor::Plugin *plugin, const QString &identifier, KTextEditor::MainWindow::ToolViewPosition pos, const QIcon &icon, const QString &text)
+QWidget *KateMainWindow::createToolView(KTextEditor::Plugin *plugin, const QString &identifier, KTextEditor::MainWindow::ToolViewPosition pos, const QIcon &icon, const QString &text)
{
- // FIXME KF5
- return KateMDI::MainWindow::createToolView (plugin, identifier, (KMultiTabBar::KMultiTabBarPosition) (pos), icon.pixmap(QSize (16, 16)), text);
+ // FIXME KF5
+ return KateMDI::MainWindow::createToolView(plugin, identifier, (KMultiTabBar::KMultiTabBarPosition)(pos), icon.pixmap(QSize(16, 16)), text);
}
-bool KateMainWindow::moveToolView (QWidget *widget, KTextEditor::MainWindow::ToolViewPosition pos)
+bool KateMainWindow::moveToolView(QWidget *widget, KTextEditor::MainWindow::ToolViewPosition pos)
{
- if (!qobject_cast<KateMDI::ToolView*>(widget))
- return false;
-
- // FIXME KF5
- return KateMDI::MainWindow::moveToolView (qobject_cast<KateMDI::ToolView*>(widget), (KMultiTabBar::KMultiTabBarPosition) (pos));
+ if (!qobject_cast<KateMDI::ToolView *>(widget)) {
+ return false;
+ }
+
+ // FIXME KF5
+ return KateMDI::MainWindow::moveToolView(qobject_cast<KateMDI::ToolView *>(widget), (KMultiTabBar::KMultiTabBarPosition)(pos));
}
-bool KateMainWindow::showToolView (QWidget *widget)
+bool KateMainWindow::showToolView(QWidget *widget)
{
- if (!qobject_cast<KateMDI::ToolView*>(widget))
- return false;
-
- return KateMDI::MainWindow::showToolView (qobject_cast<KateMDI::ToolView*>(widget));
+ if (!qobject_cast<KateMDI::ToolView *>(widget)) {
+ return false;
+ }
+
+ return KateMDI::MainWindow::showToolView(qobject_cast<KateMDI::ToolView *>(widget));
}
-bool KateMainWindow::hideToolView (QWidget *widget)
+bool KateMainWindow::hideToolView(QWidget *widget)
{
- if (!qobject_cast<KateMDI::ToolView*>(widget))
- return false;
-
- return KateMDI::MainWindow::hideToolView (qobject_cast<KateMDI::ToolView*>(widget));
+ if (!qobject_cast<KateMDI::ToolView *>(widget)) {
+ return false;
+ }
+
+ return KateMDI::MainWindow::hideToolView(qobject_cast<KateMDI::ToolView *>(widget));
}
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/app/katemainwindow.h b/kate/app/katemainwindow.h
index edf439c..1482136 100644
--- a/kate/app/katemainwindow.h
+++ b/kate/app/katemainwindow.h
@@ -44,8 +44,8 @@ class QMenu;
namespace KIO
{
- class UDSEntry;
- typedef class QList<UDSEntry> UDSEntryList;
+class UDSEntry;
+typedef class QList<UDSEntry> UDSEntryList;
}
class KFileItem;
@@ -58,25 +58,24 @@ class KateQuickOpen;
// Helper layout class to always provide minimum size
class KateContainerStackedLayout : public QStackedLayout
{
- Q_OBJECT
+ Q_OBJECT
public:
- KateContainerStackedLayout(QWidget* parent);
- virtual QSize sizeHint() const;
- virtual QSize minimumSize() const;
+ KateContainerStackedLayout(QWidget *parent);
+ virtual QSize sizeHint() const;
+ virtual QSize minimumSize() const;
};
-
class KateMainWindow : public KateMDI::MainWindow, virtual public KParts::PartBase
{
Q_OBJECT
- public:
+public:
/**
* Construct the window and restore its state from given config if any
* @param sconfig session config for this window, 0 if none
* @param sgroup session config group to use
*/
- KateMainWindow (KConfig *sconfig, const QString &sgroup);
+ KateMainWindow(KConfig *sconfig, const QString &sgroup);
/**
* Destruct the nice window
@@ -86,29 +85,26 @@ class KateMainWindow : public KateMDI::MainWindow, virtual public KParts::PartBa
/**
* Accessor methodes for interface and child objects
*/
- public:
- KateViewManager *viewManager ()
- {
- return m_viewManager;
+public:
+ KateViewManager *viewManager() {
+ return m_viewManager;
}
-
+
/**
* KTextEditor::MainWindow wrapper
* @return KTextEditor::MainWindow wrapper.
*/
- KTextEditor::MainWindow *wrapper ()
- {
- return m_wrapper;
+ KTextEditor::MainWindow *wrapper() {
+ return m_wrapper;
}
- public:
+public:
/** Returns the URL of the current document.
* anders: I add this for use from the file selector. */
QUrl activeDocumentUrl();
- uint mainWindowNumber () const
- {
- return myID;
+ uint mainWindowNumber() const {
+ return myID;
}
/**
@@ -120,12 +116,12 @@ class KateMainWindow : public KateMDI::MainWindow, virtual public KParts::PartBa
*/
bool showModOnDiskPrompt();
- public:
- /*reimp*/ void readProperties(const KConfigGroup& config);
- /*reimp*/ void saveProperties(KConfigGroup& config);
- /*reimp*/ void saveGlobalProperties( KConfig* sessionConfig );
+public:
+ /*reimp*/ void readProperties(const KConfigGroup &config);
+ /*reimp*/ void saveProperties(KConfigGroup &config);
+ /*reimp*/ void saveGlobalProperties(KConfig *sessionConfig);
- public:
+public:
bool queryClose_internal(KTextEditor::Document *doc = NULL);
/**
@@ -144,11 +140,11 @@ class KateMainWindow : public KateMDI::MainWindow, virtual public KParts::PartBa
*/
void saveOptions();
- private:
+private:
/**
* Setup actions which pointers are needed already in setupMainWindow
*/
- void setupImportantActions ();
+ void setupImportantActions();
void setupMainWindow();
void setupActions();
@@ -159,10 +155,10 @@ class KateMainWindow : public KateMDI::MainWindow, virtual public KParts::PartBa
*/
void readOptions();
- void dragEnterEvent( QDragEnterEvent * );
- void dropEvent( QDropEvent * );
+ void dragEnterEvent(QDragEnterEvent *);
+ void dropEvent(QDropEvent *);
- public Q_SLOTS:
+public Q_SLOTS:
void slotFileClose();
void slotFileQuit();
void queueModifiedOnDisc(KTextEditor::Document *doc);
@@ -170,18 +166,18 @@ class KateMainWindow : public KateMDI::MainWindow, virtual public KParts::PartBa
/**
* Show quick open
*/
- void slotQuickOpen ();
+ void slotQuickOpen();
- /**
- * slots used for actions in the menus/toolbars
- * or internal signal connections
- */
- private Q_SLOTS:
- void newWindow ();
+ /**
+ * slots used for actions in the menus/toolbars
+ * or internal signal connections
+ */
+private Q_SLOTS:
+ void newWindow();
void slotConfigure();
- void slotOpenWithMenuAction(QAction* a);
+ void slotOpenWithMenuAction(QAction *a);
void slotEditToolbars();
void slotNewToolbarConfig();
@@ -193,94 +189,121 @@ class KateMainWindow : public KateMDI::MainWindow, virtual public KParts::PartBa
void mSlotFixOpenWithMenu();
/* to update the caption */
- void slotDocumentCreated (KTextEditor::Document *doc);
- void updateCaption (KTextEditor::Document *doc);
+ void slotDocumentCreated(KTextEditor::Document *doc);
+ void updateCaption(KTextEditor::Document *doc);
// calls updateCaption(doc) with the current document
- void updateCaption ();
+ void updateCaption();
- void pluginHelp ();
+ void pluginHelp();
void aboutEditor();
void slotFullScreen(bool);
void slotListRecursiveEntries(KIO::Job *job, const KIO::UDSEntryList &list);
- private Q_SLOTS:
- void toggleShowStatusBar ();
+private Q_SLOTS:
+ void toggleShowStatusBar();
- public:
- bool showStatusBar ();
+public:
+ bool showStatusBar();
- Q_SIGNALS:
- void statusBarToggled ();
- void unhandledShortcutOverride (QEvent *e);
+Q_SIGNALS:
+ void statusBarToggled();
+ void unhandledShortcutOverride(QEvent *e);
- public:
- void openUrl (const QString &name = QString());
+public:
+ void openUrl(const QString &name = QString());
- QHash<KTextEditor::Plugin*, QObject*> &pluginViews ()
- {
- return m_pluginViews;
+ QHash<KTextEditor::Plugin *, QObject *> &pluginViews() {
+ return m_pluginViews;
}
- inline QWidget *bottomViewBarContainer() {return m_bottomViewBarContainer;}
- inline void addToBottomViewBarContainer(KTextEditor::View *view,QWidget *bar){m_bottomContainerStack->addWidget (bar); m_bottomViewBarMapping[view]=BarState(bar);}
- inline void hideBottomViewBarForView(KTextEditor::View *view) {QWidget *bar; BarState state=m_bottomViewBarMapping.value(view); bar=state.bar(); if (bar) {m_bottomContainerStack->setCurrentWidget(bar); bar->hide(); state.setState(false); m_bottomViewBarMapping[view]=state;} m_bottomViewBarContainer->hide();}
- inline void showBottomViewBarForView(KTextEditor::View *view) {QWidget *bar; BarState state=m_bottomViewBarMapping.value(view); bar=state.bar(); if (bar) {m_bottomContainerStack->setCurrentWidget(bar); bar->show(); state.setState(true); m_bottomViewBarMapping[view]=state; m_bottomViewBarContainer->show();}}
- inline void deleteBottomViewBarForView(KTextEditor::View *view) {QWidget *bar; BarState state=m_bottomViewBarMapping.take(view); bar=state.bar(); if (bar) {if (m_bottomContainerStack->currentWidget()==bar) m_bottomViewBarContainer->hide(); delete bar;}}
+ inline QWidget *bottomViewBarContainer() {
+ return m_bottomViewBarContainer;
+ }
+ inline void addToBottomViewBarContainer(KTextEditor::View *view, QWidget *bar) {
+ m_bottomContainerStack->addWidget(bar);
+ m_bottomViewBarMapping[view] = BarState(bar);
+ }
+ inline void hideBottomViewBarForView(KTextEditor::View *view) {
+ QWidget *bar;
+ BarState state = m_bottomViewBarMapping.value(view);
+ bar = state.bar();
+ if (bar) {
+ m_bottomContainerStack->setCurrentWidget(bar);
+ bar->hide();
+ state.setState(false);
+ m_bottomViewBarMapping[view] = state;
+ } m_bottomViewBarContainer->hide();
+ }
+ inline void showBottomViewBarForView(KTextEditor::View *view) {
+ QWidget *bar;
+ BarState state = m_bottomViewBarMapping.value(view);
+ bar = state.bar();
+ if (bar) {
+ m_bottomContainerStack->setCurrentWidget(bar);
+ bar->show();
+ state.setState(true);
+ m_bottomViewBarMapping[view] = state;
+ m_bottomViewBarContainer->show();
+ }
+ }
+ inline void deleteBottomViewBarForView(KTextEditor::View *view) {
+ QWidget *bar;
+ BarState state = m_bottomViewBarMapping.take(view);
+ bar = state.bar();
+ if (bar) {
+ if (m_bottomContainerStack->currentWidget() == bar) {
+ m_bottomViewBarContainer->hide();
+ } delete bar;
+ }
+ }
- bool modNotificationEnabled () const
- {
- return m_modNotification;
+ bool modNotificationEnabled() const {
+ return m_modNotification;
}
- void setModNotificationEnabled (bool e)
- {
- m_modNotification = e;
+ void setModNotificationEnabled(bool e) {
+ m_modNotification = e;
}
- KRecentFilesAction *fileOpenRecent () const
- {
- return m_fileOpenRecent;
+ KRecentFilesAction *fileOpenRecent() const {
+ return m_fileOpenRecent;
}
- //
- // KTextEditor::MainWindow interface, get called by invokeMethod from our wrapper object!
- //
- public Q_SLOTS:
+ //
+ // KTextEditor::MainWindow interface, get called by invokeMethod from our wrapper object!
+ //
+public Q_SLOTS:
/**
* get the toplevel widget.
* \return the real main window widget.
*/
- QWidget *window ()
- {
- return this;
- }
-
+ QWidget *window() {
+ return this;
+ }
+
/**
* Accessor to the XMLGUIFactory.
* \return the mainwindow's KXMLGUIFactory.
*/
- KXMLGUIFactory *guiFactory ()
- {
- return KateMDI::MainWindow::guiFactory ();
+ KXMLGUIFactory *guiFactory() {
+ return KateMDI::MainWindow::guiFactory();
}
-
+
/**
* Get a list of all views for this main window.
* @return all views
*/
- QList<KTextEditor::View *> views ()
- {
- return viewManager()->viewList();
+ QList<KTextEditor::View *> views() {
+ return viewManager()->viewList();
}
-
+
/**
* Access the active view.
* \return active view
*/
- KTextEditor::View *activeView ()
- {
- return viewManager()->activeView();
+ KTextEditor::View *activeView() {
+ return viewManager()->activeView();
}
/**
@@ -289,9 +312,8 @@ class KateMainWindow : public KateMDI::MainWindow, virtual public KParts::PartBa
* \param document the document
* \return activated view of this document
*/
- KTextEditor::View *activateView (KTextEditor::Document *document)
- {
- return viewManager()->activateView (document);
+ KTextEditor::View *activateView(KTextEditor::Document *document) {
+ return viewManager()->activateView(document);
}
/**
@@ -302,28 +324,25 @@ class KateMainWindow : public KateMDI::MainWindow, virtual public KParts::PartBa
* \return a pointer to the created view for the new document, if a document
* with this url is already existing, its view will be activated
*/
- KTextEditor::View *openUrl (const QUrl &url, const QString &encoding = QString())
- {
- return viewManager()->openUrlWithView (url, encoding);
+ KTextEditor::View *openUrl(const QUrl &url, const QString &encoding = QString()) {
+ return viewManager()->openUrlWithView(url, encoding);
}
-
+
/**
* Try to create a view bar for the given view.
* @param view view for which we want an view bar
* @return suitable widget that can host view bars widgets or nullptr
*/
- QWidget *createViewBar (KTextEditor::View *)
- {
- return bottomViewBarContainer ();
+ QWidget *createViewBar(KTextEditor::View *) {
+ return bottomViewBarContainer();
}
/**
* Delete the view bar for the given view.
* @param view view for which we want an view bar
*/
- void deleteViewBar (KTextEditor::View *view)
- {
- deleteBottomViewBarForView (view);
+ void deleteViewBar(KTextEditor::View *view) {
+ deleteBottomViewBarForView(view);
}
/**
@@ -331,29 +350,26 @@ class KateMainWindow : public KateMDI::MainWindow, virtual public KParts::PartBa
* @param view view for which the view bar is used
* @param bar bar widget, shall have the viewBarParent() as parent widget
*/
- void addWidgetToViewBar (KTextEditor::View *view, QWidget *bar)
- {
- addToBottomViewBarContainer (view, bar);
+ void addWidgetToViewBar(KTextEditor::View *view, QWidget *bar) {
+ addToBottomViewBarContainer(view, bar);
}
-
+
/**
* Show the view bar for the given view
* @param view view for which the view bar is used
*/
- void showViewBar (KTextEditor::View *view)
- {
- showBottomViewBarForView (view);
+ void showViewBar(KTextEditor::View *view) {
+ showBottomViewBarForView(view);
}
-
+
/**
* Hide the view bar for the given view
* @param view view for which the view bar is used
*/
- void hideViewBar (KTextEditor::View *view)
- {
- hideBottomViewBarForView (view);
+ void hideViewBar(KTextEditor::View *view) {
+ hideBottomViewBarForView(view);
}
-
+
/**
* Create a new toolview with unique \p identifier at side \p pos
* with \p icon and caption \p text. Use the returned widget to embedd
@@ -366,7 +382,7 @@ class KateMainWindow : public KateMDI::MainWindow, virtual public KParts::PartBa
* \param text translated text (i18n()) to use in addition to icon
* \return created toolview on success, otherwise NULL
*/
- QWidget *createToolView (KTextEditor::Plugin *plugin, const QString &identifier, KTextEditor::MainWindow::ToolViewPosition pos, const QIcon &icon, const QString &text);
+ QWidget *createToolView(KTextEditor::Plugin *plugin, const QString &identifier, KTextEditor::MainWindow::ToolViewPosition pos, const QIcon &icon, const QString &text);
/**
* Move the toolview \p widget to position \p pos.
@@ -375,7 +391,7 @@ class KateMainWindow : public KateMDI::MainWindow, virtual public KParts::PartBa
* \param pos new position to move widget to
* \return \e true on success, otherwise \e false
*/
- bool moveToolView (QWidget *widget, KTextEditor::MainWindow::ToolViewPosition pos);
+ bool moveToolView(QWidget *widget, KTextEditor::MainWindow::ToolViewPosition pos);
/**
* Show the toolview \p widget.
@@ -384,7 +400,7 @@ class KateMainWindow : public KateMDI::MainWindow, virtual public KParts::PartBa
* \return \e true on success, otherwise \e false
* \todo add focus parameter: bool showToolView (QWidget *widget, bool giveFocus );
*/
- bool showToolView (QWidget *widget);
+ bool showToolView(QWidget *widget);
/**
* Hide the toolview \p widget.
@@ -392,25 +408,25 @@ class KateMainWindow : public KateMDI::MainWindow, virtual public KParts::PartBa
* by createToolView().
* \return \e true on success, otherwise \e false
*/
- bool hideToolView (QWidget *widget);
-
+ bool hideToolView(QWidget *widget);
+
/**
* Get a plugin view for the plugin with with identifier \p name.
* \param name the plugin's name
* \return pointer to the plugin view if a plugin with \p name is loaded and has a view for this mainwindow,
* otherwise NULL
*/
- QObject *pluginView (const QString &name);
-
- private Q_SLOTS:
+ QObject *pluginView(const QString &name);
+
+private Q_SLOTS:
void slotUpdateBottomViewBar();
- private Q_SLOTS:
+private Q_SLOTS:
void slotDocumentCloseAll();
void slotDocumentCloseOther();
void slotDocumentCloseOther(KTextEditor::Document *document);
- void slotDocumentCloseSelected(const QList<KTextEditor::Document*>&);
- private:
+ void slotDocumentCloseSelected(const QList<KTextEditor::Document *> &);
+private:
static uint uniqueID;
uint myID;
@@ -423,12 +439,12 @@ class KateMainWindow : public KateMDI::MainWindow, virtual public KParts::PartBa
* stacked widget containing the central area, aka view manager, quickopen, ...
*/
QStackedWidget *m_mainStackedWidget;
-
+
/**
* quick open to fast switch documents
*/
KateQuickOpen *m_quickOpen;
-
+
/**
* keeps track of views
*/
@@ -436,14 +452,14 @@ class KateMainWindow : public KateMDI::MainWindow, virtual public KParts::PartBa
KRecentFilesAction *m_fileOpenRecent;
- KActionMenu* documentOpenWith;
+ KActionMenu *documentOpenWith;
- KToggleAction* settingsShowFileselector;
+ KToggleAction *settingsShowFileselector;
bool m_modignore;
// all plugin views for this mainwindow, used by the pluginmanager
- QHash<KTextEditor::Plugin*, QObject*> m_pluginViews;
+ QHash<KTextEditor::Plugin *, QObject *> m_pluginViews;
// options: show statusbar + show path
KToggleAction *m_paShowPath;
@@ -451,41 +467,49 @@ class KateMainWindow : public KateMDI::MainWindow, virtual public KParts::PartBa
QWidget *m_bottomViewBarContainer;
KateContainerStackedLayout *m_bottomContainerStack;
- class BarState{
- public:
- BarState():m_bar(0),m_state(false){}
- BarState(QWidget* bar):m_bar(bar),m_state(false){}
- ~BarState(){}
- QWidget *bar(){return m_bar;}
- bool state(){return m_state;}
- void setState(bool state){m_state=state;}
- private:
+ class BarState
+ {
+ public:
+ BarState(): m_bar(0), m_state(false) {}
+ BarState(QWidget *bar): m_bar(bar), m_state(false) {}
+ ~BarState() {}
+ QWidget *bar() {
+ return m_bar;
+ }
+ bool state() {
+ return m_state;
+ }
+ void setState(bool state) {
+ m_state = state;
+ }
+ private:
QWidget *m_bar;
bool m_state;
};
- QHash<KTextEditor::View*,BarState> m_bottomViewBarMapping;
+ QHash<KTextEditor::View *, BarState> m_bottomViewBarMapping;
- public:
- static void unsetModifiedOnDiscDialogIfIf(KateMwModOnHdDialog* diag) {
- if (s_modOnHdDialog==diag) s_modOnHdDialog=0;
+public:
+ static void unsetModifiedOnDiscDialogIfIf(KateMwModOnHdDialog *diag) {
+ if (s_modOnHdDialog == diag) {
+ s_modOnHdDialog = 0;
+ }
}
- private:
+private:
static KateMwModOnHdDialog *s_modOnHdDialog;
-
+
/**
* Wrapper of main window for KTextEditor
*/
KTextEditor::MainWindow *m_wrapper;
- public Q_SLOTS:
- void showPluginConfigPage(KTextEditor::ConfigPageInterface *configpageinterface,uint id);
+public Q_SLOTS:
+ void showPluginConfigPage(KTextEditor::ConfigPageInterface *configpageinterface, uint id);
+
+ void slotWindowActivated();
- void slotWindowActivated ();
-
- protected:
- virtual bool event( QEvent *e );
+protected:
+ virtual bool event(QEvent *e);
};
#endif
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/app/katemdi.cpp b/kate/app/katemdi.cpp
index 25f5914..530fdce 100644
--- a/kate/app/katemdi.cpp
+++ b/kate/app/katemdi.cpp
@@ -50,47 +50,44 @@ namespace KateMDI
//BEGIN TOGGLETOOLVIEWACTION
//
- ToggleToolViewAction::ToggleToolViewAction ( const QString& text, ToolView *tv,
- QObject* parent )
- : KToggleAction(text, parent)
- , m_tv(tv)
- {
+ToggleToolViewAction::ToggleToolViewAction(const QString &text, ToolView *tv,
+ QObject *parent)
+ : KToggleAction(text, parent)
+ , m_tv(tv)
+{
connect(this, SIGNAL(toggled(bool)), this, SLOT(slotToggled(bool)));
connect(m_tv, SIGNAL(toolVisibleChanged(bool)), this, SLOT(toolVisibleChanged(bool)));
setChecked(m_tv->toolVisible());
- }
-
- ToggleToolViewAction::~ToggleToolViewAction()
- {}
-
- void ToggleToolViewAction::toolVisibleChanged(bool)
- {
- if (isChecked() != m_tv->toolVisible())
- setChecked (m_tv->toolVisible());
- }
-
- void ToggleToolViewAction::slotToggled(bool t)
- {
- if (t)
- {
- m_tv->mainWindow()->showToolView (m_tv);
- m_tv->setFocus ();
+}
+
+ToggleToolViewAction::~ToggleToolViewAction()
+{}
+
+void ToggleToolViewAction::toolVisibleChanged(bool)
+{
+ if (isChecked() != m_tv->toolVisible()) {
+ setChecked(m_tv->toolVisible());
}
- else
- {
- m_tv->mainWindow()->hideToolView (m_tv);
+}
+
+void ToggleToolViewAction::slotToggled(bool t)
+{
+ if (t) {
+ m_tv->mainWindow()->showToolView(m_tv);
+ m_tv->setFocus();
+ } else {
+ m_tv->mainWindow()->hideToolView(m_tv);
}
- }
+}
//END TOGGLETOOLVIEWACTION
-
//BEGIN GUICLIENT
- static const QString actionListName = QStringLiteral("kate_mdi_view_actions");
+static const QString actionListName = QStringLiteral("kate_mdi_view_actions");
- static const QString guiDescription = QStringLiteral(""
+static const QString guiDescription = QStringLiteral(""
"<!DOCTYPE kpartgui><kpartgui name=\"kate_mdi_view_actions\">"
"<MenuBar>"
" <Menu name=\"view\">"
@@ -99,55 +96,54 @@ namespace KateMDI
"</MenuBar>"
"</kpartgui>");
- GUIClient::GUIClient ( MainWindow *mw )
- : QObject ( mw )
- , KXMLGUIClient ( mw )
- , m_mw (mw)
- {
- connect( m_mw->guiFactory(), SIGNAL(clientAdded(KXMLGUIClient*)),
- this, SLOT(clientAdded(KXMLGUIClient*)) );
+GUIClient::GUIClient(MainWindow *mw)
+ : QObject(mw)
+ , KXMLGUIClient(mw)
+ , m_mw(mw)
+{
+ connect(m_mw->guiFactory(), SIGNAL(clientAdded(KXMLGUIClient*)),
+ this, SLOT(clientAdded(KXMLGUIClient*)));
- if ( domDocument().documentElement().isNull() )
- {
- QString completeDescription = guiDescription.arg(actionListName);
+ if (domDocument().documentElement().isNull()) {
+ QString completeDescription = guiDescription.arg(actionListName);
- setXML( completeDescription, false /*merge*/ );
+ setXML(completeDescription, false /*merge*/);
}
m_toolMenu = new KActionMenu(i18n("Tool &Views"), this);
actionCollection()->addAction(QStringLiteral("kate_mdi_toolview_menu"), m_toolMenu);
- m_showSidebarsAction = new KToggleAction( i18n("Show Side&bars"), this );
- actionCollection()->addAction( QStringLiteral("kate_mdi_sidebar_visibility"), m_showSidebarsAction );
- m_showSidebarsAction->setShortcut( Qt::CTRL | Qt::ALT | Qt::SHIFT | Qt::Key_F );
+ m_showSidebarsAction = new KToggleAction(i18n("Show Side&bars"), this);
+ actionCollection()->addAction(QStringLiteral("kate_mdi_sidebar_visibility"), m_showSidebarsAction);
+ m_showSidebarsAction->setShortcut(Qt::CTRL | Qt::ALT | Qt::SHIFT | Qt::Key_F);
- m_showSidebarsAction->setChecked( m_mw->sidebarsVisible() );
- connect( m_showSidebarsAction, SIGNAL(toggled(bool)),
- m_mw, SLOT(setSidebarsVisible(bool)) );
+ m_showSidebarsAction->setChecked(m_mw->sidebarsVisible());
+ connect(m_showSidebarsAction, SIGNAL(toggled(bool)),
+ m_mw, SLOT(setSidebarsVisible(bool)));
- m_toolMenu->addAction( m_showSidebarsAction );
- QAction *sep_act = new QAction( this );
- sep_act->setSeparator( true );
- m_toolMenu->addAction( sep_act );
+ m_toolMenu->addAction(m_showSidebarsAction);
+ QAction *sep_act = new QAction(this);
+ sep_act->setSeparator(true);
+ m_toolMenu->addAction(sep_act);
// read shortcuts
- actionCollection()->setConfigGroup( QStringLiteral("Shortcuts") );
+ actionCollection()->setConfigGroup(QStringLiteral("Shortcuts"));
actionCollection()->readSettings();
actionCollection()->addAssociatedWidget(m_mw);
- foreach (QAction* action, actionCollection()->actions())
- action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
- }
+ foreach(QAction * action, actionCollection()->actions())
+ action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
+}
- GUIClient::~GUIClient()
+GUIClient::~GUIClient()
{}
- void GUIClient::updateSidebarsVisibleAction()
- {
- m_showSidebarsAction->setChecked( m_mw->sidebarsVisible() );
- }
+void GUIClient::updateSidebarsVisibleAction()
+{
+ m_showSidebarsAction->setChecked(m_mw->sidebarsVisible());
+}
- void GUIClient::registerToolView (ToolView *tv)
- {
+void GUIClient::registerToolView(ToolView *tv)
+{
QString aname = QString::fromLatin1("kate_mdi_toolview_") + tv->id;
// try to read the action shortcut
@@ -156,566 +152,568 @@ namespace KateMDI
KSharedConfigPtr cfg = KSharedConfig::openConfig();
QString shortcutString = cfg->group("Shortcuts").readEntry(aname, QString());
- foreach (const QString &shortcut, shortcutString.split(QLatin1String(";"))) {
- shortcuts << QKeySequence::fromString(shortcut);
+ foreach(const QString & shortcut, shortcutString.split(QLatin1String(";"))) {
+ shortcuts << QKeySequence::fromString(shortcut);
}
- KToggleAction *a = new ToggleToolViewAction(i18n("Show %1", tv->text), tv, this );
+ KToggleAction *a = new ToggleToolViewAction(i18n("Show %1", tv->text), tv, this);
a->setShortcuts(shortcuts);
- actionCollection()->addAction( aname, a );
+ actionCollection()->addAction(aname, a);
m_toolViewActions.append(a);
m_toolMenu->addAction(a);
- m_toolToAction.insert (tv, a);
+ m_toolToAction.insert(tv, a);
updateActions();
- }
+}
- void GUIClient::unregisterToolView (ToolView *tv)
- {
+void GUIClient::unregisterToolView(ToolView *tv)
+{
QAction *a = m_toolToAction[tv];
- if (!a)
- return;
+ if (!a) {
+ return;
+ }
- m_toolViewActions.removeAt( m_toolViewActions.indexOf(a) );
+ m_toolViewActions.removeAt(m_toolViewActions.indexOf(a));
delete a;
- m_toolToAction.remove (tv);
+ m_toolToAction.remove(tv);
updateActions();
- }
+}
- void GUIClient::clientAdded( KXMLGUIClient *client )
- {
- if ( client == this )
- updateActions();
- }
+void GUIClient::clientAdded(KXMLGUIClient *client)
+{
+ if (client == this) {
+ updateActions();
+ }
+}
- void GUIClient::updateActions()
- {
- if ( !factory() )
- return;
+void GUIClient::updateActions()
+{
+ if (!factory()) {
+ return;
+ }
- unplugActionList( actionListName );
+ unplugActionList(actionListName);
- QList<QAction*> addList;
+ QList<QAction *> addList;
addList.append(m_toolMenu);
- plugActionList( actionListName, addList );
- }
+ plugActionList(actionListName, addList);
+}
//END GUICLIENT
-
//BEGIN TOOLVIEW
- ToolView::ToolView (MainWindow *mainwin, Sidebar *sidebar, QWidget *parent)
- : QFrame (parent)
- , m_mainWin (mainwin)
- , m_sidebar (sidebar)
- , m_toolVisible (false)
- , persistent (false)
- {
+ToolView::ToolView(MainWindow *mainwin, Sidebar *sidebar, QWidget *parent)
+ : QFrame(parent)
+ , m_mainWin(mainwin)
+ , m_sidebar(sidebar)
+ , m_toolVisible(false)
+ , persistent(false)
+{
// try to fix resize policy
- setSizePolicy (QSizePolicy (QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
+ setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
QVBoxLayout *layout = new QVBoxLayout(this);
layout->setMargin(0);
- }
+}
- ToolView::~ToolView ()
- {
- m_mainWin->toolViewDeleted (this);
- }
+ToolView::~ToolView()
+{
+ m_mainWin->toolViewDeleted(this);
+}
- void ToolView::setToolVisible (bool vis)
- {
- if (m_toolVisible == vis)
- return;
+void ToolView::setToolVisible(bool vis)
+{
+ if (m_toolVisible == vis) {
+ return;
+ }
m_toolVisible = vis;
- emit toolVisibleChanged (m_toolVisible);
- }
+ emit toolVisibleChanged(m_toolVisible);
+}
- bool ToolView::toolVisible () const
- {
+bool ToolView::toolVisible() const
+{
return m_toolVisible;
- }
+}
- void ToolView::childEvent ( QChildEvent *ev )
- {
+void ToolView::childEvent(QChildEvent *ev)
+{
// set the widget to be focus proxy if possible
if ((ev->type() == QEvent::ChildAdded) && qobject_cast<QWidget *>(ev->child())) {
- QWidget *widget = qobject_cast<QWidget *>(ev->child());
- setFocusProxy(widget);
- layout()->addWidget(widget);
+ QWidget *widget = qobject_cast<QWidget *>(ev->child());
+ setFocusProxy(widget);
+ layout()->addWidget(widget);
}
- QFrame::childEvent (ev);
- }
+ QFrame::childEvent(ev);
+}
//END TOOLVIEW
-
//BEGIN SIDEBAR
- Sidebar::Sidebar (KMultiTabBar::KMultiTabBarPosition pos, MainWindow *mainwin, QWidget *parent)
- : KMultiTabBar (pos, parent)
- , m_mainWin (mainwin)
- , m_splitter (0)
- , m_ownSplit (0)
- , m_lastSize (0)
- {
- hide ();
- }
-
- Sidebar::~Sidebar ()
- {}
-
- void Sidebar::setSplitter (QSplitter *sp)
- {
+Sidebar::Sidebar(KMultiTabBar::KMultiTabBarPosition pos, MainWindow *mainwin, QWidget *parent)
+ : KMultiTabBar(pos, parent)
+ , m_mainWin(mainwin)
+ , m_splitter(0)
+ , m_ownSplit(0)
+ , m_lastSize(0)
+{
+ hide();
+}
+
+Sidebar::~Sidebar()
+{}
+
+void Sidebar::setSplitter(QSplitter *sp)
+{
m_splitter = sp;
- m_ownSplit = new QSplitter ((position() == KMultiTabBar::Top || position() == KMultiTabBar::Bottom) ? Qt::Horizontal : Qt::Vertical, m_splitter);
+ m_ownSplit = new QSplitter((position() == KMultiTabBar::Top || position() == KMultiTabBar::Bottom) ? Qt::Horizontal : Qt::Vertical, m_splitter);
m_ownSplit->setOpaqueResize(style()->styleHint(QStyle::SH_Splitter_OpaqueResize, 0, m_ownSplit));
- m_ownSplit->setChildrenCollapsible( false );
- m_ownSplit->hide ();
- }
+ m_ownSplit->setChildrenCollapsible(false);
+ m_ownSplit->hide();
+}
- ToolView *Sidebar::addWidget (const QPixmap &icon, const QString &text, ToolView *widget)
- {
+ToolView *Sidebar::addWidget(const QPixmap &icon, const QString &text, ToolView *widget)
+{
static int id = 0;
- if (widget)
- {
- if (widget->sidebar() == this)
- return widget;
+ if (widget) {
+ if (widget->sidebar() == this) {
+ return widget;
+ }
- widget->sidebar()->removeWidget (widget);
+ widget->sidebar()->removeWidget(widget);
}
int newId = ++id;
- appendTab (icon, newId, text);
-
- if (!widget)
- {
- widget = new ToolView (m_mainWin, this, m_ownSplit);
- widget->hide ();
- widget->icon = icon;
- widget->text = text;
- }
- else
- {
- widget->hide ();
- widget->setParent (m_ownSplit);
- widget->m_sidebar = this;
+ appendTab(icon, newId, text);
+
+ if (!widget) {
+ widget = new ToolView(m_mainWin, this, m_ownSplit);
+ widget->hide();
+ widget->icon = icon;
+ widget->text = text;
+ } else {
+ widget->hide();
+ widget->setParent(m_ownSplit);
+ widget->m_sidebar = this;
}
// save its pos ;)
widget->persistent = false;
- m_idToWidget.insert (newId, widget);
- m_widgetToId.insert (widget, newId);
- m_toolviews.push_back (widget);
+ m_idToWidget.insert(newId, widget);
+ m_widgetToId.insert(widget, newId);
+ m_toolviews.push_back(widget);
// widget => size, for correct size restoration after hide/show
// starts with invalid size
- m_widgetToSize.insert (widget, QSize());
+ m_widgetToSize.insert(widget, QSize());
- show ();
+ show();
connect(tab(newId), SIGNAL(clicked(int)), this, SLOT(tabClicked(int)));
tab(newId)->installEventFilter(this);
return widget;
- }
+}
- bool Sidebar::removeWidget (ToolView *widget)
- {
- if (!m_widgetToId.contains(widget))
- return false;
+bool Sidebar::removeWidget(ToolView *widget)
+{
+ if (!m_widgetToId.contains(widget)) {
+ return false;
+ }
removeTab(m_widgetToId[widget]);
- m_idToWidget.remove (m_widgetToId[widget]);
- m_widgetToId.remove (widget);
- m_widgetToSize.remove (widget);
- m_toolviews.removeAt (m_toolviews.indexOf (widget));
+ m_idToWidget.remove(m_widgetToId[widget]);
+ m_widgetToId.remove(widget);
+ m_widgetToSize.remove(widget);
+ m_toolviews.removeAt(m_toolviews.indexOf(widget));
bool anyVis = false;
- QMapIterator<int, ToolView*> it( m_idToWidget );
- while ( it.hasNext() )
- {
- it.next();
- if (!anyVis)
- anyVis = it.value()->isVisible();
+ QMapIterator<int, ToolView *> it(m_idToWidget);
+ while (it.hasNext()) {
+ it.next();
+ if (!anyVis) {
+ anyVis = it.value()->isVisible();
+ }
}
- if (m_idToWidget.isEmpty())
- {
- m_ownSplit->hide ();
- hide ();
+ if (m_idToWidget.isEmpty()) {
+ m_ownSplit->hide();
+ hide();
+ } else if (!anyVis) {
+ m_ownSplit->hide();
}
- else if (!anyVis)
- m_ownSplit->hide ();
return true;
- }
+}
- bool Sidebar::showWidget (ToolView *widget)
- {
- if (!m_widgetToId.contains(widget))
- return false;
+bool Sidebar::showWidget(ToolView *widget)
+{
+ if (!m_widgetToId.contains(widget)) {
+ return false;
+ }
// hide other non-persistent views
- QMapIterator<int, ToolView*> it( m_idToWidget );
- while ( it.hasNext() )
- {
- it.next();
- if ((it.value() != widget) && !it.value()->persistent)
- {
- it.value()->hide();
- setTab (it.key(), false);
- it.value()->setToolVisible(false);
- }
+ QMapIterator<int, ToolView *> it(m_idToWidget);
+ while (it.hasNext()) {
+ it.next();
+ if ((it.value() != widget) && !it.value()->persistent) {
+ it.value()->hide();
+ setTab(it.key(), false);
+ it.value()->setToolVisible(false);
+ }
}
- setTab (m_widgetToId[widget], true);
+ setTab(m_widgetToId[widget], true);
// set minimum size again to 80,80!
// we changed that on hide!
- widget->setMinimumSize (80, 80);
-
+ widget->setMinimumSize(80, 80);
+
/**
* resize to right size again and show, else artefacts
*/
- if (m_widgetToSize[widget].isValid())
- widget->resize (m_widgetToSize[widget]);
- widget->show ();
+ if (m_widgetToSize[widget].isValid()) {
+ widget->resize(m_widgetToSize[widget]);
+ }
+ widget->show();
/**
* resize to right size again and show, else artefacts
* same as for widget, both needed
*/
- if (m_preHideSize.isValid())
- m_ownSplit->resize (m_preHideSize);
- m_ownSplit->show ();
+ if (m_preHideSize.isValid()) {
+ m_ownSplit->resize(m_preHideSize);
+ }
+ m_ownSplit->show();
/**
* we are visible again!
*/
- widget->setToolVisible (true);
+ widget->setToolVisible(true);
return true;
- }
+}
- bool Sidebar::hideWidget (ToolView *widget)
- {
- if (!m_widgetToId.contains(widget))
- return false;
+bool Sidebar::hideWidget(ToolView *widget)
+{
+ if (!m_widgetToId.contains(widget)) {
+ return false;
+ }
bool anyVis = false;
- updateLastSize ();
-
- QMapIterator<int, ToolView*> it( m_idToWidget );
- while ( it.hasNext() )
- {
- it.next();
- if (it.value() == widget)
- {
- // remember size and hide
- if (widget->isVisible())
- m_widgetToSize[widget] = widget->size();
- continue;
- }
-
- if (!anyVis)
- anyVis = it.value()->isVisible();
+ updateLastSize();
+
+ QMapIterator<int, ToolView *> it(m_idToWidget);
+ while (it.hasNext()) {
+ it.next();
+ if (it.value() == widget) {
+ // remember size and hide
+ if (widget->isVisible()) {
+ m_widgetToSize[widget] = widget->size();
+ }
+ continue;
+ }
+
+ if (!anyVis) {
+ anyVis = it.value()->isVisible();
+ }
}
// lower tab
- setTab (m_widgetToId[widget], false);
+ setTab(m_widgetToId[widget], false);
if (!anyVis) {
- if (m_ownSplit->isVisible())
- m_preHideSize = m_ownSplit->size ();
- m_ownSplit->hide ();
+ if (m_ownSplit->isVisible()) {
+ m_preHideSize = m_ownSplit->size();
+ }
+ m_ownSplit->hide();
}
-
+
// set minimum size == size, this avoid artifical resizes on show
// there we will reset this again to 80,80!
- widget->setMinimumSize (widget->size());
+ widget->setMinimumSize(widget->size());
- widget->hide ();
+ widget->hide();
- widget->setToolVisible (false);
+ widget->setToolVisible(false);
return true;
- }
+}
- void Sidebar::tabClicked(int i)
- {
+void Sidebar::tabClicked(int i)
+{
ToolView *w = m_idToWidget[i];
- if (!w)
- return;
-
- if (isTabRaised(i))
- {
- showWidget (w);
- w->setFocus ();
+ if (!w) {
+ return;
}
- else
- {
- hideWidget (w);
+
+ if (isTabRaised(i)) {
+ showWidget(w);
+ w->setFocus();
+ } else {
+ hideWidget(w);
}
- }
+}
- bool Sidebar::eventFilter(QObject *obj, QEvent *ev)
- {
- if (ev->type() == QEvent::ContextMenu)
- {
- QContextMenuEvent *e = (QContextMenuEvent *) ev;
- KMultiTabBarTab *bt = dynamic_cast<KMultiTabBarTab*>(obj);
- if (bt)
- {
- //qCDebug(LOG_KATE) << "Request for popup";
+bool Sidebar::eventFilter(QObject *obj, QEvent *ev)
+{
+ if (ev->type() == QEvent::ContextMenu) {
+ QContextMenuEvent *e = (QContextMenuEvent *) ev;
+ KMultiTabBarTab *bt = dynamic_cast<KMultiTabBarTab *>(obj);
+ if (bt) {
+ //qCDebug(LOG_KATE) << "Request for popup";
- m_popupButton = bt->id();
+ m_popupButton = bt->id();
- ToolView *w = m_idToWidget[m_popupButton];
+ ToolView *w = m_idToWidget[m_popupButton];
- if (w)
- {
- QMenu *menu = new QMenu(this);
+ if (w) {
+ QMenu *menu = new QMenu(this);
- if (!w->plugin.isNull()) {
- KTextEditor::ConfigPageInterface* pcpi=dynamic_cast<KTextEditor::ConfigPageInterface*>(w->plugin.data());
- if (pcpi) {
- if (pcpi->configPages()>0)
- menu->addAction(i18n("Configure ..."))->setData(20);
- }
- }
+ if (!w->plugin.isNull()) {
+ KTextEditor::ConfigPageInterface *pcpi = dynamic_cast<KTextEditor::ConfigPageInterface *>(w->plugin.data());
+ if (pcpi) {
+ if (pcpi->configPages() > 0) {
+ menu->addAction(i18n("Configure ..."))->setData(20);
+ }
+ }
+ }
- menu->addSection(SmallIcon(QStringLiteral("view_remove")), i18n("Behavior"));
+ menu->addSection(SmallIcon(QStringLiteral("view_remove")), i18n("Behavior"));
- menu->addAction(w->persistent ? QIcon::fromTheme(QStringLiteral("view-restore")) : QIcon::fromTheme(QStringLiteral("view-fullscreen")),
- w->persistent ? i18n("Make Non-Persistent") : i18n("Make Persistent") ) -> setData(10);
+ menu->addAction(w->persistent ? QIcon::fromTheme(QStringLiteral("view-restore")) : QIcon::fromTheme(QStringLiteral("view-fullscreen")),
+ w->persistent ? i18n("Make Non-Persistent") : i18n("Make Persistent")) -> setData(10);
- menu->addSection(SmallIcon(QStringLiteral("move")), i18n("Move To"));
+ menu->addSection(SmallIcon(QStringLiteral("move")), i18n("Move To"));
- if (position() != 0)
- menu->addAction(QIcon::fromTheme(QStringLiteral("go-previous")), i18n("Left Sidebar"))->setData(0);
+ if (position() != 0) {
+ menu->addAction(QIcon::fromTheme(QStringLiteral("go-previous")), i18n("Left Sidebar"))->setData(0);
+ }
- if (position() != 1)
- menu->addAction(QIcon::fromTheme(QStringLiteral("go-next")), i18n("Right Sidebar"))->setData(1);
+ if (position() != 1) {
+ menu->addAction(QIcon::fromTheme(QStringLiteral("go-next")), i18n("Right Sidebar"))->setData(1);
+ }
- if (position() != 2)
- menu->addAction(QIcon::fromTheme(QStringLiteral("go-up")), i18n("Top Sidebar"))->setData(2);
+ if (position() != 2) {
+ menu->addAction(QIcon::fromTheme(QStringLiteral("go-up")), i18n("Top Sidebar"))->setData(2);
+ }
- if (position() != 3)
- menu->addAction(QIcon::fromTheme(QStringLiteral("go-down")), i18n("Bottom Sidebar"))->setData(3);
+ if (position() != 3) {
+ menu->addAction(QIcon::fromTheme(QStringLiteral("go-down")), i18n("Bottom Sidebar"))->setData(3);
+ }
- connect(menu, SIGNAL(triggered(QAction*)),
- this, SLOT(buttonPopupActivate(QAction*)));
+ connect(menu, SIGNAL(triggered(QAction*)),
+ this, SLOT(buttonPopupActivate(QAction*)));
- menu->exec(e->globalPos());
- delete menu;
+ menu->exec(e->globalPos());
+ delete menu;
- return true;
+ return true;
+ }
}
- }
}
return false;
- }
+}
- void Sidebar::setVisible(bool visible)
- {
+void Sidebar::setVisible(bool visible)
+{
// visible==true means show-request
- if( visible && ( m_idToWidget.isEmpty() || !m_mainWin->sidebarsVisible() ) )
- return;
+ if (visible && (m_idToWidget.isEmpty() || !m_mainWin->sidebarsVisible())) {
+ return;
+ }
KMultiTabBar::setVisible(visible);
- }
+}
- void Sidebar::buttonPopupActivate (QAction *a)
- {
+void Sidebar::buttonPopupActivate(QAction *a)
+{
int id = a->data().toInt();
ToolView *w = m_idToWidget[m_popupButton];
- if (!w)
- return;
+ if (!w) {
+ return;
+ }
// move ids
- if (id < 4)
- {
- // move + show ;)
- m_mainWin->moveToolView (w, (KMultiTabBar::KMultiTabBarPosition) id);
- m_mainWin->showToolView (w);
+ if (id < 4) {
+ // move + show ;)
+ m_mainWin->moveToolView(w, (KMultiTabBar::KMultiTabBarPosition) id);
+ m_mainWin->showToolView(w);
}
// toggle persistent
- if (id == 10)
- w->persistent = !w->persistent;
+ if (id == 10) {
+ w->persistent = !w->persistent;
+ }
// configure actionCollection
- if (id==20) {
- if (!w->plugin.isNull()) {
- KTextEditor::ConfigPageInterface* pcpi=dynamic_cast<KTextEditor::ConfigPageInterface*>(w->plugin.data());
- if (pcpi) {
- if (pcpi->configPages()>0)
- emit sigShowPluginConfigPage(pcpi,0);
- }
+ if (id == 20) {
+ if (!w->plugin.isNull()) {
+ KTextEditor::ConfigPageInterface *pcpi = dynamic_cast<KTextEditor::ConfigPageInterface *>(w->plugin.data());
+ if (pcpi) {
+ if (pcpi->configPages() > 0) {
+ emit sigShowPluginConfigPage(pcpi, 0);
+ }
+ }
}
}
- }
+}
- void Sidebar::updateLastSize ()
- {
- QList<int> s = m_splitter->sizes ();
+void Sidebar::updateLastSize()
+{
+ QList<int> s = m_splitter->sizes();
int i = 0;
- if ((position() == KMultiTabBar::Right || position() == KMultiTabBar::Bottom))
- i = 2;
+ if ((position() == KMultiTabBar::Right || position() == KMultiTabBar::Bottom)) {
+ i = 2;
+ }
// little threshold
- if (s[i] > 2)
- m_lastSize = s[i];
- }
-
- class TmpToolViewSorter
- {
- public:
- ToolView *tv;
- unsigned int pos;
- };
-
- void Sidebar::restoreSession (KConfigGroup& config)
- {
+ if (s[i] > 2) {
+ m_lastSize = s[i];
+ }
+}
+
+class TmpToolViewSorter
+{
+public:
+ ToolView *tv;
+ unsigned int pos;
+};
+
+void Sidebar::restoreSession(KConfigGroup &config)
+{
// get the last correct placed toolview
int firstWrong = 0;
- for ( ; firstWrong < m_toolviews.size(); ++firstWrong )
- {
- ToolView *tv = m_toolviews[firstWrong];
+ for (; firstWrong < m_toolviews.size(); ++firstWrong) {
+ ToolView *tv = m_toolviews[firstWrong];
- int pos = config.readEntry (QString::fromLatin1("Kate-MDI-ToolView-%1-Sidebar-Position").arg(tv->id), firstWrong);
+ int pos = config.readEntry(QString::fromLatin1("Kate-MDI-ToolView-%1-Sidebar-Position").arg(tv->id), firstWrong);
- if (pos != firstWrong)
- break;
+ if (pos != firstWrong) {
+ break;
+ }
}
// we need to reshuffle, ahhh :(
- if (firstWrong < m_toolviews.size())
- {
- // first: collect the items to reshuffle
- QList<TmpToolViewSorter> toSort;
- for (int i = firstWrong; i < m_toolviews.size(); ++i)
- {
- TmpToolViewSorter s;
- s.tv = m_toolviews[i];
- s.pos = config.readEntry (QString::fromLatin1("Kate-MDI-ToolView-%1-Sidebar-Position").arg(m_toolviews[i]->id), i);
- toSort.push_back (s);
- }
-
- // now: sort the stuff we need to reshuffle
- for (int m = 0; m < toSort.size(); ++m)
- for (int n = m + 1; n < toSort.size(); ++n)
- if (toSort[n].pos < toSort[m].pos)
- {
- TmpToolViewSorter tmp = toSort[n];
- toSort[n] = toSort[m];
- toSort[m] = tmp;
- }
-
- // then: remove this items from the button bar
- // do this backwards, to minimize the relayout efforts
- for (int i = m_toolviews.size() - 1; i >= (int)firstWrong; --i)
- {
- removeTab (m_widgetToId[m_toolviews[i]]);
- }
-
- // insert the reshuffled things in order :)
- for (int i = 0; i < toSort.size(); ++i)
- {
- ToolView *tv = toSort[i].tv;
-
- m_toolviews[firstWrong+i] = tv;
-
- // readd the button
- int newId = m_widgetToId[tv];
- appendTab (tv->icon, newId, tv->text);
- connect(tab(newId), SIGNAL(clicked(int)), this, SLOT(tabClicked(int)));
- tab(newId)->installEventFilter(this);
-
- // reshuffle in splitter: move to last
- m_ownSplit->addWidget(tv);
- }
+ if (firstWrong < m_toolviews.size()) {
+ // first: collect the items to reshuffle
+ QList<TmpToolViewSorter> toSort;
+ for (int i = firstWrong; i < m_toolviews.size(); ++i) {
+ TmpToolViewSorter s;
+ s.tv = m_toolviews[i];
+ s.pos = config.readEntry(QString::fromLatin1("Kate-MDI-ToolView-%1-Sidebar-Position").arg(m_toolviews[i]->id), i);
+ toSort.push_back(s);
+ }
+
+ // now: sort the stuff we need to reshuffle
+ for (int m = 0; m < toSort.size(); ++m)
+ for (int n = m + 1; n < toSort.size(); ++n)
+ if (toSort[n].pos < toSort[m].pos) {
+ TmpToolViewSorter tmp = toSort[n];
+ toSort[n] = toSort[m];
+ toSort[m] = tmp;
+ }
+
+ // then: remove this items from the button bar
+ // do this backwards, to minimize the relayout efforts
+ for (int i = m_toolviews.size() - 1; i >= (int)firstWrong; --i) {
+ removeTab(m_widgetToId[m_toolviews[i]]);
+ }
+
+ // insert the reshuffled things in order :)
+ for (int i = 0; i < toSort.size(); ++i) {
+ ToolView *tv = toSort[i].tv;
+
+ m_toolviews[firstWrong + i] = tv;
+
+ // readd the button
+ int newId = m_widgetToId[tv];
+ appendTab(tv->icon, newId, tv->text);
+ connect(tab(newId), SIGNAL(clicked(int)), this, SLOT(tabClicked(int)));
+ tab(newId)->installEventFilter(this);
+
+ // reshuffle in splitter: move to last
+ m_ownSplit->addWidget(tv);
+ }
}
// update last size if needed
- updateLastSize ();
+ updateLastSize();
// restore the own splitter sizes
- QList<int> s = config.readEntry (QString::fromLatin1("Kate-MDI-Sidebar-%1-Splitter").arg(position()), QList<int>());
- m_ownSplit->setSizes (s);
+ QList<int> s = config.readEntry(QString::fromLatin1("Kate-MDI-Sidebar-%1-Splitter").arg(position()), QList<int>());
+ m_ownSplit->setSizes(s);
// show only correct toolviews, remember persistent values ;)
bool anyVis = false;
- for ( int i = 0; i < m_toolviews.size(); ++i )
- {
- ToolView *tv = m_toolviews[i];
+ for (int i = 0; i < m_toolviews.size(); ++i) {
+ ToolView *tv = m_toolviews[i];
- tv->persistent = config.readEntry (QString::fromLatin1("Kate-MDI-ToolView-%1-Persistent").arg(tv->id), false);
- tv->setToolVisible (config.readEntry (QString::fromLatin1("Kate-MDI-ToolView-%1-Visible").arg(tv->id), false));
+ tv->persistent = config.readEntry(QString::fromLatin1("Kate-MDI-ToolView-%1-Persistent").arg(tv->id), false);
+ tv->setToolVisible(config.readEntry(QString::fromLatin1("Kate-MDI-ToolView-%1-Visible").arg(tv->id), false));
- if (!anyVis)
- anyVis = tv->toolVisible();
+ if (!anyVis) {
+ anyVis = tv->toolVisible();
+ }
- setTab (m_widgetToId[tv], tv->toolVisible());
+ setTab(m_widgetToId[tv], tv->toolVisible());
- if (tv->toolVisible())
- tv->show();
- else
- tv->hide ();
+ if (tv->toolVisible()) {
+ tv->show();
+ } else {
+ tv->hide();
+ }
}
- if (anyVis)
- m_ownSplit->show();
- else
- m_ownSplit->hide();
- }
+ if (anyVis) {
+ m_ownSplit->show();
+ } else {
+ m_ownSplit->hide();
+ }
+}
- void Sidebar::saveSession (KConfigGroup& config)
- {
+void Sidebar::saveSession(KConfigGroup &config)
+{
// store the own splitter sizes
QList<int> s = m_ownSplit->sizes();
- config.writeEntry (QString::fromLatin1("Kate-MDI-Sidebar-%1-Splitter").arg(position()), s);
+ config.writeEntry(QString::fromLatin1("Kate-MDI-Sidebar-%1-Splitter").arg(position()), s);
// store the data about all toolviews in this sidebar ;)
- for ( int i = 0; i < m_toolviews.size(); ++i )
- {
- ToolView *tv = m_toolviews[i];
-
- config.writeEntry (QString::fromLatin1("Kate-MDI-ToolView-%1-Position").arg(tv->id), int(tv->sidebar()->position()));
- config.writeEntry (QString::fromLatin1("Kate-MDI-ToolView-%1-Sidebar-Position").arg(tv->id), i);
- config.writeEntry (QString::fromLatin1("Kate-MDI-ToolView-%1-Visible").arg(tv->id), tv->toolVisible());
- config.writeEntry (QString::fromLatin1("Kate-MDI-ToolView-%1-Persistent").arg(tv->id), tv->persistent);
+ for (int i = 0; i < m_toolviews.size(); ++i) {
+ ToolView *tv = m_toolviews[i];
+
+ config.writeEntry(QString::fromLatin1("Kate-MDI-ToolView-%1-Position").arg(tv->id), int(tv->sidebar()->position()));
+ config.writeEntry(QString::fromLatin1("Kate-MDI-ToolView-%1-Sidebar-Position").arg(tv->id), i);
+ config.writeEntry(QString::fromLatin1("Kate-MDI-ToolView-%1-Visible").arg(tv->id), tv->toolVisible());
+ config.writeEntry(QString::fromLatin1("Kate-MDI-ToolView-%1-Persistent").arg(tv->id), tv->persistent);
}
- }
+}
//END SIDEBAR
-
//BEGIN MAIN WINDOW
- MainWindow::MainWindow (QWidget* parentWidget)
- : KParts::MainWindow(parentWidget, Qt::Window)
- , m_sidebarsVisible(true)
- , m_restoreConfig (0)
- , m_guiClient (new GUIClient (this))
- {
+MainWindow::MainWindow(QWidget *parentWidget)
+ : KParts::MainWindow(parentWidget, Qt::Window)
+ , m_sidebarsVisible(true)
+ , m_restoreConfig(0)
+ , m_guiClient(new GUIClient(this))
+{
// init the internal widgets
QFrame *hb = new QFrame(this);
QHBoxLayout *hlayout = new QHBoxLayout(hb);
@@ -724,124 +722,128 @@ namespace KateMDI
setCentralWidget(hb);
- m_sidebars[KMultiTabBar::Left] = new Sidebar (KMultiTabBar::Left, this, hb);
+ m_sidebars[KMultiTabBar::Left] = new Sidebar(KMultiTabBar::Left, this, hb);
hlayout->addWidget(m_sidebars[KMultiTabBar::Left]);
- m_hSplitter = new QSplitter (Qt::Horizontal, hb);
+ m_hSplitter = new QSplitter(Qt::Horizontal, hb);
m_hSplitter->setOpaqueResize(style()->styleHint(QStyle::SH_Splitter_OpaqueResize, 0, m_hSplitter));
hlayout->addWidget(m_hSplitter);
- m_sidebars[KMultiTabBar::Left]->setSplitter (m_hSplitter);
+ m_sidebars[KMultiTabBar::Left]->setSplitter(m_hSplitter);
QFrame *vb = new QFrame(m_hSplitter);
QVBoxLayout *vlayout = new QVBoxLayout(vb);
vlayout->setMargin(0);
vlayout->setSpacing(0);
- m_hSplitter->setCollapsible( m_hSplitter->indexOf(vb), false);
- m_hSplitter->setStretchFactor( m_hSplitter->indexOf(vb), 1);
+ m_hSplitter->setCollapsible(m_hSplitter->indexOf(vb), false);
+ m_hSplitter->setStretchFactor(m_hSplitter->indexOf(vb), 1);
- m_sidebars[KMultiTabBar::Top] = new Sidebar (KMultiTabBar::Top, this, vb);
+ m_sidebars[KMultiTabBar::Top] = new Sidebar(KMultiTabBar::Top, this, vb);
vlayout->addWidget(m_sidebars[KMultiTabBar::Top]);
- m_vSplitter = new QSplitter (Qt::Vertical, vb);
+ m_vSplitter = new QSplitter(Qt::Vertical, vb);
vlayout->addWidget(m_vSplitter);
m_vSplitter->setOpaqueResize(style()->styleHint(QStyle::SH_Splitter_OpaqueResize, 0, m_vSplitter));
- m_sidebars[KMultiTabBar::Top]->setSplitter (m_vSplitter);
+ m_sidebars[KMultiTabBar::Top]->setSplitter(m_vSplitter);
m_centralWidget = new QWidget(m_vSplitter);
m_centralWidget->setLayout(new QVBoxLayout);
m_centralWidget->layout()->setSpacing(0);
m_centralWidget->layout()->setMargin(0);
- m_vSplitter->setCollapsible( m_vSplitter->indexOf(m_centralWidget), false);
- m_vSplitter->setStretchFactor( m_vSplitter->indexOf(m_centralWidget), 1);
+ m_vSplitter->setCollapsible(m_vSplitter->indexOf(m_centralWidget), false);
+ m_vSplitter->setStretchFactor(m_vSplitter->indexOf(m_centralWidget), 1);
- m_sidebars[KMultiTabBar::Bottom] = new Sidebar (KMultiTabBar::Bottom, this, vb);
+ m_sidebars[KMultiTabBar::Bottom] = new Sidebar(KMultiTabBar::Bottom, this, vb);
vlayout->addWidget(m_sidebars[KMultiTabBar::Bottom]);
- m_sidebars[KMultiTabBar::Bottom]->setSplitter (m_vSplitter);
+ m_sidebars[KMultiTabBar::Bottom]->setSplitter(m_vSplitter);
- m_sidebars[KMultiTabBar::Right] = new Sidebar (KMultiTabBar::Right, this, hb);
+ m_sidebars[KMultiTabBar::Right] = new Sidebar(KMultiTabBar::Right, this, hb);
hlayout->addWidget(m_sidebars[KMultiTabBar::Right]);
- m_sidebars[KMultiTabBar::Right]->setSplitter (m_hSplitter);
-
- for (int i=0;i<4;i++)
- connect(m_sidebars[i],SIGNAL(sigShowPluginConfigPage(KTextEditor::ConfigPageInterface *,uint)),this,SIGNAL(sigShowPluginConfigPage(KTextEditor::ConfigPageInterface *,uint)));
+ m_sidebars[KMultiTabBar::Right]->setSplitter(m_hSplitter);
+ for (int i = 0; i < 4; i++) {
+ connect(m_sidebars[i], SIGNAL(sigShowPluginConfigPage(KTextEditor::ConfigPageInterface*,uint)), this, SIGNAL(sigShowPluginConfigPage(KTextEditor::ConfigPageInterface*,uint)));
+ }
- }
+}
- MainWindow::~MainWindow ()
- {
+MainWindow::~MainWindow()
+{
// cu toolviews
- while (!m_toolviews.isEmpty())
- delete m_toolviews[0];
+ while (!m_toolviews.isEmpty()) {
+ delete m_toolviews[0];
+ }
// seems like we really should delete this by hand ;)
delete m_centralWidget;
- for (unsigned int i = 0; i < 4; ++i)
- delete m_sidebars[i];
- }
+ for (unsigned int i = 0; i < 4; ++i) {
+ delete m_sidebars[i];
+ }
+}
- QWidget *MainWindow::centralWidget () const
- {
+QWidget *MainWindow::centralWidget() const
+{
return m_centralWidget;
- }
+}
- ToolView *MainWindow::createToolView (KTextEditor::Plugin* plugin, const QString &identifier, KMultiTabBar::KMultiTabBarPosition pos, const QPixmap &icon, const QString &text)
- {
- if (m_idToWidget[identifier])
- return 0;
+ToolView *MainWindow::createToolView(KTextEditor::Plugin *plugin, const QString &identifier, KMultiTabBar::KMultiTabBarPosition pos, const QPixmap &icon, const QString &text)
+{
+ if (m_idToWidget[identifier]) {
+ return 0;
+ }
// try the restore config to figure out real pos
- if (m_restoreConfig && m_restoreConfig->hasGroup (m_restoreGroup))
- {
- KConfigGroup cg(m_restoreConfig, m_restoreGroup);
- pos = (KMultiTabBar::KMultiTabBarPosition) cg.readEntry (QString::fromLatin1("Kate-MDI-ToolView-%1-Position").arg(identifier), int(pos));
+ if (m_restoreConfig && m_restoreConfig->hasGroup(m_restoreGroup)) {
+ KConfigGroup cg(m_restoreConfig, m_restoreGroup);
+ pos = (KMultiTabBar::KMultiTabBarPosition) cg.readEntry(QString::fromLatin1("Kate-MDI-ToolView-%1-Position").arg(identifier), int(pos));
}
- ToolView *v = m_sidebars[pos]->addWidget (icon, text, 0);
+ ToolView *v = m_sidebars[pos]->addWidget(icon, text, 0);
v->id = identifier;
v->plugin = plugin;
v->setMinimumSize(80, 80);
- m_idToWidget.insert (identifier, v);
- m_toolviews.push_back (v);
+ m_idToWidget.insert(identifier, v);
+ m_toolviews.push_back(v);
// register for menu stuff
- m_guiClient->registerToolView (v);
+ m_guiClient->registerToolView(v);
return v;
- }
+}
- ToolView *MainWindow::toolView (const QString &identifier) const
- {
+ToolView *MainWindow::toolView(const QString &identifier) const
+{
return m_idToWidget[identifier];
- }
+}
- void MainWindow::toolViewDeleted (ToolView *widget)
- {
- if (!widget)
- return;
+void MainWindow::toolViewDeleted(ToolView *widget)
+{
+ if (!widget) {
+ return;
+ }
- if (widget->mainWindow() != this)
- return;
+ if (widget->mainWindow() != this) {
+ return;
+ }
// unregister from menu stuff
- m_guiClient->unregisterToolView (widget);
+ m_guiClient->unregisterToolView(widget);
- widget->sidebar()->removeWidget (widget);
+ widget->sidebar()->removeWidget(widget);
- m_idToWidget.remove (widget->id);
- m_toolviews.removeAt ( m_toolviews.indexOf(widget) );
+ m_idToWidget.remove(widget->id);
+ m_toolviews.removeAt(m_toolviews.indexOf(widget));
- }
+}
- void MainWindow::setSidebarsVisible( bool visible )
- {
- bool old_visible=m_sidebarsVisible;
+void MainWindow::setSidebarsVisible(bool visible)
+{
+ bool old_visible = m_sidebarsVisible;
m_sidebarsVisible = visible;
m_sidebars[0]->setVisible(visible);
@@ -852,195 +854,200 @@ namespace KateMDI
m_guiClient->updateSidebarsVisibleAction();
// show information message box, if the users hides the sidebars
- if( old_visible && (!m_sidebarsVisible) )
- {
- KMessageBox::information( this,
- i18n("<qt>You are about to hide the sidebars. With "
- "hidden sidebars it is not possible to directly "
- "access the tool views with the mouse anymore, "
- "so if you need to access the sidebars again "
- "invoke <b>View &gt; Tool Views &gt; Show Sidebars</b> "
- "in the menu. It is still possible to show/hide "
- "the tool views with the assigned shortcuts.</qt>"),
- QString(), QStringLiteral("Kate hide sidebars notification message") );
+ if (old_visible && (!m_sidebarsVisible)) {
+ KMessageBox::information(this,
+ i18n("<qt>You are about to hide the sidebars. With "
+ "hidden sidebars it is not possible to directly "
+ "access the tool views with the mouse anymore, "
+ "so if you need to access the sidebars again "
+ "invoke <b>View &gt; Tool Views &gt; Show Sidebars</b> "
+ "in the menu. It is still possible to show/hide "
+ "the tool views with the assigned shortcuts.</qt>"),
+ QString(), QStringLiteral("Kate hide sidebars notification message"));
}
- }
+}
- bool MainWindow::sidebarsVisible() const
- {
+bool MainWindow::sidebarsVisible() const
+{
return m_sidebarsVisible;
- }
+}
- void MainWindow::setToolViewStyle (KMultiTabBar::KMultiTabBarStyle style)
- {
+void MainWindow::setToolViewStyle(KMultiTabBar::KMultiTabBarStyle style)
+{
m_sidebars[0]->setStyle(style);
m_sidebars[1]->setStyle(style);
m_sidebars[2]->setStyle(style);
m_sidebars[3]->setStyle(style);
- }
+}
- KMultiTabBar::KMultiTabBarStyle MainWindow::toolViewStyle () const
- {
+KMultiTabBar::KMultiTabBarStyle MainWindow::toolViewStyle() const
+{
// all sidebars have the same style, so just take Top
return m_sidebars[KMultiTabBar::Top]->tabStyle();
- }
+}
- bool MainWindow::moveToolView (ToolView *widget, KMultiTabBar::KMultiTabBarPosition pos)
- {
- if (!widget || widget->mainWindow() != this)
- return false;
+bool MainWindow::moveToolView(ToolView *widget, KMultiTabBar::KMultiTabBarPosition pos)
+{
+ if (!widget || widget->mainWindow() != this) {
+ return false;
+ }
// try the restore config to figure out real pos
- if (m_restoreConfig && m_restoreConfig->hasGroup (m_restoreGroup))
- {
- KConfigGroup cg(m_restoreConfig, m_restoreGroup);
- pos = (KMultiTabBar::KMultiTabBarPosition) cg.readEntry (QString::fromLatin1("Kate-MDI-ToolView-%1-Position").arg(widget->id), int(pos));
+ if (m_restoreConfig && m_restoreConfig->hasGroup(m_restoreGroup)) {
+ KConfigGroup cg(m_restoreConfig, m_restoreGroup);
+ pos = (KMultiTabBar::KMultiTabBarPosition) cg.readEntry(QString::fromLatin1("Kate-MDI-ToolView-%1-Position").arg(widget->id), int(pos));
}
- m_sidebars[pos]->addWidget (widget->icon, widget->text, widget);
+ m_sidebars[pos]->addWidget(widget->icon, widget->text, widget);
return true;
- }
+}
- bool MainWindow::showToolView (ToolView *widget)
- {
- if (!widget || widget->mainWindow() != this)
- return false;
+bool MainWindow::showToolView(ToolView *widget)
+{
+ if (!widget || widget->mainWindow() != this) {
+ return false;
+ }
// skip this if happens during restoring, or we will just see flicker
- if (m_restoreConfig && m_restoreConfig->hasGroup (m_restoreGroup))
- return true;
+ if (m_restoreConfig && m_restoreConfig->hasGroup(m_restoreGroup)) {
+ return true;
+ }
- return widget->sidebar()->showWidget (widget);
- }
+ return widget->sidebar()->showWidget(widget);
+}
- bool MainWindow::hideToolView (ToolView *widget)
- {
- if (!widget || widget->mainWindow() != this)
- return false;
+bool MainWindow::hideToolView(ToolView *widget)
+{
+ if (!widget || widget->mainWindow() != this) {
+ return false;
+ }
// skip this if happens during restoring, or we will just see flicker
- if (m_restoreConfig && m_restoreConfig->hasGroup (m_restoreGroup))
- return true;
+ if (m_restoreConfig && m_restoreConfig->hasGroup(m_restoreGroup)) {
+ return true;
+ }
- const bool ret = widget->sidebar()->hideWidget (widget);
+ const bool ret = widget->sidebar()->hideWidget(widget);
m_centralWidget->setFocus();
return ret;
- }
+}
- void MainWindow::startRestore (KConfigBase *config, const QString &group)
- {
+void MainWindow::startRestore(KConfigBase *config, const QString &group)
+{
// first save this stuff
m_restoreConfig = config;
m_restoreGroup = group;
- if (!m_restoreConfig || !m_restoreConfig->hasGroup (m_restoreGroup))
- {
- // if no config around, set already now sane default sizes
- // otherwise, set later in ::finishRestore(), since it does not work
- // if set already now (see bug #164438)
- QList<int> hs = (QList<int>() << 200 << 100 << 200);
- QList<int> vs = (QList<int>() << 150 << 100 << 200);
-
- m_sidebars[0]->setLastSize (hs[0]);
- m_sidebars[1]->setLastSize (hs[2]);
- m_sidebars[2]->setLastSize (vs[0]);
- m_sidebars[3]->setLastSize (vs[2]);
-
- m_hSplitter->setSizes(hs);
- m_vSplitter->setSizes(vs);
- return;
+ if (!m_restoreConfig || !m_restoreConfig->hasGroup(m_restoreGroup)) {
+ // if no config around, set already now sane default sizes
+ // otherwise, set later in ::finishRestore(), since it does not work
+ // if set already now (see bug #164438)
+ QList<int> hs = (QList<int>() << 200 << 100 << 200);
+ QList<int> vs = (QList<int>() << 150 << 100 << 200);
+
+ m_sidebars[0]->setLastSize(hs[0]);
+ m_sidebars[1]->setLastSize(hs[2]);
+ m_sidebars[2]->setLastSize(vs[0]);
+ m_sidebars[3]->setLastSize(vs[2]);
+
+ m_hSplitter->setSizes(hs);
+ m_vSplitter->setSizes(vs);
+ return;
}
// apply size once, to get sizes ready ;)
KConfigGroup cg(m_restoreConfig, m_restoreGroup);
KWindowConfig::restoreWindowSize(windowHandle(), cg);
- setToolViewStyle( (KMultiTabBar::KMultiTabBarStyle)cg.readEntry ("Kate-MDI-Sidebar-Style", (int)toolViewStyle()) );
+ setToolViewStyle((KMultiTabBar::KMultiTabBarStyle)cg.readEntry("Kate-MDI-Sidebar-Style", (int)toolViewStyle()));
// after reading m_sidebarsVisible, update the GUI toggle action
- m_sidebarsVisible = cg.readEntry ("Kate-MDI-Sidebar-Visible", true );
+ m_sidebarsVisible = cg.readEntry("Kate-MDI-Sidebar-Visible", true);
m_guiClient->updateSidebarsVisibleAction();
- }
-
- void MainWindow::finishRestore ()
- {
- if (!m_restoreConfig)
- return;
-
- if (m_restoreConfig->hasGroup (m_restoreGroup))
- {
- // apply all settings, like toolbar pos and more ;)
- KConfigGroup cg(m_restoreConfig, m_restoreGroup);
- applyMainWindowSettings(cg);
-
- // reshuffle toolviews only if needed
- for ( int i = 0; i < m_toolviews.size(); ++i )
- {
- KMultiTabBar::KMultiTabBarPosition newPos = (KMultiTabBar::KMultiTabBarPosition) cg.readEntry (QString::fromLatin1("Kate-MDI-ToolView-%1-Position").arg(m_toolviews[i]->id), int(m_toolviews[i]->sidebar()->position()));
-
- if (m_toolviews[i]->sidebar()->position() != newPos)
- {
- moveToolView (m_toolviews[i], newPos);
+}
+
+void MainWindow::finishRestore()
+{
+ if (!m_restoreConfig) {
+ return;
+ }
+
+ if (m_restoreConfig->hasGroup(m_restoreGroup)) {
+ // apply all settings, like toolbar pos and more ;)
+ KConfigGroup cg(m_restoreConfig, m_restoreGroup);
+ applyMainWindowSettings(cg);
+
+ // reshuffle toolviews only if needed
+ for (int i = 0; i < m_toolviews.size(); ++i) {
+ KMultiTabBar::KMultiTabBarPosition newPos = (KMultiTabBar::KMultiTabBarPosition) cg.readEntry(QString::fromLatin1("Kate-MDI-ToolView-%1-Position").arg(m_toolviews[i]->id), int(m_toolviews[i]->sidebar()->position()));
+
+ if (m_toolviews[i]->sidebar()->position() != newPos) {
+ moveToolView(m_toolviews[i], newPos);
+ }
}
- }
- // restore the sidebars
- for (unsigned int i = 0; i < 4; ++i)
- m_sidebars[i]->restoreSession (cg);
+ // restore the sidebars
+ for (unsigned int i = 0; i < 4; ++i) {
+ m_sidebars[i]->restoreSession(cg);
+ }
- // restore splitter sizes
- QList<int> hs = (QList<int>() << 200 << 100 << 200);
- QList<int> vs = (QList<int>() << 150 << 100 << 200);
+ // restore splitter sizes
+ QList<int> hs = (QList<int>() << 200 << 100 << 200);
+ QList<int> vs = (QList<int>() << 150 << 100 << 200);
- // get main splitter sizes ;)
- hs = cg.readEntry ("Kate-MDI-H-Splitter", hs);
- vs = cg.readEntry ("Kate-MDI-V-Splitter", vs);
+ // get main splitter sizes ;)
+ hs = cg.readEntry("Kate-MDI-H-Splitter", hs);
+ vs = cg.readEntry("Kate-MDI-V-Splitter", vs);
- m_sidebars[0]->setLastSize (hs[0]);
- m_sidebars[1]->setLastSize (hs[2]);
- m_sidebars[2]->setLastSize (vs[0]);
- m_sidebars[3]->setLastSize (vs[2]);
+ m_sidebars[0]->setLastSize(hs[0]);
+ m_sidebars[1]->setLastSize(hs[2]);
+ m_sidebars[2]->setLastSize(vs[0]);
+ m_sidebars[3]->setLastSize(vs[2]);
- m_hSplitter->setSizes(hs);
- m_vSplitter->setSizes(vs);
+ m_hSplitter->setSizes(hs);
+ m_vSplitter->setSizes(vs);
}
// clear this stuff, we are done ;)
m_restoreConfig = 0;
m_restoreGroup.clear();
- }
+}
- void MainWindow::saveSession (KConfigGroup& config)
- {
- saveMainWindowSettings (config);
+void MainWindow::saveSession(KConfigGroup &config)
+{
+ saveMainWindowSettings(config);
// save main splitter sizes ;)
QList<int> hs = m_hSplitter->sizes();
QList<int> vs = m_vSplitter->sizes();
- if (hs[0] <= 2 && !m_sidebars[0]->splitterVisible ())
- hs[0] = m_sidebars[0]->lastSize();
- if (hs[2] <= 2 && !m_sidebars[1]->splitterVisible ())
- hs[2] = m_sidebars[1]->lastSize();
- if (vs[0] <= 2 && !m_sidebars[2]->splitterVisible ())
- vs[0] = m_sidebars[2]->lastSize();
- if (vs[2] <= 2 && !m_sidebars[3]->splitterVisible ())
- vs[2] = m_sidebars[3]->lastSize();
+ if (hs[0] <= 2 && !m_sidebars[0]->splitterVisible()) {
+ hs[0] = m_sidebars[0]->lastSize();
+ }
+ if (hs[2] <= 2 && !m_sidebars[1]->splitterVisible()) {
+ hs[2] = m_sidebars[1]->lastSize();
+ }
+ if (vs[0] <= 2 && !m_sidebars[2]->splitterVisible()) {
+ vs[0] = m_sidebars[2]->lastSize();
+ }
+ if (vs[2] <= 2 && !m_sidebars[3]->splitterVisible()) {
+ vs[2] = m_sidebars[3]->lastSize();
+ }
- config.writeEntry ("Kate-MDI-H-Splitter", hs);
- config.writeEntry ("Kate-MDI-V-Splitter", vs);
+ config.writeEntry("Kate-MDI-H-Splitter", hs);
+ config.writeEntry("Kate-MDI-V-Splitter", vs);
// save sidebar style
- config.writeEntry ("Kate-MDI-Sidebar-Style", (int)toolViewStyle());
- config.writeEntry ("Kate-MDI-Sidebar-Visible", m_sidebarsVisible );
+ config.writeEntry("Kate-MDI-Sidebar-Style", (int)toolViewStyle());
+ config.writeEntry("Kate-MDI-Sidebar-Visible", m_sidebarsVisible);
// save the sidebars
- for (unsigned int i = 0; i < 4; ++i)
- m_sidebars[i]->saveSession (config);
- }
+ for (unsigned int i = 0; i < 4; ++i) {
+ m_sidebars[i]->saveSession(config);
+ }
+}
//END MAIN WINDOW
} // namespace KateMDI
-// kate: space-indent on; indent-width 2;
diff --git a/kate/app/katemdi.h b/kate/app/katemdi.h
index 58b745a..3e34968 100644
--- a/kate/app/katemdi.h
+++ b/kate/app/katemdi.h
@@ -42,422 +42,416 @@ class KActionMenu;
class QAction;
class KConfigBase;
-namespace KTextEditor {
- class ConfigPageInterface;
+namespace KTextEditor
+{
+class ConfigPageInterface;
};
namespace KateMDI
{
- class ToolView;
-
- class ToggleToolViewAction : public KToggleAction
- {
- Q_OBJECT
-
- public:
- ToggleToolViewAction ( const QString& text, ToolView *tv, QObject *parent );
-
- virtual ~ToggleToolViewAction();
-
- protected Q_SLOTS:
- void slotToggled(bool);
- void toolVisibleChanged(bool);
-
- private:
- ToolView *m_tv;
- };
-
- class GUIClient : public QObject, public KXMLGUIClient
- {
- Q_OBJECT
-
- public:
- GUIClient ( class MainWindow *mw );
- virtual ~GUIClient();
-
- void registerToolView (ToolView *tv);
- void unregisterToolView (ToolView *tv);
- void updateSidebarsVisibleAction();
-
- private Q_SLOTS:
- void clientAdded( KXMLGUIClient *client );
- void updateActions();
-
- private:
- MainWindow *m_mw;
- KToggleAction *m_showSidebarsAction;
- QList<QAction*> m_toolViewActions;
- QMap<ToolView*, QAction*> m_toolToAction;
- KActionMenu *m_toolMenu;
- };
-
- class ToolView : public QFrame
- {
- Q_OBJECT
-
- friend class Sidebar;
- friend class MainWindow;
- friend class GUIClient;
- friend class ToggleToolViewAction;
-
- protected:
- /**
- * ToolView
- * Objects of this clas represent a toolview in the mainwindow
- * you should only add one widget as child to this toolview, it will
- * be automatically set to be the focus proxy of the toolview
- * @param mainwin main window for this toolview
- * @param sidebar sidebar of this toolview
- * @param parent parent widget, e.g. the splitter of one of the sidebars
- */
- ToolView (class MainWindow *mainwin, class Sidebar *sidebar, QWidget *parent);
-
- public:
- /**
- * destuct me, this is allowed for all, will care itself that the toolview is removed
- * from the mainwindow and sidebar
- */
- virtual ~ToolView ();
-
- Q_SIGNALS:
- /**
- * toolview hidden or shown
- * @param visible is this toolview made visible?
- */
- void toolVisibleChanged (bool visible);
-
- /**
- * some internal methodes needed by the main window and the sidebars
- */
- protected:
- MainWindow *mainWindow ()
- {
+class ToolView;
+
+class ToggleToolViewAction : public KToggleAction
+{
+ Q_OBJECT
+
+public:
+ ToggleToolViewAction(const QString &text, ToolView *tv, QObject *parent);
+
+ virtual ~ToggleToolViewAction();
+
+protected Q_SLOTS:
+ void slotToggled(bool);
+ void toolVisibleChanged(bool);
+
+private:
+ ToolView *m_tv;
+};
+
+class GUIClient : public QObject, public KXMLGUIClient
+{
+ Q_OBJECT
+
+public:
+ GUIClient(class MainWindow *mw);
+ virtual ~GUIClient();
+
+ void registerToolView(ToolView *tv);
+ void unregisterToolView(ToolView *tv);
+ void updateSidebarsVisibleAction();
+
+private Q_SLOTS:
+ void clientAdded(KXMLGUIClient *client);
+ void updateActions();
+
+private:
+ MainWindow *m_mw;
+ KToggleAction *m_showSidebarsAction;
+ QList<QAction *> m_toolViewActions;
+ QMap<ToolView *, QAction *> m_toolToAction;
+ KActionMenu *m_toolMenu;
+};
+
+class ToolView : public QFrame
+{
+ Q_OBJECT
+
+ friend class Sidebar;
+ friend class MainWindow;
+ friend class GUIClient;
+ friend class ToggleToolViewAction;
+
+protected:
+ /**
+ * ToolView
+ * Objects of this clas represent a toolview in the mainwindow
+ * you should only add one widget as child to this toolview, it will
+ * be automatically set to be the focus proxy of the toolview
+ * @param mainwin main window for this toolview
+ * @param sidebar sidebar of this toolview
+ * @param parent parent widget, e.g. the splitter of one of the sidebars
+ */
+ ToolView(class MainWindow *mainwin, class Sidebar *sidebar, QWidget *parent);
+
+public:
+ /**
+ * destuct me, this is allowed for all, will care itself that the toolview is removed
+ * from the mainwindow and sidebar
+ */
+ virtual ~ToolView();
+
+Q_SIGNALS:
+ /**
+ * toolview hidden or shown
+ * @param visible is this toolview made visible?
+ */
+ void toolVisibleChanged(bool visible);
+
+ /**
+ * some internal methodes needed by the main window and the sidebars
+ */
+protected:
+ MainWindow *mainWindow() {
return m_mainWin;
- }
+ }
- Sidebar *sidebar ()
- {
+ Sidebar *sidebar() {
return m_sidebar;
- }
+ }
- void setToolVisible (bool vis);
+ void setToolVisible(bool vis);
- public:
- bool toolVisible () const;
+public:
+ bool toolVisible() const;
- protected:
- void childEvent ( QChildEvent *ev );
+protected:
+ void childEvent(QChildEvent *ev);
- private:
- MainWindow *m_mainWin;
- Sidebar *m_sidebar;
+private:
+ MainWindow *m_mainWin;
+ Sidebar *m_sidebar;
- ///plugin this view belongs to, may be 0
- QPointer<KTextEditor::Plugin> plugin;
+ ///plugin this view belongs to, may be 0
+ QPointer<KTextEditor::Plugin> plugin;
- /**
- * unique id
- */
- QString id;
+ /**
+ * unique id
+ */
+ QString id;
- /**
- * is visible in sidebar
- */
- bool m_toolVisible;
+ /**
+ * is visible in sidebar
+ */
+ bool m_toolVisible;
- /**
- * is this view persistent?
- */
- bool persistent;
+ /**
+ * is this view persistent?
+ */
+ bool persistent;
- QPixmap icon;
- QString text;
- };
+ QPixmap icon;
+ QString text;
+};
- class Sidebar : public KMultiTabBar
- {
- Q_OBJECT
+class Sidebar : public KMultiTabBar
+{
+ Q_OBJECT
- public:
- Sidebar (KMultiTabBar::KMultiTabBarPosition pos, class MainWindow *mainwin, QWidget *parent);
- virtual ~Sidebar ();
+public:
+ Sidebar(KMultiTabBar::KMultiTabBarPosition pos, class MainWindow *mainwin, QWidget *parent);
+ virtual ~Sidebar();
- void setSplitter (QSplitter *sp);
+ void setSplitter(QSplitter *sp);
- public:
- ToolView *addWidget (const QPixmap &icon, const QString &text, ToolView *widget);
- bool removeWidget (ToolView *widget);
+public:
+ ToolView *addWidget(const QPixmap &icon, const QString &text, ToolView *widget);
+ bool removeWidget(ToolView *widget);
- bool showWidget (ToolView *widget);
- bool hideWidget (ToolView *widget);
+ bool showWidget(ToolView *widget);
+ bool hideWidget(ToolView *widget);
- void setLastSize (int s)
- {
+ void setLastSize(int s) {
m_lastSize = s;
- }
- int lastSize () const
- {
+ }
+ int lastSize() const {
return m_lastSize;
- }
- void updateLastSize ();
+ }
+ void updateLastSize();
- bool splitterVisible () const
- {
+ bool splitterVisible() const {
return m_ownSplit->isVisible();
- }
-
- void restoreSession ();
-
- /**
- * restore the current session config from given object, use current group
- * @param config config object to use
- */
- void restoreSession (KConfigGroup& config);
-
- /**
- * save the current session config to given object, use current group
- * @param config config object to use
- */
- void saveSession (KConfigGroup& config);
-
- public Q_SLOTS:
- // reimplemented, to block a show() call if all sidebars are forced hidden
- virtual void setVisible(bool visible);
- private Q_SLOTS:
- void tabClicked(int);
-
- protected:
- bool eventFilter(QObject *obj, QEvent *ev);
-
- private Q_SLOTS:
- void buttonPopupActivate (QAction *);
-
- private:
- MainWindow *m_mainWin;
-
- KMultiTabBar::KMultiTabBarPosition m_pos;
- QSplitter *m_splitter;
- KMultiTabBar *m_tabBar;
- QSplitter *m_ownSplit;
-
- QMap<int, ToolView*> m_idToWidget;
- QMap<ToolView*, int> m_widgetToId;
- QMap<ToolView*, QSize> m_widgetToSize;
-
- /**
- * list of all toolviews around in this sidebar
- */
- QList<ToolView*> m_toolviews;
-
- int m_lastSize;
-
- QSize m_preHideSize;
-
- int m_popupButton;
-
- Q_SIGNALS:
- void sigShowPluginConfigPage(KTextEditor::ConfigPageInterface *configpageinterface,uint id);
-
- };
-
- class MainWindow : public KParts::MainWindow
- {
- Q_OBJECT
-
- friend class ToolView;
-
- //
- // Constructor area
- //
- public:
- /**
- * Constructor
- */
- MainWindow (QWidget* parentWidget = 0);
-
- /**
- * Destructor
- */
- virtual ~MainWindow ();
-
- //
- // public interfaces
- //
-
- /**
- * add a given widget to the given sidebar if possible, name is very important
- * @param identifier unique identifier for this toolview
- * @param pos position for the toolview, if we are in session restore, this is only a preference
- * @param icon icon to use for the toolview
- * @param text text to use in addition to icon
- * @return created toolview on success or 0
- */
- ToolView *createToolView (KTextEditor::Plugin *plugin, const QString &identifier, KMultiTabBar::KMultiTabBarPosition pos, const QPixmap &icon, const QString &text);
-
- /**
- * give you handle to toolview for the given name, 0 if no toolview around
- * @param identifier toolview name
- * @return toolview if existing, else 0
- */
- ToolView *toolView (const QString &identifier) const;
-
- /**
- * set the toolview's tabbar style.
- * @param style the tabbar style.
- */
- void setToolViewStyle (KMultiTabBar::KMultiTabBarStyle style);
-
- /**
- * get the toolview's tabbar style. Call this before @p startRestore(),
- * otherwise you overwrite the usersettings.
- * @return toolview's tabbar style
- */
- KMultiTabBar::KMultiTabBarStyle toolViewStyle () const;
-
- /**
- * get the sidebars' visibility.
- * @return false, if the sidebars' visibility is forced hidden, otherwise true
- */
- bool sidebarsVisible() const;
-
- public Q_SLOTS:
- /**
- * set the sidebars' visibility to @p visible. If false, the sidebars
- * are @e always hidden. Usually you do not have to call this because
- * the user can set this in the menu.
- * @param visible sidebars visibility
- */
- void setSidebarsVisible( bool visible );
-
- protected:
- /**
- * called by toolview destructor
- * @param widget toolview which is destroyed
- */
- void toolViewDeleted (ToolView *widget);
-
- /**
- * central widget ;)
- * use this as parent for your content
- * this widget will get focus if a toolview is hidden
- * @return central widget
- */
- QWidget *centralWidget () const;
-
- /**
- * modifiers for existing toolviews
- */
- public:
- /**
- * move a toolview around
- * @param widget toolview to move
- * @param pos position to move too, during session restore, only preference
- * @return success
- */
- bool moveToolView (ToolView *widget, KMultiTabBar::KMultiTabBarPosition pos);
-
- /**
- * show given toolview, discarded while session restore
- * @param widget toolview to show
- * @return success
- */
- bool showToolView (ToolView *widget);
-
- /**
- * hide given toolview, discarded while session restore
- * @param widget toolview to hide
- * @return success
- */
- bool hideToolView (ToolView *widget);
-
- /**
- * session saving and restore stuff
- */
- public:
- /**
- * start the restore
- * @param config config object to use
- * @param group config group to use
- */
- void startRestore (KConfigBase *config, const QString &group);
-
- /**
- * finish the restore
- */
- void finishRestore ();
-
- /**
- * save the current session config to given object and group
- * @param config config object to use
- * @param group config group to use
- */
- void saveSession (KConfigGroup &group);
-
- /**
- * internal data ;)
- */
- private:
- /**
- * map identifiers to widgets
- */
- QMap<QString, ToolView*> m_idToWidget;
-
- /**
- * list of all toolviews around
- */
- QList<ToolView*> m_toolviews;
-
-
- /**
- * widget, which is the central part of the
- * main window ;)
- */
- QWidget *m_centralWidget;
-
- /**
- * horizontal splitter
- */
- QSplitter *m_hSplitter;
-
- /**
- * vertical splitter
- */
- QSplitter *m_vSplitter;
-
- /**
- * sidebars for the four sides
- */
- Sidebar *m_sidebars[4];
-
- /**
- * sidebars state.
- */
- bool m_sidebarsVisible;
-
- /**
- * config object for session restore, only valid between
- * start and finish restore calls
- */
- KConfigBase *m_restoreConfig;
-
- /**
- * restore group
- */
- QString m_restoreGroup;
-
- /**
- * out guiclient
- */
- GUIClient *m_guiClient;
-
- Q_SIGNALS:
- void sigShowPluginConfigPage(KTextEditor::ConfigPageInterface *configpageinterface,uint id);
-
- };
+ }
+
+ void restoreSession();
+
+ /**
+ * restore the current session config from given object, use current group
+ * @param config config object to use
+ */
+ void restoreSession(KConfigGroup &config);
+
+ /**
+ * save the current session config to given object, use current group
+ * @param config config object to use
+ */
+ void saveSession(KConfigGroup &config);
+
+public Q_SLOTS:
+ // reimplemented, to block a show() call if all sidebars are forced hidden
+ virtual void setVisible(bool visible);
+private Q_SLOTS:
+ void tabClicked(int);
+
+protected:
+ bool eventFilter(QObject *obj, QEvent *ev);
+
+private Q_SLOTS:
+ void buttonPopupActivate(QAction *);
+
+private:
+ MainWindow *m_mainWin;
+
+ KMultiTabBar::KMultiTabBarPosition m_pos;
+ QSplitter *m_splitter;
+ KMultiTabBar *m_tabBar;
+ QSplitter *m_ownSplit;
+
+ QMap<int, ToolView *> m_idToWidget;
+ QMap<ToolView *, int> m_widgetToId;
+ QMap<ToolView *, QSize> m_widgetToSize;
+
+ /**
+ * list of all toolviews around in this sidebar
+ */
+ QList<ToolView *> m_toolviews;
+
+ int m_lastSize;
+
+ QSize m_preHideSize;
+
+ int m_popupButton;
+
+Q_SIGNALS:
+ void sigShowPluginConfigPage(KTextEditor::ConfigPageInterface *configpageinterface, uint id);
+
+};
+
+class MainWindow : public KParts::MainWindow
+{
+ Q_OBJECT
+
+ friend class ToolView;
+
+ //
+ // Constructor area
+ //
+public:
+ /**
+ * Constructor
+ */
+ MainWindow(QWidget *parentWidget = 0);
+
+ /**
+ * Destructor
+ */
+ virtual ~MainWindow();
+
+ //
+ // public interfaces
+ //
+
+ /**
+ * add a given widget to the given sidebar if possible, name is very important
+ * @param identifier unique identifier for this toolview
+ * @param pos position for the toolview, if we are in session restore, this is only a preference
+ * @param icon icon to use for the toolview
+ * @param text text to use in addition to icon
+ * @return created toolview on success or 0
+ */
+ ToolView *createToolView(KTextEditor::Plugin *plugin, const QString &identifier, KMultiTabBar::KMultiTabBarPosition pos, const QPixmap &icon, const QString &text);
+
+ /**
+ * give you handle to toolview for the given name, 0 if no toolview around
+ * @param identifier toolview name
+ * @return toolview if existing, else 0
+ */
+ ToolView *toolView(const QString &identifier) const;
+
+ /**
+ * set the toolview's tabbar style.
+ * @param style the tabbar style.
+ */
+ void setToolViewStyle(KMultiTabBar::KMultiTabBarStyle style);
+
+ /**
+ * get the toolview's tabbar style. Call this before @p startRestore(),
+ * otherwise you overwrite the usersettings.
+ * @return toolview's tabbar style
+ */
+ KMultiTabBar::KMultiTabBarStyle toolViewStyle() const;
+
+ /**
+ * get the sidebars' visibility.
+ * @return false, if the sidebars' visibility is forced hidden, otherwise true
+ */
+ bool sidebarsVisible() const;
+
+public Q_SLOTS:
+ /**
+ * set the sidebars' visibility to @p visible. If false, the sidebars
+ * are @e always hidden. Usually you do not have to call this because
+ * the user can set this in the menu.
+ * @param visible sidebars visibility
+ */
+ void setSidebarsVisible(bool visible);
+
+protected:
+ /**
+ * called by toolview destructor
+ * @param widget toolview which is destroyed
+ */
+ void toolViewDeleted(ToolView *widget);
+
+ /**
+ * central widget ;)
+ * use this as parent for your content
+ * this widget will get focus if a toolview is hidden
+ * @return central widget
+ */
+ QWidget *centralWidget() const;
+
+ /**
+ * modifiers for existing toolviews
+ */
+public:
+ /**
+ * move a toolview around
+ * @param widget toolview to move
+ * @param pos position to move too, during session restore, only preference
+ * @return success
+ */
+ bool moveToolView(ToolView *widget, KMultiTabBar::KMultiTabBarPosition pos);
+
+ /**
+ * show given toolview, discarded while session restore
+ * @param widget toolview to show
+ * @return success
+ */
+ bool showToolView(ToolView *widget);
+
+ /**
+ * hide given toolview, discarded while session restore
+ * @param widget toolview to hide
+ * @return success
+ */
+ bool hideToolView(ToolView *widget);
+
+ /**
+ * session saving and restore stuff
+ */
+public:
+ /**
+ * start the restore
+ * @param config config object to use
+ * @param group config group to use
+ */
+ void startRestore(KConfigBase *config, const QString &group);
+
+ /**
+ * finish the restore
+ */
+ void finishRestore();
+
+ /**
+ * save the current session config to given object and group
+ * @param config config object to use
+ * @param group config group to use
+ */
+ void saveSession(KConfigGroup &group);
+
+ /**
+ * internal data ;)
+ */
+private:
+ /**
+ * map identifiers to widgets
+ */
+ QMap<QString, ToolView *> m_idToWidget;
+
+ /**
+ * list of all toolviews around
+ */
+ QList<ToolView *> m_toolviews;
+
+ /**
+ * widget, which is the central part of the
+ * main window ;)
+ */
+ QWidget *m_centralWidget;
+
+ /**
+ * horizontal splitter
+ */
+ QSplitter *m_hSplitter;
+
+ /**
+ * vertical splitter
+ */
+ QSplitter *m_vSplitter;
+
+ /**
+ * sidebars for the four sides
+ */
+ Sidebar *m_sidebars[4];
+
+ /**
+ * sidebars state.
+ */
+ bool m_sidebarsVisible;
+
+ /**
+ * config object for session restore, only valid between
+ * start and finish restore calls
+ */
+ KConfigBase *m_restoreConfig;
+
+ /**
+ * restore group
+ */
+ QString m_restoreGroup;
+
+ /**
+ * out guiclient
+ */
+ GUIClient *m_guiClient;
+
+Q_SIGNALS:
+ void sigShowPluginConfigPage(KTextEditor::ConfigPageInterface *configpageinterface, uint id);
+
+};
}
#endif
-// kate: space-indent on; indent-width 2;
diff --git a/kate/app/katemwmodonhddialog.cpp b/kate/app/katemwmodonhddialog.cpp
index 3c38cb0..ecfc547 100644
--- a/kate/app/katemwmodonhddialog.cpp
+++ b/kate/app/katemwmodonhddialog.cpp
@@ -2,17 +2,17 @@
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
-
+
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
-
+
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
-
+
---
Copyright (C) 2004, Anders Lund <anders@alweb.dk>
*/
@@ -39,314 +39,309 @@
class KateDocItem : public QTreeWidgetItem
{
- public:
- KateDocItem( KTextEditor::Document *doc, const QString &status, QTreeWidget *tw )
- : QTreeWidgetItem( tw ),
- document( doc )
- {
- setText( 0, doc->url().toString() );
- setText( 1, status );
- if ( ! doc->isModified() )
- setCheckState( 0, Qt::Checked );
- else
- setCheckState( 0, Qt::Unchecked );
+public:
+ KateDocItem(KTextEditor::Document *doc, const QString &status, QTreeWidget *tw)
+ : QTreeWidgetItem(tw),
+ document(doc) {
+ setText(0, doc->url().toString());
+ setText(1, status);
+ if (! doc->isModified()) {
+ setCheckState(0, Qt::Checked);
+ } else {
+ setCheckState(0, Qt::Unchecked);
+ }
}
~KateDocItem()
- {}
+ {}
KTextEditor::Document *document;
};
-
-KateMwModOnHdDialog::KateMwModOnHdDialog( DocVector docs, QWidget *parent, const char *name )
- : QDialog( parent ),
- m_proc( 0 ),
- m_diffFile( 0 )
+KateMwModOnHdDialog::KateMwModOnHdDialog(DocVector docs, QWidget *parent, const char *name)
+ : QDialog(parent),
+ m_proc(0),
+ m_diffFile(0)
{
- setWindowTitle(i18n("Documents Modified on Disk"));
- setObjectName(QString::fromLatin1(name));
- setModal(true);
-
- QVBoxLayout *mainLayout = new QVBoxLayout;
- setLayout(mainLayout);
-
- // Message
- QHBoxLayout *hb = new QHBoxLayout;
- mainLayout->addLayout(hb);
-
- // dialog text
- QLabel *icon = new QLabel(this);
- hb->addWidget(icon);
- icon->setPixmap( DesktopIcon(QStringLiteral("dialog-warning")) );
-
- QLabel *t = new QLabel(i18n(
- "<qt>The documents listed below have changed on disk.<p>Select one "
- "or more at once, and press an action button until the list is empty.</p></qt>"), this);
- hb->addWidget(t);
- hb->setStretchFactor(t, 1000);
-
- // Document list
- twDocuments = new QTreeWidget(this);
- mainLayout->addWidget(twDocuments);
- QStringList header;
- header << i18n("Filename") << i18n("Status on Disk");
- twDocuments->setHeaderLabels(header);
- twDocuments->setSelectionMode( QAbstractItemView::SingleSelection );
- twDocuments->setRootIsDecorated( false );
-
- m_stateTexts << QString() << i18n("Modified") << i18n("Created") << i18n("Deleted");
- for ( int i = 0; i < docs.size(); i++ )
- {
- new KateDocItem( docs[i], m_stateTexts[ (uint)KateDocManager::self()->documentInfo( docs[i] )->modifiedOnDiscReason ], twDocuments );
- }
- twDocuments->header()->setStretchLastSection(false);
- twDocuments->header()->setSectionResizeMode(0, QHeaderView::Stretch);
- twDocuments->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
-
- connect(twDocuments, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(slotSelectionChanged(QTreeWidgetItem*,QTreeWidgetItem*)) );
-
- // Diff line
- hb = new QHBoxLayout;
- mainLayout->addLayout(hb);
-
- QPushButton *btnDiff = new QPushButton(QIcon::fromTheme(QStringLiteral("document-preview")), i18n("&View Difference"), this);
- btnDiff->setWhatsThis(i18n(
- "Calculates the difference between the editor contents and the disk "
- "file for the selected document, and shows the difference with the "
- "default application. Requires diff(1).") );
- hb->addWidget(btnDiff);
- connect(btnDiff, SIGNAL(clicked()), this, SLOT(slotDiff()));
-
- // Dialog buttons
- QDialogButtonBox *buttons = new QDialogButtonBox(this);
- mainLayout->addWidget(buttons);
-
- QPushButton *ignoreButton = new QPushButton(QIcon::fromTheme(QStringLiteral("dialog-warning")), i18n("&Ignore Changes"));
- ignoreButton->setToolTip(i18n("Remove modified flag from selected documents"));
- buttons->addButton(ignoreButton, QDialogButtonBox::RejectRole);
- connect(ignoreButton, SIGNAL(clicked()), this, SLOT(slotIgnore()));
-
- QPushButton *overwriteButton = new QPushButton;
- KGuiItem::assign(overwriteButton, KStandardGuiItem::overwrite());
- overwriteButton->setToolTip(i18n("Overwrite selected documents, discarding disk changes"));
- connect(overwriteButton, SIGNAL(clicked()), this, SLOT(slotOverwrite()));
-
-
- QPushButton *reloadButton = new QPushButton(QIcon::fromTheme(QStringLiteral("view-refresh")), i18n("&Reload"));
- reloadButton->setDefault(true);
- reloadButton->setToolTip(i18n("Reload selected documents from disk"));
- connect(reloadButton, SIGNAL(clicked()), this, SLOT(slotReload()));
-
- slotSelectionChanged(NULL, NULL);
+ setWindowTitle(i18n("Documents Modified on Disk"));
+ setObjectName(QString::fromLatin1(name));
+ setModal(true);
+
+ QVBoxLayout *mainLayout = new QVBoxLayout;
+ setLayout(mainLayout);
+
+ // Message
+ QHBoxLayout *hb = new QHBoxLayout;
+ mainLayout->addLayout(hb);
+
+ // dialog text
+ QLabel *icon = new QLabel(this);
+ hb->addWidget(icon);
+ icon->setPixmap(DesktopIcon(QStringLiteral("dialog-warning")));
+
+ QLabel *t = new QLabel(i18n(
+ "<qt>The documents listed below have changed on disk.<p>Select one "
+ "or more at once, and press an action button until the list is empty.</p></qt>"), this);
+ hb->addWidget(t);
+ hb->setStretchFactor(t, 1000);
+
+ // Document list
+ twDocuments = new QTreeWidget(this);
+ mainLayout->addWidget(twDocuments);
+ QStringList header;
+ header << i18n("Filename") << i18n("Status on Disk");
+ twDocuments->setHeaderLabels(header);
+ twDocuments->setSelectionMode(QAbstractItemView::SingleSelection);
+ twDocuments->setRootIsDecorated(false);
+
+ m_stateTexts << QString() << i18n("Modified") << i18n("Created") << i18n("Deleted");
+ for (int i = 0; i < docs.size(); i++) {
+ new KateDocItem(docs[i], m_stateTexts[(uint)KateDocManager::self()->documentInfo(docs[i])->modifiedOnDiscReason ], twDocuments);
+ }
+ twDocuments->header()->setStretchLastSection(false);
+ twDocuments->header()->setSectionResizeMode(0, QHeaderView::Stretch);
+ twDocuments->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
+
+ connect(twDocuments, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(slotSelectionChanged(QTreeWidgetItem*,QTreeWidgetItem*)));
+
+ // Diff line
+ hb = new QHBoxLayout;
+ mainLayout->addLayout(hb);
+
+ QPushButton *btnDiff = new QPushButton(QIcon::fromTheme(QStringLiteral("document-preview")), i18n("&View Difference"), this);
+ btnDiff->setWhatsThis(i18n(
+ "Calculates the difference between the editor contents and the disk "
+ "file for the selected document, and shows the difference with the "
+ "default application. Requires diff(1)."));
+ hb->addWidget(btnDiff);
+ connect(btnDiff, SIGNAL(clicked()), this, SLOT(slotDiff()));
+
+ // Dialog buttons
+ QDialogButtonBox *buttons = new QDialogButtonBox(this);
+ mainLayout->addWidget(buttons);
+
+ QPushButton *ignoreButton = new QPushButton(QIcon::fromTheme(QStringLiteral("dialog-warning")), i18n("&Ignore Changes"));
+ ignoreButton->setToolTip(i18n("Remove modified flag from selected documents"));
+ buttons->addButton(ignoreButton, QDialogButtonBox::RejectRole);
+ connect(ignoreButton, SIGNAL(clicked()), this, SLOT(slotIgnore()));
+
+ QPushButton *overwriteButton = new QPushButton;
+ KGuiItem::assign(overwriteButton, KStandardGuiItem::overwrite());
+ overwriteButton->setToolTip(i18n("Overwrite selected documents, discarding disk changes"));
+ connect(overwriteButton, SIGNAL(clicked()), this, SLOT(slotOverwrite()));
+
+ QPushButton *reloadButton = new QPushButton(QIcon::fromTheme(QStringLiteral("view-refresh")), i18n("&Reload"));
+ reloadButton->setDefault(true);
+ reloadButton->setToolTip(i18n("Reload selected documents from disk"));
+ connect(reloadButton, SIGNAL(clicked()), this, SLOT(slotReload()));
+
+ slotSelectionChanged(NULL, NULL);
}
KateMwModOnHdDialog::~KateMwModOnHdDialog()
{
- KateMainWindow::unsetModifiedOnDiscDialogIfIf(this);
- delete m_proc;
- m_proc = 0;
- if (m_diffFile) {
- m_diffFile->setAutoRemove(true);
- delete m_diffFile;
- m_diffFile = 0;
- }
+ KateMainWindow::unsetModifiedOnDiscDialogIfIf(this);
+ delete m_proc;
+ m_proc = 0;
+ if (m_diffFile) {
+ m_diffFile->setAutoRemove(true);
+ delete m_diffFile;
+ m_diffFile = 0;
+ }
}
void KateMwModOnHdDialog::slotIgnore()
{
- handleSelected( Ignore );
+ handleSelected(Ignore);
}
void KateMwModOnHdDialog::slotOverwrite()
{
- handleSelected( Overwrite );
+ handleSelected(Overwrite);
}
void KateMwModOnHdDialog::slotReload()
{
- handleSelected( Reload );
+ handleSelected(Reload);
}
-void KateMwModOnHdDialog::handleSelected( int action )
+void KateMwModOnHdDialog::handleSelected(int action)
{
- // collect all items we can remove
- QList<QTreeWidgetItem *> itemsToDelete;
- for ( QTreeWidgetItemIterator it ( twDocuments ); *it; ++it )
- {
- KateDocItem *item = (KateDocItem *) * it;
- if ( item->checkState(0) == Qt::Checked )
- {
- KTextEditor::ModificationInterface::ModifiedOnDiskReason reason = KateDocManager::self()->documentInfo( item->document )->modifiedOnDiscReason;
- bool success = true;
-
- if (KTextEditor::ModificationInterface *iface = qobject_cast<KTextEditor::ModificationInterface *>(item->document))
- iface->setModifiedOnDisk( KTextEditor::ModificationInterface::OnDiskUnmodified );
-
- switch ( action )
- {
- case Overwrite:
- success = item->document->save();
- if ( ! success )
- {
- KMessageBox::sorry( this,
- i18n("Could not save the document \n'%1'",
- item->document->url().toString() ) );
- }
- break;
-
- case Reload:
- item->document->documentReload();
- break;
-
- default:
- break;
- }
-
- if ( success )
- itemsToDelete.append( item );
- else
- {
- if (KTextEditor::ModificationInterface *iface = qobject_cast<KTextEditor::ModificationInterface *>(item->document))
- iface->setModifiedOnDisk( reason );
- }
+ // collect all items we can remove
+ QList<QTreeWidgetItem *> itemsToDelete;
+ for (QTreeWidgetItemIterator it(twDocuments); *it; ++it) {
+ KateDocItem *item = (KateDocItem *) * it;
+ if (item->checkState(0) == Qt::Checked) {
+ KTextEditor::ModificationInterface::ModifiedOnDiskReason reason = KateDocManager::self()->documentInfo(item->document)->modifiedOnDiscReason;
+ bool success = true;
+
+ if (KTextEditor::ModificationInterface *iface = qobject_cast<KTextEditor::ModificationInterface *>(item->document)) {
+ iface->setModifiedOnDisk(KTextEditor::ModificationInterface::OnDiskUnmodified);
+ }
+
+ switch (action) {
+ case Overwrite:
+ success = item->document->save();
+ if (! success) {
+ KMessageBox::sorry(this,
+ i18n("Could not save the document \n'%1'",
+ item->document->url().toString()));
+ }
+ break;
+
+ case Reload:
+ item->document->documentReload();
+ break;
+
+ default:
+ break;
+ }
+
+ if (success) {
+ itemsToDelete.append(item);
+ } else {
+ if (KTextEditor::ModificationInterface *iface = qobject_cast<KTextEditor::ModificationInterface *>(item->document)) {
+ iface->setModifiedOnDisk(reason);
+ }
+ }
+ }
}
- }
- // remove the marked items
- for (int i = 0; i < itemsToDelete.count(); ++i)
- delete itemsToDelete[i];
+ // remove the marked items
+ for (int i = 0; i < itemsToDelete.count(); ++i) {
+ delete itemsToDelete[i];
+ }
// any documents left unhandled?
- if ( ! twDocuments->topLevelItemCount() )
- accept();
+ if (! twDocuments->topLevelItemCount()) {
+ accept();
+ }
}
void KateMwModOnHdDialog::slotSelectionChanged(QTreeWidgetItem *current, QTreeWidgetItem *)
{
- // set the diff button enabled
- btnDiff->setEnabled( current &&
- KateDocManager::self()->documentInfo( (static_cast<KateDocItem*>(current))->document )->modifiedOnDiscReason != KTextEditor::ModificationInterface::OnDiskDeleted );
+ // set the diff button enabled
+ btnDiff->setEnabled(current &&
+ KateDocManager::self()->documentInfo((static_cast<KateDocItem *>(current))->document)->modifiedOnDiscReason != KTextEditor::ModificationInterface::OnDiskDeleted);
}
// ### the code below is slightly modified from kdelibs/kate/part/katedialogs,
// class KateModOnHdPrompt.
void KateMwModOnHdDialog::slotDiff()
{
- if ( !btnDiff->isEnabled()) // diff button already pressed, proc not finished yet
- return;
+ if (!btnDiff->isEnabled()) { // diff button already pressed, proc not finished yet
+ return;
+ }
- if ( ! twDocuments->currentItem() )
- return;
+ if (! twDocuments->currentItem()) {
+ return;
+ }
- KTextEditor::Document *doc = (static_cast<KateDocItem*>(twDocuments->currentItem()))->document;
+ KTextEditor::Document *doc = (static_cast<KateDocItem *>(twDocuments->currentItem()))->document;
- // don't try to diff a deleted file
- if ( KateDocManager::self()->documentInfo( doc )->modifiedOnDiscReason == KTextEditor::ModificationInterface::OnDiskDeleted )
- return;
+ // don't try to diff a deleted file
+ if (KateDocManager::self()->documentInfo(doc)->modifiedOnDiscReason == KTextEditor::ModificationInterface::OnDiskDeleted) {
+ return;
+ }
- if (m_diffFile)
- return;
+ if (m_diffFile) {
+ return;
+ }
- m_diffFile = new QTemporaryFile();
- m_diffFile->open();
+ m_diffFile = new QTemporaryFile();
+ m_diffFile->open();
- // Start a KProcess that creates a diff
- m_proc = new KProcess( this );
- m_proc->setOutputChannelMode( KProcess::MergedChannels );
- *m_proc << QStringLiteral("diff") << QStringLiteral("-ub") << QStringLiteral("-") << doc->url().toLocalFile();
- connect( m_proc, SIGNAL(readyRead()), this, SLOT(slotDataAvailable()) );
- connect( m_proc, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(slotPDone()) );
+ // Start a KProcess that creates a diff
+ m_proc = new KProcess(this);
+ m_proc->setOutputChannelMode(KProcess::MergedChannels);
+ *m_proc << QStringLiteral("diff") << QStringLiteral("-ub") << QStringLiteral("-") << doc->url().toLocalFile();
+ connect(m_proc, SIGNAL(readyRead()), this, SLOT(slotDataAvailable()));
+ connect(m_proc, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(slotPDone()));
- setCursor( Qt::WaitCursor );
- btnDiff->setEnabled(false);
+ setCursor(Qt::WaitCursor);
+ btnDiff->setEnabled(false);
- m_proc->start();
+ m_proc->start();
- QTextStream ts(m_proc);
- int lastln = doc->lines() - 1;
- for ( int l = 0; l < lastln; ++l ) {
- ts << doc->line( l ) << QLatin1Char('\n');
- }
- ts << doc->line(lastln);
- ts.flush();
- m_proc->closeWriteChannel();
+ QTextStream ts(m_proc);
+ int lastln = doc->lines() - 1;
+ for (int l = 0; l < lastln; ++l) {
+ ts << doc->line(l) << QLatin1Char('\n');
+ }
+ ts << doc->line(lastln);
+ ts.flush();
+ m_proc->closeWriteChannel();
}
void KateMwModOnHdDialog::slotDataAvailable()
{
- m_diffFile->write(m_proc->readAll());
+ m_diffFile->write(m_proc->readAll());
}
void KateMwModOnHdDialog::slotPDone()
{
- setCursor( Qt::ArrowCursor );
- slotSelectionChanged(twDocuments->currentItem(), 0);
-
- const QProcess::ExitStatus es = m_proc->exitStatus();
- delete m_proc;
- m_proc = 0;
-
- if ( es != QProcess::NormalExit )
- {
- KMessageBox::sorry( this,
- i18n("The diff command failed. Please make sure that "
- "diff(1) is installed and in your PATH."),
- i18n("Error Creating Diff") );
- delete m_diffFile;
- m_diffFile = 0;
- return;
- }
-
- if ( m_diffFile->size() == 0 )
- {
- KMessageBox::information( this,
- i18n("Ignoring amount of white space changed, the files are identical."),
- i18n("Diff Output") );
+ setCursor(Qt::ArrowCursor);
+ slotSelectionChanged(twDocuments->currentItem(), 0);
+
+ const QProcess::ExitStatus es = m_proc->exitStatus();
+ delete m_proc;
+ m_proc = 0;
+
+ if (es != QProcess::NormalExit) {
+ KMessageBox::sorry(this,
+ i18n("The diff command failed. Please make sure that "
+ "diff(1) is installed and in your PATH."),
+ i18n("Error Creating Diff"));
+ delete m_diffFile;
+ m_diffFile = 0;
+ return;
+ }
+
+ if (m_diffFile->size() == 0) {
+ KMessageBox::information(this,
+ i18n("Ignoring amount of white space changed, the files are identical."),
+ i18n("Diff Output"));
+ delete m_diffFile;
+ m_diffFile = 0;
+ return;
+ }
+
+ m_diffFile->setAutoRemove(false);
+ QUrl url = QUrl::fromLocalFile(m_diffFile->fileName());
delete m_diffFile;
m_diffFile = 0;
- return;
- }
- m_diffFile->setAutoRemove(false);
- QUrl url = QUrl::fromLocalFile(m_diffFile->fileName());
- delete m_diffFile;
- m_diffFile = 0;
-
- // KRun::runUrl should delete the file, once the client exits
- KRun::runUrl( url, QStringLiteral("text/x-patch"), this, true );
+ // KRun::runUrl should delete the file, once the client exits
+ KRun::runUrl(url, QStringLiteral("text/x-patch"), this, true);
}
void KateMwModOnHdDialog::addDocument(KTextEditor::Document *doc)
{
- for ( QTreeWidgetItemIterator it ( twDocuments ); *it; ++it )
- {
- KateDocItem *item = (KateDocItem *) * it;
- if (item->document==doc)
- {
- delete item;
- break;
- }
+ for (QTreeWidgetItemIterator it(twDocuments); *it; ++it) {
+ KateDocItem *item = (KateDocItem *) * it;
+ if (item->document == doc) {
+ delete item;
+ break;
+ }
}
- new KateDocItem( doc, m_stateTexts[ (uint)KateDocManager::self()->documentInfo( doc )->modifiedOnDiscReason ], twDocuments );
+ new KateDocItem(doc, m_stateTexts[(uint)KateDocManager::self()->documentInfo(doc)->modifiedOnDiscReason ], twDocuments);
}
-void KateMwModOnHdDialog::keyPressEvent( QKeyEvent *event )
+void KateMwModOnHdDialog::keyPressEvent(QKeyEvent *event)
{
- if ( event->modifiers() == 0 )
- {
- if ( event->key() == Qt::Key_Escape )
- {
- event->accept();
- return;
+ if (event->modifiers() == 0) {
+ if (event->key() == Qt::Key_Escape) {
+ event->accept();
+ return;
+ }
}
- }
- QDialog::keyPressEvent(event);
+ QDialog::keyPressEvent(event);
}
-void KateMwModOnHdDialog::closeEvent( QCloseEvent *e )
+void KateMwModOnHdDialog::closeEvent(QCloseEvent *e)
{
- if ( ! twDocuments->topLevelItemCount() )
- QDialog::closeEvent(e);
- else e->ignore();
+ if (! twDocuments->topLevelItemCount()) {
+ QDialog::closeEvent(e);
+ } else {
+ e->ignore();
+ }
}
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/app/katemwmodonhddialog.h b/kate/app/katemwmodonhddialog.h
index 3b1153f..db95fb4 100644
--- a/kate/app/katemwmodonhddialog.h
+++ b/kate/app/katemwmodonhddialog.h
@@ -1,6 +1,6 @@
/*
Copyright (C) 2004, Anders Lund <anders@alweb.dk>
-
+
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
@@ -30,7 +30,7 @@ class QTemporaryFile;
class QTreeWidget;
class QTreeWidgetItem;
-typedef QVector<KTextEditor::Document*> DocVector;
+typedef QVector<KTextEditor::Document *> DocVector;
/**
* A dialog for handling multiple documents modified on disk
@@ -39,12 +39,12 @@ typedef QVector<KTextEditor::Document*> DocVector;
class KateMwModOnHdDialog : public QDialog
{
Q_OBJECT
- public:
- explicit KateMwModOnHdDialog( DocVector docs, QWidget *parent = 0, const char *name = 0 );
+public:
+ explicit KateMwModOnHdDialog(DocVector docs, QWidget *parent = 0, const char *name = 0);
~KateMwModOnHdDialog();
void addDocument(KTextEditor::Document *doc);
- private Q_SLOTS:
+private Q_SLOTS:
void slotIgnore();
void slotOverwrite();
void slotReload();
@@ -53,20 +53,19 @@ class KateMwModOnHdDialog : public QDialog
void slotDataAvailable();
void slotPDone();
- private:
+private:
enum Action { Ignore, Overwrite, Reload };
- void handleSelected( int action );
+ void handleSelected(int action);
class QTreeWidget *twDocuments;
class QPushButton *btnDiff;
KProcess *m_proc;
QTemporaryFile *m_diffFile;
QStringList m_stateTexts;
- protected:
- virtual void closeEvent( QCloseEvent *e );
- virtual void keyPressEvent( QKeyEvent* );
+protected:
+ virtual void closeEvent(QCloseEvent *e);
+ virtual void keyPressEvent(QKeyEvent *);
};
#endif // _KATE_MW_MODONHD_DIALOG_H_
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/app/katepluginmanager.cpp b/kate/app/katepluginmanager.cpp
index 35f2f1f..72a9c32 100644
--- a/kate/app/katepluginmanager.cpp
+++ b/kate/app/katepluginmanager.cpp
@@ -36,290 +36,300 @@
QString KatePluginInfo::saveName() const
{
- return service->library();
+ return service->library();
}
-KatePluginManager::KatePluginManager(QObject *parent) : QObject (parent)
+KatePluginManager::KatePluginManager(QObject *parent) : QObject(parent)
{
- setupPluginList ();
+ setupPluginList();
}
KatePluginManager::~KatePluginManager()
{
- // than unload the plugins
- unloadAllPlugins ();
+ // than unload the plugins
+ unloadAllPlugins();
}
KatePluginManager *KatePluginManager::self()
{
- return KateApp::self()->pluginManager ();
+ return KateApp::self()->pluginManager();
}
-void KatePluginManager::setupPluginList ()
+void KatePluginManager::setupPluginList()
{
- KService::List traderList = KServiceTypeTrader::self()->query(QStringLiteral("KTextEditor/Plugin"));
-
- KatePluginList alwaysLoad;
- KatePluginList others;
- foreach(const KService::Ptr &ptr, traderList)
- {
- KatePluginInfo info;
- info.service = ptr;
-
- // decide if this is an integral plugin
- if (info.service->library() == QStringLiteral("katefiletreeplugin"))
- info.alwaysLoad = true;
- else
- info.alwaysLoad = false;
-
- info.load = false;
- info.plugin = 0L;
-
- if (info.alwaysLoad)
- alwaysLoad.push_back (info);
- else
- others.push_back (info);
- }
-
- /**
- * prefer always load plugins in handling
- */
- m_pluginList = alwaysLoad;
- m_pluginList << others;
-
- /**
- * construct fast lookup map
- */
- m_name2Plugin.clear ();
- for (int i = 0; i < m_pluginList.size(); ++i)
- m_name2Plugin[m_pluginList[i].service->library()] = &(m_pluginList[i]);
+ KService::List traderList = KServiceTypeTrader::self()->query(QStringLiteral("KTextEditor/Plugin"));
+
+ KatePluginList alwaysLoad;
+ KatePluginList others;
+ foreach(const KService::Ptr & ptr, traderList) {
+ KatePluginInfo info;
+ info.service = ptr;
+
+ // decide if this is an integral plugin
+ if (info.service->library() == QStringLiteral("katefiletreeplugin")) {
+ info.alwaysLoad = true;
+ } else {
+ info.alwaysLoad = false;
+ }
+
+ info.load = false;
+ info.plugin = 0L;
+
+ if (info.alwaysLoad) {
+ alwaysLoad.push_back(info);
+ } else {
+ others.push_back(info);
+ }
+ }
+
+ /**
+ * prefer always load plugins in handling
+ */
+ m_pluginList = alwaysLoad;
+ m_pluginList << others;
+
+ /**
+ * construct fast lookup map
+ */
+ m_name2Plugin.clear();
+ for (int i = 0; i < m_pluginList.size(); ++i) {
+ m_name2Plugin[m_pluginList[i].service->library()] = &(m_pluginList[i]);
+ }
}
-void KatePluginManager::loadConfig (KConfig* config)
+void KatePluginManager::loadConfig(KConfig *config)
{
- // first: unload the plugins
- unloadAllPlugins ();
-
- /**
- * ask config object
- */
- if (config) {
- KConfigGroup cg = KConfigGroup(config, QStringLiteral("Kate Plugins"));
+ // first: unload the plugins
+ unloadAllPlugins();
+
+ /**
+ * ask config object
+ */
+ if (config) {
+ KConfigGroup cg = KConfigGroup(config, QStringLiteral("Kate Plugins"));
+
+ // disable all plugin if no config...
+ for (int i = 0; i < m_pluginList.size(); ++i) {
+ m_pluginList[i].load = cg.readEntry(m_pluginList[i].service->library(), false);
+ }
+ }
- // disable all plugin if no config...
- for (int i = 0; i < m_pluginList.size(); ++i)
- m_pluginList[i].load = cg.readEntry (m_pluginList[i].service->library(), false);
- }
-
- /**
- * load plugins, some are always enforced to load!
- */
- for (KatePluginList::iterator it = m_pluginList.begin();it != m_pluginList.end(); ++it)
- {
- if (it->load || it->alwaysLoad)
- {
- loadPlugin(&(*it));
-
- // restore config
- if (auto interface = qobject_cast<KTextEditor::SessionConfigInterface *> (it->plugin)) {
- KConfigGroup group (config, QString::fromLatin1("Plugin:%1:").arg(it->saveName()));
- interface->readSessionConfig (group);
- }
+ /**
+ * load plugins, some are always enforced to load!
+ */
+ for (KatePluginList::iterator it = m_pluginList.begin(); it != m_pluginList.end(); ++it) {
+ if (it->load || it->alwaysLoad) {
+ loadPlugin(&(*it));
+
+ // restore config
+ if (auto interface = qobject_cast<KTextEditor::SessionConfigInterface *> (it->plugin)) {
+ KConfigGroup group(config, QString::fromLatin1("Plugin:%1:").arg(it->saveName()));
+ interface->readSessionConfig(group);
+ }
+ }
}
- }
}
-void KatePluginManager::writeConfig(KConfig* config)
+void KatePluginManager::writeConfig(KConfig *config)
{
- Q_ASSERT( config );
+ Q_ASSERT(config);
- KConfigGroup cg = KConfigGroup( config, QStringLiteral("Kate Plugins") );
- foreach(const KatePluginInfo &plugin, m_pluginList)
- {
- QString saveName = plugin.saveName();
+ KConfigGroup cg = KConfigGroup(config, QStringLiteral("Kate Plugins"));
+ foreach(const KatePluginInfo & plugin, m_pluginList) {
+ QString saveName = plugin.saveName();
- cg.writeEntry (saveName, plugin.load);
+ cg.writeEntry(saveName, plugin.load);
- // save config
- if (auto interface = qobject_cast<KTextEditor::SessionConfigInterface *> (plugin.plugin)) {
- KConfigGroup group (config, QString::fromLatin1("Plugin:%1:").arg(saveName));
- interface->writeSessionConfig (group);
+ // save config
+ if (auto interface = qobject_cast<KTextEditor::SessionConfigInterface *> (plugin.plugin)) {
+ KConfigGroup group(config, QString::fromLatin1("Plugin:%1:").arg(saveName));
+ interface->writeSessionConfig(group);
+ }
}
- }
}
-void KatePluginManager::unloadAllPlugins ()
+void KatePluginManager::unloadAllPlugins()
{
- for (KatePluginList::iterator it = m_pluginList.begin();it != m_pluginList.end(); ++it)
- {
- if (it->plugin)
- unloadPlugin(&(*it));
- }
+ for (KatePluginList::iterator it = m_pluginList.begin(); it != m_pluginList.end(); ++it) {
+ if (it->plugin) {
+ unloadPlugin(&(*it));
+ }
+ }
}
-void KatePluginManager::enableAllPluginsGUI (KateMainWindow *win, KConfigBase *config)
+void KatePluginManager::enableAllPluginsGUI(KateMainWindow *win, KConfigBase *config)
{
- for (KatePluginList::iterator it = m_pluginList.begin();it != m_pluginList.end(); ++it)
- {
- if (it->plugin)
- enablePluginGUI(&(*it), win, config);
- }
+ for (KatePluginList::iterator it = m_pluginList.begin(); it != m_pluginList.end(); ++it) {
+ if (it->plugin) {
+ enablePluginGUI(&(*it), win, config);
+ }
+ }
}
-void KatePluginManager::disableAllPluginsGUI (KateMainWindow *win)
+void KatePluginManager::disableAllPluginsGUI(KateMainWindow *win)
{
- for (KatePluginList::iterator it = m_pluginList.begin();it != m_pluginList.end(); ++it)
- {
- if (it->plugin)
- disablePluginGUI(&(*it), win);
- }
+ for (KatePluginList::iterator it = m_pluginList.begin(); it != m_pluginList.end(); ++it) {
+ if (it->plugin) {
+ disablePluginGUI(&(*it), win);
+ }
+ }
}
-void KatePluginManager::loadPlugin (KatePluginInfo *item)
+void KatePluginManager::loadPlugin(KatePluginInfo *item)
{
- const QString pluginName = item->service->library();
- item->load = (item->plugin = item->service->createInstance<KTextEditor::Plugin>(this, QVariantList() << pluginName));
- if (item->plugin)
- emit KateApp::self ()->wrapper()->pluginCreated (pluginName, item->plugin);
+ const QString pluginName = item->service->library();
+ item->load = (item->plugin = item->service->createInstance<KTextEditor::Plugin>(this, QVariantList() << pluginName));
+ if (item->plugin) {
+ emit KateApp::self()->wrapper()->pluginCreated(pluginName, item->plugin);
+ }
}
-void KatePluginManager::unloadPlugin (KatePluginInfo *item)
+void KatePluginManager::unloadPlugin(KatePluginInfo *item)
{
- disablePluginGUI (item);
- delete item->plugin;
- KTextEditor::Plugin *plugin = item->plugin;
- item->plugin = 0L;
- item->load=false;
- emit KateApp::self ()->wrapper()->pluginDeleted (item->service->library(), plugin);
+ disablePluginGUI(item);
+ delete item->plugin;
+ KTextEditor::Plugin *plugin = item->plugin;
+ item->plugin = 0L;
+ item->load = false;
+ emit KateApp::self()->wrapper()->pluginDeleted(item->service->library(), plugin);
}
-void KatePluginManager::enablePluginGUI (KatePluginInfo *item, KateMainWindow *win, KConfigBase *config)
+void KatePluginManager::enablePluginGUI(KatePluginInfo *item, KateMainWindow *win, KConfigBase *config)
{
- // plugin around at all?
- if (!item->plugin)
- return;
-
- // lookup if there is already a view for it..
- QObject *createdView = nullptr;
- if (!win->pluginViews().contains(item->plugin))
- {
- // create the view + try to correctly load shortcuts, if it's a GUI Client
- createdView = item->plugin->createView(win->wrapper());
- if (createdView)
- win->pluginViews().insert (item->plugin, createdView);
- }
-
- // load session config if needed
- if (config && win->pluginViews().contains(item->plugin))
- {
- if (auto interface = qobject_cast<KTextEditor::SessionConfigInterface *> (win->pluginViews().value(item->plugin))) {
- KConfigGroup group (config, QString::fromLatin1("Plugin:%1:MainWindow:0").arg(item->saveName()));
- interface->readSessionConfig (group);
+ // plugin around at all?
+ if (!item->plugin) {
+ return;
+ }
+
+ // lookup if there is already a view for it..
+ QObject *createdView = nullptr;
+ if (!win->pluginViews().contains(item->plugin)) {
+ // create the view + try to correctly load shortcuts, if it's a GUI Client
+ createdView = item->plugin->createView(win->wrapper());
+ if (createdView) {
+ win->pluginViews().insert(item->plugin, createdView);
+ }
}
- }
- if (createdView)
- emit win->wrapper()->pluginViewCreated (item->service->library(), createdView);
+ // load session config if needed
+ if (config && win->pluginViews().contains(item->plugin)) {
+ if (auto interface = qobject_cast<KTextEditor::SessionConfigInterface *> (win->pluginViews().value(item->plugin))) {
+ KConfigGroup group(config, QString::fromLatin1("Plugin:%1:MainWindow:0").arg(item->saveName()));
+ interface->readSessionConfig(group);
+ }
+ }
+
+ if (createdView) {
+ emit win->wrapper()->pluginViewCreated(item->service->library(), createdView);
+ }
}
-void KatePluginManager::enablePluginGUI (KatePluginInfo *item)
+void KatePluginManager::enablePluginGUI(KatePluginInfo *item)
{
- // plugin around at all?
- if (!item->plugin)
- return;
+ // plugin around at all?
+ if (!item->plugin) {
+ return;
+ }
- // enable the gui for all mainwindows...
- for (int i = 0; i < KateApp::self()->mainWindowsCount(); i++)
- enablePluginGUI (item, KateApp::self()->mainWindow(i), 0);
+ // enable the gui for all mainwindows...
+ for (int i = 0; i < KateApp::self()->mainWindowsCount(); i++) {
+ enablePluginGUI(item, KateApp::self()->mainWindow(i), 0);
+ }
}
-void KatePluginManager::disablePluginGUI (KatePluginInfo *item, KateMainWindow *win)
+void KatePluginManager::disablePluginGUI(KatePluginInfo *item, KateMainWindow *win)
{
- // plugin around at all?
- if (!item->plugin)
- return;
-
- // lookup if there is a view for it..
- if (!win->pluginViews().contains(item->plugin))
- return;
-
- // really delete the view of this plugin
- QObject *deletedView = win->pluginViews().value(item->plugin);
- delete deletedView;
- win->pluginViews().remove (item->plugin);
- emit win->wrapper()->pluginViewDeleted (item->service->library(), deletedView);
+ // plugin around at all?
+ if (!item->plugin) {
+ return;
+ }
+
+ // lookup if there is a view for it..
+ if (!win->pluginViews().contains(item->plugin)) {
+ return;
+ }
+
+ // really delete the view of this plugin
+ QObject *deletedView = win->pluginViews().value(item->plugin);
+ delete deletedView;
+ win->pluginViews().remove(item->plugin);
+ emit win->wrapper()->pluginViewDeleted(item->service->library(), deletedView);
}
-void KatePluginManager::disablePluginGUI (KatePluginInfo *item)
+void KatePluginManager::disablePluginGUI(KatePluginInfo *item)
{
- // plugin around at all?
- if (!item->plugin)
- return;
+ // plugin around at all?
+ if (!item->plugin) {
+ return;
+ }
- // disable the gui for all mainwindows...
- for (int i = 0; i < KateApp::self()->mainWindowsCount(); i++)
- disablePluginGUI (item, KateApp::self()->mainWindow(i));
+ // disable the gui for all mainwindows...
+ for (int i = 0; i < KateApp::self()->mainWindowsCount(); i++) {
+ disablePluginGUI(item, KateApp::self()->mainWindow(i));
+ }
}
-KTextEditor::Plugin *KatePluginManager::plugin (const QString &name)
+KTextEditor::Plugin *KatePluginManager::plugin(const QString &name)
{
- /**
- * name known?
- */
- if (!m_name2Plugin.contains(name))
- return 0;
-
- /**
- * real plugin instance, if any ;)
- */
- return m_name2Plugin.value(name)->plugin;
+ /**
+ * name known?
+ */
+ if (!m_name2Plugin.contains(name)) {
+ return 0;
+ }
+
+ /**
+ * real plugin instance, if any ;)
+ */
+ return m_name2Plugin.value(name)->plugin;
}
-bool KatePluginManager::pluginAvailable (const QString &name)
+bool KatePluginManager::pluginAvailable(const QString &name)
{
- return m_name2Plugin.contains (name);
+ return m_name2Plugin.contains(name);
}
-class KTextEditor::Plugin *KatePluginManager::loadPlugin (const QString &name, bool permanent)
+class KTextEditor::Plugin *KatePluginManager::loadPlugin(const QString &name, bool permanent)
{
- /**
- * name known?
- */
- if (!m_name2Plugin.contains(name))
- return 0;
-
- /**
- * load, bail out on error
- */
- loadPlugin (m_name2Plugin.value(name));
- if (!m_name2Plugin.value(name)->plugin)
- return 0;
-
- /**
- * perhaps patch not load again back to "ok, load it once again on next loadConfig"
- */
- m_name2Plugin.value(name)->load = permanent;
- return m_name2Plugin.value(name)->plugin;
+ /**
+ * name known?
+ */
+ if (!m_name2Plugin.contains(name)) {
+ return 0;
+ }
+
+ /**
+ * load, bail out on error
+ */
+ loadPlugin(m_name2Plugin.value(name));
+ if (!m_name2Plugin.value(name)->plugin) {
+ return 0;
+ }
+
+ /**
+ * perhaps patch not load again back to "ok, load it once again on next loadConfig"
+ */
+ m_name2Plugin.value(name)->load = permanent;
+ return m_name2Plugin.value(name)->plugin;
}
-void KatePluginManager::unloadPlugin (const QString &name, bool permanent)
+void KatePluginManager::unloadPlugin(const QString &name, bool permanent)
{
- /**
- * name known?
- */
- if (!m_name2Plugin.contains(name))
- return;
-
- /**
- * unload
- */
- unloadPlugin (m_name2Plugin.value(name));
-
- /**
- * perhaps patch load again back to "ok, load it once again on next loadConfig"
- */
- m_name2Plugin.value(name)->load = !permanent;
-}
+ /**
+ * name known?
+ */
+ if (!m_name2Plugin.contains(name)) {
+ return;
+ }
-// kate: space-indent on; indent-width 2; replace-tabs on;
+ /**
+ * unload
+ */
+ unloadPlugin(m_name2Plugin.value(name));
+
+ /**
+ * perhaps patch load again back to "ok, load it once again on next loadConfig"
+ */
+ m_name2Plugin.value(name)->load = !permanent;
+}
diff --git a/kate/app/katepluginmanager.h b/kate/app/katepluginmanager.h
index 1dcf434..a5b14f5 100644
--- a/kate/app/katepluginmanager.h
+++ b/kate/app/katepluginmanager.h
@@ -2,7 +2,7 @@
Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org>
Copyright (C) 2001 Anders Lund <anders.lund@lund.tdcadsl.dk>
-
+
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
@@ -34,7 +34,7 @@ class KateMainWindow;
class KatePluginInfo
{
- public:
+public:
bool load;
bool alwaysLoad;
KService::Ptr service;
@@ -48,48 +48,47 @@ class KatePluginManager : public QObject
{
Q_OBJECT
- public:
+public:
KatePluginManager(QObject *parent);
~KatePluginManager();
static KatePluginManager *self();
- void unloadAllPlugins ();
+ void unloadAllPlugins();
- void enableAllPluginsGUI (KateMainWindow *win, KConfigBase *config = 0);
- void disableAllPluginsGUI (KateMainWindow *win);
+ void enableAllPluginsGUI(KateMainWindow *win, KConfigBase *config = 0);
+ void disableAllPluginsGUI(KateMainWindow *win);
- void loadConfig (KConfig*);
- void writeConfig (KConfig*);
+ void loadConfig(KConfig *);
+ void writeConfig(KConfig *);
- void loadPlugin (KatePluginInfo *item);
- void unloadPlugin (KatePluginInfo *item);
+ void loadPlugin(KatePluginInfo *item);
+ void unloadPlugin(KatePluginInfo *item);
- void enablePluginGUI (KatePluginInfo *item, KateMainWindow *win, KConfigBase *config = 0);
- void enablePluginGUI (KatePluginInfo *item);
+ void enablePluginGUI(KatePluginInfo *item, KateMainWindow *win, KConfigBase *config = 0);
+ void enablePluginGUI(KatePluginInfo *item);
- void disablePluginGUI (KatePluginInfo *item, KateMainWindow *win);
- void disablePluginGUI (KatePluginInfo *item);
+ void disablePluginGUI(KatePluginInfo *item, KateMainWindow *win);
+ void disablePluginGUI(KatePluginInfo *item);
- inline KatePluginList & pluginList ()
- {
- return m_pluginList;
+ inline KatePluginList &pluginList() {
+ return m_pluginList;
}
- KTextEditor::Plugin *plugin (const QString &name);
- bool pluginAvailable (const QString &name);
+ KTextEditor::Plugin *plugin(const QString &name);
+ bool pluginAvailable(const QString &name);
- KTextEditor::Plugin *loadPlugin (const QString &name, bool permanent = true);
- void unloadPlugin (const QString &name, bool permanent = true);
+ KTextEditor::Plugin *loadPlugin(const QString &name, bool permanent = true);
+ void unloadPlugin(const QString &name, bool permanent = true);
- private:
- void setupPluginList ();
+private:
+ void setupPluginList();
/**
* all known plugins
*/
KatePluginList m_pluginList;
-
+
/**
* fast access map from name => plugin info
* uses the info stored in the plugin list
@@ -98,5 +97,4 @@ class KatePluginManager : public QObject
};
#endif
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/app/katequickopen.cpp b/kate/app/katequickopen.cpp
index 5f1f117..37df39c 100644
--- a/kate/app/katequickopen.cpp
+++ b/kate/app/katequickopen.cpp
@@ -46,21 +46,21 @@
Q_DECLARE_METATYPE(QPointer<KTextEditor::Document>)
-const int DocumentRole=Qt::UserRole+1;
-const int UrlRole=Qt::UserRole+2;
-const int SortFilterRole=Qt::UserRole+3;
+const int DocumentRole = Qt::UserRole + 1;
+const int UrlRole = Qt::UserRole + 2;
+const int SortFilterRole = Qt::UserRole + 3;
KateQuickOpen::KateQuickOpen(QWidget *parent, KateMainWindow *mainWindow)
: QWidget(parent)
- , m_mainWindow (mainWindow)
+ , m_mainWindow(mainWindow)
{
QVBoxLayout *layout = new QVBoxLayout();
layout->setSpacing(0);
layout->setMargin(0);
- setLayout (layout);
+ setLayout(layout);
m_inputLine = new KLineEdit();
- setFocusProxy (m_inputLine);
+ setFocusProxy(m_inputLine);
m_inputLine->setPlaceholderText(i18n("Quick Open Search"));
layout->addWidget(m_inputLine);
@@ -79,8 +79,8 @@ KateQuickOpen::KateQuickOpen(QWidget *parent, KateMainWindow *mainWindow)
connect(m_inputLine, SIGNAL(textChanged(QString)), m_model, SLOT(setFilterFixedString(QString)));
connect(m_inputLine, SIGNAL(returnPressed()), this, SLOT(slotReturnPressed()));
- connect(m_model, SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(reselectFirst()));
- connect(m_model, SIGNAL(rowsRemoved(QModelIndex, int, int)), this, SLOT(reselectFirst()));
+ connect(m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(reselectFirst()));
+ connect(m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(reselectFirst()));
connect(m_listView, SIGNAL(activated(QModelIndex)), this, SLOT(slotReturnPressed()));
@@ -96,29 +96,29 @@ KateQuickOpen::KateQuickOpen(QWidget *parent, KateMainWindow *mainWindow)
bool KateQuickOpen::eventFilter(QObject *obj, QEvent *event)
{
if (event->type() == QEvent::KeyPress) {
- QKeyEvent *keyEvent=static_cast<QKeyEvent*>(event);
+ QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
if (obj == m_inputLine) {
const bool forward2list = (keyEvent->key() == Qt::Key_Up)
- || (keyEvent->key() == Qt::Key_Down)
- || (keyEvent->key() == Qt::Key_PageUp)
- || (keyEvent->key() == Qt::Key_PageDown);
+ || (keyEvent->key() == Qt::Key_Down)
+ || (keyEvent->key() == Qt::Key_PageUp)
+ || (keyEvent->key() == Qt::Key_PageDown);
if (forward2list) {
QCoreApplication::sendEvent(m_listView, event);
return true;
}
if (keyEvent->key() == Qt::Key_Escape) {
- m_mainWindow->slotWindowActivated ();
- m_inputLine->clear ();
- return true;
+ m_mainWindow->slotWindowActivated();
+ m_inputLine->clear();
+ return true;
}
} else {
const bool forward2input = (keyEvent->key() != Qt::Key_Up)
- && (keyEvent->key() != Qt::Key_Down)
- && (keyEvent->key() != Qt::Key_PageUp)
- && (keyEvent->key() != Qt::Key_PageDown)
- && (keyEvent->key() != Qt::Key_Tab)
- && (keyEvent->key() != Qt::Key_Backtab);
+ && (keyEvent->key() != Qt::Key_Down)
+ && (keyEvent->key() != Qt::Key_PageUp)
+ && (keyEvent->key() != Qt::Key_PageDown)
+ && (keyEvent->key() != Qt::Key_Tab)
+ && (keyEvent->key() != Qt::Key_Backtab);
if (forward2input) {
QCoreApplication::sendEvent(m_inputLine, event);
return true;
@@ -128,49 +128,51 @@ bool KateQuickOpen::eventFilter(QObject *obj, QEvent *event)
return QWidget::eventFilter(obj, event);
}
-void KateQuickOpen::reselectFirst() {
+void KateQuickOpen::reselectFirst()
+{
QModelIndex index = m_model->index(0, 0);
m_listView->setCurrentIndex(index);
}
-void KateQuickOpen::update ()
+void KateQuickOpen::update()
{
- /**
- * new base mode creation
- */
- QStandardItemModel *base_model = new QStandardItemModel(0, 2, this);
-
- /**
- * remember local file names to avoid dupes with project files
- */
- QSet<QString> alreadySeenFiles;
- QSet<KTextEditor::Document *> alreadySeenDocs;
-
- /**
- * get views in lru order
- */
- QMap<qint64, KTextEditor::View *> sortedViews;
- QHashIterator<KTextEditor::View *, qint64> i(m_mainWindow->viewManager()->lruViews());
- while (i.hasNext()) {
- i.next ();
- sortedViews[i.value()] = i.key();
- }
-
- /**
- * now insert them in order
- */
- QModelIndex idxToSelect;
- int linecount = 0;
- QMapIterator<qint64, KTextEditor::View *> i2(sortedViews);
- while (i2.hasNext()) {
+ /**
+ * new base mode creation
+ */
+ QStandardItemModel *base_model = new QStandardItemModel(0, 2, this);
+
+ /**
+ * remember local file names to avoid dupes with project files
+ */
+ QSet<QString> alreadySeenFiles;
+ QSet<KTextEditor::Document *> alreadySeenDocs;
+
+ /**
+ * get views in lru order
+ */
+ QMap<qint64, KTextEditor::View *> sortedViews;
+ QHashIterator<KTextEditor::View *, qint64> i(m_mainWindow->viewManager()->lruViews());
+ while (i.hasNext()) {
+ i.next();
+ sortedViews[i.value()] = i.key();
+ }
+
+ /**
+ * now insert them in order
+ */
+ QModelIndex idxToSelect;
+ int linecount = 0;
+ QMapIterator<qint64, KTextEditor::View *> i2(sortedViews);
+ while (i2.hasNext()) {
i2.next();
KTextEditor::Document *doc = i2.value()->document();
-
- if (alreadySeenDocs.contains(doc))
- continue;
-
- alreadySeenDocs.insert (doc);
+
+ if (alreadySeenDocs.contains(doc)) {
+ continue;
+ }
+
+ alreadySeenDocs.insert(doc);
//QStandardItem *item=new QStandardItem(i18n("%1: %2",doc->documentName(),doc->url().toString()));
QStandardItem *itemName = new QStandardItem(doc->documentName());
@@ -188,24 +190,27 @@ void KateQuickOpen::update ()
base_model->setItem(linecount, 1, itemUrl);
linecount++;
- if (!doc->url().isEmpty() && doc->url().isLocalFile())
- alreadySeenFiles.insert (doc->url().toLocalFile());
+ if (!doc->url().isEmpty() && doc->url().isLocalFile()) {
+ alreadySeenFiles.insert(doc->url().toLocalFile());
+ }
// select second document, that is the last used (beside the active one)
- if (linecount == 2)
- idxToSelect = itemName->index();
+ if (linecount == 2) {
+ idxToSelect = itemName->index();
+ }
}
- /**
- * get all open documents
- */
- QList<KTextEditor::Document*> docs = KateApp::self()->documentManager()->documentList();
- foreach(KTextEditor::Document *doc, docs) {
+ /**
+ * get all open documents
+ */
+ QList<KTextEditor::Document *> docs = KateApp::self()->documentManager()->documentList();
+ foreach(KTextEditor::Document * doc, docs) {
/**
* skip docs already open
*/
- if (alreadySeenDocs.contains (doc))
- continue;
+ if (alreadySeenDocs.contains(doc)) {
+ continue;
+ }
//QStandardItem *item=new QStandardItem(i18n("%1: %2",doc->documentName(),doc->url().toString()));
QStandardItem *itemName = new QStandardItem(doc->documentName());
@@ -223,51 +228,54 @@ void KateQuickOpen::update ()
base_model->setItem(linecount, 1, itemUrl);
linecount++;
- if (!doc->url().isEmpty() && doc->url().isLocalFile())
- alreadySeenFiles.insert (doc->url().toLocalFile());
+ if (!doc->url().isEmpty() && doc->url().isLocalFile()) {
+ alreadySeenFiles.insert(doc->url().toLocalFile());
+ }
}
/**
* insert all project files, if any project around
*/
- if (QObject *projectView = m_mainWindow->pluginView (QStringLiteral("kateprojectplugin"))) {
- QStringList projectFiles = projectView->property ("projectFiles").toStringList();
- foreach (const QString &file, projectFiles) {
- /**
- * skip files already open
- */
- if (alreadySeenFiles.contains (file))
- continue;
-
- QFileInfo fi (file);
- QStandardItem *itemName = new QStandardItem(fi.fileName());
-
- itemName->setData(qVariantFromValue(QUrl::fromLocalFile(file)), UrlRole);
- itemName->setData(QString::fromLatin1("%1: %2").arg(fi.fileName()).arg(file), SortFilterRole);
- itemName->setEditable(false);
- QFont font = itemName->font();
- font.setBold(true);
- itemName->setFont(font);
+ if (QObject *projectView = m_mainWindow->pluginView(QStringLiteral("kateprojectplugin"))) {
+ QStringList projectFiles = projectView->property("projectFiles").toStringList();
+ foreach(const QString & file, projectFiles) {
+ /**
+ * skip files already open
+ */
+ if (alreadySeenFiles.contains(file)) {
+ continue;
+ }
- QStandardItem *itemUrl = new QStandardItem(file);
- itemUrl->setEditable(false);
- base_model->setItem(linecount, 0, itemName);
- base_model->setItem(linecount, 1, itemUrl);
- linecount++;
- }
+ QFileInfo fi(file);
+ QStandardItem *itemName = new QStandardItem(fi.fileName());
+
+ itemName->setData(qVariantFromValue(QUrl::fromLocalFile(file)), UrlRole);
+ itemName->setData(QString::fromLatin1("%1: %2").arg(fi.fileName()).arg(file), SortFilterRole);
+ itemName->setEditable(false);
+ QFont font = itemName->font();
+ font.setBold(true);
+ itemName->setFont(font);
+
+ QStandardItem *itemUrl = new QStandardItem(file);
+ itemUrl->setEditable(false);
+ base_model->setItem(linecount, 0, itemName);
+ base_model->setItem(linecount, 1, itemUrl);
+ linecount++;
+ }
}
/**
* swap models and kill old one
*/
- m_model->setSourceModel (base_model);
+ m_model->setSourceModel(base_model);
delete m_base_model;
m_base_model = base_model;
- if(idxToSelect.isValid())
+ if (idxToSelect.isValid()) {
m_listView->setCurrentIndex(m_model->mapFromSource(idxToSelect));
- else
+ } else {
reselectFirst();
+ }
/**
* adjust view
@@ -275,24 +283,25 @@ void KateQuickOpen::update ()
m_listView->resizeColumnToContents(0);
}
-void KateQuickOpen::slotReturnPressed ()
+void KateQuickOpen::slotReturnPressed()
{
- /**
- * open document for first element, if possible
- * prefer to use the document pointer
- */
- KTextEditor::Document *doc = m_listView->currentIndex().data(DocumentRole).value<QPointer<KTextEditor::Document> >();
- if (doc) {
- m_mainWindow->wrapper()->activateView (doc);
- } else {
- QUrl url = m_listView->currentIndex().data(UrlRole).value<QUrl>();
- if (!url.isEmpty())
- m_mainWindow->wrapper()->openUrl (url);
- }
-
- /**
- * in any case, switch back to view manager
- */
- m_mainWindow->slotWindowActivated ();
- m_inputLine->clear ();
+ /**
+ * open document for first element, if possible
+ * prefer to use the document pointer
+ */
+ KTextEditor::Document *doc = m_listView->currentIndex().data(DocumentRole).value<QPointer<KTextEditor::Document> >();
+ if (doc) {
+ m_mainWindow->wrapper()->activateView(doc);
+ } else {
+ QUrl url = m_listView->currentIndex().data(UrlRole).value<QUrl>();
+ if (!url.isEmpty()) {
+ m_mainWindow->wrapper()->openUrl(url);
+ }
+ }
+
+ /**
+ * in any case, switch back to view manager
+ */
+ m_mainWindow->slotWindowActivated();
+ m_inputLine->clear();
}
diff --git a/kate/app/katequickopen.h b/kate/app/katequickopen.h
index b02cca3..2abcce0 100644
--- a/kate/app/katequickopen.h
+++ b/kate/app/katequickopen.h
@@ -30,42 +30,43 @@ class QStandardItemModel;
class QSortFilterProxyModel;
class QTreeView;
-class KateQuickOpen : public QWidget {
+class KateQuickOpen : public QWidget
+{
Q_OBJECT
- public:
- KateQuickOpen(QWidget *parent, KateMainWindow *mainWindow);
- /**
- * update state
- * will fill model with current open documents, project documents, ...
- */
- void update ();
+public:
+ KateQuickOpen(QWidget *parent, KateMainWindow *mainWindow);
+ /**
+ * update state
+ * will fill model with current open documents, project documents, ...
+ */
+ void update();
- protected:
- bool eventFilter(QObject *obj, QEvent *event);
+protected:
+ bool eventFilter(QObject *obj, QEvent *event);
- private Q_SLOTS:
- void reselectFirst();
+private Q_SLOTS:
+ void reselectFirst();
- /**
- * Return pressed, activate the selected document
- * and go back to background
- */
- void slotReturnPressed ();
+ /**
+ * Return pressed, activate the selected document
+ * and go back to background
+ */
+ void slotReturnPressed();
- private:
- KateMainWindow *m_mainWindow;
- QTreeView *m_listView;
- KLineEdit *m_inputLine;
+private:
+ KateMainWindow *m_mainWindow;
+ QTreeView *m_listView;
+ KLineEdit *m_inputLine;
- /**
- * our model we search in
- */
- QStandardItemModel *m_base_model;
+ /**
+ * our model we search in
+ */
+ QStandardItemModel *m_base_model;
- /**
- * filtered model we search in
- */
- QSortFilterProxyModel *m_model;
+ /**
+ * filtered model we search in
+ */
+ QSortFilterProxyModel *m_model;
};
#endif
diff --git a/kate/app/katerunninginstanceinfo.cpp b/kate/app/katerunninginstanceinfo.cpp
index 4846cff..5558bda 100644
--- a/kate/app/katerunninginstanceinfo.cpp
+++ b/kate/app/katerunninginstanceinfo.cpp
@@ -1,6 +1,6 @@
/* This file is part of the KDE project
-
- Copyright (C) 2009 Joseph Wenninger <jowenn@kde.org>
+
+ Copyright (C) 2009 Joseph Wenninger <jowenn@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -23,46 +23,48 @@
#include <QCoreApplication>
#include <QDBusConnectionInterface>
-int KateRunningInstanceInfo::dummy_session=0;
+int KateRunningInstanceInfo::dummy_session = 0;
bool fillinRunningKateAppInstances(KateRunningInstanceMap *map)
{
- QDBusConnectionInterface *i = QDBusConnection::sessionBus().interface ();
-
- // look up all running kate instances and there sessions
- QDBusReply<QStringList> servicesReply = i->registeredServiceNames ();
- QStringList services;
- if (servicesReply.isValid())
- services = servicesReply.value ();
+ QDBusConnectionInterface *i = QDBusConnection::sessionBus().interface();
+
+ // look up all running kate instances and there sessions
+ QDBusReply<QStringList> servicesReply = i->registeredServiceNames();
+ QStringList services;
+ if (servicesReply.isValid()) {
+ services = servicesReply.value();
+ }
- QString serviceName;
+ QString serviceName;
- QString my_pid = QString::number(QCoreApplication::applicationPid());
+ QString my_pid = QString::number(QCoreApplication::applicationPid());
- foreach (const QString &s, services)
- {
- if (s.startsWith (QStringLiteral("org.kde.kate-")))
- {
- if (s.contains(my_pid)) continue;
- KateRunningInstanceInfo* rii=new KateRunningInstanceInfo(s);
- if (rii->valid)
- {
- if (map->contains(rii->sessionName)) return false; //ERROR no two instances may have the same session name
- map->insert(rii->sessionName,rii);
- //std::cerr<<qPrintable(s)<<"running instance:"<< rii->sessionName.toUtf8().data()<<std::endl;
- } else delete rii;
+ foreach(const QString & s, services) {
+ if (s.startsWith(QStringLiteral("org.kde.kate-"))) {
+ if (s.contains(my_pid)) {
+ continue;
+ }
+ KateRunningInstanceInfo *rii = new KateRunningInstanceInfo(s);
+ if (rii->valid) {
+ if (map->contains(rii->sessionName)) {
+ return false; //ERROR no two instances may have the same session name
+ }
+ map->insert(rii->sessionName, rii);
+ //std::cerr<<qPrintable(s)<<"running instance:"<< rii->sessionName.toUtf8().data()<<std::endl;
+ } else {
+ delete rii;
+ }
+ }
}
- }
- return true;
+ return true;
}
-void cleanupRunningKateAppInstanceMap(KateRunningInstanceMap *map)
+void cleanupRunningKateAppInstanceMap(KateRunningInstanceMap *map)
{
- for(KateRunningInstanceMap::const_iterator it=map->constBegin();it!=map->constEnd();++it)
- {
- delete it.value();
- }
- map->clear();
+ for (KateRunningInstanceMap::const_iterator it = map->constBegin(); it != map->constEnd(); ++it) {
+ delete it.value();
+ }
+ map->clear();
}
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/app/katerunninginstanceinfo.h b/kate/app/katerunninginstanceinfo.h
index 07b5230..340fc7a 100644
--- a/kate/app/katerunninginstanceinfo.h
+++ b/kate/app/katerunninginstanceinfo.h
@@ -1,7 +1,7 @@
/* This file is part of the KDE project
-
- Copyright (C) 2009 Joseph Wenninger <jowenn@kde.org>
-
+
+ Copyright (C) 2009 Joseph Wenninger <jowenn@kde.org>
+
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
@@ -27,53 +27,52 @@
#include <QVariant>
#include <iostream>
-class KateRunningInstanceInfo: public QObject {
- Q_OBJECT
-
- public:
- KateRunningInstanceInfo(const QString& serviceName_):
- QObject(),valid(false),
- serviceName(serviceName_),
- dbus_if(new QDBusInterface(serviceName_,QStringLiteral("/MainApplication"),
- QString(), //I don't know why it does not work if I specify org.kde.Kate.Application here
- QDBusConnection::sessionBus(),this)) {
- if (!dbus_if->isValid()) {
- std::cerr<<qPrintable(QDBusConnection::sessionBus().lastError().message())<<std::endl;
- }
- QVariant a_s=dbus_if->property("activeSession");
-/* std::cerr<<a_s.isValid()<<std::endl;
- std::cerr<<"property:"<<qPrintable(a_s.toString())<<std::endl;
- std::cerr<<qPrintable(QDBusConnection::sessionBus().lastError().message())<<std::endl;*/
- if (!a_s.isValid()) {
- sessionName=QString::fromLatin1("___NO_SESSION_OPENED__%1").arg(dummy_session++);
- valid=false;
- }
- else {
- if (a_s.toString().isEmpty())
- sessionName=QString::fromLatin1("___DEFAULT_CONSTRUCTED_SESSION__%1").arg(dummy_session++);
- else
- sessionName=a_s.toString();
- valid=true;
- }
+class KateRunningInstanceInfo: public QObject
+{
+ Q_OBJECT
+
+public:
+ KateRunningInstanceInfo(const QString &serviceName_):
+ QObject(), valid(false),
+ serviceName(serviceName_),
+ dbus_if(new QDBusInterface(serviceName_, QStringLiteral("/MainApplication"),
+ QString(), //I don't know why it does not work if I specify org.kde.Kate.Application here
+ QDBusConnection::sessionBus(), this)) {
+ if (!dbus_if->isValid()) {
+ std::cerr << qPrintable(QDBusConnection::sessionBus().lastError().message()) << std::endl;
+ }
+ QVariant a_s = dbus_if->property("activeSession");
+ /* std::cerr<<a_s.isValid()<<std::endl;
+ std::cerr<<"property:"<<qPrintable(a_s.toString())<<std::endl;
+ std::cerr<<qPrintable(QDBusConnection::sessionBus().lastError().message())<<std::endl;*/
+ if (!a_s.isValid()) {
+ sessionName = QString::fromLatin1("___NO_SESSION_OPENED__%1").arg(dummy_session++);
+ valid = false;
+ } else {
+ if (a_s.toString().isEmpty()) {
+ sessionName = QString::fromLatin1("___DEFAULT_CONSTRUCTED_SESSION__%1").arg(dummy_session++);
+ } else {
+ sessionName = a_s.toString();
+ }
+ valid = true;
+ }
};
- virtual ~KateRunningInstanceInfo(){ delete dbus_if;}
+ virtual ~KateRunningInstanceInfo() {
+ delete dbus_if;
+ }
bool valid;
const QString serviceName;
- QDBusInterface* dbus_if;
+ QDBusInterface *dbus_if;
QString sessionName;
-
-
- private:
+
+private:
static int dummy_session;
};
-
-typedef QMap<QString, KateRunningInstanceInfo*> KateRunningInstanceMap;
-
+typedef QMap<QString, KateRunningInstanceInfo *> KateRunningInstanceMap;
Q_DECL_EXPORT bool fillinRunningKateAppInstances(KateRunningInstanceMap *map);
Q_DECL_EXPORT void cleanupRunningKateAppInstanceMap(KateRunningInstanceMap *map);
#endif
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/app/katesavemodifieddialog.cpp b/kate/app/katesavemodifieddialog.cpp
index 8978776..5d83a1e 100644
--- a/kate/app/katesavemodifieddialog.cpp
+++ b/kate/app/katesavemodifieddialog.cpp
@@ -34,264 +34,236 @@
class AbstractKateSaveModifiedDialogCheckListItem: public QTreeWidgetItem
{
- public:
- AbstractKateSaveModifiedDialogCheckListItem(const QString& title, const QString& url): QTreeWidgetItem()
- {
- setFlags(flags() | Qt::ItemIsUserCheckable);
- setText(0, title);
- setText(1, url);
- setCheckState(0, Qt::Checked);
- setState(InitialState);
+public:
+ AbstractKateSaveModifiedDialogCheckListItem(const QString &title, const QString &url): QTreeWidgetItem() {
+ setFlags(flags() | Qt::ItemIsUserCheckable);
+ setText(0, title);
+ setText(1, url);
+ setCheckState(0, Qt::Checked);
+ setState(InitialState);
}
virtual ~AbstractKateSaveModifiedDialogCheckListItem()
{}
virtual bool synchronousSave(QWidget *dialogParent) = 0;
- enum STATE{InitialState, SaveOKState, SaveFailedState};
- STATE state() const
- {
- return m_state;
+ enum STATE {InitialState, SaveOKState, SaveFailedState};
+ STATE state() const {
+ return m_state;
}
- void setState(enum STATE state)
- {
- m_state = state;
- KIconLoader *loader = KIconLoader::global();
- switch (state)
- {
+ void setState(enum STATE state) {
+ m_state = state;
+ KIconLoader *loader = KIconLoader::global();
+ switch (state) {
case InitialState:
- setIcon(0, QIcon());
- break;
+ setIcon(0, QIcon());
+ break;
case SaveOKState:
- setIcon(0, loader->loadIcon(QStringLiteral("dialog-ok"), KIconLoader::NoGroup,/*height()*/16));
- // QStringLiteral("ok") icon should probably be QStringLiteral("dialog-success"), but we don't have that icon in KDE 4.0
- break;
+ setIcon(0, loader->loadIcon(QStringLiteral("dialog-ok"), KIconLoader::NoGroup,/*height()*/16));
+ // QStringLiteral("ok") icon should probably be QStringLiteral("dialog-success"), but we don't have that icon in KDE 4.0
+ break;
case SaveFailedState:
- setIcon(0, loader->loadIcon(QStringLiteral("dialog-error"), KIconLoader::NoGroup,/*height()*/16));
- break;
- }
+ setIcon(0, loader->loadIcon(QStringLiteral("dialog-error"), KIconLoader::NoGroup,/*height()*/16));
+ break;
+ }
}
- private:
+private:
STATE m_state;
};
class KateSaveModifiedDocumentCheckListItem: public AbstractKateSaveModifiedDialogCheckListItem
{
- public:
+public:
KateSaveModifiedDocumentCheckListItem(KTextEditor::Document *document)
- : AbstractKateSaveModifiedDialogCheckListItem(document->documentName(), document->url().toString())
- {
- m_document = document;
+ : AbstractKateSaveModifiedDialogCheckListItem(document->documentName(), document->url().toString()) {
+ m_document = document;
}
virtual ~KateSaveModifiedDocumentCheckListItem()
{}
- virtual bool synchronousSave(QWidget *dialogParent)
- {
- if (m_document->url().isEmpty() )
- {
- KEncodingFileDialog::Result r = KEncodingFileDialog::getSaveUrlAndEncoding(
- m_document->encoding(), QUrl(), QString(), dialogParent, i18n("Save As (%1)", m_document->documentName()));
-
- if (!r.URLs.isEmpty())
- {
- QUrl tmp = r.URLs.first();
-
- // check for overwriting a file
- if( tmp.isLocalFile() )
- {
- QFileInfo info( tmp.path() );
- if( info.exists() ) {
- if (KMessageBox::Cancel == KMessageBox::warningContinueCancel( dialogParent,
- i18n( "A file named \"%1\" already exists. "
- "Are you sure you want to overwrite it?" , info.fileName() ),
- i18n( "Overwrite File?" ), KStandardGuiItem::overwrite(),
- KStandardGuiItem::cancel(), QString(), KMessageBox::Notify | KMessageBox::Dangerous ))
- {
- setState(SaveFailedState);
+ virtual bool synchronousSave(QWidget *dialogParent) {
+ if (m_document->url().isEmpty()) {
+ KEncodingFileDialog::Result r = KEncodingFileDialog::getSaveUrlAndEncoding(
+ m_document->encoding(), QUrl(), QString(), dialogParent, i18n("Save As (%1)", m_document->documentName()));
+
+ if (!r.URLs.isEmpty()) {
+ QUrl tmp = r.URLs.first();
+
+ // check for overwriting a file
+ if (tmp.isLocalFile()) {
+ QFileInfo info(tmp.path());
+ if (info.exists()) {
+ if (KMessageBox::Cancel == KMessageBox::warningContinueCancel(dialogParent,
+ i18n("A file named \"%1\" already exists. "
+ "Are you sure you want to overwrite it?" , info.fileName()),
+ i18n("Overwrite File?"), KStandardGuiItem::overwrite(),
+ KStandardGuiItem::cancel(), QString(), KMessageBox::Notify | KMessageBox::Dangerous)) {
+ setState(SaveFailedState);
+ return false;
+ }
+ }
+ }
+
+ m_document->setEncoding(r.encoding);
+
+ if (!m_document->saveAs(tmp)) {
+ setState(SaveFailedState);
+ setText(1, m_document->url().toString());
+ return false;
+ } else {
+ bool sc = m_document->waitSaveComplete();
+ setText(1, m_document->url().toString());
+ if (!sc) {
+ setState(SaveFailedState);
+ return false;
+ } else {
+ setState(SaveOKState);
+ return true;
+ }
+ }
+ } else {
+ //setState(SaveFailedState);
return false;
- }
- }
- }
-
- m_document->setEncoding( r.encoding );
-
- if ( !m_document->saveAs( tmp ) )
- {
- setState(SaveFailedState);
- setText(1, m_document->url().toString());
- return false;
- }
- else
- {
- bool sc = m_document->waitSaveComplete();
- setText(1, m_document->url().toString());
- if (!sc)
- {
- setState(SaveFailedState);
- return false;
}
- else
- {
- setState(SaveOKState);
- return true;
+ } else {
+ //document has an exising location
+ if (!m_document->save()) {
+ setState(SaveFailedState);
+ setText(1, m_document->url().toString());
+ return false;
+ } else {
+ bool sc = m_document->waitSaveComplete();
+ setText(1, m_document->url().toString());
+ if (!sc) {
+ setState(SaveFailedState);
+ return false;
+ } else {
+ setState(SaveOKState);
+ return true;
+ }
}
- }
- }
- else
- {
- //setState(SaveFailedState);
- return false;
- }
- }
- else
- { //document has an exising location
- if ( !m_document->save() )
- {
- setState(SaveFailedState);
- setText(1, m_document->url().toString());
- return false;
- }
- else
- {
- bool sc = m_document->waitSaveComplete();
- setText(1, m_document->url().toString());
- if (!sc)
- {
- setState(SaveFailedState);
- return false;
- }
- else
- {
- setState(SaveOKState);
- return true;
- }
- }
- }
+ }
- return false;
+ return false;
}
- private:
+private:
KTextEditor::Document *m_document;
};
-KateSaveModifiedDialog::KateSaveModifiedDialog(QWidget *parent, QList<KTextEditor::Document*> documents):
+KateSaveModifiedDialog::KateSaveModifiedDialog(QWidget *parent, QList<KTextEditor::Document *> documents):
QDialog(parent)
{
- setWindowTitle(i18n("Save Documents"));
- setObjectName(QStringLiteral("KateSaveModifiedDialog"));
- setModal(true);
-
- QVBoxLayout *mainLayout = new QVBoxLayout;
- setLayout(mainLayout);
-
- // label
- QLabel *lbl = new QLabel(i18n("<qt>The following documents have been modified. Do you want to save them before closing?</qt>"), this);
- mainLayout->addWidget(lbl);
-
- // main view
- m_list = new QTreeWidget(this);
- mainLayout->addWidget(m_list);
- m_list->setColumnCount(2);
- m_list->setHeaderLabels(QStringList() << i18n("Documents") << i18n("Location"));
- m_list->setRootIsDecorated(true);
-
- foreach (KTextEditor::Document* doc, documents) {
- m_list->addTopLevelItem(new KateSaveModifiedDocumentCheckListItem(doc));
- }
- m_list->resizeColumnToContents(0);
-
- connect(m_list, SIGNAL(itemChanged(QTreeWidgetItem*,int)), SLOT(slotItemActivated(QTreeWidgetItem*,int)));
-
- QPushButton *selectAllButton = new QPushButton(i18n("Se&lect All"), this);
- mainLayout->addWidget(selectAllButton);
- connect(selectAllButton, SIGNAL(clicked()), this, SLOT(slotSelectAll()));
-
- // dialog buttons
- QDialogButtonBox *buttons = new QDialogButtonBox(this);
- mainLayout->addWidget(buttons);
-
- m_saveButton = new QPushButton;
- KGuiItem::assign(m_saveButton, KStandardGuiItem::save());
- buttons->addButton(m_saveButton, QDialogButtonBox::YesRole);
- connect(m_saveButton, SIGNAL(clicked()), this, SLOT(slotSaveSelected()));
-
- QPushButton *discardButton = new QPushButton;
- KGuiItem::assign(discardButton, KStandardGuiItem::discard());
- buttons->addButton(discardButton, QDialogButtonBox::NoRole);
- connect(discardButton, SIGNAL(clicked()), this, SLOT(slotDoNotSave()));
-
- QPushButton *cancelButton = new QPushButton;
- KGuiItem::assign(cancelButton, KStandardGuiItem::cancel());
- cancelButton->setDefault(true);
- cancelButton->setFocus();
- buttons->addButton(cancelButton, QDialogButtonBox::RejectRole);
- connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
+ setWindowTitle(i18n("Save Documents"));
+ setObjectName(QStringLiteral("KateSaveModifiedDialog"));
+ setModal(true);
+
+ QVBoxLayout *mainLayout = new QVBoxLayout;
+ setLayout(mainLayout);
+
+ // label
+ QLabel *lbl = new QLabel(i18n("<qt>The following documents have been modified. Do you want to save them before closing?</qt>"), this);
+ mainLayout->addWidget(lbl);
+
+ // main view
+ m_list = new QTreeWidget(this);
+ mainLayout->addWidget(m_list);
+ m_list->setColumnCount(2);
+ m_list->setHeaderLabels(QStringList() << i18n("Documents") << i18n("Location"));
+ m_list->setRootIsDecorated(true);
+
+ foreach(KTextEditor::Document * doc, documents) {
+ m_list->addTopLevelItem(new KateSaveModifiedDocumentCheckListItem(doc));
+ }
+ m_list->resizeColumnToContents(0);
+
+ connect(m_list, SIGNAL(itemChanged(QTreeWidgetItem*,int)), SLOT(slotItemActivated(QTreeWidgetItem*,int)));
+
+ QPushButton *selectAllButton = new QPushButton(i18n("Se&lect All"), this);
+ mainLayout->addWidget(selectAllButton);
+ connect(selectAllButton, SIGNAL(clicked()), this, SLOT(slotSelectAll()));
+
+ // dialog buttons
+ QDialogButtonBox *buttons = new QDialogButtonBox(this);
+ mainLayout->addWidget(buttons);
+
+ m_saveButton = new QPushButton;
+ KGuiItem::assign(m_saveButton, KStandardGuiItem::save());
+ buttons->addButton(m_saveButton, QDialogButtonBox::YesRole);
+ connect(m_saveButton, SIGNAL(clicked()), this, SLOT(slotSaveSelected()));
+
+ QPushButton *discardButton = new QPushButton;
+ KGuiItem::assign(discardButton, KStandardGuiItem::discard());
+ buttons->addButton(discardButton, QDialogButtonBox::NoRole);
+ connect(discardButton, SIGNAL(clicked()), this, SLOT(slotDoNotSave()));
+
+ QPushButton *cancelButton = new QPushButton;
+ KGuiItem::assign(cancelButton, KStandardGuiItem::cancel());
+ cancelButton->setDefault(true);
+ cancelButton->setFocus();
+ buttons->addButton(cancelButton, QDialogButtonBox::RejectRole);
+ connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
}
KateSaveModifiedDialog::~KateSaveModifiedDialog()
{}
-void KateSaveModifiedDialog::slotItemActivated(QTreeWidgetItem*, int)
+void KateSaveModifiedDialog::slotItemActivated(QTreeWidgetItem *, int)
{
- bool enableSaveButton = false;
+ bool enableSaveButton = false;
- for (int i = 0; i < m_list->topLevelItemCount(); ++i) {
- if (m_list->topLevelItem(i)->checkState(0) == Qt::Checked) {
- enableSaveButton = true;
- break;
+ for (int i = 0; i < m_list->topLevelItemCount(); ++i) {
+ if (m_list->topLevelItem(i)->checkState(0) == Qt::Checked) {
+ enableSaveButton = true;
+ break;
+ }
}
- }
- m_saveButton->setEnabled(enableSaveButton);
+ m_saveButton->setEnabled(enableSaveButton);
}
void KateSaveModifiedDialog::slotSelectAll()
{
- for (int i = 0; i < m_list->topLevelItemCount(); ++i) {
- m_list->topLevelItem(i)->setCheckState(0, Qt::Checked);
- }
+ for (int i = 0; i < m_list->topLevelItemCount(); ++i) {
+ m_list->topLevelItem(i)->setCheckState(0, Qt::Checked);
+ }
- m_saveButton->setEnabled(true);
+ m_saveButton->setEnabled(true);
}
-
void KateSaveModifiedDialog::slotSaveSelected()
{
- if (doSave()) done(QDialog::Accepted);
+ if (doSave()) {
+ done(QDialog::Accepted);
+ }
}
void KateSaveModifiedDialog::slotDoNotSave()
{
- done(QDialog::Accepted);
+ done(QDialog::Accepted);
}
bool KateSaveModifiedDialog::doSave()
{
- for (int i = 0; i < m_list->topLevelItemCount(); ++i) {
- AbstractKateSaveModifiedDialogCheckListItem * cit = static_cast<AbstractKateSaveModifiedDialogCheckListItem*>(m_list->topLevelItem(i));
-
- if (cit->checkState(0) == Qt::Checked && (cit->state() != AbstractKateSaveModifiedDialogCheckListItem::SaveOKState))
- {
- if (!cit->synchronousSave(this /*perhaps that should be the kate mainwindow*/))
- {
- if (cit->state()==AbstractKateSaveModifiedDialogCheckListItem::SaveFailedState)
- KMessageBox::sorry( this, i18n("Data you requested to be saved could not be written. Please choose how you want to proceed."));
- return false;
- }
- }
- else if ((cit->checkState(0) != Qt::Checked) && (cit->state() == AbstractKateSaveModifiedDialogCheckListItem::SaveFailedState))
- {
- cit->setState(AbstractKateSaveModifiedDialogCheckListItem::InitialState);
+ for (int i = 0; i < m_list->topLevelItemCount(); ++i) {
+ AbstractKateSaveModifiedDialogCheckListItem *cit = static_cast<AbstractKateSaveModifiedDialogCheckListItem *>(m_list->topLevelItem(i));
+
+ if (cit->checkState(0) == Qt::Checked && (cit->state() != AbstractKateSaveModifiedDialogCheckListItem::SaveOKState)) {
+ if (!cit->synchronousSave(this /*perhaps that should be the kate mainwindow*/)) {
+ if (cit->state() == AbstractKateSaveModifiedDialogCheckListItem::SaveFailedState) {
+ KMessageBox::sorry(this, i18n("Data you requested to be saved could not be written. Please choose how you want to proceed."));
+ }
+ return false;
+ }
+ } else if ((cit->checkState(0) != Qt::Checked) && (cit->state() == AbstractKateSaveModifiedDialogCheckListItem::SaveFailedState)) {
+ cit->setState(AbstractKateSaveModifiedDialogCheckListItem::InitialState);
+ }
}
- }
- return true;
+ return true;
}
-bool KateSaveModifiedDialog::queryClose(QWidget *parent, QList<KTextEditor::Document*> documents)
+bool KateSaveModifiedDialog::queryClose(QWidget *parent, QList<KTextEditor::Document *> documents)
{
- KateSaveModifiedDialog d(parent, documents);
- return (d.exec() != QDialog::Rejected);
+ KateSaveModifiedDialog d(parent, documents);
+ return (d.exec() != QDialog::Rejected);
}
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/app/katesavemodifieddialog.h b/kate/app/katesavemodifieddialog.h
index daa3b16..5bccdb2 100644
--- a/kate/app/katesavemodifieddialog.h
+++ b/kate/app/katesavemodifieddialog.h
@@ -32,24 +32,23 @@ class QPushButton;
class KateSaveModifiedDialog: public QDialog
{
Q_OBJECT
- public:
- KateSaveModifiedDialog(QWidget *parent, QList<KTextEditor::Document*> documents);
+public:
+ KateSaveModifiedDialog(QWidget *parent, QList<KTextEditor::Document *> documents);
virtual ~KateSaveModifiedDialog();
- static bool queryClose(QWidget *parent, QList<KTextEditor::Document*> documents);
- protected:
+ static bool queryClose(QWidget *parent, QList<KTextEditor::Document *> documents);
+protected:
bool doSave();
- protected Q_SLOTS:
+protected Q_SLOTS:
void slotSelectAll();
- void slotItemActivated(QTreeWidgetItem*, int);
+ void slotItemActivated(QTreeWidgetItem *, int);
void slotSaveSelected();
void slotDoNotSave();
- private:
+private:
QTreeWidgetItem *m_documentRoot;
QTreeWidget *m_list;
QPushButton *m_saveButton;
};
#endif
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/app/katetabbar.cpp b/kate/app/katetabbar.cpp
index e4b3618..c3811fb 100644
--- a/kate/app/katetabbar.cpp
+++ b/kate/app/katetabbar.cpp
@@ -260,14 +260,14 @@ int KateTabBar::addTab(const QIcon &icon, const QString &text)
m_tabButtons.append(tabButton);
m_IDToTabButton[m_nextID] = tabButton;
- connect(tabButton, SIGNAL(activated(KateTabButton *)),
- this, SLOT(tabButtonActivated(KateTabButton *)));
- connect(tabButton, SIGNAL(highlightChanged(KateTabButton *)),
- this, SLOT(tabButtonHighlightChanged(KateTabButton *)));
- connect(tabButton, SIGNAL(closeRequest(KateTabButton *)),
- this, SLOT(tabButtonCloseRequest(KateTabButton *)));
- connect(tabButton, SIGNAL(closeOtherTabsRequest(KateTabButton *)),
- this, SLOT(tabButtonCloseOtherRequest(KateTabButton *)));
+ connect(tabButton, SIGNAL(activated(KateTabButton*)),
+ this, SLOT(tabButtonActivated(KateTabButton*)));
+ connect(tabButton, SIGNAL(highlightChanged(KateTabButton*)),
+ this, SLOT(tabButtonHighlightChanged(KateTabButton*)));
+ connect(tabButton, SIGNAL(closeRequest(KateTabButton*)),
+ this, SLOT(tabButtonCloseRequest(KateTabButton*)));
+ connect(tabButton, SIGNAL(closeOtherTabsRequest(KateTabButton*)),
+ this, SLOT(tabButtonCloseOtherRequest(KateTabButton*)));
connect(tabButton, SIGNAL(closeAllTabsRequest()),
this, SLOT(tabButtonCloseAllRequest()));
@@ -431,7 +431,6 @@ QString KateTabBar::tabToolTip(int index) const
return QString();
}
-
/**
* Sets the icon of the tab with ID \a index to \a icon.
* \see tabIcon()
@@ -692,4 +691,3 @@ void KateTabBar::triggerResizeEvent()
QApplication::sendEvent(this, &ev);
}
-// kate: space-indent on; indent-width 4; tab-width 4; replace-tabs on; eol unix;
diff --git a/kate/app/katetabbar.h b/kate/app/katetabbar.h
index 5ec0336..6577b2c 100644
--- a/kate/app/katetabbar.h
+++ b/kate/app/katetabbar.h
@@ -160,4 +160,3 @@ private:
#endif // KATE_TAB_BAR_H
-// kate: space-indent on; indent-width 4; tab-width 4; replace-tabs on; eol unix;
diff --git a/kate/app/katetabbutton.cpp b/kate/app/katetabbutton.cpp
index e20d527..c727706 100644
--- a/kate/app/katetabbutton.cpp
+++ b/kate/app/katetabbutton.cpp
@@ -35,7 +35,6 @@ QColor KateTabButton::s_predefinedColors[] = { Qt::red, Qt::yellow, Qt::green, Q
const int KateTabButton::s_colorCount = 6;
int KateTabButton::s_currentColor = 0;
-
KateTabButton::KateTabButton(const QString &caption,
int button_id, QWidget *parent)
: QPushButton(parent)
@@ -232,4 +231,3 @@ bool KateTabButton::isModified() const
return m_modified;
}
-// kate: space-indent on; indent-width 4; tab-width 4; replace-tabs on; eol unix;
diff --git a/kate/app/katetabbutton.h b/kate/app/katetabbutton.h
index beedda5..1cd307f 100644
--- a/kate/app/katetabbutton.h
+++ b/kate/app/katetabbutton.h
@@ -128,7 +128,6 @@ protected:
/** middle mouse button changes color */
virtual void mousePressEvent(QMouseEvent *ev);
-
private:
int m_buttonId;
bool m_modified;
@@ -142,4 +141,3 @@ private:
#endif
-// kate: space-indent on; indent-width 4; tab-width 4; replace-tabs on; eol unix;
diff --git a/kate/app/kateviewmanager.cpp b/kate/app/kateviewmanager.cpp
index 86df415..5e67601 100644
--- a/kate/app/kateviewmanager.cpp
+++ b/kate/app/kateviewmanager.cpp
@@ -60,966 +60,1005 @@
static const qint64 FileSizeAboveToAskUserIfProceedWithOpen = 10 * 1024 * 1024; // 10MB should suffice
-KateViewManager::KateViewManager (QWidget *parentW, KateMainWindow *parent)
- : QSplitter (parentW)
+KateViewManager::KateViewManager(QWidget *parentW, KateMainWindow *parent)
+ : QSplitter(parentW)
, m_mainWindow(parent)
- , m_blockViewCreationAndActivation (false)
- , m_activeViewRunning (false)
- , m_minAge (0)
+ , m_blockViewCreationAndActivation(false)
+ , m_activeViewRunning(false)
+ , m_minAge(0)
{
- // while init
- m_init = true;
+ // while init
+ m_init = true;
- // important, set them up, as we use them in other methodes
- setupActions ();
+ // important, set them up, as we use them in other methodes
+ setupActions();
- guiMergedView = 0;
+ guiMergedView = 0;
- // resize mode
- setOpaqueResize(style()->styleHint(QStyle::SH_Splitter_OpaqueResize, 0, this));
+ // resize mode
+ setOpaqueResize(style()->styleHint(QStyle::SH_Splitter_OpaqueResize, 0, this));
- KateViewSpace* vs = new KateViewSpace( this, 0 );
- addWidget (vs);
+ KateViewSpace *vs = new KateViewSpace(this, 0);
+ addWidget(vs);
- vs->setActive( true );
- m_viewSpaceList.append(vs);
+ vs->setActive(true);
+ m_viewSpaceList.append(vs);
- connect( this, SIGNAL(viewChanged(KTextEditor::View*)), this, SLOT(slotViewChanged()) );
+ connect(this, SIGNAL(viewChanged(KTextEditor::View*)), this, SLOT(slotViewChanged()));
- connect(KateDocManager::self(), SIGNAL(documentCreatedViewManager(KTextEditor::Document*)), this, SLOT(documentCreated(KTextEditor::Document*)));
- connect(KateDocManager::self(), SIGNAL(documentDeleted(KTextEditor::Document*)), this, SLOT(documentDeleted(KTextEditor::Document*)));
+ connect(KateDocManager::self(), SIGNAL(documentCreatedViewManager(KTextEditor::Document*)), this, SLOT(documentCreated(KTextEditor::Document*)));
+ connect(KateDocManager::self(), SIGNAL(documentDeleted(KTextEditor::Document*)), this, SLOT(documentDeleted(KTextEditor::Document*)));
- // register all already existing documents
- m_blockViewCreationAndActivation = true;
- const QList<KTextEditor::Document*> &docs = KateDocManager::self()->documentList ();
- foreach (KTextEditor::Document *doc, docs)
- documentCreated (doc);
- m_blockViewCreationAndActivation = false;
+ // register all already existing documents
+ m_blockViewCreationAndActivation = true;
+ const QList<KTextEditor::Document *> &docs = KateDocManager::self()->documentList();
+ foreach(KTextEditor::Document * doc, docs)
+ documentCreated(doc);
+ m_blockViewCreationAndActivation = false;
- // init done
- m_init = false;
+ // init done
+ m_init = false;
}
-KateViewManager::~KateViewManager ()
+KateViewManager::~KateViewManager()
{
- // make sure all xml gui clients are removed to avoid warnings on exit
- Q_FOREACH (KTextEditor::View* view, m_viewList)
+ // make sure all xml gui clients are removed to avoid warnings on exit
+ Q_FOREACH(KTextEditor::View * view, m_viewList)
mainWindow()->guiFactory()->removeClient(view);
}
-void KateViewManager::setupActions ()
+void KateViewManager::setupActions()
{
- /**
- * view splitting
- */
- QAction *a = m_mainWindow->actionCollection()->addAction(QStringLiteral("view_split_vert"));
- a->setIcon( QIcon::fromTheme(QStringLiteral("view-split-left-right")) );
- a->setText( i18n("Split Ve&rtical") );
- a->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_L );
- connect(a, SIGNAL(triggered()), this, SLOT(slotSplitViewSpaceVert()));
+ /**
+ * view splitting
+ */
+ QAction *a = m_mainWindow->actionCollection()->addAction(QStringLiteral("view_split_vert"));
+ a->setIcon(QIcon::fromTheme(QStringLiteral("view-split-left-right")));
+ a->setText(i18n("Split Ve&rtical"));
+ a->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_L);
+ connect(a, SIGNAL(triggered()), this, SLOT(slotSplitViewSpaceVert()));
- a->setWhatsThis(i18n("Split the currently active view vertically into two views."));
+ a->setWhatsThis(i18n("Split the currently active view vertically into two views."));
- a = m_mainWindow->actionCollection()->addAction(QStringLiteral("view_split_horiz"));
- a->setIcon( QIcon::fromTheme(QStringLiteral("view-split-top-bottom")) );
- a->setText( i18n("Split &Horizontal") );
- a->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_T );
- connect(a, SIGNAL(triggered()), this, SLOT(slotSplitViewSpaceHoriz()));
+ a = m_mainWindow->actionCollection()->addAction(QStringLiteral("view_split_horiz"));
+ a->setIcon(QIcon::fromTheme(QStringLiteral("view-split-top-bottom")));
+ a->setText(i18n("Split &Horizontal"));
+ a->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_T);
+ connect(a, SIGNAL(triggered()), this, SLOT(slotSplitViewSpaceHoriz()));
- a->setWhatsThis(i18n("Split the currently active view horizontally into two views."));
+ a->setWhatsThis(i18n("Split the currently active view horizontally into two views."));
- m_closeView = m_mainWindow->actionCollection()->addAction(QStringLiteral("view_close_current_space"));
- m_closeView->setIcon( QIcon::fromTheme(QStringLiteral("view-close")) );
- m_closeView->setText( i18n("Cl&ose Current View") );
- m_closeView->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_R );
- connect(m_closeView, SIGNAL(triggered()), this, SLOT(slotCloseCurrentViewSpace()), Qt::QueuedConnection);
+ m_closeView = m_mainWindow->actionCollection()->addAction(QStringLiteral("view_close_current_space"));
+ m_closeView->setIcon(QIcon::fromTheme(QStringLiteral("view-close")));
+ m_closeView->setText(i18n("Cl&ose Current View"));
+ m_closeView->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_R);
+ connect(m_closeView, SIGNAL(triggered()), this, SLOT(slotCloseCurrentViewSpace()), Qt::QueuedConnection);
- m_closeView->setWhatsThis(i18n("Close the currently active split view"));
+ m_closeView->setWhatsThis(i18n("Close the currently active split view"));
- m_closeOtherViews = m_mainWindow->actionCollection()->addAction(QStringLiteral("view_close_others"));
- m_closeOtherViews->setIcon(QIcon::fromTheme(QStringLiteral("view-close")));
- m_closeOtherViews->setText(i18n("Close Inactive Views"));
- connect(m_closeOtherViews, SIGNAL(triggered()), this, SLOT(slotCloseOtherViews()), Qt::QueuedConnection);
+ m_closeOtherViews = m_mainWindow->actionCollection()->addAction(QStringLiteral("view_close_others"));
+ m_closeOtherViews->setIcon(QIcon::fromTheme(QStringLiteral("view-close")));
+ m_closeOtherViews->setText(i18n("Close Inactive Views"));
+ connect(m_closeOtherViews, SIGNAL(triggered()), this, SLOT(slotCloseOtherViews()), Qt::QueuedConnection);
- m_closeOtherViews->setWhatsThis(i18n("Close every view but the active one"));
+ m_closeOtherViews->setWhatsThis(i18n("Close every view but the active one"));
- goNext = m_mainWindow->actionCollection()->addAction( QStringLiteral("go_next_split_view") );
- goNext->setText( i18n("Next Split View") );
- goNext->setShortcut( Qt::Key_F8 );
- connect(goNext, SIGNAL(triggered()), this, SLOT(activateNextView()));
+ goNext = m_mainWindow->actionCollection()->addAction(QStringLiteral("go_next_split_view"));
+ goNext->setText(i18n("Next Split View"));
+ goNext->setShortcut(Qt::Key_F8);
+ connect(goNext, SIGNAL(triggered()), this, SLOT(activateNextView()));
- goNext->setWhatsThis(i18n("Make the next split view the active one."));
+ goNext->setWhatsThis(i18n("Make the next split view the active one."));
- goPrev = m_mainWindow->actionCollection()->addAction( QStringLiteral("go_prev_split_view") );
- goPrev->setText( i18n("Previous Split View") );
- goPrev->setShortcut( Qt::SHIFT + Qt::Key_F8 );
- connect(goPrev, SIGNAL(triggered()), this, SLOT(activatePrevView()));
+ goPrev = m_mainWindow->actionCollection()->addAction(QStringLiteral("go_prev_split_view"));
+ goPrev->setText(i18n("Previous Split View"));
+ goPrev->setShortcut(Qt::SHIFT + Qt::Key_F8);
+ connect(goPrev, SIGNAL(triggered()), this, SLOT(activatePrevView()));
- goPrev->setWhatsThis(i18n("Make the previous split view the active one."));
+ goPrev->setWhatsThis(i18n("Make the previous split view the active one."));
- a = m_mainWindow->actionCollection()->addAction(QStringLiteral("view_split_move_right"));
- a->setText( i18n("Move Splitter Right") );
- connect(a, SIGNAL(triggered()), this, SLOT(moveSplitterRight()));
+ a = m_mainWindow->actionCollection()->addAction(QStringLiteral("view_split_move_right"));
+ a->setText(i18n("Move Splitter Right"));
+ connect(a, SIGNAL(triggered()), this, SLOT(moveSplitterRight()));
- a->setWhatsThis(i18n("Move the splitter of the current view to the right"));
+ a->setWhatsThis(i18n("Move the splitter of the current view to the right"));
- a = m_mainWindow->actionCollection()->addAction(QStringLiteral("view_split_move_left"));
- a->setText( i18n("Move Splitter Left") );
- connect(a, SIGNAL(triggered()), this, SLOT(moveSplitterLeft()));
+ a = m_mainWindow->actionCollection()->addAction(QStringLiteral("view_split_move_left"));
+ a->setText(i18n("Move Splitter Left"));
+ connect(a, SIGNAL(triggered()), this, SLOT(moveSplitterLeft()));
- a->setWhatsThis(i18n("Move the splitter of the current view to the left"));
+ a->setWhatsThis(i18n("Move the splitter of the current view to the left"));
- a = m_mainWindow->actionCollection()->addAction(QStringLiteral("view_split_move_up"));
- a->setText( i18n("Move Splitter Up") );
- connect(a, SIGNAL(triggered()), this, SLOT(moveSplitterUp()));
+ a = m_mainWindow->actionCollection()->addAction(QStringLiteral("view_split_move_up"));
+ a->setText(i18n("Move Splitter Up"));
+ connect(a, SIGNAL(triggered()), this, SLOT(moveSplitterUp()));
- a->setWhatsThis(i18n("Move the splitter of the current view up"));
+ a->setWhatsThis(i18n("Move the splitter of the current view up"));
- a = m_mainWindow->actionCollection()->addAction(QStringLiteral("view_split_move_down"));
- a->setText( i18n("Move Splitter Down") );
- connect(a, SIGNAL(triggered()), this, SLOT(moveSplitterDown()));
+ a = m_mainWindow->actionCollection()->addAction(QStringLiteral("view_split_move_down"));
+ a->setText(i18n("Move Splitter Down"));
+ connect(a, SIGNAL(triggered()), this, SLOT(moveSplitterDown()));
- a->setWhatsThis(i18n("Move the splitter of the current view down"));
+ a->setWhatsThis(i18n("Move the splitter of the current view down"));
}
-void KateViewManager::updateViewSpaceActions ()
+void KateViewManager::updateViewSpaceActions()
{
- m_closeView->setEnabled (viewSpaceCount() > 1);
- m_closeOtherViews->setEnabled(viewSpaceCount() > 1);
- goNext->setEnabled (viewSpaceCount() > 1);
- goPrev->setEnabled (viewSpaceCount() > 1);
+ m_closeView->setEnabled(viewSpaceCount() > 1);
+ m_closeOtherViews->setEnabled(viewSpaceCount() > 1);
+ goNext->setEnabled(viewSpaceCount() > 1);
+ goPrev->setEnabled(viewSpaceCount() > 1);
}
-void KateViewManager::setViewActivationBlocked (bool block)
+void KateViewManager::setViewActivationBlocked(bool block)
{
- m_blockViewCreationAndActivation = block;
+ m_blockViewCreationAndActivation = block;
}
-void KateViewManager::slotDocumentNew ()
+void KateViewManager::slotDocumentNew()
{
- createView ();
+ createView();
}
-void KateViewManager::slotDocumentOpen ()
+void KateViewManager::slotDocumentOpen()
{
- KTextEditor::View *cv = activeView();
- if (!cv)
- return;
+ KTextEditor::View *cv = activeView();
+ if (!cv) {
+ return;
+ }
- KEncodingFileDialog::Result r = KEncodingFileDialog::getOpenUrlsAndEncoding(
- KTextEditor::Editor::instance()->defaultEncoding(),
- cv->document()->url(),
- QString(), m_mainWindow, i18n("Open File"));
+ KEncodingFileDialog::Result r = KEncodingFileDialog::getOpenUrlsAndEncoding(
+ KTextEditor::Editor::instance()->defaultEncoding(),
+ cv->document()->url(),
+ QString(), m_mainWindow, i18n("Open File"));
- KateDocumentInfo docInfo;
- docInfo.openedByUser = true;
+ KateDocumentInfo docInfo;
+ docInfo.openedByUser = true;
- QString fileList;
+ QString fileList;
- foreach ( const QUrl &url, r.URLs )
- {
- qint64 size = QFile( url.toLocalFile() ).size();
+ foreach(const QUrl & url, r.URLs) {
+ qint64 size = QFile(url.toLocalFile()).size();
- if ( size > FileSizeAboveToAskUserIfProceedWithOpen )
- {
- fileList += QString::fromLatin1("<li>%1 (%2MB)</li>").arg( url.fileName() ).arg( size / 1024 / 1024 );
+ if (size > FileSizeAboveToAskUserIfProceedWithOpen) {
+ fileList += QString::fromLatin1("<li>%1 (%2MB)</li>").arg(url.fileName()).arg(size / 1024 / 1024);
+ }
}
- }
- if ( !fileList.isEmpty() )
- {
- QString text = i18n( "<p>You are attempting to open one or more large files:</p><ul>%1</ul><p>Do you want to proceed?</p><p><strong>Beware that kate may stop responding for some time when opening large files.</strong></p>" );
+ if (!fileList.isEmpty()) {
+ QString text = i18n("<p>You are attempting to open one or more large files:</p><ul>%1</ul><p>Do you want to proceed?</p><p><strong>Beware that kate may stop responding for some time when opening large files.</strong></p>");
- int ret = KMessageBox::warningYesNo( this, text.arg( fileList ), i18n("Opening Large File"), KStandardGuiItem::cont(), KStandardGuiItem::stop() );
- if ( ret == KMessageBox::No )
- return;
- }
+ int ret = KMessageBox::warningYesNo(this, text.arg(fileList), i18n("Opening Large File"), KStandardGuiItem::cont(), KStandardGuiItem::stop());
+ if (ret == KMessageBox::No) {
+ return;
+ }
+ }
- KTextEditor::Document *lastID = openUrls(r.URLs, r.encoding, false, docInfo);
+ KTextEditor::Document *lastID = openUrls(r.URLs, r.encoding, false, docInfo);
- if (lastID)
- activateView (lastID);
+ if (lastID) {
+ activateView(lastID);
+ }
}
-void KateViewManager::slotDocumentClose(KTextEditor::Document *document) {
+void KateViewManager::slotDocumentClose(KTextEditor::Document *document)
+{
// prevent close document if only one view alive and the document of
- // it is not modified and empty !!!
- if ( (KateDocManager::self()->documents() == 1)
- && !document->isModified()
- && document->url().isEmpty()
- && document->documentEnd() == KTextEditor::Cursor::start() )
- {
- document->closeUrl();
- return;
- }
-
- // close document
- KateDocManager::self()->closeDocument (document);
-}
+ // it is not modified and empty !!!
+ if ((KateDocManager::self()->documents() == 1)
+ && !document->isModified()
+ && document->url().isEmpty()
+ && document->documentEnd() == KTextEditor::Cursor::start()) {
+ document->closeUrl();
+ return;
+ }
+ // close document
+ KateDocManager::self()->closeDocument(document);
+}
-void KateViewManager::slotDocumentClose ()
+void KateViewManager::slotDocumentClose()
{
- // no active view, do nothing
- if (!activeView()) return;
-
- slotDocumentClose(activeView()->document());
+ // no active view, do nothing
+ if (!activeView()) {
+ return;
+ }
+ slotDocumentClose(activeView()->document());
}
-KTextEditor::Document *KateViewManager::openUrl (const QUrl &url,
- const QString& encoding,
- bool activate,
- bool isTempFile,
- const KateDocumentInfo& docInfo)
+KTextEditor::Document *KateViewManager::openUrl(const QUrl &url,
+ const QString &encoding,
+ bool activate,
+ bool isTempFile,
+ const KateDocumentInfo &docInfo)
{
- KTextEditor::Document *doc = KateDocManager::self()->openUrl (url, encoding, isTempFile, docInfo);
+ KTextEditor::Document *doc = KateDocManager::self()->openUrl(url, encoding, isTempFile, docInfo);
- if (!doc->url().isEmpty())
- m_mainWindow->fileOpenRecent()->addUrl( doc->url() );
+ if (!doc->url().isEmpty()) {
+ m_mainWindow->fileOpenRecent()->addUrl(doc->url());
+ }
- if (activate)
- activateView( doc );
+ if (activate) {
+ activateView(doc);
+ }
- return doc;
+ return doc;
}
-KTextEditor::Document *KateViewManager::openUrls (const QList<QUrl> &urls,
- const QString& encoding,
- bool isTempFile,
- const KateDocumentInfo& docInfo)
+KTextEditor::Document *KateViewManager::openUrls(const QList<QUrl> &urls,
+ const QString &encoding,
+ bool isTempFile,
+ const KateDocumentInfo &docInfo)
{
- QList<KTextEditor::Document *> docs = KateDocManager::self()->openUrls(urls, encoding, isTempFile, docInfo);
+ QList<KTextEditor::Document *> docs = KateDocManager::self()->openUrls(urls, encoding, isTempFile, docInfo);
- foreach (const KTextEditor::Document *doc, docs) {
- if (!doc->url().isEmpty()) {
- m_mainWindow->fileOpenRecent()->addUrl( doc->url() );
+ foreach(const KTextEditor::Document * doc, docs) {
+ if (!doc->url().isEmpty()) {
+ m_mainWindow->fileOpenRecent()->addUrl(doc->url());
+ }
}
- }
- return docs.isEmpty() ? 0 : docs.last();
+ return docs.isEmpty() ? 0 : docs.last();
}
-KTextEditor::View *KateViewManager::openUrlWithView (const QUrl &url, const QString& encoding)
+KTextEditor::View *KateViewManager::openUrlWithView(const QUrl &url, const QString &encoding)
{
- KTextEditor::Document *doc = KateDocManager::self()->openUrl (url, encoding);
+ KTextEditor::Document *doc = KateDocManager::self()->openUrl(url, encoding);
- if (!doc)
- return 0;
+ if (!doc) {
+ return 0;
+ }
- if (!doc->url().isEmpty())
- m_mainWindow->fileOpenRecent()->addUrl( doc->url() );
+ if (!doc->url().isEmpty()) {
+ m_mainWindow->fileOpenRecent()->addUrl(doc->url());
+ }
- activateView( doc );
+ activateView(doc);
- return activeView ();
+ return activeView();
}
-void KateViewManager::openUrl (const QUrl &url)
+void KateViewManager::openUrl(const QUrl &url)
{
- openUrl (url, QString());
+ openUrl(url, QString());
}
KateMainWindow *KateViewManager::mainWindow()
{
- return m_mainWindow;
+ return m_mainWindow;
}
-void KateViewManager::documentCreated (KTextEditor::Document *doc)
+void KateViewManager::documentCreated(KTextEditor::Document *doc)
{
- // forward to currently active view space
- activeViewSpace()->registerDocument(doc);
+ // forward to currently active view space
+ activeViewSpace()->registerDocument(doc);
- // to update open recent files on saving
- connect (doc, SIGNAL(documentSavedOrUploaded(KTextEditor::Document*,bool)), this, SLOT(documentSavedOrUploaded(KTextEditor::Document*,bool)));
+ // to update open recent files on saving
+ connect(doc, SIGNAL(documentSavedOrUploaded(KTextEditor::Document*,bool)), this, SLOT(documentSavedOrUploaded(KTextEditor::Document*,bool)));
- if (m_blockViewCreationAndActivation) return;
+ if (m_blockViewCreationAndActivation) {
+ return;
+ }
- if (!activeView())
- activateView (doc);
+ if (!activeView()) {
+ activateView(doc);
+ }
}
-void KateViewManager::documentDeleted (KTextEditor::Document *)
+void KateViewManager::documentDeleted(KTextEditor::Document *)
{
- if (m_blockViewCreationAndActivation) return;
+ if (m_blockViewCreationAndActivation) {
+ return;
+ }
- // just for the case we close a document out of many and this was the active one
- // if all docs are closed, this will be handled by the documentCreated
- if (!activeView() && (KateDocManager::self()->documents() > 0))
- createView (KateDocManager::self()->document(KateDocManager::self()->documents() - 1));
+ // just for the case we close a document out of many and this was the active one
+ // if all docs are closed, this will be handled by the documentCreated
+ if (!activeView() && (KateDocManager::self()->documents() > 0)) {
+ createView(KateDocManager::self()->document(KateDocManager::self()->documents() - 1));
+ }
}
void KateViewManager::documentSavedOrUploaded(KTextEditor::Document *doc, bool)
{
- if (!doc->url().isEmpty())
- m_mainWindow->fileOpenRecent()->addUrl( doc->url() );
+ if (!doc->url().isEmpty()) {
+ m_mainWindow->fileOpenRecent()->addUrl(doc->url());
+ }
}
-bool KateViewManager::createView ( KTextEditor::Document *doc, KateViewSpace *vs )
+bool KateViewManager::createView(KTextEditor::Document *doc, KateViewSpace *vs)
{
- if (m_blockViewCreationAndActivation) return false;
+ if (m_blockViewCreationAndActivation) {
+ return false;
+ }
- // create doc
- if (!doc)
- doc = KateDocManager::self()->createDoc ();
+ // create doc
+ if (!doc) {
+ doc = KateDocManager::self()->createDoc();
+ }
- /**
- * create view, registers its XML gui itself
- * pass the view the correct main window
- */
- KTextEditor::View *view = (vs ? vs : activeViewSpace())->createView (doc);
+ /**
+ * create view, registers its XML gui itself
+ * pass the view the correct main window
+ */
+ KTextEditor::View *view = (vs ? vs : activeViewSpace())->createView(doc);
- m_viewList.append (view);
- m_activeStates[view] = false;
+ m_viewList.append(view);
+ m_activeStates[view] = false;
- // disable settings dialog action
- delete view->actionCollection()->action( QStringLiteral("set_confdlg") );
- delete view->actionCollection()->action( QStringLiteral("editor_options") );
+ // disable settings dialog action
+ delete view->actionCollection()->action(QStringLiteral("set_confdlg"));
+ delete view->actionCollection()->action(QStringLiteral("editor_options"));
- connect(view, SIGNAL(dropEventPass(QDropEvent*)), mainWindow(), SLOT(slotDropEvent(QDropEvent*)));
- connect(view, SIGNAL(focusIn(KTextEditor::View*)), this, SLOT(activateSpace(KTextEditor::View*)));
+ connect(view, SIGNAL(dropEventPass(QDropEvent*)), mainWindow(), SLOT(slotDropEvent(QDropEvent*)));
+ connect(view, SIGNAL(focusIn(KTextEditor::View*)), this, SLOT(activateSpace(KTextEditor::View*)));
- viewCreated(view);
+ viewCreated(view);
#ifdef KActivities_FOUND
- Q_ASSERT(!m_activityResources.contains(view)); // view was just created -> cannot be in hash
- m_activityResources[view] = new KActivities::ResourceInstance(view->window()->winId(), view);
- m_activityResources[view]->setUri(doc->url());
+ Q_ASSERT(!m_activityResources.contains(view)); // view was just created -> cannot be in hash
+ m_activityResources[view] = new KActivities::ResourceInstance(view->window()->winId(), view);
+ m_activityResources[view]->setUri(doc->url());
#endif
- if (!vs)
- activateView( view );
+ if (!vs) {
+ activateView(view);
+ }
- return true;
+ return true;
}
-bool KateViewManager::deleteView (KTextEditor::View *view)
+bool KateViewManager::deleteView(KTextEditor::View *view)
{
- if (!view) return true;
+ if (!view) {
+ return true;
+ }
- KateViewSpace *viewspace = static_cast<KateViewSpace *>(view->parentWidget()->parentWidget());
+ KateViewSpace *viewspace = static_cast<KateViewSpace *>(view->parentWidget()->parentWidget());
- viewspace->removeView (view);
+ viewspace->removeView(view);
- mainWindow()->guiFactory ()->removeClient (view);
+ mainWindow()->guiFactory()->removeClient(view);
#ifdef KActivities_FOUND
- m_activityResources.remove(view);
+ m_activityResources.remove(view);
#endif
- // kill LRU mapping
- m_lruViews.remove (view);
+ // kill LRU mapping
+ m_lruViews.remove(view);
- // remove view from list and memory !!
- m_viewList.removeAt ( m_viewList.indexOf (view) );
- m_activeStates.remove (view);
- delete view;
- view = 0L;
+ // remove view from list and memory !!
+ m_viewList.removeAt(m_viewList.indexOf(view));
+ m_activeStates.remove(view);
+ delete view;
+ view = 0L;
- return true;
+ return true;
}
-KateViewSpace* KateViewManager::activeViewSpace ()
+KateViewSpace *KateViewManager::activeViewSpace()
{
- for ( QList<KateViewSpace*>::const_iterator it = m_viewSpaceList.constBegin();
- it != m_viewSpaceList.constEnd(); ++it )
- {
- if ( (*it)->isActiveSpace() )
- return *it;
- }
-
- // none active, so use the first we grab
- if ( !m_viewSpaceList.isEmpty() )
- {
- m_viewSpaceList.first()->setActive( true );
- return m_viewSpaceList.first();
- }
-
- Q_ASSERT(false);
- return 0L;
+ for (QList<KateViewSpace *>::const_iterator it = m_viewSpaceList.constBegin();
+ it != m_viewSpaceList.constEnd(); ++it) {
+ if ((*it)->isActiveSpace()) {
+ return *it;
+ }
+ }
+
+ // none active, so use the first we grab
+ if (!m_viewSpaceList.isEmpty()) {
+ m_viewSpaceList.first()->setActive(true);
+ return m_viewSpaceList.first();
+ }
+
+ Q_ASSERT(false);
+ return 0L;
}
-KTextEditor::View* KateViewManager::activeView ()
+KTextEditor::View *KateViewManager::activeView()
{
- if (m_activeViewRunning)
- return 0L;
+ if (m_activeViewRunning) {
+ return 0L;
+ }
- m_activeViewRunning = true;
+ m_activeViewRunning = true;
- for ( QList<KTextEditor::View*>::const_iterator it = m_viewList.constBegin();
- it != m_viewList.constEnd(); ++it )
- {
- if ( m_activeStates[*it] )
- {
- m_activeViewRunning = false;
- return *it;
+ for (QList<KTextEditor::View *>::const_iterator it = m_viewList.constBegin();
+ it != m_viewList.constEnd(); ++it) {
+ if (m_activeStates[*it]) {
+ m_activeViewRunning = false;
+ return *it;
+ }
}
- }
- // if we get to here, no view isActive()
- // first, try to get one from activeViewSpace()
- KateViewSpace* vs = activeViewSpace();
- if ( vs && vs->currentView() )
- {
- activateView (vs->currentView());
+ // if we get to here, no view isActive()
+ // first, try to get one from activeViewSpace()
+ KateViewSpace *vs = activeViewSpace();
+ if (vs && vs->currentView()) {
+ activateView(vs->currentView());
- m_activeViewRunning = false;
- return vs->currentView();
- }
+ m_activeViewRunning = false;
+ return vs->currentView();
+ }
- // last attempt: just pick first
- if ( !m_viewList.isEmpty() )
- {
- activateView (m_viewList.first());
+ // last attempt: just pick first
+ if (!m_viewList.isEmpty()) {
+ activateView(m_viewList.first());
- m_activeViewRunning = false;
- return m_viewList.first();
- }
+ m_activeViewRunning = false;
+ return m_viewList.first();
+ }
- m_activeViewRunning = false;
+ m_activeViewRunning = false;
- // no views exists!
- return 0L;
+ // no views exists!
+ return 0L;
}
-void KateViewManager::setActiveSpace ( KateViewSpace* vs )
+void KateViewManager::setActiveSpace(KateViewSpace *vs)
{
- if (activeViewSpace())
- activeViewSpace()->setActive( false );
+ if (activeViewSpace()) {
+ activeViewSpace()->setActive(false);
+ }
- vs->setActive( true, viewSpaceCount() > 1 );
+ vs->setActive(true, viewSpaceCount() > 1);
}
-void KateViewManager::setActiveView ( KTextEditor::View* view )
+void KateViewManager::setActiveView(KTextEditor::View *view)
{
- if (activeView())
- m_activeStates[activeView()] = false;
+ if (activeView()) {
+ m_activeStates[activeView()] = false;
+ }
- m_activeStates[view] = true;
+ m_activeStates[view] = true;
}
-void KateViewManager::activateSpace (KTextEditor::View* v)
+void KateViewManager::activateSpace(KTextEditor::View *v)
{
- if (!v) return;
+ if (!v) {
+ return;
+ }
- KateViewSpace* vs = static_cast<KateViewSpace*>(v->parentWidget()->parentWidget());
+ KateViewSpace *vs = static_cast<KateViewSpace *>(v->parentWidget()->parentWidget());
- if (!vs->isActiveSpace())
- {
- setActiveSpace (vs);
- activateView(v);
- }
+ if (!vs->isActiveSpace()) {
+ setActiveSpace(vs);
+ activateView(v);
+ }
}
void KateViewManager::reactivateActiveView()
{
- KTextEditor::View *view = activeView();
- if (view)
- {
- m_activeStates[view] = false;
- activateView(view);
- }
+ KTextEditor::View *view = activeView();
+ if (view) {
+ m_activeStates[view] = false;
+ activateView(view);
+ }
}
-void KateViewManager::activateView ( KTextEditor::View *view )
+void KateViewManager::activateView(KTextEditor::View *view)
{
- if (!view) return;
+ if (!view) {
+ return;
+ }
#ifdef KActivities_FOUND
- if (m_activityResources.contains(view)) {
- m_activityResources[view]->setUri(view->document()->url());
- m_activityResources[view]->notifyFocusedIn();
- }
+ if (m_activityResources.contains(view)) {
+ m_activityResources[view]->setUri(view->document()->url());
+ m_activityResources[view]->notifyFocusedIn();
+ }
#endif
- if (!m_activeStates[view])
- {
- if ( !activeViewSpace()->showView(view) )
- {
- // since it wasn't found, give'em a new one
- createView( view->document() );
- return;
- }
+ if (!m_activeStates[view]) {
+ if (!activeViewSpace()->showView(view)) {
+ // since it wasn't found, give'em a new one
+ createView(view->document());
+ return;
+ }
- setActiveView (view);
+ setActiveView(view);
- mainWindow()->setUpdatesEnabled( false );
- bool toolbarVisible = mainWindow()->toolBar()->isVisible();
- if (toolbarVisible)
- mainWindow()->toolBar()->hide(); // hide to avoid toolbar flickering
+ mainWindow()->setUpdatesEnabled(false);
+ bool toolbarVisible = mainWindow()->toolBar()->isVisible();
+ if (toolbarVisible) {
+ mainWindow()->toolBar()->hide(); // hide to avoid toolbar flickering
+ }
- if (guiMergedView)
- mainWindow()->guiFactory()->removeClient( guiMergedView );
+ if (guiMergedView) {
+ mainWindow()->guiFactory()->removeClient(guiMergedView);
+ }
- guiMergedView = view;
+ guiMergedView = view;
- if (!m_blockViewCreationAndActivation)
- mainWindow()->guiFactory()->addClient( view );
+ if (!m_blockViewCreationAndActivation) {
+ mainWindow()->guiFactory()->addClient(view);
+ }
- if (toolbarVisible)
- mainWindow()->toolBar()->show();
- mainWindow()->setUpdatesEnabled( true );
+ if (toolbarVisible) {
+ mainWindow()->toolBar()->show();
+ }
+ mainWindow()->setUpdatesEnabled(true);
- // remember age of this view
- m_lruViews[view] = m_minAge--;
+ // remember age of this view
+ m_lruViews[view] = m_minAge--;
- emit viewChanged(view);
- }
+ emit viewChanged(view);
+ }
}
-KTextEditor::View *KateViewManager::activateView( KTextEditor::Document *d )
+KTextEditor::View *KateViewManager::activateView(KTextEditor::Document *d)
{
- // no doc with this id found
- if (!d)
- return activeView ();
-
- // activate existing view if possible
- if ( activeViewSpace()->showView(d) )
- {
- activateView( activeViewSpace()->currentView() );
- return activeView ();
- }
-
- // create new view otherwise
- createView (d);
- return activeView ();
+ // no doc with this id found
+ if (!d) {
+ return activeView();
+ }
+
+ // activate existing view if possible
+ if (activeViewSpace()->showView(d)) {
+ activateView(activeViewSpace()->currentView());
+ return activeView();
+ }
+
+ // create new view otherwise
+ createView(d);
+ return activeView();
}
-int KateViewManager::viewCount () const
+int KateViewManager::viewCount() const
{
- return m_viewList.count();
+ return m_viewList.count();
}
-int KateViewManager::viewSpaceCount () const
+int KateViewManager::viewSpaceCount() const
{
- return m_viewSpaceList.count();
+ return m_viewSpaceList.count();
}
void KateViewManager::slotViewChanged()
{
- if ( activeView() && !activeView()->hasFocus())
- activeView()->setFocus();
+ if (activeView() && !activeView()->hasFocus()) {
+ activeView()->setFocus();
+ }
}
void KateViewManager::activateNextView()
{
- int i = m_viewSpaceList.indexOf (activeViewSpace()) + 1;
+ int i = m_viewSpaceList.indexOf(activeViewSpace()) + 1;
- if (i >= m_viewSpaceList.count())
- i = 0;
+ if (i >= m_viewSpaceList.count()) {
+ i = 0;
+ }
- setActiveSpace (m_viewSpaceList.at(i));
- activateView(m_viewSpaceList.at(i)->currentView());
+ setActiveSpace(m_viewSpaceList.at(i));
+ activateView(m_viewSpaceList.at(i)->currentView());
}
void KateViewManager::activatePrevView()
{
- int i = m_viewSpaceList.indexOf (activeViewSpace()) - 1;
+ int i = m_viewSpaceList.indexOf(activeViewSpace()) - 1;
- if (i < 0)
- i = m_viewSpaceList.count() - 1;
+ if (i < 0) {
+ i = m_viewSpaceList.count() - 1;
+ }
- setActiveSpace (m_viewSpaceList.at(i));
- activateView(m_viewSpaceList.at(i)->currentView());
+ setActiveSpace(m_viewSpaceList.at(i));
+ activateView(m_viewSpaceList.at(i)->currentView());
}
void KateViewManager::closeViews(KTextEditor::Document *doc)
{
- QList<KTextEditor::View*> closeList;
-
- for ( QList<KTextEditor::View*>::const_iterator it = m_viewList.constBegin();
- it != m_viewList.constEnd(); ++it)
- {
- if ( (*it)->document() == doc )
- closeList.append( *it );
- }
-
- while ( !closeList.isEmpty() )
- deleteView( closeList.takeFirst());
-
- if (m_blockViewCreationAndActivation) return;
-
- setUpdatesEnabled(false);
- QTimer::singleShot(0, this, SLOT(slotDelayedViewChanged()));
+ QList<KTextEditor::View *> closeList;
+
+ for (QList<KTextEditor::View *>::const_iterator it = m_viewList.constBegin();
+ it != m_viewList.constEnd(); ++it) {
+ if ((*it)->document() == doc) {
+ closeList.append(*it);
+ }
+ }
+
+ while (!closeList.isEmpty()) {
+ deleteView(closeList.takeFirst());
+ }
+
+ if (m_blockViewCreationAndActivation) {
+ return;
+ }
+
+ setUpdatesEnabled(false);
+ QTimer::singleShot(0, this, SLOT(slotDelayedViewChanged()));
}
-void KateViewManager::slotDelayedViewChanged ()
+void KateViewManager::slotDelayedViewChanged()
{
- KTextEditor::View * const newActiveView = activeView();
-
- /**
- * check if we have any empty viewspaces and give them a view
- */
- Q_FOREACH (KateViewSpace *vs, m_viewSpaceList) {
- if (!vs->currentView())
- createView (newActiveView->document(), vs);
- }
-
- emit viewChanged (newActiveView);
-
- setUpdatesEnabled(true);
+ KTextEditor::View *const newActiveView = activeView();
+
+ /**
+ * check if we have any empty viewspaces and give them a view
+ */
+ Q_FOREACH(KateViewSpace * vs, m_viewSpaceList) {
+ if (!vs->currentView()) {
+ createView(newActiveView->document(), vs);
+ }
+ }
+
+ emit viewChanged(newActiveView);
+
+ setUpdatesEnabled(true);
}
-void KateViewManager::splitViewSpace( KateViewSpace* vs, // = 0
- Qt::Orientation o )// = Qt::Horizontal
+void KateViewManager::splitViewSpace(KateViewSpace *vs, // = 0
+ Qt::Orientation o) // = Qt::Horizontal
{
- // emergency: fallback to activeViewSpace, and if still invalid, abort
- if (!vs) vs = activeViewSpace();
- if (!vs) return;
-
- // get current splitter, and abort if null
- QSplitter *currentSplitter = qobject_cast<QSplitter*>(vs->parentWidget());
- if (!currentSplitter) return;
-
- // index where to insert new splitter/viewspace
- const int index = currentSplitter->indexOf( vs );
-
- // create new viewspace
- KateViewSpace* vsNew = new KateViewSpace( this );
-
- // only 1 children -> we are the root container. So simply set the orientation
- // and add the new view space, then correct the sizes to 50%:50%
- if (currentSplitter->count() == 1)
- {
- if( currentSplitter->orientation() != o )
- currentSplitter->setOrientation( o );
- QList<int> sizes = currentSplitter->sizes();
- sizes << (sizes.first() - currentSplitter->handleWidth() ) / 2;
- sizes[0] = sizes[1];
- currentSplitter->insertWidget( index, vsNew );
- currentSplitter->setSizes( sizes );
- }
- else
- {
- // create a new QSplitter and replace vs with the splitter. vs and newVS are
- // the new children of the new QSplitter
- QSplitter* newContainer = new QSplitter( o );
- newContainer->setOpaqueResize(style()->styleHint(QStyle::SH_Splitter_OpaqueResize, 0, newContainer));
- QList<int> currentSizes = currentSplitter->sizes();
-
- newContainer->addWidget( vs );
- newContainer->addWidget( vsNew );
- currentSplitter->insertWidget( index, newContainer );
- newContainer->show();
-
- // fix sizes of children of old and new splitter
- currentSplitter->setSizes( currentSizes );
- QList<int> newSizes = newContainer->sizes();
- newSizes[0] = (newSizes[0] + newSizes[1] - newContainer->handleWidth()) / 2;
- newSizes[1] = newSizes[0];
- newContainer->setSizes( newSizes );
- }
-
- m_viewSpaceList.append( vsNew );
- activeViewSpace()->setActive( false );
- vsNew->setActive( true, true );
- vsNew->show();
-
- createView ((KTextEditor::Document*)activeView()->document());
-
- updateViewSpaceActions ();
+ // emergency: fallback to activeViewSpace, and if still invalid, abort
+ if (!vs) {
+ vs = activeViewSpace();
+ }
+ if (!vs) {
+ return;
+ }
+
+ // get current splitter, and abort if null
+ QSplitter *currentSplitter = qobject_cast<QSplitter *>(vs->parentWidget());
+ if (!currentSplitter) {
+ return;
+ }
+
+ // index where to insert new splitter/viewspace
+ const int index = currentSplitter->indexOf(vs);
+
+ // create new viewspace
+ KateViewSpace *vsNew = new KateViewSpace(this);
+
+ // only 1 children -> we are the root container. So simply set the orientation
+ // and add the new view space, then correct the sizes to 50%:50%
+ if (currentSplitter->count() == 1) {
+ if (currentSplitter->orientation() != o) {
+ currentSplitter->setOrientation(o);
+ }
+ QList<int> sizes = currentSplitter->sizes();
+ sizes << (sizes.first() - currentSplitter->handleWidth()) / 2;
+ sizes[0] = sizes[1];
+ currentSplitter->insertWidget(index, vsNew);
+ currentSplitter->setSizes(sizes);
+ } else {
+ // create a new QSplitter and replace vs with the splitter. vs and newVS are
+ // the new children of the new QSplitter
+ QSplitter *newContainer = new QSplitter(o);
+ newContainer->setOpaqueResize(style()->styleHint(QStyle::SH_Splitter_OpaqueResize, 0, newContainer));
+ QList<int> currentSizes = currentSplitter->sizes();
+
+ newContainer->addWidget(vs);
+ newContainer->addWidget(vsNew);
+ currentSplitter->insertWidget(index, newContainer);
+ newContainer->show();
+
+ // fix sizes of children of old and new splitter
+ currentSplitter->setSizes(currentSizes);
+ QList<int> newSizes = newContainer->sizes();
+ newSizes[0] = (newSizes[0] + newSizes[1] - newContainer->handleWidth()) / 2;
+ newSizes[1] = newSizes[0];
+ newContainer->setSizes(newSizes);
+ }
+
+ m_viewSpaceList.append(vsNew);
+ activeViewSpace()->setActive(false);
+ vsNew->setActive(true, true);
+ vsNew->show();
+
+ createView((KTextEditor::Document *)activeView()->document());
+
+ updateViewSpaceActions();
}
-void KateViewManager::removeViewSpace (KateViewSpace *viewspace)
+void KateViewManager::removeViewSpace(KateViewSpace *viewspace)
{
- // abort if viewspace is 0
- if (!viewspace) return;
-
- // abort if this is the last viewspace
- if (m_viewSpaceList.count() < 2) return;
-
- // get current splitter
- QSplitter *currentSplitter = qobject_cast<QSplitter*>(viewspace->parentWidget());
-
- // no splitter found, bah
- if (!currentSplitter)
- return;
-
- // delete views of the viewspace
- while (viewspace->currentView()) {
- deleteView( viewspace->currentView());
- }
-
- // cu viewspace
- m_viewSpaceList.removeAt( m_viewSpaceList.indexOf( viewspace ) );
- delete viewspace;
-
- // at this point, the splitter has exactly 1 child
- Q_ASSERT( currentSplitter->count() == 1 );
-
- // if we are not the root splitter, move the child one level up and delete
- // the splitter then.
- if (currentSplitter != this)
- {
- // get parent splitter
- QSplitter *parentSplitter = qobject_cast<QSplitter*>(currentSplitter->parentWidget());
-
- // only do magic if found ;)
- if (parentSplitter)
- {
- int index = parentSplitter->indexOf (currentSplitter);
-
- // save current splitter size, as the removal of currentSplitter looses the info
- QList<int> parentSizes = parentSplitter->sizes();
- parentSplitter->insertWidget (index, currentSplitter->widget (0));
- delete currentSplitter;
- // now restore the sizes again
- parentSplitter->setSizes(parentSizes);
- }
- }
- else if( QSplitter* splitter = qobject_cast<QSplitter*>(currentSplitter->widget(0)) )
- {
- // we are the root splitter and have only one child, which is also a splitter
- // -> eliminate the redundant splitter and move both children into the root splitter
- QList<int> sizes = splitter->sizes();
- // adapt splitter orientation to the splitter we are about to delete
- currentSplitter->setOrientation(splitter->orientation());
- currentSplitter->addWidget( splitter->widget(0) );
- currentSplitter->addWidget( splitter->widget(0) );
- delete splitter;
- currentSplitter->setSizes( sizes );
- }
-
- // find the view that is now active.
- KTextEditor::View* v = activeViewSpace()->currentView();
- if ( v )
- activateView( v );
-
- updateViewSpaceActions ();
-
- emit viewChanged(v);
+ // abort if viewspace is 0
+ if (!viewspace) {
+ return;
+ }
+
+ // abort if this is the last viewspace
+ if (m_viewSpaceList.count() < 2) {
+ return;
+ }
+
+ // get current splitter
+ QSplitter *currentSplitter = qobject_cast<QSplitter *>(viewspace->parentWidget());
+
+ // no splitter found, bah
+ if (!currentSplitter) {
+ return;
+ }
+
+ // delete views of the viewspace
+ while (viewspace->currentView()) {
+ deleteView(viewspace->currentView());
+ }
+
+ // cu viewspace
+ m_viewSpaceList.removeAt(m_viewSpaceList.indexOf(viewspace));
+ delete viewspace;
+
+ // at this point, the splitter has exactly 1 child
+ Q_ASSERT(currentSplitter->count() == 1);
+
+ // if we are not the root splitter, move the child one level up and delete
+ // the splitter then.
+ if (currentSplitter != this) {
+ // get parent splitter
+ QSplitter *parentSplitter = qobject_cast<QSplitter *>(currentSplitter->parentWidget());
+
+ // only do magic if found ;)
+ if (parentSplitter) {
+ int index = parentSplitter->indexOf(currentSplitter);
+
+ // save current splitter size, as the removal of currentSplitter looses the info
+ QList<int> parentSizes = parentSplitter->sizes();
+ parentSplitter->insertWidget(index, currentSplitter->widget(0));
+ delete currentSplitter;
+ // now restore the sizes again
+ parentSplitter->setSizes(parentSizes);
+ }
+ } else if (QSplitter *splitter = qobject_cast<QSplitter *>(currentSplitter->widget(0))) {
+ // we are the root splitter and have only one child, which is also a splitter
+ // -> eliminate the redundant splitter and move both children into the root splitter
+ QList<int> sizes = splitter->sizes();
+ // adapt splitter orientation to the splitter we are about to delete
+ currentSplitter->setOrientation(splitter->orientation());
+ currentSplitter->addWidget(splitter->widget(0));
+ currentSplitter->addWidget(splitter->widget(0));
+ delete splitter;
+ currentSplitter->setSizes(sizes);
+ }
+
+ // find the view that is now active.
+ KTextEditor::View *v = activeViewSpace()->currentView();
+ if (v) {
+ activateView(v);
+ }
+
+ updateViewSpaceActions();
+
+ emit viewChanged(v);
}
void KateViewManager::slotCloseCurrentViewSpace()
{
- removeViewSpace(activeViewSpace());
+ removeViewSpace(activeViewSpace());
}
void KateViewManager::slotCloseOtherViews()
{
- KateViewSpace* active = activeViewSpace();
- foreach (KateViewSpace *v, m_viewSpaceList) {
- if (active != v) {
- removeViewSpace(v);
+ KateViewSpace *active = activeViewSpace();
+ foreach(KateViewSpace * v, m_viewSpaceList) {
+ if (active != v) {
+ removeViewSpace(v);
+ }
}
- }
}
-
/**
* session config functions
*/
-void KateViewManager::saveViewConfiguration(KConfigGroup& config)
+void KateViewManager::saveViewConfiguration(KConfigGroup &config)
{
- // set Active ViewSpace to 0, just in case there is none active (would be
- // strange) and config somehow has previous value set
- config.writeEntry("Active ViewSpace", 0);
+ // set Active ViewSpace to 0, just in case there is none active (would be
+ // strange) and config somehow has previous value set
+ config.writeEntry("Active ViewSpace", 0);
- m_splitterIndex = 0;
- saveSplitterConfig(this, config.config(), config.name());
+ m_splitterIndex = 0;
+ saveSplitterConfig(this, config.config(), config.name());
}
-void KateViewManager::restoreViewConfiguration (const KConfigGroup& config)
+void KateViewManager::restoreViewConfiguration(const KConfigGroup &config)
{
- // remove all views and viewspaces + remove their xml gui clients
- for (int i = 0; i < m_viewList.count(); ++i)
- mainWindow()->guiFactory ()->removeClient (m_viewList.at(i));
-
- qDeleteAll( m_viewList );
- m_viewList.clear();
- qDeleteAll( m_viewSpaceList );
- m_viewSpaceList.clear();
- m_activeStates.clear();
-
+ // remove all views and viewspaces + remove their xml gui clients
+ for (int i = 0; i < m_viewList.count(); ++i) {
+ mainWindow()->guiFactory()->removeClient(m_viewList.at(i));
+ }
+
+ qDeleteAll(m_viewList);
+ m_viewList.clear();
+ qDeleteAll(m_viewSpaceList);
+ m_viewSpaceList.clear();
+ m_activeStates.clear();
+
#ifdef KActivities_FOUND
- m_activityResources.clear();
+ m_activityResources.clear();
#endif
- // reset lru history, too!
- m_lruViews.clear();
- m_minAge = 0;
-
- // start recursion for the root splitter (Splitter 0)
- restoreSplitter( config.config(), config.name() + QStringLiteral("-Splitter 0"), this, config.name() );
-
- // finally, make the correct view from the last session active
- int lastViewSpace = config.readEntry("Active ViewSpace", 0);
- if( lastViewSpace > m_viewSpaceList.size() ) lastViewSpace = 0;
- if( lastViewSpace >= 0 && lastViewSpace < m_viewSpaceList.size())
- {
- setActiveSpace( m_viewSpaceList.at( lastViewSpace ) );
- // activate correct view (wish #195435, #188764)
- activateView( m_viewSpaceList.at( lastViewSpace )->currentView() );
- // give view the focus to avoid focus stealing by toolviews / plugins
- m_viewSpaceList.at( lastViewSpace )->currentView()->setFocus();
- }
-
- // emergency
- if (m_viewSpaceList.empty())
- {
- // kill bad children
- while (count())
- delete widget (0);
-
- KateViewSpace* vs = new KateViewSpace( this, 0 );
- addWidget (vs);
- vs->setActive( true );
- m_viewSpaceList.append(vs);
- }
+ // reset lru history, too!
+ m_lruViews.clear();
+ m_minAge = 0;
+
+ // start recursion for the root splitter (Splitter 0)
+ restoreSplitter(config.config(), config.name() + QStringLiteral("-Splitter 0"), this, config.name());
+
+ // finally, make the correct view from the last session active
+ int lastViewSpace = config.readEntry("Active ViewSpace", 0);
+ if (lastViewSpace > m_viewSpaceList.size()) {
+ lastViewSpace = 0;
+ }
+ if (lastViewSpace >= 0 && lastViewSpace < m_viewSpaceList.size()) {
+ setActiveSpace(m_viewSpaceList.at(lastViewSpace));
+ // activate correct view (wish #195435, #188764)
+ activateView(m_viewSpaceList.at(lastViewSpace)->currentView());
+ // give view the focus to avoid focus stealing by toolviews / plugins
+ m_viewSpaceList.at(lastViewSpace)->currentView()->setFocus();
+ }
- updateViewSpaceActions();
+ // emergency
+ if (m_viewSpaceList.empty()) {
+ // kill bad children
+ while (count()) {
+ delete widget(0);
+ }
+
+ KateViewSpace *vs = new KateViewSpace(this, 0);
+ addWidget(vs);
+ vs->setActive(true);
+ m_viewSpaceList.append(vs);
+ }
+
+ updateViewSpaceActions();
}
-void KateViewManager::saveSplitterConfig( QSplitter* s, KConfigBase* configBase, const QString& viewConfGrp )
+void KateViewManager::saveSplitterConfig(QSplitter *s, KConfigBase *configBase, const QString &viewConfGrp)
{
- QString grp = QString(viewConfGrp + QStringLiteral("-Splitter %1")).arg(m_splitterIndex);
- KConfigGroup config( configBase, grp );
-
- // Save sizes, orient, children for this splitter
- config.writeEntry( "Sizes", s->sizes() );
- config.writeEntry( "Orientation", int(s->orientation()) );
-
- QStringList childList;
- // a QSplitter has two children, either QSplitters and/or KateViewSpaces
- // special case: root splitter might have only one child (just for info)
- for (int it = 0; it < s->count(); ++it)
- {
- QWidget *obj = s->widget(it);
- KateViewSpace* kvs = qobject_cast<KateViewSpace*>(obj);
-
- QString n; // name for child list, see below
- // For KateViewSpaces, ask them to save the file list.
- if ( kvs )
- {
- n = QString(viewConfGrp + QStringLiteral("-ViewSpace %1")).arg( m_viewSpaceList.indexOf(kvs) );
- kvs->saveConfig ( configBase, m_viewSpaceList.indexOf(kvs), viewConfGrp);
- // save active viewspace
- if ( kvs->isActiveSpace() )
- {
- KConfigGroup viewConfGroup(configBase, viewConfGrp);
- viewConfGroup.writeEntry("Active ViewSpace", m_viewSpaceList.indexOf(kvs) );
- }
- }
- // for QSplitters, recurse
- else if ( QSplitter* splitter = qobject_cast<QSplitter*>(obj) )
- {
- ++m_splitterIndex;
- n = QString(viewConfGrp + QStringLiteral("-Splitter %1")).arg( m_splitterIndex );
- saveSplitterConfig( splitter, configBase, viewConfGrp);
- }
-
- childList.append( n );
- }
-
- config.writeEntry("Children", childList);
+ QString grp = QString(viewConfGrp + QStringLiteral("-Splitter %1")).arg(m_splitterIndex);
+ KConfigGroup config(configBase, grp);
+
+ // Save sizes, orient, children for this splitter
+ config.writeEntry("Sizes", s->sizes());
+ config.writeEntry("Orientation", int(s->orientation()));
+
+ QStringList childList;
+ // a QSplitter has two children, either QSplitters and/or KateViewSpaces
+ // special case: root splitter might have only one child (just for info)
+ for (int it = 0; it < s->count(); ++it) {
+ QWidget *obj = s->widget(it);
+ KateViewSpace *kvs = qobject_cast<KateViewSpace *>(obj);
+
+ QString n; // name for child list, see below
+ // For KateViewSpaces, ask them to save the file list.
+ if (kvs) {
+ n = QString(viewConfGrp + QStringLiteral("-ViewSpace %1")).arg(m_viewSpaceList.indexOf(kvs));
+ kvs->saveConfig(configBase, m_viewSpaceList.indexOf(kvs), viewConfGrp);
+ // save active viewspace
+ if (kvs->isActiveSpace()) {
+ KConfigGroup viewConfGroup(configBase, viewConfGrp);
+ viewConfGroup.writeEntry("Active ViewSpace", m_viewSpaceList.indexOf(kvs));
+ }
+ }
+ // for QSplitters, recurse
+ else if (QSplitter *splitter = qobject_cast<QSplitter *>(obj)) {
+ ++m_splitterIndex;
+ n = QString(viewConfGrp + QStringLiteral("-Splitter %1")).arg(m_splitterIndex);
+ saveSplitterConfig(splitter, configBase, viewConfGrp);
+ }
+
+ childList.append(n);
+ }
+
+ config.writeEntry("Children", childList);
}
-void KateViewManager::restoreSplitter( const KConfigBase* configBase, const QString &group,
- QSplitter* parent, const QString& viewConfGrp)
+void KateViewManager::restoreSplitter(const KConfigBase *configBase, const QString &group,
+ QSplitter *parent, const QString &viewConfGrp)
{
- KConfigGroup config( configBase, group );
-
- parent->setOrientation((Qt::Orientation)config.readEntry("Orientation", int(Qt::Horizontal)));
-
- QStringList children = config.readEntry( "Children", QStringList() );
- for (QStringList::Iterator it = children.begin(); it != children.end(); ++it)
- {
- // for a viewspace, create it and open all documents therein.
- if ( (*it).startsWith(viewConfGrp + QStringLiteral("-ViewSpace")) )
- {
- KateViewSpace* vs = new KateViewSpace( this, 0 );
- m_viewSpaceList.append( vs );
- // make active so that the view created in restoreConfig has this
- // new view space as parent.
- setActiveSpace( vs );
-
- parent->addWidget( vs );
- vs->restoreConfig (this, configBase, *it);
- vs->show();
- }
- else
- {
- // for a splitter, recurse.
- restoreSplitter( configBase, *it, new QSplitter( parent ), viewConfGrp );
- }
- }
-
- // set sizes
- parent->setSizes( config.readEntry("Sizes", QList<int>()) );
- parent->show();
+ KConfigGroup config(configBase, group);
+
+ parent->setOrientation((Qt::Orientation)config.readEntry("Orientation", int(Qt::Horizontal)));
+
+ QStringList children = config.readEntry("Children", QStringList());
+ for (QStringList::Iterator it = children.begin(); it != children.end(); ++it) {
+ // for a viewspace, create it and open all documents therein.
+ if ((*it).startsWith(viewConfGrp + QStringLiteral("-ViewSpace"))) {
+ KateViewSpace *vs = new KateViewSpace(this, 0);
+ m_viewSpaceList.append(vs);
+ // make active so that the view created in restoreConfig has this
+ // new view space as parent.
+ setActiveSpace(vs);
+
+ parent->addWidget(vs);
+ vs->restoreConfig(this, configBase, *it);
+ vs->show();
+ } else {
+ // for a splitter, recurse.
+ restoreSplitter(configBase, *it, new QSplitter(parent), viewConfGrp);
+ }
+ }
+
+ // set sizes
+ parent->setSizes(config.readEntry("Sizes", QList<int>()));
+ parent->show();
}
void KateViewManager::moveSplitter(Qt::Key key, int repeats)
{
- if (repeats < 1) return;
+ if (repeats < 1) {
+ return;
+ }
- KateViewSpace *vs = activeViewSpace();
- if (!vs) return;
+ KateViewSpace *vs = activeViewSpace();
+ if (!vs) {
+ return;
+ }
- QSplitter *currentSplitter = qobject_cast<QSplitter*>(vs->parentWidget());
+ QSplitter *currentSplitter = qobject_cast<QSplitter *>(vs->parentWidget());
- if (!currentSplitter) return;
- if (currentSplitter->count() == 1) return;
+ if (!currentSplitter) {
+ return;
+ }
+ if (currentSplitter->count() == 1) {
+ return;
+ }
- int move = 4 * repeats;
- // try to use font height in pixel to move splitter
- KTextEditor::HighlightInterface *hi = qobject_cast<KTextEditor::HighlightInterface*>(vs->currentView()->document());
- if (hi) {
- KTextEditor::Attribute::Ptr attrib(hi->defaultStyle(KTextEditor::HighlightInterface::dsNormal));
- QFontMetrics fm(attrib->font());
- move = fm.height() * repeats;
- }
+ int move = 4 * repeats;
+ // try to use font height in pixel to move splitter
+ KTextEditor::HighlightInterface *hi = qobject_cast<KTextEditor::HighlightInterface *>(vs->currentView()->document());
+ if (hi) {
+ KTextEditor::Attribute::Ptr attrib(hi->defaultStyle(KTextEditor::HighlightInterface::dsNormal));
+ QFontMetrics fm(attrib->font());
+ move = fm.height() * repeats;
+ }
- QWidget* currentWidget = (QWidget*)vs;
- bool foundSplitter = false;
+ QWidget *currentWidget = (QWidget *)vs;
+ bool foundSplitter = false;
- // find correct splitter to be moved
- while ( currentSplitter && currentSplitter->count() != 1 ) {
+ // find correct splitter to be moved
+ while (currentSplitter && currentSplitter->count() != 1) {
- if ( currentSplitter->orientation() == Qt::Horizontal
- && ( key == Qt::Key_Right || key == Qt::Key_Left ))
- foundSplitter = true;
+ if (currentSplitter->orientation() == Qt::Horizontal
+ && (key == Qt::Key_Right || key == Qt::Key_Left)) {
+ foundSplitter = true;
+ }
- if ( currentSplitter->orientation() == Qt::Vertical
- && ( key == Qt::Key_Up || key == Qt::Key_Down ))
- foundSplitter = true;
+ if (currentSplitter->orientation() == Qt::Vertical
+ && (key == Qt::Key_Up || key == Qt::Key_Down)) {
+ foundSplitter = true;
+ }
- // if the views within the current splitter can be resized, resize them
- if (foundSplitter) {
- QList<int> currentSizes = currentSplitter->sizes();
- int index = currentSplitter->indexOf(currentWidget);
+ // if the views within the current splitter can be resized, resize them
+ if (foundSplitter) {
+ QList<int> currentSizes = currentSplitter->sizes();
+ int index = currentSplitter->indexOf(currentWidget);
- if (( index == 0 && ( key == Qt::Key_Left || key == Qt::Key_Up ))
- ||( index == 1 && ( key == Qt::Key_Right || key == Qt::Key_Down )))
- currentSizes[index] -= move;
+ if ((index == 0 && (key == Qt::Key_Left || key == Qt::Key_Up))
+ || (index == 1 && (key == Qt::Key_Right || key == Qt::Key_Down))) {
+ currentSizes[index] -= move;
+ }
- if (( index == 0 && ( key == Qt::Key_Right || key == Qt::Key_Down ))
- ||( index == 1 && ( key == Qt::Key_Left || key == Qt::Key_Up )))
- currentSizes[index] += move;
+ if ((index == 0 && (key == Qt::Key_Right || key == Qt::Key_Down))
+ || (index == 1 && (key == Qt::Key_Left || key == Qt::Key_Up))) {
+ currentSizes[index] += move;
+ }
- if ( index == 0 && ( key == Qt::Key_Right || key == Qt::Key_Down ))
- currentSizes[index+1] -= move;
+ if (index == 0 && (key == Qt::Key_Right || key == Qt::Key_Down)) {
+ currentSizes[index + 1] -= move;
+ }
- if ( index == 0 && ( key == Qt::Key_Left || key == Qt::Key_Up ))
- currentSizes[index+1] += move;
+ if (index == 0 && (key == Qt::Key_Left || key == Qt::Key_Up)) {
+ currentSizes[index + 1] += move;
+ }
- if( index == 1 && ( key == Qt::Key_Right || key == Qt::Key_Down ))
- currentSizes[index-1] += move;
+ if (index == 1 && (key == Qt::Key_Right || key == Qt::Key_Down)) {
+ currentSizes[index - 1] += move;
+ }
- if( index == 1 && ( key == Qt::Key_Left || key == Qt::Key_Up ))
- currentSizes[index-1] -= move;
+ if (index == 1 && (key == Qt::Key_Left || key == Qt::Key_Up)) {
+ currentSizes[index - 1] -= move;
+ }
- currentSplitter->setSizes(currentSizes);
- break;
- }
+ currentSplitter->setSizes(currentSizes);
+ break;
+ }
- currentWidget = (QWidget*)currentSplitter;
- // the parent of the current splitter will become the current splitter
- currentSplitter = qobject_cast<QSplitter*>(currentSplitter->parentWidget());
- }
+ currentWidget = (QWidget *)currentSplitter;
+ // the parent of the current splitter will become the current splitter
+ currentSplitter = qobject_cast<QSplitter *>(currentSplitter->parentWidget());
+ }
}
-
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/app/kateviewmanager.h b/kate/app/kateviewmanager.h
index 66f3158..a94f8b1 100644
--- a/kate/app/kateviewmanager.h
+++ b/kate/app/kateviewmanager.h
@@ -33,7 +33,10 @@
#include <config.h>
#ifdef KActivities_FOUND
-namespace KActivities { class ResourceInstance; }
+namespace KActivities
+{
+class ResourceInstance;
+}
#endif
class KateDocumentInfo;
@@ -47,127 +50,124 @@ class KateViewManager : public QSplitter
{
Q_OBJECT
- public:
- KateViewManager (QWidget *parentW, KateMainWindow *parent);
- ~KateViewManager ();
+public:
+ KateViewManager(QWidget *parentW, KateMainWindow *parent);
+ ~KateViewManager();
- void updateViewSpaceActions ();
+ void updateViewSpaceActions();
- private:
+private:
/**
* create all actions needed for the view manager
*/
- void setupActions ();
+ void setupActions();
- public:
+public:
/* This will save the splitter configuration */
- void saveViewConfiguration(KConfigGroup& group);
+ void saveViewConfiguration(KConfigGroup &group);
/* restore it */
- void restoreViewConfiguration (const KConfigGroup& group);
-
- KTextEditor::Document *openUrl (const QUrl &url,
- const QString& encoding,
- bool activate = true,
- bool isTempFile = false,
- const KateDocumentInfo& docInfo = KateDocumentInfo());
+ void restoreViewConfiguration(const KConfigGroup &group);
- KTextEditor::Document *openUrls (const QList<QUrl> &url,
- const QString& encoding,
- bool isTempFile = false,
- const KateDocumentInfo& docInfo = KateDocumentInfo());
+ KTextEditor::Document *openUrl(const QUrl &url,
+ const QString &encoding,
+ bool activate = true,
+ bool isTempFile = false,
+ const KateDocumentInfo &docInfo = KateDocumentInfo());
- KTextEditor::View *openUrlWithView (const QUrl &url, const QString& encoding);
+ KTextEditor::Document *openUrls(const QList<QUrl> &url,
+ const QString &encoding,
+ bool isTempFile = false,
+ const KateDocumentInfo &docInfo = KateDocumentInfo());
- public Q_SLOTS:
- void openUrl (const QUrl &url);
+ KTextEditor::View *openUrlWithView(const QUrl &url, const QString &encoding);
- public:
+public Q_SLOTS:
+ void openUrl(const QUrl &url);
- void setViewActivationBlocked (bool block);
+public:
+ void setViewActivationBlocked(bool block);
- public:
+public:
void closeViews(KTextEditor::Document *doc);
KateMainWindow *mainWindow();
- private Q_SLOTS:
- void activateView ( KTextEditor::View *view );
- void activateSpace ( KTextEditor::View* v );
- void slotDelayedViewChanged ();
+private Q_SLOTS:
+ void activateView(KTextEditor::View *view);
+ void activateSpace(KTextEditor::View *v);
+ void slotDelayedViewChanged();
- public Q_SLOTS:
- void slotDocumentNew ();
- void slotDocumentOpen ();
- void slotDocumentClose ();
- void slotDocumentClose (KTextEditor::Document *document);
+public Q_SLOTS:
+ void slotDocumentNew();
+ void slotDocumentOpen();
+ void slotDocumentClose();
+ void slotDocumentClose(KTextEditor::Document *document);
- void setActiveSpace ( KateViewSpace* vs );
- void setActiveView ( KTextEditor::View* view );
+ void setActiveSpace(KateViewSpace *vs);
+ void setActiveView(KTextEditor::View *view);
void activateNextView();
void activatePrevView();
- protected:
+protected:
QPointer<KTextEditor::View> guiMergedView;
- Q_SIGNALS:
- void statChanged ();
- void viewChanged (KTextEditor::View *);
- void viewCreated (KTextEditor::View *);
+Q_SIGNALS:
+ void statChanged();
+ void viewChanged(KTextEditor::View *);
+ void viewCreated(KTextEditor::View *);
- public:
- inline QList<KTextEditor::View*> &viewList ()
- {
- return m_viewList;
+public:
+ inline QList<KTextEditor::View *> &viewList() {
+ return m_viewList;
}
/**
* create and activate a new view for doc, if doc == 0, then
* create a new document
*/
- bool createView ( KTextEditor::Document *doc = 0L, KateViewSpace *vs = nullptr );
+ bool createView(KTextEditor::Document *doc = 0L, KateViewSpace *vs = nullptr);
- private:
- bool deleteView ( KTextEditor::View *view);
+private:
+ bool deleteView(KTextEditor::View *view);
- void moveViewtoSplit (KTextEditor::View *view);
- void moveViewtoStack (KTextEditor::View *view);
+ void moveViewtoSplit(KTextEditor::View *view);
+ void moveViewtoStack(KTextEditor::View *view);
/* Save the configuration of a single splitter.
* If child splitters are found, it calls it self with those as the argument.
* If a viewspace child is found, it is asked to save its filelist.
*/
- void saveSplitterConfig(QSplitter* s, KConfigBase* config, const QString& viewConfGrp);
+ void saveSplitterConfig(QSplitter *s, KConfigBase *config, const QString &viewConfGrp);
/** Restore a single splitter.
* This is all the work is done for @see saveSplitterConfig()
*/
- void restoreSplitter ( const KConfigBase* config, const QString &group, QSplitter* parent, const QString& viewConfGrp);
+ void restoreSplitter(const KConfigBase *config, const QString &group, QSplitter *parent, const QString &viewConfGrp);
- void removeViewSpace (KateViewSpace *viewspace);
+ void removeViewSpace(KateViewSpace *viewspace);
- public:
- KTextEditor::View* activeView ();
- KateViewSpace* activeViewSpace ();
+public:
+ KTextEditor::View *activeView();
+ KateViewSpace *activeViewSpace();
- int viewCount () const;
- int viewSpaceCount () const;
+ int viewCount() const;
+ int viewSpaceCount() const;
- bool isViewActivationBlocked()
- {
- return m_blockViewCreationAndActivation;
+ bool isViewActivationBlocked() {
+ return m_blockViewCreationAndActivation;
}
- private Q_SLOTS:
+private Q_SLOTS:
void slotViewChanged();
- void documentCreated (KTextEditor::Document *doc);
- void documentDeleted (KTextEditor::Document *doc);
+ void documentCreated(KTextEditor::Document *doc);
+ void documentDeleted(KTextEditor::Document *doc);
+
+ void documentSavedOrUploaded(KTextEditor::Document *document, bool saveAs);
- void documentSavedOrUploaded(KTextEditor::Document* document,bool saveAs);
-
- public Q_SLOTS:
+public Q_SLOTS:
/**
* Splits a KateViewSpace into two in the following steps:
* 1. create a QSplitter in the parent of the KateViewSpace to be split
@@ -179,55 +179,49 @@ class KateViewManager : public QSplitter
* The orientation of the new splitter is determined by the value of o.
* Note: horizontal splitter means vertically aligned views.
*/
- void splitViewSpace( KateViewSpace* vs = 0L, Qt::Orientation o = Qt::Horizontal );
+ void splitViewSpace(KateViewSpace *vs = 0L, Qt::Orientation o = Qt::Horizontal);
/**
* activate view for given document
* @param doc document to activate view for
*/
- KTextEditor::View *activateView ( KTextEditor::Document *doc );
+ KTextEditor::View *activateView(KTextEditor::Document *doc);
/** Splits the active viewspace horizontally */
- void slotSplitViewSpaceHoriz ()
- {
- splitViewSpace(0L, Qt::Vertical);
+ void slotSplitViewSpaceHoriz() {
+ splitViewSpace(0L, Qt::Vertical);
}
/** Splits the active viewspace vertically */
- void slotSplitViewSpaceVert ()
- {
- splitViewSpace();
+ void slotSplitViewSpaceVert() {
+ splitViewSpace();
}
/** moves the splitter according to the key that has been pressed */
void moveSplitter(Qt::Key key, int repeats = 1);
/** moves the splitter to the right */
- void moveSplitterRight()
- {
+ void moveSplitterRight() {
moveSplitter(Qt::Key_Right);
}
/** moves the splitter to the left */
- void moveSplitterLeft()
- {
+ void moveSplitterLeft() {
moveSplitter(Qt::Key_Left);
}
/** moves the splitter up */
- void moveSplitterUp()
- {
+ void moveSplitterUp() {
moveSplitter(Qt::Key_Up);
}
/** moves the splitter down */
- void moveSplitterDown()
- {
+ void moveSplitterDown() {
moveSplitter(Qt::Key_Down);
}
void slotCloseCurrentViewSpace();
-
+
/** closes every view but the active one */
void slotCloseOtherViews();
@@ -238,12 +232,11 @@ class KateViewManager : public QSplitter
* useful to show views in a LRU way
* important: smallest age ==> latest used view
*/
- const QHash<KTextEditor::View *, qint64> &lruViews () const
- {
- return m_lruViews;
+ const QHash<KTextEditor::View *, qint64> &lruViews() const {
+ return m_lruViews;
}
- private:
+private:
KateMainWindow *m_mainWindow;
bool m_init;
@@ -252,12 +245,12 @@ class KateViewManager : public QSplitter
QAction *goNext;
QAction *goPrev;
- QList<KateViewSpace*> m_viewSpaceList;
- QList<KTextEditor::View*> m_viewList;
- QHash<KTextEditor::View*, bool> m_activeStates;
+ QList<KateViewSpace *> m_viewSpaceList;
+ QList<KTextEditor::View *> m_viewList;
+ QHash<KTextEditor::View *, bool> m_activeStates;
#ifdef KActivities_FOUND
- QHash<KTextEditor::View*, KActivities::ResourceInstance*> m_activityResources;
+ QHash<KTextEditor::View *, KActivities::ResourceInstance *> m_activityResources;
#endif
bool m_blockViewCreationAndActivation;
@@ -279,5 +272,4 @@ class KateViewManager : public QSplitter
};
#endif
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/app/kateviewspace.cpp b/kate/app/kateviewspace.cpp
index 7a55d8d..da2d91d 100644
--- a/kate/app/kateviewspace.cpp
+++ b/kate/app/kateviewspace.cpp
@@ -40,62 +40,62 @@
#include <QToolTip>
//BEGIN KateViewSpace
-KateViewSpace::KateViewSpace( KateViewManager *viewManager,
- QWidget* parent, const char* name )
+KateViewSpace::KateViewSpace(KateViewManager *viewManager,
+ QWidget *parent, const char *name)
: QWidget(parent)
, m_viewManager(viewManager)
{
- setObjectName(QString::fromLatin1(name));
- QVBoxLayout *layout = new QVBoxLayout(this);
- layout->setSpacing(0);
- layout->setMargin(0);
-
- //BEGIN tab bar
- QHBoxLayout * hLayout = new QHBoxLayout();
- hLayout->setSpacing(0);
- hLayout->setMargin(0);
-
- // add tab bar
- m_tabBar = new KateTabBar(this);
- connect(m_tabBar, &KateTabBar::currentChanged, this, &KateViewSpace::changeView);
- hLayout->addWidget(m_tabBar);
-
- // add vertical split view space
- QToolButton * split = new QToolButton(this);
- split->setAutoRaise(true);
- split->setPopupMode(QToolButton::InstantPopup);
- split->setIcon(QIcon::fromTheme(QStringLiteral("view-split-left-right")));
- split->addAction(m_viewManager->mainWindow()->actionCollection()->action(QStringLiteral("view_split_vert")));
- split->addAction(m_viewManager->mainWindow()->actionCollection()->action(QStringLiteral("view_split_horiz")));
- split->addAction(m_viewManager->mainWindow()->actionCollection()->action(QStringLiteral("view_close_current_space")));
- split->setWhatsThis(i18n("Control view space splitting"));
- split->installEventFilter(this); // on click, active this view space
- hLayout->addWidget(split);
-
- // add quick open
- QToolButton * quickOpen = new QToolButton(this);
- quickOpen->setAutoRaise(true);
- quickOpen->setDefaultAction(m_viewManager->mainWindow()->actionCollection()->action(QStringLiteral("view_quick_open")));
- quickOpen->installEventFilter(this); // on click, active this view space
- hLayout->addWidget(quickOpen);
-
- layout->addLayout(hLayout);
- //END tab bar
-
- stack = new QStackedWidget( this );
- stack->setFocus();
- stack->setSizePolicy (QSizePolicy (QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
- layout->addWidget(stack);
-
- mIsActiveSpace = false;
-
- m_group.clear();
-
- // connect signal to hide/show statusbar
- connect (m_viewManager->mainWindow(), SIGNAL(statusBarToggled()), this, SLOT(statusBarToggled()));
-
- // init the statusbar...
- statusBarToggled ();
+ setObjectName(QString::fromLatin1(name));
+ QVBoxLayout *layout = new QVBoxLayout(this);
+ layout->setSpacing(0);
+ layout->setMargin(0);
+
+ //BEGIN tab bar
+ QHBoxLayout *hLayout = new QHBoxLayout();
+ hLayout->setSpacing(0);
+ hLayout->setMargin(0);
+
+ // add tab bar
+ m_tabBar = new KateTabBar(this);
+ connect(m_tabBar, &KateTabBar::currentChanged, this, &KateViewSpace::changeView);
+ hLayout->addWidget(m_tabBar);
+
+ // add vertical split view space
+ QToolButton *split = new QToolButton(this);
+ split->setAutoRaise(true);
+ split->setPopupMode(QToolButton::InstantPopup);
+ split->setIcon(QIcon::fromTheme(QStringLiteral("view-split-left-right")));
+ split->addAction(m_viewManager->mainWindow()->actionCollection()->action(QStringLiteral("view_split_vert")));
+ split->addAction(m_viewManager->mainWindow()->actionCollection()->action(QStringLiteral("view_split_horiz")));
+ split->addAction(m_viewManager->mainWindow()->actionCollection()->action(QStringLiteral("view_close_current_space")));
+ split->setWhatsThis(i18n("Control view space splitting"));
+ split->installEventFilter(this); // on click, active this view space
+ hLayout->addWidget(split);
+
+ // add quick open
+ QToolButton *quickOpen = new QToolButton(this);
+ quickOpen->setAutoRaise(true);
+ quickOpen->setDefaultAction(m_viewManager->mainWindow()->actionCollection()->action(QStringLiteral("view_quick_open")));
+ quickOpen->installEventFilter(this); // on click, active this view space
+ hLayout->addWidget(quickOpen);
+
+ layout->addLayout(hLayout);
+ //END tab bar
+
+ stack = new QStackedWidget(this);
+ stack->setFocus();
+ stack->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
+ layout->addWidget(stack);
+
+ mIsActiveSpace = false;
+
+ m_group.clear();
+
+ // connect signal to hide/show statusbar
+ connect(m_viewManager->mainWindow(), SIGNAL(statusBarToggled()), this, SLOT(statusBarToggled()));
+
+ // init the statusbar...
+ statusBarToggled();
}
KateViewSpace::~KateViewSpace()
@@ -103,264 +103,261 @@ KateViewSpace::~KateViewSpace()
bool KateViewSpace::eventFilter(QObject *obj, QEvent *event)
{
- QToolButton * button = qobject_cast<QToolButton*>(obj);
-
- // maybe a tool tip of a QToolButton: show shortcuts
- if (button && event->type() == QEvent::ToolTip) {
- QHelpEvent * e = static_cast<QHelpEvent *>(event);
- if (button->defaultAction()) {
- QToolTip::showText(e->globalPos(),
- button->toolTip() + QStringLiteral(" (%1)").arg(button->defaultAction()->shortcut().toString()), button);
- return true;
+ QToolButton *button = qobject_cast<QToolButton *>(obj);
+
+ // maybe a tool tip of a QToolButton: show shortcuts
+ if (button && event->type() == QEvent::ToolTip) {
+ QHelpEvent *e = static_cast<QHelpEvent *>(event);
+ if (button->defaultAction()) {
+ QToolTip::showText(e->globalPos(),
+ button->toolTip() + QStringLiteral(" (%1)").arg(button->defaultAction()->shortcut().toString()), button);
+ return true;
+ }
}
- }
-
- // on mouse press on view space bar tool buttons: activate this space
- if (button && ! isActiveSpace() && event->type() == QEvent::MouseButtonPress) {
- m_viewManager->setActiveSpace(this);
- m_viewManager->activateView(currentView()->document());
- }
- return false;
+
+ // on mouse press on view space bar tool buttons: activate this space
+ if (button && ! isActiveSpace() && event->type() == QEvent::MouseButtonPress) {
+ m_viewManager->setActiveSpace(this);
+ m_viewManager->activateView(currentView()->document());
+ }
+ return false;
}
-void KateViewSpace::statusBarToggled ()
+void KateViewSpace::statusBarToggled()
{
- Q_FOREACH(auto view, mViewList) {
- view->setStatusBarEnabled(m_viewManager->mainWindow()->showStatusBar());
- }
+ Q_FOREACH(auto view, mViewList) {
+ view->setStatusBarEnabled(m_viewManager->mainWindow()->showStatusBar());
+ }
}
-KTextEditor::View *KateViewSpace::createView (KTextEditor::Document *doc)
+KTextEditor::View *KateViewSpace::createView(KTextEditor::Document *doc)
{
- /**
- * Create a fresh view
- */
- KTextEditor::View *v = doc->createView (stack, m_viewManager->mainWindow()->wrapper());
-
- // set status bar to right state
- v->setStatusBarEnabled(m_viewManager->mainWindow()->showStatusBar());
-
- // restore the config of this view if possible
- if ( !m_group.isEmpty() )
- {
- QString fn = v->document()->url().toString();
- if ( ! fn.isEmpty() )
- {
- QString vgroup = QString::fromLatin1("%1 %2").arg(m_group).arg(fn);
-
- KateSession::Ptr as = KateSessionManager::self()->activeSession ();
- if ( as->config() && as->config()->hasGroup( vgroup ) )
- {
- KConfigGroup cg( as->config(), vgroup );
-
- if (KTextEditor::SessionConfigInterface *iface = qobject_cast<KTextEditor::SessionConfigInterface *>(v))
- iface->readSessionConfig ( cg );
- }
+ /**
+ * Create a fresh view
+ */
+ KTextEditor::View *v = doc->createView(stack, m_viewManager->mainWindow()->wrapper());
+
+ // set status bar to right state
+ v->setStatusBarEnabled(m_viewManager->mainWindow()->showStatusBar());
+
+ // restore the config of this view if possible
+ if (!m_group.isEmpty()) {
+ QString fn = v->document()->url().toString();
+ if (! fn.isEmpty()) {
+ QString vgroup = QString::fromLatin1("%1 %2").arg(m_group).arg(fn);
+
+ KateSession::Ptr as = KateSessionManager::self()->activeSession();
+ if (as->config() && as->config()->hasGroup(vgroup)) {
+ KConfigGroup cg(as->config(), vgroup);
+
+ if (KTextEditor::SessionConfigInterface *iface = qobject_cast<KTextEditor::SessionConfigInterface *>(v)) {
+ iface->readSessionConfig(cg);
+ }
+ }
+ }
}
- }
- // just register document, it is shown below through showView() then
- if ( ! m_docToTabId.contains(doc)) {
- registerDocument(doc);
- Q_ASSERT(m_docToTabId.contains(doc));
- }
+ // just register document, it is shown below through showView() then
+ if (! m_docToTabId.contains(doc)) {
+ registerDocument(doc);
+ Q_ASSERT(m_docToTabId.contains(doc));
+ }
- // insert View into stack
- stack->addWidget(v);
- mViewList.append(v);
- showView( v );
+ // insert View into stack
+ stack->addWidget(v);
+ mViewList.append(v);
+ showView(v);
- return v;
+ return v;
}
-void KateViewSpace::removeView(KTextEditor::View* v)
+void KateViewSpace::removeView(KTextEditor::View *v)
{
- // remove from tab bar
- Q_ASSERT(m_docToTabId.contains(v->document()));
- documentDestroyed(v->document());
-
- // remove from view space
- bool active = ( v == currentView() );
-
- mViewList.removeAt ( mViewList.indexOf ( v ) );
- stack->removeWidget (v);
-
- if ( ! active )
- return;
-
- // the last recently used viewspace is always at the end of the list
- if (!mViewList.isEmpty()) {
- showView(mViewList.last());
- }
- // if we still have tabs, use these
- else if (! m_docToTabId.isEmpty()) {
- QList<KTextEditor::Document*> keys = m_docToTabId.keys();
- m_viewManager->createView(keys.first());
- }
+ // remove from tab bar
+ Q_ASSERT(m_docToTabId.contains(v->document()));
+ documentDestroyed(v->document());
+
+ // remove from view space
+ bool active = (v == currentView());
+
+ mViewList.removeAt(mViewList.indexOf(v));
+ stack->removeWidget(v);
+
+ if (! active) {
+ return;
+ }
+
+ // the last recently used viewspace is always at the end of the list
+ if (!mViewList.isEmpty()) {
+ showView(mViewList.last());
+ }
+ // if we still have tabs, use these
+ else if (! m_docToTabId.isEmpty()) {
+ QList<KTextEditor::Document *> keys = m_docToTabId.keys();
+ m_viewManager->createView(keys.first());
+ }
}
-KTextEditor::View * KateViewSpace::viewForDocument(KTextEditor::Document * doc) const
+KTextEditor::View *KateViewSpace::viewForDocument(KTextEditor::Document *doc) const
{
- QList<KTextEditor::View*>::const_iterator it = mViewList.constEnd();
- while (it != mViewList.constBegin()) {
- --it;
- if ((*it)->document() == doc) {
- return *it;
+ QList<KTextEditor::View *>::const_iterator it = mViewList.constEnd();
+ while (it != mViewList.constBegin()) {
+ --it;
+ if ((*it)->document() == doc) {
+ return *it;
+ }
}
- }
- return 0;
+ return 0;
}
bool KateViewSpace::showView(KTextEditor::Document *document)
{
- QList<KTextEditor::View*>::const_iterator it = mViewList.constEnd();
- while( it != mViewList.constBegin() )
- {
- --it;
- if ((*it)->document() == document)
- {
- KTextEditor::View* kv = *it;
-
- // move view to end of list
- mViewList.removeAt( mViewList.indexOf(kv) );
- mViewList.append( kv );
- stack->setCurrentWidget( kv );
- kv->show();
-
- // raise tab in tab bar
- Q_ASSERT(m_docToTabId.contains(document));
+ QList<KTextEditor::View *>::const_iterator it = mViewList.constEnd();
+ while (it != mViewList.constBegin()) {
+ --it;
+ if ((*it)->document() == document) {
+ KTextEditor::View *kv = *it;
+
+ // move view to end of list
+ mViewList.removeAt(mViewList.indexOf(kv));
+ mViewList.append(kv);
+ stack->setCurrentWidget(kv);
+ kv->show();
+
+ // raise tab in tab bar
+ Q_ASSERT(m_docToTabId.contains(document));
// m_tabBar->raiseTab(m_docToTabId[document]);
- m_tabBar->setCurrentTab(m_docToTabId[document]);
+ m_tabBar->setCurrentTab(m_docToTabId[document]);
- return true;
+ return true;
+ }
}
- }
- return false;
+ return false;
}
void KateViewSpace::changeView(int buttonId)
{
- KTextEditor::Document * doc = m_docToTabId.key(buttonId);
- Q_ASSERT(doc);
+ KTextEditor::Document *doc = m_docToTabId.key(buttonId);
+ Q_ASSERT(doc);
- // make sure we open the view in this view space
- if (! isActiveSpace()) {
- m_viewManager->setActiveSpace(this);
- }
+ // make sure we open the view in this view space
+ if (! isActiveSpace()) {
+ m_viewManager->setActiveSpace(this);
+ }
- // tell the view manager to show the view
- m_viewManager->activateView(doc);
+ // tell the view manager to show the view
+ m_viewManager->activateView(doc);
}
-KTextEditor::View* KateViewSpace::currentView()
+KTextEditor::View *KateViewSpace::currentView()
{
- // stack->currentWidget() returns NULL, if stack.count() == 0,
- // i.e. if mViewList.isEmpty()
- return (KTextEditor::View*)stack->currentWidget();
+ // stack->currentWidget() returns NULL, if stack.count() == 0,
+ // i.e. if mViewList.isEmpty()
+ return (KTextEditor::View *)stack->currentWidget();
}
bool KateViewSpace::isActiveSpace()
{
- return mIsActiveSpace;
+ return mIsActiveSpace;
}
-void KateViewSpace::setActive( bool active, bool )
+void KateViewSpace::setActive(bool active, bool)
{
- mIsActiveSpace = active;
+ mIsActiveSpace = active;
- // change the statusbar palette according to the activation state
- // FIXME KF5 mStatusBar->setEnabled(active);
+ // change the statusbar palette according to the activation state
+ // FIXME KF5 mStatusBar->setEnabled(active);
}
void KateViewSpace::registerDocument(KTextEditor::Document *doc)
{
- Q_ASSERT( ! m_docToTabId.contains(doc));
- // add to tab bar
- const int index = m_tabBar->addTab(doc->documentName());
- m_tabBar->setTabToolTip(index, doc->url().toString());
- m_docToTabId[doc] = index;
-
- connect(doc, SIGNAL(documentNameChanged(KTextEditor::Document*)),
- this, SLOT(updateDocumentName(KTextEditor::Document*)));
- connect(doc, SIGNAL(destroyed(QObject*)), this, SLOT(documentDestroyed(QObject*)));
+ Q_ASSERT(! m_docToTabId.contains(doc));
+ // add to tab bar
+ const int index = m_tabBar->addTab(doc->documentName());
+ m_tabBar->setTabToolTip(index, doc->url().toString());
+ m_docToTabId[doc] = index;
+
+ connect(doc, SIGNAL(documentNameChanged(KTextEditor::Document*)),
+ this, SLOT(updateDocumentName(KTextEditor::Document*)));
+ connect(doc, SIGNAL(destroyed(QObject*)), this, SLOT(documentDestroyed(QObject*)));
}
-void KateViewSpace::documentDestroyed(QObject * doc)
+void KateViewSpace::documentDestroyed(QObject *doc)
{
- Q_ASSERT(m_docToTabId.contains(static_cast<KTextEditor::Document*>(doc)));
- const int index = m_docToTabId[static_cast<KTextEditor::Document*>(doc)];
- m_tabBar->removeTab(index);
- m_docToTabId.remove(static_cast<KTextEditor::Document*>(doc));
- disconnect(doc, 0, this, 0);
+ Q_ASSERT(m_docToTabId.contains(static_cast<KTextEditor::Document *>(doc)));
+ const int index = m_docToTabId[static_cast<KTextEditor::Document *>(doc)];
+ m_tabBar->removeTab(index);
+ m_docToTabId.remove(static_cast<KTextEditor::Document *>(doc));
+ disconnect(doc, 0, this, 0);
}
-void KateViewSpace::updateDocumentName(KTextEditor::Document* doc)
+void KateViewSpace::updateDocumentName(KTextEditor::Document *doc)
{
- const int buttonId = m_docToTabId[doc];
- Q_ASSERT(buttonId >= 0);
- m_tabBar->setTabText(buttonId, doc->documentName());
- m_tabBar->setTabToolTip(buttonId, doc->url().toDisplayString());
+ const int buttonId = m_docToTabId[doc];
+ Q_ASSERT(buttonId >= 0);
+ m_tabBar->setTabText(buttonId, doc->documentName());
+ m_tabBar->setTabToolTip(buttonId, doc->url().toDisplayString());
}
-void KateViewSpace::saveConfig ( KConfigBase* config, int myIndex , const QString& viewConfGrp)
+void KateViewSpace::saveConfig(KConfigBase *config, int myIndex , const QString &viewConfGrp)
{
// qCDebug(LOG_KATE)<<"KateViewSpace::saveConfig("<<myIndex<<", "<<viewConfGrp<<") - currentView: "<<currentView()<<")";
- QString groupname = QString(viewConfGrp + QStringLiteral("-ViewSpace %1")).arg( myIndex );
+ QString groupname = QString(viewConfGrp + QStringLiteral("-ViewSpace %1")).arg(myIndex);
- KConfigGroup group (config, groupname);
- group.writeEntry ("Count", mViewList.count());
+ KConfigGroup group(config, groupname);
+ group.writeEntry("Count", mViewList.count());
- if (currentView())
- group.writeEntry( "Active View", currentView()->document()->url().toString() );
+ if (currentView()) {
+ group.writeEntry("Active View", currentView()->document()->url().toString());
+ }
- // Save file list, including cursor position in this instance.
- int idx = 0;
- for (QList<KTextEditor::View*>::iterator it = mViewList.begin();
- it != mViewList.end(); ++it)
- {
- if ( !(*it)->document()->url().isEmpty() )
- {
- group.writeEntry( QString::fromLatin1("View %1").arg( idx ), (*it)->document()->url().toString() );
+ // Save file list, including cursor position in this instance.
+ int idx = 0;
+ for (QList<KTextEditor::View *>::iterator it = mViewList.begin();
+ it != mViewList.end(); ++it) {
+ if (!(*it)->document()->url().isEmpty()) {
+ group.writeEntry(QString::fromLatin1("View %1").arg(idx), (*it)->document()->url().toString());
- // view config, group: "ViewSpace <n> url"
- QString vgroup = QString::fromLatin1("%1 %2").arg(groupname).arg((*it)->document()->url().toString());
- KConfigGroup viewGroup( config, vgroup );
+ // view config, group: "ViewSpace <n> url"
+ QString vgroup = QString::fromLatin1("%1 %2").arg(groupname).arg((*it)->document()->url().toString());
+ KConfigGroup viewGroup(config, vgroup);
- if (KTextEditor::SessionConfigInterface *iface = qobject_cast<KTextEditor::SessionConfigInterface *>(*it))
- iface->writeSessionConfig( viewGroup );
- }
+ if (KTextEditor::SessionConfigInterface *iface = qobject_cast<KTextEditor::SessionConfigInterface *>(*it)) {
+ iface->writeSessionConfig(viewGroup);
+ }
+ }
- ++idx;
- }
+ ++idx;
+ }
}
-void KateViewSpace::restoreConfig ( KateViewManager *viewMan, const KConfigBase* config, const QString &groupname )
+void KateViewSpace::restoreConfig(KateViewManager *viewMan, const KConfigBase *config, const QString &groupname)
{
- KConfigGroup group (config, groupname);
- QString fn = group.readEntry( "Active View" );
+ KConfigGroup group(config, groupname);
+ QString fn = group.readEntry("Active View");
- if ( !fn.isEmpty() )
- {
- KTextEditor::Document *doc = KateDocManager::self()->findDocument (QUrl(fn));
+ if (!fn.isEmpty()) {
+ KTextEditor::Document *doc = KateDocManager::self()->findDocument(QUrl(fn));
- if (doc)
- {
- // view config, group: "ViewSpace <n> url"
- QString vgroup = QString::fromLatin1("%1 %2").arg(groupname).arg(fn);
- KConfigGroup configGroup( config, vgroup );
+ if (doc) {
+ // view config, group: "ViewSpace <n> url"
+ QString vgroup = QString::fromLatin1("%1 %2").arg(groupname).arg(fn);
+ KConfigGroup configGroup(config, vgroup);
- viewMan->createView (doc);
+ viewMan->createView(doc);
- KTextEditor::View *v = viewMan->activeView ();
+ KTextEditor::View *v = viewMan->activeView();
- if (KTextEditor::SessionConfigInterface *iface = qobject_cast<KTextEditor::SessionConfigInterface *>(v))
- iface->readSessionConfig( configGroup );
+ if (KTextEditor::SessionConfigInterface *iface = qobject_cast<KTextEditor::SessionConfigInterface *>(v)) {
+ iface->readSessionConfig(configGroup);
+ }
+ }
}
- }
- if (mViewList.isEmpty())
- viewMan->createView (KateDocManager::self()->document(0));
+ if (mViewList.isEmpty()) {
+ viewMan->createView(KateDocManager::self()->document(0));
+ }
- m_group = groupname; // used for restroing view configs later
+ m_group = groupname; // used for restroing view configs later
}
//END KateViewSpace
diff --git a/kate/app/kateviewspace.h b/kate/app/kateviewspace.h
index 627de20..a1298a8 100644
--- a/kate/app/kateviewspace.h
+++ b/kate/app/kateviewspace.h
@@ -40,8 +40,8 @@ class KateViewSpace : public QWidget
{
Q_OBJECT
- public:
- explicit KateViewSpace(KateViewManager *, QWidget* parent = 0, const char* name = 0);
+public:
+ explicit KateViewSpace(KateViewManager *, QWidget *parent = 0, const char *name = 0);
~KateViewSpace();
bool isActiveSpace();
@@ -52,25 +52,23 @@ class KateViewSpace : public QWidget
* @param doc document to create view for
* @return new created view
*/
- KTextEditor::View *createView (KTextEditor::Document *doc);
- void removeView(KTextEditor::View* v);
+ KTextEditor::View *createView(KTextEditor::Document *doc);
+ void removeView(KTextEditor::View *v);
- bool showView(KTextEditor::View *view)
- {
- return showView(view->document());
+ bool showView(KTextEditor::View *view) {
+ return showView(view->document());
}
bool showView(KTextEditor::Document *document);
- KTextEditor::View * viewForDocument(KTextEditor::Document *document) const;
+ KTextEditor::View *viewForDocument(KTextEditor::Document *document) const;
- KTextEditor::View* currentView();
- int viewCount() const
- {
- return mViewList.count();
+ KTextEditor::View *currentView();
+ int viewCount() const {
+ return mViewList.count();
}
- void saveConfig (KConfigBase* config, int myIndex, const QString& viewConfGrp);
- void restoreConfig ( KateViewManager *viewMan, const KConfigBase* config, const QString &group );
+ void saveConfig(KConfigBase *config, int myIndex, const QString &viewConfGrp);
+ void restoreConfig(KateViewManager *viewMan, const KConfigBase *config, const QString &group);
/**
* Called by the view manager to notify that new documents were created
@@ -83,29 +81,29 @@ class KateViewSpace : public QWidget
*/
bool eventFilter(QObject *obj, QEvent *event);
- public Q_SLOTS:
- void documentDestroyed(QObject * doc);
- void updateDocumentName(KTextEditor::Document* doc);
+public Q_SLOTS:
+ void documentDestroyed(QObject *doc);
+ void updateDocumentName(KTextEditor::Document *doc);
- private Q_SLOTS:
- void statusBarToggled ();
+private Q_SLOTS:
+ void statusBarToggled();
void changeView(int buttonId);
- private:
- QStackedWidget* stack;
+private:
+ QStackedWidget *stack;
bool mIsActiveSpace;
/// This list is necessary to only save the order of the accessed views.
/// The order is important. The least recently viewed view is always the
/// last entry in the list, i.e. mViewList.last()
/// mViewList.count() == stack.count() is always true!
- QList<KTextEditor::View*> mViewList;
+ QList<KTextEditor::View *> mViewList;
KateViewManager *m_viewManager;
QString m_group;
// tab bar that contains viewspace tabs
- KateTabBar * m_tabBar;
+ KateTabBar *m_tabBar;
// map from Document to button id
- QHash<KTextEditor::Document*, int> m_docToTabId;
+ QHash<KTextEditor::Document *, int> m_docToTabId;
};
#endif
diff --git a/kate/app/katewaiter.h b/kate/app/katewaiter.h
index 2f75930..465652d 100644
--- a/kate/app/katewaiter.h
+++ b/kate/app/katewaiter.h
@@ -26,35 +26,39 @@
#include <QDBusConnection>
#include <QDBusConnectionInterface>
-class KateWaiter : public QObject {
- Q_OBJECT
+class KateWaiter : public QObject
+{
+ Q_OBJECT
- private:
+private:
QCoreApplication *m_app;
QString m_service;
QStringList m_tokens;
- public:
- KateWaiter (QCoreApplication *app, const QString &service,const QStringList &tokens)
- : QObject (app), m_app (app), m_service (service),m_tokens(tokens) {
- connect ( QDBusConnection::sessionBus().interface(), SIGNAL(serviceOwnerChanged(QString,QString,QString))
- , this, SLOT(serviceOwnerChanged(QString,QString,QString)) );
+public:
+ KateWaiter(QCoreApplication *app, const QString &service, const QStringList &tokens)
+ : QObject(app), m_app(app), m_service(service), m_tokens(tokens) {
+ connect(QDBusConnection::sessionBus().interface(), SIGNAL(serviceOwnerChanged(QString, QString, QString))
+ , this, SLOT(serviceOwnerChanged(QString, QString, QString)));
}
- public Q_SLOTS:
- void exiting () {
- m_app->quit ();
+public Q_SLOTS:
+ void exiting() {
+ m_app->quit();
}
- void documentClosed(const QString& token) {
- m_tokens.removeAll(token);
- if (m_tokens.count()==0) m_app->quit();
+ void documentClosed(const QString &token) {
+ m_tokens.removeAll(token);
+ if (m_tokens.count() == 0) {
+ m_app->quit();
+ }
}
- void serviceOwnerChanged( const QString & name, const QString &, const QString &) {
- if (name != m_service)
- return;
+ void serviceOwnerChanged(const QString &name, const QString &, const QString &) {
+ if (name != m_service) {
+ return;
+ }
- m_app->quit ();
+ m_app->quit();
}
};
diff --git a/kate/app/main.cpp b/kate/app/main.cpp
index eecd86e..7f4dd6b 100644
--- a/kate/app/main.cpp
+++ b/kate/app/main.cpp
@@ -39,387 +39,373 @@
#include <QApplication>
#include <QDir>
-extern "C" Q_DECL_EXPORT int kdemain( int argc, char **argv )
+extern "C" Q_DECL_EXPORT int kdemain(int argc, char **argv)
{
- /**
- * Create application first
- */
- QApplication app (argc, argv);
-
- /**
- * FIXME: activate debug
- */
- QLoggingCategory::setFilterRules(QStringLiteral("kate = true"));
-
- /**
- * construct about data for Kate
- */
- KAboutData aboutData (QStringLiteral("kate"), QString(), i18n("Kate"), QStringLiteral(KATE_VERSION),
- i18n( "Kate - Advanced Text Editor" ), KAboutData::License_LGPL_V2,
- i18n( "(c) 2000-2014 The Kate Authors" ), QString(), QStringLiteral("http://kate-editor.org"));
-
- /**
- * right dbus prefix == org.kde.
- */
- aboutData.setOrganizationDomain ("kde.org");
-
- aboutData.addAuthor (i18n("Christoph Cullmann"), i18n("Maintainer"), QStringLiteral("cullmann@kde.org"), QStringLiteral("http://www.cullmann.io"));
- aboutData.addAuthor (i18n("Anders Lund"), i18n("Core Developer"), QStringLiteral("anders@alweb.dk"), QStringLiteral("http://www.alweb.dk"));
- aboutData.addAuthor (i18n("Joseph Wenninger"), i18n("Core Developer"), QStringLiteral("jowenn@kde.org"), QStringLiteral("http://stud3.tuwien.ac.at/~e9925371"));
- aboutData.addAuthor (i18n("Hamish Rodda"), i18n("Core Developer"), QStringLiteral("rodda@kde.org"));
- aboutData.addAuthor (i18n("Dominik Haumann"), i18n("Developer & Highlight wizard"), QStringLiteral("dhdev@gmx.de"));
- aboutData.addAuthor (i18n("Waldo Bastian"), i18n("The cool buffersystem"), QStringLiteral("bastian@kde.org") );
- aboutData.addAuthor (i18n("Charles Samuels"), i18n("The Editing Commands"), QStringLiteral("charles@kde.org"));
- aboutData.addAuthor (i18n("Matt Newell"), i18n("Testing, ..."), QStringLiteral("newellm@proaxis.com"));
- aboutData.addAuthor (i18n("Michael Bartl"), i18n("Former Core Developer"), QStringLiteral("michael.bartl1@chello.at"));
- aboutData.addAuthor (i18n("Michael McCallum"), i18n("Core Developer"), QStringLiteral("gholam@xtra.co.nz"));
- aboutData.addAuthor (i18n("Jochen Wilhemly"), i18n("KWrite Author"), QStringLiteral("digisnap@cs.tu-berlin.de") );
- aboutData.addAuthor (i18n("Michael Koch"), i18n("KWrite port to KParts"), QStringLiteral("koch@kde.org"));
- aboutData.addAuthor (i18n("Christian Gebauer"), QString(), QStringLiteral("gebauer@kde.org") );
- aboutData.addAuthor (i18n("Simon Hausmann"), QString(), QStringLiteral("hausmann@kde.org") );
- aboutData.addAuthor (i18n("Glen Parker"), i18n("KWrite Undo History, Kspell integration"), QStringLiteral("glenebob@nwlink.com"));
- aboutData.addAuthor (i18n("Scott Manson"), i18n("KWrite XML Syntax highlighting support"), QStringLiteral("sdmanson@alltel.net"));
- aboutData.addAuthor (i18n("John Firebaugh"), i18n("Patches and more"), QStringLiteral("jfirebaugh@kde.org"));
- aboutData.addAuthor (i18n("Pablo Martín"), i18n("Python Plugin Developer"), QStringLiteral("goinnn@gmail.com"), QStringLiteral("http://github.com/goinnn/"));
- aboutData.addAuthor (i18n("Gerald Senarclens de Grancy"), i18n("QA and Scripting"), QStringLiteral("oss@senarclens.eu"), QStringLiteral("http://find-santa.eu/"));
-
- aboutData.addCredit (i18n("Matteo Merli"), i18n("Highlighting for RPM Spec-Files, Perl, Diff and more"), QStringLiteral("merlim@libero.it"));
- aboutData.addCredit (i18n("Rocky Scaletta"), i18n("Highlighting for VHDL"), QStringLiteral("rocky@purdue.edu"));
- aboutData.addCredit (i18n("Yury Lebedev"), i18n("Highlighting for SQL"));
- aboutData.addCredit (i18n("Chris Ross"), i18n("Highlighting for Ferite"));
- aboutData.addCredit (i18n("Nick Roux"), i18n("Highlighting for ILERPG"));
- aboutData.addCredit (i18n("Carsten Niehaus"), i18n("Highlighting for LaTeX"));
- aboutData.addCredit (i18n("Per Wigren"), i18n("Highlighting for Makefiles, Python"));
- aboutData.addCredit (i18n("Jan Fritz"), i18n("Highlighting for Python"));
- aboutData.addCredit (i18n("Daniel Naber"));
- aboutData.addCredit (i18n("Roland Pabel"), i18n("Highlighting for Scheme"));
- aboutData.addCredit (i18n("Cristi Dumitrescu"), i18n("PHP Keyword/Datatype list"));
- aboutData.addCredit (i18n("Carsten Pfeiffer"), i18n("Very nice help"));
- aboutData.addCredit (i18n("All people who have contributed and I have forgotten to mention"));
-
- /**
- * register about data
- */
- KAboutData::setApplicationData (aboutData);
-
- /**
- * take component name and org. name from KAboutData
- */
- app.setApplicationName (aboutData.componentName());
- app.setApplicationDisplayName (aboutData.displayName());
- app.setOrganizationDomain (aboutData.organizationDomain());
- app.setApplicationVersion (aboutData.version());
- app.setQuitOnLastWindowClosed (false);
-
- /**
- * Create command line parser and feed it with known options
- */
- QCommandLineParser parser;
- aboutData.setupCommandLine (&parser);
- parser.setApplicationDescription (aboutData.shortDescription());
- parser.addHelpOption ();
- parser.addVersionOption ();
-
- // -s/--start session option
- const QCommandLineOption startSessionOption (QStringList () << QStringLiteral("s") << QStringLiteral("start"), i18n("Start Kate with a given session."), QStringLiteral("session"));
- parser.addOption (startSessionOption);
-
- // --startanon session option
- const QCommandLineOption startAnonymousSessionOption (QStringList () << QStringLiteral("startanon"), i18n("Start Kate with a new anonymous session, implies '-n'."));
- parser.addOption (startAnonymousSessionOption);
-
- // -n/--new option
- const QCommandLineOption startNewInstanceOption (QStringList () << QStringLiteral("n") << QStringLiteral("new"), i18n("Force start of a new kate instance (is ignored if start is used and another kate instance already has the given session opened), forced if no parameters and no URLs are given at all."));
- parser.addOption (startNewInstanceOption);
-
- // -b/--block option
- const QCommandLineOption startBlockingOption (QStringList () << QStringLiteral("b") << QStringLiteral("block"), i18n("If using an already running kate instance, block until it exits, if URLs given to open."));
- parser.addOption (startBlockingOption);
-
- // -p/--pid option
- const QCommandLineOption usePidOption (QStringList () << QStringLiteral("p") << QStringLiteral("pid"), i18n("Only try to reuse kate instance with this pid (is ignored if start is used and another kate instance already has the given session opened)."), QStringLiteral("pid"));
- parser.addOption (usePidOption);
-
- // -e/--encoding option
- const QCommandLineOption useEncodingOption (QStringList () << QStringLiteral("e") << QStringLiteral("encoding"), i18n("Set encoding for the file to open."), QStringLiteral("encoding"));
- parser.addOption (useEncodingOption);
-
- // -l/--line option
- const QCommandLineOption gotoLineOption (QStringList () << QStringLiteral("l") << QStringLiteral("line"), i18n("Navigate to this line."), QStringLiteral("line"));
- parser.addOption (gotoLineOption);
-
- // -c/--column option
- const QCommandLineOption gotoColumnOption (QStringList () << QStringLiteral("c") << QStringLiteral("column"), i18n("Navigate to this column."), QStringLiteral("column"));
- parser.addOption (gotoColumnOption);
-
- // -i/--stdin option
- const QCommandLineOption readStdInOption (QStringList () << QStringLiteral("i") << QStringLiteral("stdin"), i18n("Read the contents of stdin."));
- parser.addOption (readStdInOption);
-
- // --tempfile option
- const QCommandLineOption tempfileOption (QStringList () << QStringLiteral("tempfile"), i18n("The files/URLs opened by the application will be deleted after use"));
- parser.addOption (tempfileOption);
-
- // urls to open
- parser.addPositionalArgument(QStringLiteral("urls"), i18n("Documents to open."), QStringLiteral("[urls...]"));
-
- /**
- * do the command line parsing
- */
- parser.process (app);
-
- /**
- * handle standard options
- */
- aboutData.processCommandLine (&parser);
-
- QDBusConnectionInterface *i = QDBusConnection::sessionBus().interface ();
-
- KateRunningInstanceMap mapSessionRii;
- if (!fillinRunningKateAppInstances(&mapSessionRii)) return 1;
-
- QStringList kateServices;
- for(KateRunningInstanceMap::const_iterator it=mapSessionRii.constBegin();it!=mapSessionRii.constEnd();++it)
- {
- kateServices<<(*it)->serviceName;
- }
- QString serviceName;
-
- const QStringList urls = parser.positionalArguments();
-
- bool force_new = parser.isSet(startNewInstanceOption);
-
- if (!force_new) {
- if ( !(
- parser.isSet(startSessionOption) ||
- parser.isSet(startNewInstanceOption) ||
- parser.isSet(usePidOption) ||
- parser.isSet(useEncodingOption) ||
- parser.isSet(gotoLineOption) ||
- parser.isSet(gotoColumnOption) ||
- parser.isSet(readStdInOption)
- ) && (urls.isEmpty())) force_new = true;
- }
-
- QString start_session;
- bool session_already_opened=false;
-
- //check if we try to start an already opened session
- if (parser.isSet(startAnonymousSessionOption))
- {
- force_new = true;
- }
- else if (parser.isSet(startSessionOption))
- {
- start_session = parser.value(startSessionOption);
- if (mapSessionRii.contains(start_session)) {
- serviceName=mapSessionRii[start_session]->serviceName;
- force_new=false;
- session_already_opened=true;
+ /**
+ * Create application first
+ */
+ QApplication app(argc, argv);
+
+ /**
+ * FIXME: activate debug
+ */
+ QLoggingCategory::setFilterRules(QStringLiteral("kate = true"));
+
+ /**
+ * construct about data for Kate
+ */
+ KAboutData aboutData(QStringLiteral("kate"), QString(), i18n("Kate"), QStringLiteral(KATE_VERSION),
+ i18n("Kate - Advanced Text Editor"), KAboutData::License_LGPL_V2,
+ i18n("(c) 2000-2014 The Kate Authors"), QString(), QStringLiteral("http://kate-editor.org"));
+
+ /**
+ * right dbus prefix == org.kde.
+ */
+ aboutData.setOrganizationDomain("kde.org");
+
+ aboutData.addAuthor(i18n("Christoph Cullmann"), i18n("Maintainer"), QStringLiteral("cullmann@kde.org"), QStringLiteral("http://www.cullmann.io"));
+ aboutData.addAuthor(i18n("Anders Lund"), i18n("Core Developer"), QStringLiteral("anders@alweb.dk"), QStringLiteral("http://www.alweb.dk"));
+ aboutData.addAuthor(i18n("Joseph Wenninger"), i18n("Core Developer"), QStringLiteral("jowenn@kde.org"), QStringLiteral("http://stud3.tuwien.ac.at/~e9925371"));
+ aboutData.addAuthor(i18n("Hamish Rodda"), i18n("Core Developer"), QStringLiteral("rodda@kde.org"));
+ aboutData.addAuthor(i18n("Dominik Haumann"), i18n("Developer & Highlight wizard"), QStringLiteral("dhdev@gmx.de"));
+ aboutData.addAuthor(i18n("Waldo Bastian"), i18n("The cool buffersystem"), QStringLiteral("bastian@kde.org"));
+ aboutData.addAuthor(i18n("Charles Samuels"), i18n("The Editing Commands"), QStringLiteral("charles@kde.org"));
+ aboutData.addAuthor(i18n("Matt Newell"), i18n("Testing, ..."), QStringLiteral("newellm@proaxis.com"));
+ aboutData.addAuthor(i18n("Michael Bartl"), i18n("Former Core Developer"), QStringLiteral("michael.bartl1@chello.at"));
+ aboutData.addAuthor(i18n("Michael McCallum"), i18n("Core Developer"), QStringLiteral("gholam@xtra.co.nz"));
+ aboutData.addAuthor(i18n("Jochen Wilhemly"), i18n("KWrite Author"), QStringLiteral("digisnap@cs.tu-berlin.de"));
+ aboutData.addAuthor(i18n("Michael Koch"), i18n("KWrite port to KParts"), QStringLiteral("koch@kde.org"));
+ aboutData.addAuthor(i18n("Christian Gebauer"), QString(), QStringLiteral("gebauer@kde.org"));
+ aboutData.addAuthor(i18n("Simon Hausmann"), QString(), QStringLiteral("hausmann@kde.org"));
+ aboutData.addAuthor(i18n("Glen Parker"), i18n("KWrite Undo History, Kspell integration"), QStringLiteral("glenebob@nwlink.com"));
+ aboutData.addAuthor(i18n("Scott Manson"), i18n("KWrite XML Syntax highlighting support"), QStringLiteral("sdmanson@alltel.net"));
+ aboutData.addAuthor(i18n("John Firebaugh"), i18n("Patches and more"), QStringLiteral("jfirebaugh@kde.org"));
+ aboutData.addAuthor(i18n("Pablo Martín"), i18n("Python Plugin Developer"), QStringLiteral("goinnn@gmail.com"), QStringLiteral("http://github.com/goinnn/"));
+ aboutData.addAuthor(i18n("Gerald Senarclens de Grancy"), i18n("QA and Scripting"), QStringLiteral("oss@senarclens.eu"), QStringLiteral("http://find-santa.eu/"));
+
+ aboutData.addCredit(i18n("Matteo Merli"), i18n("Highlighting for RPM Spec-Files, Perl, Diff and more"), QStringLiteral("merlim@libero.it"));
+ aboutData.addCredit(i18n("Rocky Scaletta"), i18n("Highlighting for VHDL"), QStringLiteral("rocky@purdue.edu"));
+ aboutData.addCredit(i18n("Yury Lebedev"), i18n("Highlighting for SQL"));
+ aboutData.addCredit(i18n("Chris Ross"), i18n("Highlighting for Ferite"));
+ aboutData.addCredit(i18n("Nick Roux"), i18n("Highlighting for ILERPG"));
+ aboutData.addCredit(i18n("Carsten Niehaus"), i18n("Highlighting for LaTeX"));
+ aboutData.addCredit(i18n("Per Wigren"), i18n("Highlighting for Makefiles, Python"));
+ aboutData.addCredit(i18n("Jan Fritz"), i18n("Highlighting for Python"));
+ aboutData.addCredit(i18n("Daniel Naber"));
+ aboutData.addCredit(i18n("Roland Pabel"), i18n("Highlighting for Scheme"));
+ aboutData.addCredit(i18n("Cristi Dumitrescu"), i18n("PHP Keyword/Datatype list"));
+ aboutData.addCredit(i18n("Carsten Pfeiffer"), i18n("Very nice help"));
+ aboutData.addCredit(i18n("All people who have contributed and I have forgotten to mention"));
+
+ /**
+ * register about data
+ */
+ KAboutData::setApplicationData(aboutData);
+
+ /**
+ * take component name and org. name from KAboutData
+ */
+ app.setApplicationName(aboutData.componentName());
+ app.setApplicationDisplayName(aboutData.displayName());
+ app.setOrganizationDomain(aboutData.organizationDomain());
+ app.setApplicationVersion(aboutData.version());
+ app.setQuitOnLastWindowClosed(false);
+
+ /**
+ * Create command line parser and feed it with known options
+ */
+ QCommandLineParser parser;
+ aboutData.setupCommandLine(&parser);
+ parser.setApplicationDescription(aboutData.shortDescription());
+ parser.addHelpOption();
+ parser.addVersionOption();
+
+ // -s/--start session option
+ const QCommandLineOption startSessionOption(QStringList() << QStringLiteral("s") << QStringLiteral("start"), i18n("Start Kate with a given session."), QStringLiteral("session"));
+ parser.addOption(startSessionOption);
+
+ // --startanon session option
+ const QCommandLineOption startAnonymousSessionOption(QStringList() << QStringLiteral("startanon"), i18n("Start Kate with a new anonymous session, implies '-n'."));
+ parser.addOption(startAnonymousSessionOption);
+
+ // -n/--new option
+ const QCommandLineOption startNewInstanceOption(QStringList() << QStringLiteral("n") << QStringLiteral("new"), i18n("Force start of a new kate instance (is ignored if start is used and another kate instance already has the given session opened), forced if no parameters and no URLs are given at all."));
+ parser.addOption(startNewInstanceOption);
+
+ // -b/--block option
+ const QCommandLineOption startBlockingOption(QStringList() << QStringLiteral("b") << QStringLiteral("block"), i18n("If using an already running kate instance, block until it exits, if URLs given to open."));
+ parser.addOption(startBlockingOption);
+
+ // -p/--pid option
+ const QCommandLineOption usePidOption(QStringList() << QStringLiteral("p") << QStringLiteral("pid"), i18n("Only try to reuse kate instance with this pid (is ignored if start is used and another kate instance already has the given session opened)."), QStringLiteral("pid"));
+ parser.addOption(usePidOption);
+
+ // -e/--encoding option
+ const QCommandLineOption useEncodingOption(QStringList() << QStringLiteral("e") << QStringLiteral("encoding"), i18n("Set encoding for the file to open."), QStringLiteral("encoding"));
+ parser.addOption(useEncodingOption);
+
+ // -l/--line option
+ const QCommandLineOption gotoLineOption(QStringList() << QStringLiteral("l") << QStringLiteral("line"), i18n("Navigate to this line."), QStringLiteral("line"));
+ parser.addOption(gotoLineOption);
+
+ // -c/--column option
+ const QCommandLineOption gotoColumnOption(QStringList() << QStringLiteral("c") << QStringLiteral("column"), i18n("Navigate to this column."), QStringLiteral("column"));
+ parser.addOption(gotoColumnOption);
+
+ // -i/--stdin option
+ const QCommandLineOption readStdInOption(QStringList() << QStringLiteral("i") << QStringLiteral("stdin"), i18n("Read the contents of stdin."));
+ parser.addOption(readStdInOption);
+
+ // --tempfile option
+ const QCommandLineOption tempfileOption(QStringList() << QStringLiteral("tempfile"), i18n("The files/URLs opened by the application will be deleted after use"));
+ parser.addOption(tempfileOption);
+
+ // urls to open
+ parser.addPositionalArgument(QStringLiteral("urls"), i18n("Documents to open."), QStringLiteral("[urls...]"));
+
+ /**
+ * do the command line parsing
+ */
+ parser.process(app);
+
+ /**
+ * handle standard options
+ */
+ aboutData.processCommandLine(&parser);
+
+ QDBusConnectionInterface *i = QDBusConnection::sessionBus().interface();
+
+ KateRunningInstanceMap mapSessionRii;
+ if (!fillinRunningKateAppInstances(&mapSessionRii)) {
+ return 1;
}
- }
-
- //cleanup map
- cleanupRunningKateAppInstanceMap(&mapSessionRii);
-
- //if no new instance is forced and no already opened session is requested,
- //check if a pid is given, which should be reused.
- // two possibilities: pid given or not...
- if ((!force_new) && serviceName.isEmpty())
- {
- if ( (parser.isSet(usePidOption)) || (!qgetenv("KATE_PID").isEmpty()))
- {
- QString usePid = (parser.isSet(usePidOption)) ?
- parser.value(usePidOption) :
- QString::fromLocal8Bit(qgetenv("KATE_PID"));
-
- serviceName = QStringLiteral("org.kde.kate-") + usePid;
- if (!kateServices.contains(serviceName)) serviceName.clear();
+
+ QStringList kateServices;
+ for (KateRunningInstanceMap::const_iterator it = mapSessionRii.constBegin(); it != mapSessionRii.constEnd(); ++it) {
+ kateServices << (*it)->serviceName;
+ }
+ QString serviceName;
+
+ const QStringList urls = parser.positionalArguments();
+
+ bool force_new = parser.isSet(startNewInstanceOption);
+
+ if (!force_new) {
+ if (!(
+ parser.isSet(startSessionOption) ||
+ parser.isSet(startNewInstanceOption) ||
+ parser.isSet(usePidOption) ||
+ parser.isSet(useEncodingOption) ||
+ parser.isSet(gotoLineOption) ||
+ parser.isSet(gotoColumnOption) ||
+ parser.isSet(readStdInOption)
+ ) && (urls.isEmpty())) {
+ force_new = true;
+ }
}
- }
-
- if ( (!force_new) && ( serviceName.isEmpty()))
- {
- if (kateServices.count()>0)
- serviceName = kateServices[0];
- }
-
-
- //check again if service is still running
- bool foundRunningService = false;
- if (!serviceName.isEmpty ())
- {
- QDBusReply<bool> there = i->isServiceRegistered (serviceName);
- foundRunningService = there.isValid () && there.value();
- }
-
-
- if (foundRunningService)
- {
- // open given session
- if (parser.isSet(startSessionOption) && (!session_already_opened) )
- {
- QDBusMessage m = QDBusMessage::createMethodCall (serviceName,
- QStringLiteral("/MainApplication"), QStringLiteral("org.kde.Kate.Application"), QStringLiteral("activateSession"));
-
- QList<QVariant> dbusargs;
- dbusargs.append(parser.value(startSessionOption));
- m.setArguments(dbusargs);
-
- QDBusConnection::sessionBus().call (m);
+
+ QString start_session;
+ bool session_already_opened = false;
+
+ //check if we try to start an already opened session
+ if (parser.isSet(startAnonymousSessionOption)) {
+ force_new = true;
+ } else if (parser.isSet(startSessionOption)) {
+ start_session = parser.value(startSessionOption);
+ if (mapSessionRii.contains(start_session)) {
+ serviceName = mapSessionRii[start_session]->serviceName;
+ force_new = false;
+ session_already_opened = true;
+ }
}
- QString enc = parser.isSet(useEncodingOption) ? parser.value(useEncodingOption) : QString();
-
- bool tempfileSet = parser.isSet(tempfileOption);
-
- // only block, if files to open there....
- bool needToBlock = parser.isSet(startBlockingOption) && !urls.isEmpty();
-
- QStringList tokens;
-
- // open given files...
- foreach(const QString &url, urls)
- {
- QDBusMessage m = QDBusMessage::createMethodCall (serviceName,
- QStringLiteral("/MainApplication"), QStringLiteral("org.kde.Kate.Application"), QStringLiteral("tokenOpenUrl"));
-
- QList<QVariant> dbusargs;
-
- // convert to an url
- QRegExp withProtocol(QStringLiteral("^[a-zA-Z]+:")); // TODO: remove after Qt supports this on its own
- if (withProtocol.indexIn(url) == 0) {
- dbusargs.append(QUrl::fromUserInput(url));
- } else {
- const QString path = QDir::current().absoluteFilePath(url);
- dbusargs.append(QUrl::fromLocalFile(path));
- }
-
- dbusargs.append(enc);
- dbusargs.append(tempfileSet);
- m.setArguments(dbusargs);
-
- QDBusMessage res=QDBusConnection::sessionBus().call (m);
- if (res.type()==QDBusMessage::ReplyMessage)
- {
- if (res.arguments().count()==1)
- {
- QVariant v=res.arguments()[0];
- if (v.isValid())
- {
- QString s=v.toString();
- if ((!s.isEmpty()) && (s != QStringLiteral("ERROR")))
- {
- tokens<<s;
- }
+ //cleanup map
+ cleanupRunningKateAppInstanceMap(&mapSessionRii);
+
+ //if no new instance is forced and no already opened session is requested,
+ //check if a pid is given, which should be reused.
+ // two possibilities: pid given or not...
+ if ((!force_new) && serviceName.isEmpty()) {
+ if ((parser.isSet(usePidOption)) || (!qgetenv("KATE_PID").isEmpty())) {
+ QString usePid = (parser.isSet(usePidOption)) ?
+ parser.value(usePidOption) :
+ QString::fromLocal8Bit(qgetenv("KATE_PID"));
+
+ serviceName = QStringLiteral("org.kde.kate-") + usePid;
+ if (!kateServices.contains(serviceName)) {
+ serviceName.clear();
}
}
- }
}
-
- if(parser.isSet(readStdInOption))
- {
- QTextStream input(stdin, QIODevice::ReadOnly);
- // set chosen codec
- QTextCodec *codec = parser.isSet(useEncodingOption) ?
- QTextCodec::codecForName(parser.value(useEncodingOption).toUtf8()) : 0;
+ if ((!force_new) && (serviceName.isEmpty())) {
+ if (kateServices.count() > 0) {
+ serviceName = kateServices[0];
+ }
+ }
- if (codec)
- input.setCodec (codec);
+ //check again if service is still running
+ bool foundRunningService = false;
+ if (!serviceName.isEmpty()) {
+ QDBusReply<bool> there = i->isServiceRegistered(serviceName);
+ foundRunningService = there.isValid() && there.value();
+ }
- QString line;
- QString text;
+ if (foundRunningService) {
+ // open given session
+ if (parser.isSet(startSessionOption) && (!session_already_opened)) {
+ QDBusMessage m = QDBusMessage::createMethodCall(serviceName,
+ QStringLiteral("/MainApplication"), QStringLiteral("org.kde.Kate.Application"), QStringLiteral("activateSession"));
- do
- {
- line = input.readLine();
- text.append( line + QLatin1Char('\n') );
- }
- while( !line.isNull() );
+ QList<QVariant> dbusargs;
+ dbusargs.append(parser.value(startSessionOption));
+ m.setArguments(dbusargs);
- QDBusMessage m = QDBusMessage::createMethodCall (serviceName,
- QStringLiteral("/MainApplication"), QStringLiteral("org.kde.Kate.Application"), QStringLiteral("openInput"));
+ QDBusConnection::sessionBus().call(m);
+ }
- QList<QVariant> dbusargs;
- dbusargs.append(text);
- m.setArguments(dbusargs);
+ QString enc = parser.isSet(useEncodingOption) ? parser.value(useEncodingOption) : QString();
- QDBusConnection::sessionBus().call (m);
- }
+ bool tempfileSet = parser.isSet(tempfileOption);
- int line = 0;
- int column = 0;
- bool nav = false;
+ // only block, if files to open there....
+ bool needToBlock = parser.isSet(startBlockingOption) && !urls.isEmpty();
- if (parser.isSet(gotoLineOption))
- {
- line = parser.value(gotoLineOption).toInt() - 1;
- nav = true;
- }
+ QStringList tokens;
- if (parser.isSet(gotoColumnOption))
- {
- column = parser.value(gotoColumnOption).toInt() - 1;
- nav = true;
- }
+ // open given files...
+ foreach(const QString & url, urls) {
+ QDBusMessage m = QDBusMessage::createMethodCall(serviceName,
+ QStringLiteral("/MainApplication"), QStringLiteral("org.kde.Kate.Application"), QStringLiteral("tokenOpenUrl"));
- if (nav)
- {
- QDBusMessage m = QDBusMessage::createMethodCall (serviceName,
- QStringLiteral("/MainApplication"), QStringLiteral("org.kde.Kate.Application"), QStringLiteral("setCursor"));
+ QList<QVariant> dbusargs;
- QList<QVariant> args;
- args.append(line);
- args.append(column);
- m.setArguments(args);
+ // convert to an url
+ QRegExp withProtocol(QStringLiteral("^[a-zA-Z]+:")); // TODO: remove after Qt supports this on its own
+ if (withProtocol.indexIn(url) == 0) {
+ dbusargs.append(QUrl::fromUserInput(url));
+ } else {
+ const QString path = QDir::current().absoluteFilePath(url);
+ dbusargs.append(QUrl::fromLocalFile(path));
+ }
- QDBusConnection::sessionBus().call (m);
- }
+ dbusargs.append(enc);
+ dbusargs.append(tempfileSet);
+ m.setArguments(dbusargs);
+
+ QDBusMessage res = QDBusConnection::sessionBus().call(m);
+ if (res.type() == QDBusMessage::ReplyMessage) {
+ if (res.arguments().count() == 1) {
+ QVariant v = res.arguments()[0];
+ if (v.isValid()) {
+ QString s = v.toString();
+ if ((!s.isEmpty()) && (s != QStringLiteral("ERROR"))) {
+ tokens << s;
+ }
+ }
+ }
+ }
+ }
+
+ if (parser.isSet(readStdInOption)) {
+ QTextStream input(stdin, QIODevice::ReadOnly);
+
+ // set chosen codec
+ QTextCodec *codec = parser.isSet(useEncodingOption) ?
+ QTextCodec::codecForName(parser.value(useEncodingOption).toUtf8()) : 0;
+
+ if (codec) {
+ input.setCodec(codec);
+ }
+
+ QString line;
+ QString text;
+
+ do {
+ line = input.readLine();
+ text.append(line + QLatin1Char('\n'));
+ } while (!line.isNull());
+
+ QDBusMessage m = QDBusMessage::createMethodCall(serviceName,
+ QStringLiteral("/MainApplication"), QStringLiteral("org.kde.Kate.Application"), QStringLiteral("openInput"));
+
+ QList<QVariant> dbusargs;
+ dbusargs.append(text);
+ m.setArguments(dbusargs);
+
+ QDBusConnection::sessionBus().call(m);
+ }
+
+ int line = 0;
+ int column = 0;
+ bool nav = false;
+
+ if (parser.isSet(gotoLineOption)) {
+ line = parser.value(gotoLineOption).toInt() - 1;
+ nav = true;
+ }
+
+ if (parser.isSet(gotoColumnOption)) {
+ column = parser.value(gotoColumnOption).toInt() - 1;
+ nav = true;
+ }
+
+ if (nav) {
+ QDBusMessage m = QDBusMessage::createMethodCall(serviceName,
+ QStringLiteral("/MainApplication"), QStringLiteral("org.kde.Kate.Application"), QStringLiteral("setCursor"));
+
+ QList<QVariant> args;
+ args.append(line);
+ args.append(column);
+ m.setArguments(args);
+
+ QDBusConnection::sessionBus().call(m);
+ }
+
+ // activate the used instance
+ QDBusMessage activateMsg = QDBusMessage::createMethodCall(serviceName,
+ QStringLiteral("/MainApplication"), QStringLiteral("org.kde.Kate.Application"), QStringLiteral("activate"));
+ QDBusConnection::sessionBus().call(activateMsg);
+
+ // connect dbus signal
+ if (needToBlock) {
+ KateWaiter *waiter = new KateWaiter(&app, serviceName, tokens);
+ QDBusConnection::sessionBus().connect(serviceName, QStringLiteral("/MainApplication"), QStringLiteral("org.kde.Kate.Application"), QStringLiteral("exiting"), waiter, SLOT(exiting()));
+ QDBusConnection::sessionBus().connect(serviceName, QStringLiteral("/MainApplication"), QStringLiteral("org.kde.Kate.Application"), QStringLiteral("documentClosed"), waiter, SLOT(documentClosed(QString)));
+ }
- // activate the used instance
- QDBusMessage activateMsg = QDBusMessage::createMethodCall (serviceName,
- QStringLiteral("/MainApplication"), QStringLiteral("org.kde.Kate.Application"), QStringLiteral("activate"));
- QDBusConnection::sessionBus().call (activateMsg);
-
- // connect dbus signal
- if (needToBlock) {
- KateWaiter *waiter = new KateWaiter (&app, serviceName,tokens);
- QDBusConnection::sessionBus().connect(serviceName, QStringLiteral("/MainApplication"), QStringLiteral("org.kde.Kate.Application"), QStringLiteral("exiting"), waiter, SLOT(exiting()));
- QDBusConnection::sessionBus().connect(serviceName, QStringLiteral("/MainApplication"), QStringLiteral("org.kde.Kate.Application"), QStringLiteral("documentClosed"), waiter, SLOT(documentClosed(QString)));
- }
-
#ifdef Q_WS_X11
- // make the world happy, we are started, kind of...
- KStartupInfo::appStarted ();
+ // make the world happy, we are started, kind of...
+ KStartupInfo::appStarted();
#endif
- // this will wait until exiting is emitted by the used instance, if wanted...
- return needToBlock ? app.exec () : 0;
- }
-
- /**
- * construct the real kate app object ;)
- * behaves like a singleton, one unique instance
- * we are passing our local command line parser to it
- */
- KateApp kateApp (parser);
-
- /**
- * init kate
- * if this returns false, we shall exit
- * else we may enter the main event loop
- */
- if (!kateApp.init())
- return 0;
-
- /**
- * finally register this kate instance for dbus
- */
- const KDBusService dbusService (KDBusService::Multiple);
-
- /**
- * start main event loop for our application
- */
- return app.exec();
+ // this will wait until exiting is emitted by the used instance, if wanted...
+ return needToBlock ? app.exec() : 0;
+ }
+
+ /**
+ * construct the real kate app object ;)
+ * behaves like a singleton, one unique instance
+ * we are passing our local command line parser to it
+ */
+ KateApp kateApp(parser);
+
+ /**
+ * init kate
+ * if this returns false, we shall exit
+ * else we may enter the main event loop
+ */
+ if (!kateApp.init()) {
+ return 0;
+ }
+
+ /**
+ * finally register this kate instance for dbus
+ */
+ const KDBusService dbusService(KDBusService::Multiple);
+
+ /**
+ * start main event loop for our application
+ */
+ return app.exec();
}
diff --git a/kate/autotests/session_manager_test.cpp b/kate/autotests/session_manager_test.cpp
index e9f4920..b800ba1 100644
--- a/kate/autotests/session_manager_test.cpp
+++ b/kate/autotests/session_manager_test.cpp
@@ -31,140 +31,139 @@ QTEST_MAIN(KateSessionManagerTest)
void KateSessionManagerTest::initTestCase()
{
- m_app = new KateApp(QCommandLineParser()); // FIXME: aaaah, why, why, why?!
+ m_app = new KateApp(QCommandLineParser()); // FIXME: aaaah, why, why, why?!
}
void KateSessionManagerTest::cleanupTestCase()
{
- delete m_app;
+ delete m_app;
}
void KateSessionManagerTest::init()
{
- m_tempdir = new QTemporaryDir;
- QVERIFY(m_tempdir->isValid());
+ m_tempdir = new QTemporaryDir;
+ QVERIFY(m_tempdir->isValid());
- m_manager = new KateSessionManager(this, m_tempdir->path());
+ m_manager = new KateSessionManager(this, m_tempdir->path());
}
void KateSessionManagerTest::cleanup()
{
- delete m_manager;
- delete m_tempdir;
+ delete m_manager;
+ delete m_tempdir;
}
void KateSessionManagerTest::basic()
{
- QCOMPARE(m_manager->sessionsDir(), m_tempdir->path());
- QCOMPARE(m_manager->sessionList().size(), 0);
- QCOMPARE(m_manager->activeSession()->isAnonymous(), true);
+ QCOMPARE(m_manager->sessionsDir(), m_tempdir->path());
+ QCOMPARE(m_manager->sessionList().size(), 0);
+ QCOMPARE(m_manager->activeSession()->isAnonymous(), true);
}
void KateSessionManagerTest::activateNewNamedSession()
{
- const QString sessionName = QString::fromLatin1("hello_world");
+ const QString sessionName = QString::fromLatin1("hello_world");
- QVERIFY(m_manager->activateSession(sessionName, false, false));
- QCOMPARE(m_manager->sessionList().size(), 1);
+ QVERIFY(m_manager->activateSession(sessionName, false, false));
+ QCOMPARE(m_manager->sessionList().size(), 1);
- KateSession::Ptr s = m_manager->activeSession();
- QCOMPARE(s->name(), sessionName);
- QCOMPARE(s->isAnonymous(), false);
+ KateSession::Ptr s = m_manager->activeSession();
+ QCOMPARE(s->name(), sessionName);
+ QCOMPARE(s->isAnonymous(), false);
- const QString sessionFile = m_tempdir->path() + QLatin1Char('/') + sessionName + QLatin1String(".katesession");
- QCOMPARE(s->config()->name(), sessionFile);
+ const QString sessionFile = m_tempdir->path() + QLatin1Char('/') + sessionName + QLatin1String(".katesession");
+ QCOMPARE(s->config()->name(), sessionFile);
}
void KateSessionManagerTest::anonymousSessionFile()
{
- const QString anonfile = QDir().cleanPath(m_tempdir->path() + QLatin1String("/../anonymous.katesession"));
- QVERIFY(m_manager->activeSession()->isAnonymous());
- QCOMPARE(m_manager->activeSession()->config()->name(), anonfile);
+ const QString anonfile = QDir().cleanPath(m_tempdir->path() + QLatin1String("/../anonymous.katesession"));
+ QVERIFY(m_manager->activeSession()->isAnonymous());
+ QCOMPARE(m_manager->activeSession()->config()->name(), anonfile);
}
void KateSessionManagerTest::urlizeSessionFile()
{
- const QString sessionName = QString::fromLatin1("hello world/#");
+ const QString sessionName = QString::fromLatin1("hello world/#");
- m_manager->activateSession(sessionName, false, false);
- KateSession::Ptr s = m_manager->activeSession();
+ m_manager->activateSession(sessionName, false, false);
+ KateSession::Ptr s = m_manager->activeSession();
- const QString sessionFile = m_tempdir->path() + QLatin1String("/hello%20world%2F%23.katesession");
- QCOMPARE(s->config()->name(), sessionFile);
+ const QString sessionFile = m_tempdir->path() + QLatin1String("/hello%20world%2F%23.katesession");
+ QCOMPARE(s->config()->name(), sessionFile);
}
void KateSessionManagerTest::deleteSession()
{
- m_manager->activateSession(QLatin1String("foo"));
- KateSession::Ptr s = m_manager->activeSession();
+ m_manager->activateSession(QLatin1String("foo"));
+ KateSession::Ptr s = m_manager->activeSession();
- m_manager->activateSession(QLatin1String("bar"));
+ m_manager->activateSession(QLatin1String("bar"));
- QCOMPARE(m_manager->sessionList().size(), 2);
+ QCOMPARE(m_manager->sessionList().size(), 2);
- m_manager->deleteSession(s);
- QCOMPARE(m_manager->sessionList().size(), 1);
+ m_manager->deleteSession(s);
+ QCOMPARE(m_manager->sessionList().size(), 1);
}
void KateSessionManagerTest::deleteActiveSession()
{
- m_manager->activateSession(QLatin1String("foo"));
- KateSession::Ptr s = m_manager->activeSession();
+ m_manager->activateSession(QLatin1String("foo"));
+ KateSession::Ptr s = m_manager->activeSession();
- QCOMPARE(m_manager->sessionList().size(), 1);
- m_manager->deleteSession(s);
- QCOMPARE(m_manager->sessionList().size(), 1);
+ QCOMPARE(m_manager->sessionList().size(), 1);
+ m_manager->deleteSession(s);
+ QCOMPARE(m_manager->sessionList().size(), 1);
}
void KateSessionManagerTest::renameSession()
{
- m_manager->activateSession(QLatin1String("foo"));
- KateSession::Ptr s = m_manager->activeSession();
+ m_manager->activateSession(QLatin1String("foo"));
+ KateSession::Ptr s = m_manager->activeSession();
- QCOMPARE(m_manager->sessionList().size(), 1);
+ QCOMPARE(m_manager->sessionList().size(), 1);
- const QString newName = QString::fromLatin1("bar");
- m_manager->renameSession(s, newName); // non-collision path
- QCOMPARE(s->name(), newName);
- QCOMPARE(m_manager->sessionList().size(), 1);
- QCOMPARE(m_manager->sessionList().first(), s);
+ const QString newName = QString::fromLatin1("bar");
+ m_manager->renameSession(s, newName); // non-collision path
+ QCOMPARE(s->name(), newName);
+ QCOMPARE(m_manager->sessionList().size(), 1);
+ QCOMPARE(m_manager->sessionList().first(), s);
}
void KateSessionManagerTest::saveActiveSessionWithAnynomous()
{
- QVERIFY(m_manager->activeSession()->isAnonymous());
- QVERIFY(m_manager->sessionList().size() == 0);
+ QVERIFY(m_manager->activeSession()->isAnonymous());
+ QVERIFY(m_manager->sessionList().size() == 0);
- QCOMPARE(m_manager->saveActiveSession(), true);
- QCOMPARE(m_manager->activeSession()->isAnonymous(), true);
- QCOMPARE(m_manager->activeSession()->name(), QString());
- QCOMPARE(m_manager->sessionList().size(), 0);
+ QCOMPARE(m_manager->saveActiveSession(), true);
+ QCOMPARE(m_manager->activeSession()->isAnonymous(), true);
+ QCOMPARE(m_manager->activeSession()->name(), QString());
+ QCOMPARE(m_manager->sessionList().size(), 0);
}
void KateSessionManagerTest::deletingSessionFilesUnderRunningApp()
{
- m_manager->activateSession(QLatin1String("foo"));
- m_manager->activateSession(QLatin1String("bar"));
+ m_manager->activateSession(QLatin1String("foo"));
+ m_manager->activateSession(QLatin1String("bar"));
- QVERIFY(m_manager->sessionList().size() == 2);
- QVERIFY(m_manager->activeSession()->name() == QLatin1String("bar"));
+ QVERIFY(m_manager->sessionList().size() == 2);
+ QVERIFY(m_manager->activeSession()->name() == QLatin1String("bar"));
- const QString file = m_tempdir->path() + QLatin1String("/foo.katesession");
- QVERIFY(QFile(file).remove());
+ const QString file = m_tempdir->path() + QLatin1String("/foo.katesession");
+ QVERIFY(QFile(file).remove());
- QTRY_COMPARE_WITH_TIMEOUT(m_manager->sessionList().size(), 1, 1000); // that should be enought for KDirWatch to kick in
- QCOMPARE(m_manager->activeSession()->name(), QLatin1String("bar"));
+ QTRY_COMPARE_WITH_TIMEOUT(m_manager->sessionList().size(), 1, 1000); // that should be enought for KDirWatch to kick in
+ QCOMPARE(m_manager->activeSession()->name(), QLatin1String("bar"));
}
void KateSessionManagerTest::startNonEmpty()
{
- m_manager->activateSession(QLatin1String("foo"));
- m_manager->activateSession(QLatin1String("bar"));
+ m_manager->activateSession(QLatin1String("foo"));
+ m_manager->activateSession(QLatin1String("bar"));
- KateSessionManager m(this, m_tempdir->path());
- QCOMPARE(m.sessionList().size(), 2);
+ KateSessionManager m(this, m_tempdir->path());
+ QCOMPARE(m.sessionList().size(), 2);
}
#include "session_manager_test.moc"
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/autotests/session_manager_test.h b/kate/autotests/session_manager_test.h
index 30d0c36..ffb25c6 100644
--- a/kate/autotests/session_manager_test.h
+++ b/kate/autotests/session_manager_test.h
@@ -23,9 +23,9 @@
class KateSessionManagerTest : public QObject
{
- Q_OBJECT
+ Q_OBJECT
- private Q_SLOTS:
+private Q_SLOTS:
void init();
void cleanup();
void initTestCase();
@@ -43,7 +43,7 @@ class KateSessionManagerTest : public QObject
void deletingSessionFilesUnderRunningApp();
void startNonEmpty();
- private:
+private:
class QTemporaryDir *m_tempdir;
class KateSessionManager *m_manager;
class KateApp *m_app; // dependency, sigh...
@@ -51,4 +51,3 @@ class KateSessionManagerTest : public QObject
#endif
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/autotests/session_test.cpp b/kate/autotests/session_test.cpp
index 74addb2..879982e 100644
--- a/kate/autotests/session_test.cpp
+++ b/kate/autotests/session_test.cpp
@@ -34,118 +34,117 @@ void KateSessionTest::cleanupTestCase() {}
void KateSessionTest::init()
{
- m_tmpfile = new QTemporaryFile;
- QVERIFY(m_tmpfile->open());
+ m_tmpfile = new QTemporaryFile;
+ QVERIFY(m_tmpfile->open());
}
void KateSessionTest::cleanup()
{
- delete m_tmpfile;
+ delete m_tmpfile;
}
void KateSessionTest::create()
{
- const QString name = QString::fromLatin1("session name");
- KateSession::Ptr s = KateSession::create(m_tmpfile->fileName(), name);
- QCOMPARE(s->name(), name);
- QCOMPARE((int)s->documents(), 0);
- QCOMPARE(s->isAnonymous(), false);
- QCOMPARE(s->config()->name(), m_tmpfile->fileName());
+ const QString name = QString::fromLatin1("session name");
+ KateSession::Ptr s = KateSession::create(m_tmpfile->fileName(), name);
+ QCOMPARE(s->name(), name);
+ QCOMPARE((int)s->documents(), 0);
+ QCOMPARE(s->isAnonymous(), false);
+ QCOMPARE(s->config()->name(), m_tmpfile->fileName());
}
void KateSessionTest::createAnonymous()
{
- KateSession::Ptr s = KateSession::createAnonymous(m_tmpfile->fileName());
- QCOMPARE(s->name(), QString());
- QCOMPARE((int)s->documents(), 0);
- QCOMPARE(s->isAnonymous(), true);
- QCOMPARE(s->config()->name(), m_tmpfile->fileName());
+ KateSession::Ptr s = KateSession::createAnonymous(m_tmpfile->fileName());
+ QCOMPARE(s->name(), QString());
+ QCOMPARE((int)s->documents(), 0);
+ QCOMPARE(s->isAnonymous(), true);
+ QCOMPARE(s->config()->name(), m_tmpfile->fileName());
}
void KateSessionTest::createAnonymousFrom()
{
- // Regular
- KateSession::Ptr s = KateSession::create(m_tmpfile->fileName(), QLatin1String("session name"));
-
- const QString groupName = QString::fromLatin1("test group");
- QTemporaryFile newFile;
- newFile.open();
- KateSession::Ptr ns;
-
- s->config()->group(groupName).writeEntry("foo", "bar");
-
- // Create Anon from Other
- ns = KateSession::createAnonymousFrom(s, newFile.fileName());
- QCOMPARE(ns->name(), QString());
- QCOMPARE((int)ns->documents(), 0);
- QCOMPARE(ns->isAnonymous(), true);
- QCOMPARE(ns->config()->name(), newFile.fileName());
- QCOMPARE(ns->config()->group(groupName).readEntry("foo"), QLatin1String("bar"));
+ // Regular
+ KateSession::Ptr s = KateSession::create(m_tmpfile->fileName(), QLatin1String("session name"));
+
+ const QString groupName = QString::fromLatin1("test group");
+ QTemporaryFile newFile;
+ newFile.open();
+ KateSession::Ptr ns;
+
+ s->config()->group(groupName).writeEntry("foo", "bar");
+
+ // Create Anon from Other
+ ns = KateSession::createAnonymousFrom(s, newFile.fileName());
+ QCOMPARE(ns->name(), QString());
+ QCOMPARE((int)ns->documents(), 0);
+ QCOMPARE(ns->isAnonymous(), true);
+ QCOMPARE(ns->config()->name(), newFile.fileName());
+ QCOMPARE(ns->config()->group(groupName).readEntry("foo"), QLatin1String("bar"));
}
void KateSessionTest::createFrom()
{
- KateSession::Ptr s = KateSession::create(m_tmpfile->fileName(), QLatin1String("session name"));
+ KateSession::Ptr s = KateSession::create(m_tmpfile->fileName(), QLatin1String("session name"));
- const QString newName = QString::fromLatin1("new session name");
- const QString groupName = QString::fromLatin1("test group");
+ const QString newName = QString::fromLatin1("new session name");
+ const QString groupName = QString::fromLatin1("test group");
- QTemporaryFile newFile;
- newFile.open();
- KateSession::Ptr ns;
+ QTemporaryFile newFile;
+ newFile.open();
+ KateSession::Ptr ns;
- s->config()->group(groupName).writeEntry("foo", "bar");
+ s->config()->group(groupName).writeEntry("foo", "bar");
- ns = KateSession::createFrom(s, newFile.fileName(), newName);
- QCOMPARE(ns->name(), newName);
- QCOMPARE((int)ns->documents(), 0);
- QCOMPARE(ns->isAnonymous(), false);
- QCOMPARE(ns->config()->name(), newFile.fileName());
- QCOMPARE(ns->config()->group(groupName).readEntry("foo"), QLatin1String("bar"));
+ ns = KateSession::createFrom(s, newFile.fileName(), newName);
+ QCOMPARE(ns->name(), newName);
+ QCOMPARE((int)ns->documents(), 0);
+ QCOMPARE(ns->isAnonymous(), false);
+ QCOMPARE(ns->config()->name(), newFile.fileName());
+ QCOMPARE(ns->config()->group(groupName).readEntry("foo"), QLatin1String("bar"));
}
void KateSessionTest::documents()
{
- KateSession::Ptr s = KateSession::create(m_tmpfile->fileName(), QLatin1String("session name"));
+ KateSession::Ptr s = KateSession::create(m_tmpfile->fileName(), QLatin1String("session name"));
- s->setDocuments(42);
- QCOMPARE((int)s->documents(), 42);
+ s->setDocuments(42);
+ QCOMPARE((int)s->documents(), 42);
- s->config()->sync();
- KConfig c(m_tmpfile->fileName());
- QCOMPARE(c.group("Open Documents").readEntry<int>("Count", 0), 42);
+ s->config()->sync();
+ KConfig c(m_tmpfile->fileName());
+ QCOMPARE(c.group("Open Documents").readEntry<int>("Count", 0), 42);
}
void KateSessionTest::setFile()
{
- KateSession::Ptr s = KateSession::create(m_tmpfile->fileName(), QLatin1String("session name"));
- s->config()->group("test").writeEntry("foo", "bar");
+ KateSession::Ptr s = KateSession::create(m_tmpfile->fileName(), QLatin1String("session name"));
+ s->config()->group("test").writeEntry("foo", "bar");
- QTemporaryFile file2;
- file2.open();
+ QTemporaryFile file2;
+ file2.open();
- s->setFile(file2.fileName());
- QCOMPARE(s->config()->name(), file2.fileName());
- QCOMPARE(s->config()->group("test").readEntry("foo"), QLatin1String("bar"));
+ s->setFile(file2.fileName());
+ QCOMPARE(s->config()->name(), file2.fileName());
+ QCOMPARE(s->config()->group("test").readEntry("foo"), QLatin1String("bar"));
}
void KateSessionTest::timestamp()
{
- QFileInfo i(m_tmpfile->fileName());
- KateSession::Ptr s = KateSession::create(m_tmpfile->fileName(), QLatin1String("session name"));
+ QFileInfo i(m_tmpfile->fileName());
+ KateSession::Ptr s = KateSession::create(m_tmpfile->fileName(), QLatin1String("session name"));
- QCOMPARE(s->timestamp(), i.lastModified());
+ QCOMPARE(s->timestamp(), i.lastModified());
}
void KateSessionTest::setName()
{
- KateSession::Ptr s = KateSession::create(m_tmpfile->fileName(), QLatin1String("session name"));
- const QString newName = QString::fromLatin1("bar");
- s->setName(newName);
- QCOMPARE(s->name(), newName);
- QCOMPARE(s->file(), m_tmpfile->fileName()); // on purpose, orthogonal
+ KateSession::Ptr s = KateSession::create(m_tmpfile->fileName(), QLatin1String("session name"));
+ const QString newName = QString::fromLatin1("bar");
+ s->setName(newName);
+ QCOMPARE(s->name(), newName);
+ QCOMPARE(s->file(), m_tmpfile->fileName()); // on purpose, orthogonal
}
#include "session_test.moc"
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/autotests/session_test.h b/kate/autotests/session_test.h
index f4a3376..537b47f 100644
--- a/kate/autotests/session_test.h
+++ b/kate/autotests/session_test.h
@@ -23,9 +23,9 @@
class KateSessionTest : public QObject
{
- Q_OBJECT
+ Q_OBJECT
- private Q_SLOTS:
+private Q_SLOTS:
void init();
void cleanup();
void initTestCase();
@@ -40,10 +40,9 @@ class KateSessionTest : public QObject
void setName();
void timestamp();
- private:
+private:
class QTemporaryFile *m_tmpfile;
};
#endif
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/autotests/sessions_action_test.cpp b/kate/autotests/sessions_action_test.cpp
index 9a0af3a..2353324 100644
--- a/kate/autotests/sessions_action_test.cpp
+++ b/kate/autotests/sessions_action_test.cpp
@@ -30,71 +30,70 @@ QTEST_MAIN(KateSessionsActionTest)
void KateSessionsActionTest::initTestCase()
{
- m_app = new KateApp(QCommandLineParser()); // FIXME: aaaah, why, why, why?!
+ m_app = new KateApp(QCommandLineParser()); // FIXME: aaaah, why, why, why?!
}
void KateSessionsActionTest::cleanupTestCase()
{
- delete m_app;
+ delete m_app;
}
void KateSessionsActionTest::init()
{
- m_tempdir = new QTemporaryDir;
- QVERIFY(m_tempdir->isValid());
+ m_tempdir = new QTemporaryDir;
+ QVERIFY(m_tempdir->isValid());
- m_manager = new KateSessionManager(this, m_tempdir->path());
- m_ac = new KateSessionsAction(QLatin1String("menu"), this, m_manager);
+ m_manager = new KateSessionManager(this, m_tempdir->path());
+ m_ac = new KateSessionsAction(QLatin1String("menu"), this, m_manager);
}
void KateSessionsActionTest::cleanup()
{
- delete m_ac;
- delete m_manager;
- delete m_tempdir;
+ delete m_ac;
+ delete m_manager;
+ delete m_tempdir;
}
void KateSessionsActionTest::basic()
{
- m_ac->slotAboutToShow();
- QCOMPARE(m_ac->isEnabled(), false);
+ m_ac->slotAboutToShow();
+ QCOMPARE(m_ac->isEnabled(), false);
- QList<QAction*> actions = m_ac->sessionsGroup->actions();
- QCOMPARE(actions.size(), 0);
+ QList<QAction *> actions = m_ac->sessionsGroup->actions();
+ QCOMPARE(actions.size(), 0);
}
void KateSessionsActionTest::limit()
{
- for (int i = 0; i < 14; i++) {
- m_manager->activateSession(QString::fromLatin1("session %1").arg(i));
- }
+ for (int i = 0; i < 14; i++) {
+ m_manager->activateSession(QString::fromLatin1("session %1").arg(i));
+ }
- QCOMPARE(m_manager->activeSession()->isAnonymous(), false);
- QCOMPARE(m_manager->sessionList().size(), 14);
- QCOMPARE(m_ac->isEnabled(), true);
+ QCOMPARE(m_manager->activeSession()->isAnonymous(), false);
+ QCOMPARE(m_manager->sessionList().size(), 14);
+ QCOMPARE(m_ac->isEnabled(), true);
- m_ac->slotAboutToShow();
+ m_ac->slotAboutToShow();
- QList<QAction*> actions = m_ac->sessionsGroup->actions();
- QCOMPARE(actions.size(), 10);
+ QList<QAction *> actions = m_ac->sessionsGroup->actions();
+ QCOMPARE(actions.size(), 10);
}
void KateSessionsActionTest::timesorted()
{
- /*
- m_manager->activateSession("one", false, false);
- m_manager->saveActiveSession();
- m_manager->activateSession("two", false, false);
- m_manager->saveActiveSession();
- m_manager->activateSession("three", false, false);
- m_manager->saveActiveSession();
-
- KateSessionList list = m_manager->sessionList();
- QCOMPARE(list.size(), 3);
-
- TODO: any idea how to test this simply and not calling utime()?
- */
+ /*
+ m_manager->activateSession("one", false, false);
+ m_manager->saveActiveSession();
+ m_manager->activateSession("two", false, false);
+ m_manager->saveActiveSession();
+ m_manager->activateSession("three", false, false);
+ m_manager->saveActiveSession();
+
+ KateSessionList list = m_manager->sessionList();
+ QCOMPARE(list.size(), 3);
+
+ TODO: any idea how to test this simply and not calling utime()?
+ */
}
#include "sessions_action_test.moc"
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/autotests/sessions_action_test.h b/kate/autotests/sessions_action_test.h
index 7dd20b4..bb6fc79 100644
--- a/kate/autotests/sessions_action_test.h
+++ b/kate/autotests/sessions_action_test.h
@@ -23,9 +23,9 @@
class KateSessionsActionTest : public QObject
{
- Q_OBJECT
+ Q_OBJECT
- private Q_SLOTS:
+private Q_SLOTS:
void basic();
void timesorted();
void limit();
@@ -35,7 +35,7 @@ class KateSessionsActionTest : public QObject
void initTestCase();
void cleanupTestCase();
- private:
+private:
class QTemporaryDir *m_tempdir;
class KateSessionManager *m_manager;
class KateApp *m_app; // dependency, sigh...
@@ -44,4 +44,3 @@ class KateSessionsActionTest : public QObject
#endif
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/session/katesession.cpp b/kate/session/katesession.cpp
index 1f47f95..cf09c19 100644
--- a/kate/session/katesession.cpp
+++ b/kate/session/katesession.cpp
@@ -34,98 +34,97 @@ static const QLatin1String opGroupName("Open Documents");
static const QLatin1String keyCount("Count");
KateSession::KateSession(const QString &file, const QString &name, const bool anonymous, const KConfig *_config)
- : m_name(name)
- , m_file(file)
- , m_anonymous(anonymous)
- , m_documents(0)
- , m_config(0)
- , m_timestamp()
+ : m_name(name)
+ , m_file(file)
+ , m_anonymous(anonymous)
+ , m_documents(0)
+ , m_config(0)
+ , m_timestamp()
{
- Q_ASSERT(!m_file.isEmpty());
+ Q_ASSERT(!m_file.isEmpty());
- if (_config) { // copy data from config instead
- m_config = _config->copyTo(m_file);
- } else if (!QFile::exists(m_file)) { // given file exists, use it to load some stuff
- qCDebug(LOG_KATE) << "Warning, session file not found: " << m_file;
- return;
- }
+ if (_config) { // copy data from config instead
+ m_config = _config->copyTo(m_file);
+ } else if (!QFile::exists(m_file)) { // given file exists, use it to load some stuff
+ qCDebug(LOG_KATE) << "Warning, session file not found: " << m_file;
+ return;
+ }
- m_timestamp = QFileInfo(m_file).lastModified();
+ m_timestamp = QFileInfo(m_file).lastModified();
- // get the document count
- m_documents = config()->group(opGroupName).readEntry(keyCount, 0);
+ // get the document count
+ m_documents = config()->group(opGroupName).readEntry(keyCount, 0);
}
-KateSession::~KateSession ()
+KateSession::~KateSession()
{
- delete m_config;
+ delete m_config;
}
const QString &KateSession::file() const
{
- return m_file;
+ return m_file;
}
void KateSession::setDocuments(const unsigned int number)
{
- config()->group(opGroupName).writeEntry(keyCount, number);
- m_documents = number;
+ config()->group(opGroupName).writeEntry(keyCount, number);
+ m_documents = number;
}
void KateSession::setFile(const QString &filename)
{
- if (m_config) {
- KConfig *cfg = m_config->copyTo(filename);
- delete m_config;
- m_config = cfg;
- }
+ if (m_config) {
+ KConfig *cfg = m_config->copyTo(filename);
+ delete m_config;
+ m_config = cfg;
+ }
- m_file = filename;
+ m_file = filename;
}
-void KateSession::setName(const QString& name)
+void KateSession::setName(const QString &name)
{
- m_name = name;
+ m_name = name;
}
KConfig *KateSession::config()
{
- if (m_config) {
- return m_config;
- }
+ if (m_config) {
+ return m_config;
+ }
- // reread documents number?
- return m_config = new KConfig(m_file, KConfig::SimpleConfig);
+ // reread documents number?
+ return m_config = new KConfig(m_file, KConfig::SimpleConfig);
}
KateSession::Ptr KateSession::create(const QString &file, const QString &name)
{
- return Ptr(new KateSession(file, name, false));
+ return Ptr(new KateSession(file, name, false));
}
KateSession::Ptr KateSession::createFrom(const KateSession::Ptr &session, const QString &file, const QString &name)
{
- return Ptr(new KateSession(file, name, false, session->config()));
+ return Ptr(new KateSession(file, name, false, session->config()));
}
KateSession::Ptr KateSession::createAnonymous(const QString &file)
{
- return Ptr(new KateSession(file, QString(), true));
+ return Ptr(new KateSession(file, QString(), true));
}
KateSession::Ptr KateSession::createAnonymousFrom(const KateSession::Ptr &session, const QString &file)
{
- return Ptr(new KateSession(file, QString(), true, session->config()));
+ return Ptr(new KateSession(file, QString(), true, session->config()));
}
bool KateSession::compareByName(const KateSession::Ptr &s1, const KateSession::Ptr &s2)
{
- return QCollator().compare(s1->name(), s2->name()) == -1;
+ return QCollator().compare(s1->name(), s2->name()) == -1;
}
bool KateSession::compareByTimeDesc(const KateSession::Ptr &s1, const KateSession::Ptr &s2)
{
- return s1->timestamp() < s2->timestamp();
+ return s1->timestamp() < s2->timestamp();
}
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/session/katesession.h b/kate/session/katesession.h
index 786757d..7bf3459 100644
--- a/kate/session/katesession.h
+++ b/kate/session/katesession.h
@@ -30,20 +30,22 @@ class KConfig;
class KATE_TESTS_EXPORT KateSession : public QSharedData
{
- public:
+public:
/**
* Define a Shared-Pointer type
*/
typedef QExplicitlySharedDataPointer<KateSession> Ptr;
- public:
+public:
~KateSession();
/**
* session name
* @return name for this session
*/
- const QString &name() const { return m_name; }
+ const QString &name() const {
+ return m_name;
+ }
/**
* session config
@@ -59,7 +61,9 @@ class KATE_TESTS_EXPORT KateSession : public QSharedData
* count of documents in this session
* @return documents count
*/
- unsigned int documents() const { return m_documents; }
+ unsigned int documents() const {
+ return m_documents;
+ }
/**
* update @number of openned documents in session
@@ -69,7 +73,9 @@ class KATE_TESTS_EXPORT KateSession : public QSharedData
/**
* @return true if this is anonymouse/new session
*/
- bool isAnonymous() const { return m_anonymous; }
+ bool isAnonymous() const {
+ return m_anonymous;
+ }
/**
* @return path to session file
@@ -79,12 +85,14 @@ class KATE_TESTS_EXPORT KateSession : public QSharedData
/**
* returns last save time of this session
*/
- const QDateTime &timestamp() const { return m_timestamp; };
+ const QDateTime &timestamp() const {
+ return m_timestamp;
+ };
/**
* Factories
*/
- public:
+public:
static KateSession::Ptr create(const QString &file, const QString &name);
static KateSession::Ptr createFrom(const KateSession::Ptr &session, const QString &file, const QString &name);
static KateSession::Ptr createAnonymous(const QString &file);
@@ -93,7 +101,7 @@ class KATE_TESTS_EXPORT KateSession : public QSharedData
static bool compareByName(const KateSession::Ptr &s1, const KateSession::Ptr &s2);
static bool compareByTimeDesc(const KateSession::Ptr &s1, const KateSession::Ptr &s2);
- private:
+private:
friend class KateSessionManager;
friend class KateSessionTest;
/**
@@ -115,7 +123,7 @@ class KATE_TESTS_EXPORT KateSession : public QSharedData
*/
KateSession(const QString &file, const QString &name, const bool anonymous, const KConfig *config = 0);
- private:
+private:
QString m_name;
QString m_file;
bool m_anonymous;
@@ -126,4 +134,3 @@ class KATE_TESTS_EXPORT KateSession : public QSharedData
#endif
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/session/katesessionchooser.cpp b/kate/session/katesessionchooser.cpp
index 336dc20..afb7ae9 100644
--- a/kate/session/katesessionchooser.cpp
+++ b/kate/session/katesessionchooser.cpp
@@ -37,159 +37,159 @@
//BEGIN CHOOSER DIALOG
-KateSessionChooser::KateSessionChooser (QWidget *parent, const QString &lastSession)
- : QDialog (parent)
+KateSessionChooser::KateSessionChooser(QWidget *parent, const QString &lastSession)
+ : QDialog(parent)
{
- setWindowTitle(i18n("Session Chooser"));
- QVBoxLayout *mainLayout = new QVBoxLayout(this);
-
- m_sessions = new QTreeWidget(this);
- m_sessions->setMinimumSize(400, 200);
- mainLayout->addWidget(m_sessions);
- QStringList header;
- header << i18n("Session Name");
- header << i18nc("The number of open documents", "Open Documents");
- header << QString();
- m_sessions->setHeaderLabels(header);
- m_sessions->header()->setStretchLastSection(false);
- m_sessions->header()->resizeSection(0,(m_sessions->size().width()-32)*2/3);
- m_sessions->header()->resizeSection(1,(m_sessions->size().width()-32)/3);
- m_sessions->header()->resizeSection(2,32);
- m_sessions->header()->setSectionResizeMode(QHeaderView::Fixed);
- m_sessions->setRootIsDecorated( false );
- m_sessions->setItemsExpandable( false );
- m_sessions->setAllColumnsShowFocus( true );
- m_sessions->setSelectionBehavior(QAbstractItemView::SelectRows);
- m_sessions->setSelectionMode (QAbstractItemView::SingleSelection);
-
- qCDebug(LOG_KATE) << "Last session is:" << lastSession;
-
- KateSessionList slist = KateSessionManager::self()->sessionList();
- qSort(slist.begin(), slist.end(), KateSession::compareByName);
-
- foreach(const KateSession::Ptr &session, slist) {
- KateSessionChooserItem *item = new KateSessionChooserItem (m_sessions, session);
- QPushButton *tmp=new QPushButton(QIcon::fromTheme(QStringLiteral("document")),QString(),m_sessions);
- QMenu* popup = new QMenu(tmp);
- QAction *a = popup->addAction(i18n("Clone session settings"));
- a->setData(QVariant::fromValue((void*)item));
- connect(a, SIGNAL(triggered()), this, SLOT(slotCopySession()));
- a=popup->addAction(i18n("Delete this session"));
- a->setData(QVariant::fromValue((void*)item));
- connect(a, SIGNAL(triggered()), this, SLOT(slotDeleteSession()));
- tmp->setMenu(popup);
- m_sessions->setItemWidget (item, 2, tmp );
-
- if (session->name() == lastSession) {
- m_sessions->setCurrentItem (item);
+ setWindowTitle(i18n("Session Chooser"));
+ QVBoxLayout *mainLayout = new QVBoxLayout(this);
+
+ m_sessions = new QTreeWidget(this);
+ m_sessions->setMinimumSize(400, 200);
+ mainLayout->addWidget(m_sessions);
+ QStringList header;
+ header << i18n("Session Name");
+ header << i18nc("The number of open documents", "Open Documents");
+ header << QString();
+ m_sessions->setHeaderLabels(header);
+ m_sessions->header()->setStretchLastSection(false);
+ m_sessions->header()->resizeSection(0, (m_sessions->size().width() - 32) * 2 / 3);
+ m_sessions->header()->resizeSection(1, (m_sessions->size().width() - 32) / 3);
+ m_sessions->header()->resizeSection(2, 32);
+ m_sessions->header()->setSectionResizeMode(QHeaderView::Fixed);
+ m_sessions->setRootIsDecorated(false);
+ m_sessions->setItemsExpandable(false);
+ m_sessions->setAllColumnsShowFocus(true);
+ m_sessions->setSelectionBehavior(QAbstractItemView::SelectRows);
+ m_sessions->setSelectionMode(QAbstractItemView::SingleSelection);
+
+ qCDebug(LOG_KATE) << "Last session is:" << lastSession;
+
+ KateSessionList slist = KateSessionManager::self()->sessionList();
+ qSort(slist.begin(), slist.end(), KateSession::compareByName);
+
+ foreach(const KateSession::Ptr & session, slist) {
+ KateSessionChooserItem *item = new KateSessionChooserItem(m_sessions, session);
+ QPushButton *tmp = new QPushButton(QIcon::fromTheme(QStringLiteral("document")), QString(), m_sessions);
+ QMenu *popup = new QMenu(tmp);
+ QAction *a = popup->addAction(i18n("Clone session settings"));
+ a->setData(QVariant::fromValue((void *)item));
+ connect(a, SIGNAL(triggered()), this, SLOT(slotCopySession()));
+ a = popup->addAction(i18n("Delete this session"));
+ a->setData(QVariant::fromValue((void *)item));
+ connect(a, SIGNAL(triggered()), this, SLOT(slotDeleteSession()));
+ tmp->setMenu(popup);
+ m_sessions->setItemWidget(item, 2, tmp);
+
+ if (session->name() == lastSession) {
+ m_sessions->setCurrentItem(item);
+ }
}
- }
-
- connect(m_sessions, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(selectionChanged(QTreeWidgetItem*,QTreeWidgetItem*)));
- connect(m_sessions, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(slotOpen()));
-
- // bottom box
- QHBoxLayout *hb = new QHBoxLayout();
- hb->setMargin(0);
- mainLayout->addLayout(hb);
-
- m_useLast = new QCheckBox (i18n ("&Always use this choice"), this);
- hb->addWidget(m_useLast);
-
- // buttons
- QDialogButtonBox *buttonBox = new QDialogButtonBox(this);
- hb->addWidget(buttonBox);
-
- QPushButton *cancelButton = new QPushButton();
- KGuiItem::assign(cancelButton, KStandardGuiItem::quit());
- connect(cancelButton, SIGNAL(clicked()), this, SLOT(slotCancel()));
- buttonBox->addButton(cancelButton, QDialogButtonBox::RejectRole);
-
- m_openButton = new QPushButton(QIcon::fromTheme(QStringLiteral("document-open")), i18n("Open Session"));
- m_openButton->setEnabled(m_sessions->currentIndex().isValid());
- m_openButton->setDefault(true);
- m_openButton->setFocus();
- buttonBox->addButton(m_openButton, QDialogButtonBox::ActionRole);
- connect(m_openButton, SIGNAL(clicked()), this, SLOT(slotOpen()));
-
- QPushButton *newButton = new QPushButton(QIcon::fromTheme(QStringLiteral("document-new")), i18n("New Session"));
- buttonBox->addButton(newButton, QDialogButtonBox::ActionRole);
- connect(newButton, SIGNAL(clicked()), this, SLOT(slotNew()));
-
- setResult (resultNone);
- //m_sessions->resizeColumnToContents(0);
- selectionChanged (NULL, NULL);
+
+ connect(m_sessions, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(selectionChanged(QTreeWidgetItem*,QTreeWidgetItem*)));
+ connect(m_sessions, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(slotOpen()));
+
+ // bottom box
+ QHBoxLayout *hb = new QHBoxLayout();
+ hb->setMargin(0);
+ mainLayout->addLayout(hb);
+
+ m_useLast = new QCheckBox(i18n("&Always use this choice"), this);
+ hb->addWidget(m_useLast);
+
+ // buttons
+ QDialogButtonBox *buttonBox = new QDialogButtonBox(this);
+ hb->addWidget(buttonBox);
+
+ QPushButton *cancelButton = new QPushButton();
+ KGuiItem::assign(cancelButton, KStandardGuiItem::quit());
+ connect(cancelButton, SIGNAL(clicked()), this, SLOT(slotCancel()));
+ buttonBox->addButton(cancelButton, QDialogButtonBox::RejectRole);
+
+ m_openButton = new QPushButton(QIcon::fromTheme(QStringLiteral("document-open")), i18n("Open Session"));
+ m_openButton->setEnabled(m_sessions->currentIndex().isValid());
+ m_openButton->setDefault(true);
+ m_openButton->setFocus();
+ buttonBox->addButton(m_openButton, QDialogButtonBox::ActionRole);
+ connect(m_openButton, SIGNAL(clicked()), this, SLOT(slotOpen()));
+
+ QPushButton *newButton = new QPushButton(QIcon::fromTheme(QStringLiteral("document-new")), i18n("New Session"));
+ buttonBox->addButton(newButton, QDialogButtonBox::ActionRole);
+ connect(newButton, SIGNAL(clicked()), this, SLOT(slotNew()));
+
+ setResult(resultNone);
+ //m_sessions->resizeColumnToContents(0);
+ selectionChanged(NULL, NULL);
}
void KateSessionChooser::resizeEvent(QResizeEvent *)
{
- m_sessions->header()->resizeSection(0,(m_sessions->size().width()-32)*2/3);
- m_sessions->header()->resizeSection(1,(m_sessions->size().width()-32)/3);
- m_sessions->header()->resizeSection(2,32);
+ m_sessions->header()->resizeSection(0, (m_sessions->size().width() - 32) * 2 / 3);
+ m_sessions->header()->resizeSection(1, (m_sessions->size().width() - 32) / 3);
+ m_sessions->header()->resizeSection(2, 32);
}
-KateSessionChooser::~KateSessionChooser ()
+KateSessionChooser::~KateSessionChooser()
{}
void KateSessionChooser::slotCopySession()
{
- m_sessions->setCurrentItem( (KateSessionChooserItem*) ((QAction*)sender())->data().value<void*>() );
- Q_ASSERT(static_cast<KateSessionChooserItem *>(m_sessions->currentItem()));
- done(resultCopy);
+ m_sessions->setCurrentItem((KateSessionChooserItem *)((QAction *)sender())->data().value<void *>());
+ Q_ASSERT(static_cast<KateSessionChooserItem *>(m_sessions->currentItem()));
+ done(resultCopy);
}
void KateSessionChooser::slotDeleteSession()
{
- KateSessionChooserItem* item=(KateSessionChooserItem*) ((QAction*)sender())->data().value<void*>();
- if (!item)
- return;
+ KateSessionChooserItem *item = (KateSessionChooserItem *)((QAction *)sender())->data().value<void *>();
+ if (!item) {
+ return;
+ }
- KateSessionManager::self()->deleteSession(item->session);
- m_sessions->removeItemWidget(item,2);
- delete item;
+ KateSessionManager::self()->deleteSession(item->session);
+ m_sessions->removeItemWidget(item, 2);
+ delete item;
}
-
-KateSession::Ptr KateSessionChooser::selectedSession ()
+KateSession::Ptr KateSessionChooser::selectedSession()
{
- KateSessionChooserItem *item = static_cast<KateSessionChooserItem *>(m_sessions->currentItem ());
+ KateSessionChooserItem *item = static_cast<KateSessionChooserItem *>(m_sessions->currentItem());
- Q_ASSERT(item || ((result() != resultOpen) && (result() != resultCopy)));
+ Q_ASSERT(item || ((result() != resultOpen) && (result() != resultCopy)));
- if (!item)
- return KateSession::Ptr();
+ if (!item) {
+ return KateSession::Ptr();
+ }
- return item->session;
+ return item->session;
}
-bool KateSessionChooser::reopenLastSession ()
+bool KateSessionChooser::reopenLastSession()
{
- return m_useLast->isChecked ();
+ return m_useLast->isChecked();
}
void KateSessionChooser::slotOpen()
{
- Q_ASSERT(static_cast<KateSessionChooserItem *>(m_sessions->currentItem()));
- done(resultOpen);
+ Q_ASSERT(static_cast<KateSessionChooserItem *>(m_sessions->currentItem()));
+ done(resultOpen);
}
void KateSessionChooser::slotNew()
{
- done(resultNew);
+ done(resultNew);
}
void KateSessionChooser::slotCancel()
{
- done(resultQuit);
+ done(resultQuit);
}
void KateSessionChooser::selectionChanged(QTreeWidgetItem *current, QTreeWidgetItem *)
{
- Q_UNUSED(current);
- m_openButton->setEnabled(true);
+ Q_UNUSED(current);
+ m_openButton->setEnabled(true);
}
//END CHOOSER DIALOG
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/session/katesessionchooser.h b/kate/session/katesessionchooser.h
index a8deec7..bc82ee6 100644
--- a/kate/session/katesessionchooser.h
+++ b/kate/session/katesessionchooser.h
@@ -34,22 +34,22 @@ class KateSessionChooser : public QDialog
{
Q_OBJECT
- public:
- KateSessionChooser (QWidget *parent, const QString &lastSession);
- ~KateSessionChooser ();
+public:
+ KateSessionChooser(QWidget *parent, const QString &lastSession);
+ ~KateSessionChooser();
- KateSession::Ptr selectedSession ();
- bool reopenLastSession ();
+ KateSession::Ptr selectedSession();
+ bool reopenLastSession();
enum {
- resultQuit = QDialog::Rejected,
- resultOpen,
- resultNew,
- resultNone,
- resultCopy
+ resultQuit = QDialog::Rejected,
+ resultOpen,
+ resultNew,
+ resultNone,
+ resultCopy
};
- protected Q_SLOTS:
+protected Q_SLOTS:
void slotCancel();
void slotOpen();
void slotNew();
@@ -59,12 +59,12 @@ class KateSessionChooser : public QDialog
/**
* selection has changed
*/
- void selectionChanged (QTreeWidgetItem *current, QTreeWidgetItem *previous);
+ void selectionChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
- protected:
+protected:
void resizeEvent(QResizeEvent *);
-
- private:
+
+private:
QTreeWidget *m_sessions;
QCheckBox *m_useLast;
QPushButton *m_openButton;
@@ -72,4 +72,3 @@ class KateSessionChooser : public QDialog
#endif
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/session/katesessionchooseritem.h b/kate/session/katesessionchooseritem.h
index c6b2f5f..5b7ecf8 100644
--- a/kate/session/katesessionchooseritem.h
+++ b/kate/session/katesessionchooseritem.h
@@ -28,18 +28,16 @@
class KateSessionChooserItem : public QTreeWidgetItem
{
public:
- KateSessionChooserItem (QTreeWidget *tw, KateSession::Ptr s)
- : QTreeWidgetItem (tw, QStringList(s->name()))
- , session (s)
- {
- QString docs;
- docs.setNum (s->documents());
- setText (1, docs);
- }
+ KateSessionChooserItem(QTreeWidget *tw, KateSession::Ptr s)
+ : QTreeWidgetItem(tw, QStringList(s->name()))
+ , session(s) {
+ QString docs;
+ docs.setNum(s->documents());
+ setText(1, docs);
+ }
- KateSession::Ptr session;
+ KateSession::Ptr session;
};
#endif
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/session/katesessionmanagedialog.cpp b/kate/session/katesessionmanagedialog.cpp
index 9866ae3..27e6eaa 100644
--- a/kate/session/katesessionmanagedialog.cpp
+++ b/kate/session/katesessionmanagedialog.cpp
@@ -35,145 +35,146 @@
#include <QTreeWidget>
#include <QVBoxLayout>
-KateSessionManageDialog::KateSessionManageDialog (QWidget *parent)
+KateSessionManageDialog::KateSessionManageDialog(QWidget *parent)
: QDialog(parent)
{
- setWindowTitle(i18n("Manage Sessions"));
-
- QVBoxLayout *mainLayout = new QVBoxLayout(this);
- setLayout(mainLayout);
-
- QHBoxLayout *hb = new QHBoxLayout();
- mainLayout->addLayout(hb);
-
- m_sessions = new QTreeWidget(this);
- m_sessions->setMinimumSize(400, 200);
- hb->addWidget(m_sessions);
- m_sessions->setColumnCount(2);
- QStringList header;
- header << i18n("Session Name");
- header << i18nc("The number of open documents", "Open Documents");
- m_sessions->setHeaderLabels(header);
- m_sessions->setRootIsDecorated( false );
- m_sessions->setItemsExpandable( false );
- m_sessions->setAllColumnsShowFocus( true );
- m_sessions->setSelectionBehavior(QAbstractItemView::SelectRows);
- m_sessions->setSelectionMode (QAbstractItemView::SingleSelection);
-
- connect (m_sessions, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(selectionChanged(QTreeWidgetItem*,QTreeWidgetItem*)));
-
- updateSessionList ();
- m_sessions->resizeColumnToContents(0);
-
- // right column buttons
- QDialogButtonBox *rightButtons = new QDialogButtonBox(this);
- rightButtons->setOrientation(Qt::Vertical);
- hb->addWidget(rightButtons);
-
- m_rename = new QPushButton(i18n("&Rename..."));
- connect (m_rename, SIGNAL(clicked()), this, SLOT(rename()));
- rightButtons->addButton(m_rename, QDialogButtonBox::ApplyRole);
-
- m_del = new QPushButton();
- KGuiItem::assign(m_del, KStandardGuiItem::del());
- connect (m_del, SIGNAL(clicked()), this, SLOT(del()));
- rightButtons->addButton(m_del, QDialogButtonBox::ApplyRole);
-
- // dialog buttons
- QDialogButtonBox *bottomButtons = new QDialogButtonBox(this);
- mainLayout->addWidget(bottomButtons);
-
- QPushButton *closeButton = new QPushButton;
- KGuiItem::assign(closeButton, KStandardGuiItem::close());
- closeButton->setDefault(true);
- bottomButtons->addButton(closeButton, QDialogButtonBox::RejectRole);
- connect(closeButton, SIGNAL(clicked()), this, SLOT(slotClose()));
-
- m_openButton = new QPushButton(QIcon::fromTheme(QStringLiteral("document-open")), i18n("&Open"));
- bottomButtons->addButton(m_openButton, QDialogButtonBox::AcceptRole);
- connect(m_openButton, SIGNAL(clicked()), this, SLOT(open()));
-
- // trigger action update
- selectionChanged (NULL, NULL);
+ setWindowTitle(i18n("Manage Sessions"));
+
+ QVBoxLayout *mainLayout = new QVBoxLayout(this);
+ setLayout(mainLayout);
+
+ QHBoxLayout *hb = new QHBoxLayout();
+ mainLayout->addLayout(hb);
+
+ m_sessions = new QTreeWidget(this);
+ m_sessions->setMinimumSize(400, 200);
+ hb->addWidget(m_sessions);
+ m_sessions->setColumnCount(2);
+ QStringList header;
+ header << i18n("Session Name");
+ header << i18nc("The number of open documents", "Open Documents");
+ m_sessions->setHeaderLabels(header);
+ m_sessions->setRootIsDecorated(false);
+ m_sessions->setItemsExpandable(false);
+ m_sessions->setAllColumnsShowFocus(true);
+ m_sessions->setSelectionBehavior(QAbstractItemView::SelectRows);
+ m_sessions->setSelectionMode(QAbstractItemView::SingleSelection);
+
+ connect(m_sessions, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(selectionChanged(QTreeWidgetItem*,QTreeWidgetItem*)));
+
+ updateSessionList();
+ m_sessions->resizeColumnToContents(0);
+
+ // right column buttons
+ QDialogButtonBox *rightButtons = new QDialogButtonBox(this);
+ rightButtons->setOrientation(Qt::Vertical);
+ hb->addWidget(rightButtons);
+
+ m_rename = new QPushButton(i18n("&Rename..."));
+ connect(m_rename, SIGNAL(clicked()), this, SLOT(rename()));
+ rightButtons->addButton(m_rename, QDialogButtonBox::ApplyRole);
+
+ m_del = new QPushButton();
+ KGuiItem::assign(m_del, KStandardGuiItem::del());
+ connect(m_del, SIGNAL(clicked()), this, SLOT(del()));
+ rightButtons->addButton(m_del, QDialogButtonBox::ApplyRole);
+
+ // dialog buttons
+ QDialogButtonBox *bottomButtons = new QDialogButtonBox(this);
+ mainLayout->addWidget(bottomButtons);
+
+ QPushButton *closeButton = new QPushButton;
+ KGuiItem::assign(closeButton, KStandardGuiItem::close());
+ closeButton->setDefault(true);
+ bottomButtons->addButton(closeButton, QDialogButtonBox::RejectRole);
+ connect(closeButton, SIGNAL(clicked()), this, SLOT(slotClose()));
+
+ m_openButton = new QPushButton(QIcon::fromTheme(QStringLiteral("document-open")), i18n("&Open"));
+ bottomButtons->addButton(m_openButton, QDialogButtonBox::AcceptRole);
+ connect(m_openButton, SIGNAL(clicked()), this, SLOT(open()));
+
+ // trigger action update
+ selectionChanged(NULL, NULL);
}
-KateSessionManageDialog::~KateSessionManageDialog ()
+KateSessionManageDialog::~KateSessionManageDialog()
{}
void KateSessionManageDialog::slotClose()
{
- done(0);
+ done(0);
}
-void KateSessionManageDialog::selectionChanged (QTreeWidgetItem *current, QTreeWidgetItem *)
+void KateSessionManageDialog::selectionChanged(QTreeWidgetItem *current, QTreeWidgetItem *)
{
- const bool validItem = (current != NULL);
+ const bool validItem = (current != NULL);
- m_rename->setEnabled (validItem);
- m_del->setEnabled (validItem && (static_cast<KateSessionChooserItem*>(current))->session!=KateSessionManager::self()->activeSession());
- m_openButton->setEnabled(true);
+ m_rename->setEnabled(validItem);
+ m_del->setEnabled(validItem && (static_cast<KateSessionChooserItem *>(current))->session != KateSessionManager::self()->activeSession());
+ m_openButton->setEnabled(true);
}
-void KateSessionManageDialog::rename ()
+void KateSessionManageDialog::rename()
{
- KateSessionChooserItem *item = static_cast<KateSessionChooserItem *>(m_sessions->currentItem ());
+ KateSessionChooserItem *item = static_cast<KateSessionChooserItem *>(m_sessions->currentItem());
- if (!item)
- return;
+ if (!item) {
+ return;
+ }
- bool ok = false;
- QString name = QInputDialog::getText(QApplication::activeWindow(), // nasty trick:)
- i18n("Specify New Name for Session"), i18n("Session name:"),
- QLineEdit::Normal, item->session->name(), &ok);
+ bool ok = false;
+ QString name = QInputDialog::getText(QApplication::activeWindow(), // nasty trick:)
+ i18n("Specify New Name for Session"), i18n("Session name:"),
+ QLineEdit::Normal, item->session->name(), &ok);
- if (!ok)
- return;
+ if (!ok) {
+ return;
+ }
- if (name.isEmpty())
- {
- KMessageBox::sorry (this, i18n("To save a session, you must specify a name."), i18n ("Missing Session Name"));
- return;
- }
+ if (name.isEmpty()) {
+ KMessageBox::sorry(this, i18n("To save a session, you must specify a name."), i18n("Missing Session Name"));
+ return;
+ }
- if (KateSessionManager::self()->renameSession(item->session, name)) {
- updateSessionList();
- }
+ if (KateSessionManager::self()->renameSession(item->session, name)) {
+ updateSessionList();
+ }
}
-void KateSessionManageDialog::del ()
+void KateSessionManageDialog::del()
{
- KateSessionChooserItem *item = static_cast<KateSessionChooserItem *>(m_sessions->currentItem ());
+ KateSessionChooserItem *item = static_cast<KateSessionChooserItem *>(m_sessions->currentItem());
- if (!item) {
- return;
- }
+ if (!item) {
+ return;
+ }
- KateSessionManager::self()->deleteSession(item->session);
- updateSessionList ();
+ KateSessionManager::self()->deleteSession(item->session);
+ updateSessionList();
}
-void KateSessionManageDialog::open ()
+void KateSessionManageDialog::open()
{
- KateSessionChooserItem *item = static_cast<KateSessionChooserItem *>(m_sessions->currentItem ());
+ KateSessionChooserItem *item = static_cast<KateSessionChooserItem *>(m_sessions->currentItem());
- if (!item)
- return;
+ if (!item) {
+ return;
+ }
- hide();
- KateSessionManager::self()->activateSession (item->session);
- done(0);
+ hide();
+ KateSessionManager::self()->activateSession(item->session);
+ done(0);
}
-void KateSessionManageDialog::updateSessionList ()
+void KateSessionManageDialog::updateSessionList()
{
- m_sessions->clear ();
+ m_sessions->clear();
- KateSessionList slist = KateSessionManager::self()->sessionList();
- qSort(slist.begin(), slist.end(), KateSession::compareByName);
+ KateSessionList slist = KateSessionManager::self()->sessionList();
+ qSort(slist.begin(), slist.end(), KateSession::compareByName);
- foreach(const KateSession::Ptr &session, slist) {
- new KateSessionChooserItem(m_sessions, session);
- }
+ foreach(const KateSession::Ptr & session, slist) {
+ new KateSessionChooserItem(m_sessions, session);
+ }
}
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/session/katesessionmanagedialog.h b/kate/session/katesessionmanagedialog.h
index 8b483e7..feb31d7 100644
--- a/kate/session/katesessionmanagedialog.h
+++ b/kate/session/katesessionmanagedialog.h
@@ -31,43 +31,43 @@ class KateSessionManageDialog : public QDialog
{
Q_OBJECT
- public:
- KateSessionManageDialog (QWidget *parent);
- ~KateSessionManageDialog ();
+public:
+ KateSessionManageDialog(QWidget *parent);
+ ~KateSessionManageDialog();
- protected Q_SLOTS:
+protected Q_SLOTS:
/**
* close pressed
*/
- void slotClose ();
+ void slotClose();
/**
* selection has changed
*/
- void selectionChanged (QTreeWidgetItem *current, QTreeWidgetItem *previous);
+ void selectionChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
/**
* try to rename session
*/
- void rename ();
+ void rename();
/**
* try to delete session
*/
- void del ();
+ void del();
/**
* close dialog and open the selected session
*/
- void open ();
+ void open();
- private:
+private:
/**
* update our list
*/
- void updateSessionList ();
+ void updateSessionList();
- private:
+private:
QTreeWidget *m_sessions;
QPushButton *m_rename;
QPushButton *m_del;
@@ -76,4 +76,3 @@ class KateSessionManageDialog : public QDialog
#endif
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/session/katesessionmanager.cpp b/kate/session/katesessionmanager.cpp
index 8b0166e..db833c7 100644
--- a/kate/session/katesessionmanager.cpp
+++ b/kate/session/katesessionmanager.cpp
@@ -46,475 +46,466 @@
//BEGIN KateSessionManager
-KateSessionManager::KateSessionManager (QObject *parent, const QString &sessionsDir)
- : QObject (parent)
+KateSessionManager::KateSessionManager(QObject *parent, const QString &sessionsDir)
+ : QObject(parent)
{
- if (sessionsDir.isEmpty()) {
- m_sessionsDir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QStringLiteral("/kate/sessions");
- } else {
- m_sessionsDir = sessionsDir;
- }
+ if (sessionsDir.isEmpty()) {
+ m_sessionsDir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QStringLiteral("/kate/sessions");
+ } else {
+ m_sessionsDir = sessionsDir;
+ }
- QDir().mkpath(m_sessionsDir); // create dir if needed
- qCDebug(LOG_KATE) << "LOCAL SESSION DIR: " << m_sessionsDir;
+ QDir().mkpath(m_sessionsDir); // create dir if needed
+ qCDebug(LOG_KATE) << "LOCAL SESSION DIR: " << m_sessionsDir;
- m_dirWatch = new KDirWatch(this);
- m_dirWatch->addDir(m_sessionsDir);
- connect(m_dirWatch, SIGNAL(dirty(const QString &)), this, SLOT(updateSessionList()));
+ m_dirWatch = new KDirWatch(this);
+ m_dirWatch->addDir(m_sessionsDir);
+ connect(m_dirWatch, SIGNAL(dirty(QString)), this, SLOT(updateSessionList()));
- updateSessionList();
+ updateSessionList();
- m_activeSession = KateSession::createAnonymous(anonymousSessionFile());
+ m_activeSession = KateSession::createAnonymous(anonymousSessionFile());
}
KateSessionManager::~KateSessionManager()
{
- delete m_dirWatch;
+ delete m_dirWatch;
}
KateSessionManager *KateSessionManager::self()
{
- return KateApp::self()->sessionManager();
+ return KateApp::self()->sessionManager();
}
void KateSessionManager::updateSessionList()
{
- QStringList list;
-
- // Let's get a list of all session we have atm
- QDir dir (m_sessionsDir, QStringLiteral("*.katesession"));
-
- for (unsigned int i = 0; i < dir.count(); ++i) {
- QString name = dir[i];
- name.chop(12); // .katesession
- list << QUrl::fromPercentEncoding(name.toLatin1());
- }
-
- // delete old items;
- QMutableHashIterator<QString, KateSession::Ptr> i(m_sessions);
-
- while (i.hasNext()) {
- i.next();
- const int idx = list.indexOf(i.key());
- if (idx == -1) { // the key is invalid, remove it from m_session
- if (i.value() != m_activeSession) { // if active, ignore missing config
- i.remove();
- }
- } else { // remove it from scan list
- list.removeAt(idx);
- }
- }
+ QStringList list;
- // load the new ones
- foreach(const QString &newName, list) {
- const QString file = sessionFileForName(newName);
- m_sessions[newName] = KateSession::create(file, newName);
- }
-}
+ // Let's get a list of all session we have atm
+ QDir dir(m_sessionsDir, QStringLiteral("*.katesession"));
-bool KateSessionManager::activateSession (KateSession::Ptr session,
- const bool closeAndSaveLast,
- const bool loadNew)
-{
- if (m_activeSession == session) {
- return true;
- }
-
- if (!session->isAnonymous()) {
- //check if the requested session is already open in another instance
- KateRunningInstanceMap instances;
- if (!fillinRunningKateAppInstances(&instances))
- {
- KMessageBox::error(0,i18n("Internal error: there is more than one instance open for a given session."));
- return false;
+ for (unsigned int i = 0; i < dir.count(); ++i) {
+ QString name = dir[i];
+ name.chop(12); // .katesession
+ list << QUrl::fromPercentEncoding(name.toLatin1());
}
- if (instances.contains(session->name()))
- {
- if (KMessageBox::questionYesNo(0,i18n("Session '%1' is already opened in another kate instance, change there instead of reopening?",session->name()),
- QString(),KStandardGuiItem::yes(),KStandardGuiItem::no(),QStringLiteral("katesessionmanager_switch_instance"))==KMessageBox::Yes)
- {
- instances[session->name()]->dbus_if->call(QStringLiteral("activate"));
- cleanupRunningKateAppInstanceMap(&instances);
- return false;
- }
+ // delete old items;
+ QMutableHashIterator<QString, KateSession::Ptr> i(m_sessions);
+
+ while (i.hasNext()) {
+ i.next();
+ const int idx = list.indexOf(i.key());
+ if (idx == -1) { // the key is invalid, remove it from m_session
+ if (i.value() != m_activeSession) { // if active, ignore missing config
+ i.remove();
+ }
+ } else { // remove it from scan list
+ list.removeAt(idx);
+ }
}
- cleanupRunningKateAppInstanceMap(&instances);
- }
- // try to close and save last session
- if (closeAndSaveLast) {
- if (KateApp::self()->activeKateMainWindow()) {
- if (!KateApp::self()->activeKateMainWindow()->queryClose_internal())
- return true;
+ // load the new ones
+ foreach(const QString & newName, list) {
+ const QString file = sessionFileForName(newName);
+ m_sessions[newName] = KateSession::create(file, newName);
}
-
- // save last session or not?
- saveActiveSession ();
-
- // really close last
- KateDocManager::self()->closeAllDocuments ();
- }
-
- // set the new session
- m_activeSession = session;
-
- // there is one case in which we don't want the restoration and that is
- // when restoring session from session manager.
- // In that case the restore is handled by the caller
- if (loadNew) {
- loadSession(session);
- }
-
- emit sessionChanged();
- return true;
}
-void KateSessionManager::loadSession(const KateSession::Ptr& session) const
+bool KateSessionManager::activateSession(KateSession::Ptr session,
+ const bool closeAndSaveLast,
+ const bool loadNew)
{
- // open the new session
- KSharedConfigPtr sharedConfig = KSharedConfig::openConfig();
- KConfig *sc = session->config();
- const bool loadDocs = !session->isAnonymous(); // do not load docs for new sessions
-
- // if we have no session config object, try to load the default
- // (anonymous/unnamed sessions)
- // load plugin config + plugins
- KatePluginManager::self()->loadConfig (sc);
-
- if (loadDocs)
- KateApp::self()->documentManager()->restoreDocumentList (sc);
-
- // window config
- KConfigGroup c(sharedConfig, "General");
-
- if (c.readEntry("Restore Window Configuration", true))
- {
- KConfig *cfg = sc;
- bool delete_cfg = false;
- // a new, named session, read settings of the default session.
- if ( ! sc->hasGroup("Open MainWindows") ) {
- delete_cfg = true;
- cfg = new KConfig(anonymousSessionFile(), KConfig::SimpleConfig);
+ if (m_activeSession == session) {
+ return true;
}
- int wCount = cfg->group("Open MainWindows").readEntry("Count", 1);
+ if (!session->isAnonymous()) {
+ //check if the requested session is already open in another instance
+ KateRunningInstanceMap instances;
+ if (!fillinRunningKateAppInstances(&instances)) {
+ KMessageBox::error(0, i18n("Internal error: there is more than one instance open for a given session."));
+ return false;
+ }
+
+ if (instances.contains(session->name())) {
+ if (KMessageBox::questionYesNo(0, i18n("Session '%1' is already opened in another kate instance, change there instead of reopening?", session->name()),
+ QString(), KStandardGuiItem::yes(), KStandardGuiItem::no(), QStringLiteral("katesessionmanager_switch_instance")) == KMessageBox::Yes) {
+ instances[session->name()]->dbus_if->call(QStringLiteral("activate"));
+ cleanupRunningKateAppInstanceMap(&instances);
+ return false;
+ }
+ }
+
+ cleanupRunningKateAppInstanceMap(&instances);
+ }
+ // try to close and save last session
+ if (closeAndSaveLast) {
+ if (KateApp::self()->activeKateMainWindow()) {
+ if (!KateApp::self()->activeKateMainWindow()->queryClose_internal()) {
+ return true;
+ }
+ }
+
+ // save last session or not?
+ saveActiveSession();
+
+ // really close last
+ KateDocManager::self()->closeAllDocuments();
+ }
- for (int i = 0; i < wCount; ++i)
- {
- if (i >= KateApp::self()->mainWindowsCount())
- {
- KateApp::self()->newMainWindow(cfg, QString::fromLatin1("MainWindow%1").arg(i));
- }
- else
- {
- KateApp::self()->mainWindow(i)->readProperties(KConfigGroup(cfg, QString::fromLatin1("MainWindow%1").arg(i) ));
- }
+ // set the new session
+ m_activeSession = session;
- KateApp::self()->mainWindow(i)->restoreWindowConfig(KConfigGroup(cfg, QString::fromLatin1("MainWindow%1 Settings").arg(i)));
+ // there is one case in which we don't want the restoration and that is
+ // when restoring session from session manager.
+ // In that case the restore is handled by the caller
+ if (loadNew) {
+ loadSession(session);
}
- if (delete_cfg) {
- delete cfg;
+ emit sessionChanged();
+ return true;
+}
+
+void KateSessionManager::loadSession(const KateSession::Ptr &session) const
+{
+ // open the new session
+ KSharedConfigPtr sharedConfig = KSharedConfig::openConfig();
+ KConfig *sc = session->config();
+ const bool loadDocs = !session->isAnonymous(); // do not load docs for new sessions
+
+ // if we have no session config object, try to load the default
+ // (anonymous/unnamed sessions)
+ // load plugin config + plugins
+ KatePluginManager::self()->loadConfig(sc);
+
+ if (loadDocs) {
+ KateApp::self()->documentManager()->restoreDocumentList(sc);
}
- // remove mainwindows we need no longer...
- if (wCount > 0)
- {
- while (wCount < KateApp::self()->mainWindowsCount())
- delete KateApp::self()->mainWindow(KateApp::self()->mainWindowsCount() - 1);
+ // window config
+ KConfigGroup c(sharedConfig, "General");
+
+ if (c.readEntry("Restore Window Configuration", true)) {
+ KConfig *cfg = sc;
+ bool delete_cfg = false;
+ // a new, named session, read settings of the default session.
+ if (! sc->hasGroup("Open MainWindows")) {
+ delete_cfg = true;
+ cfg = new KConfig(anonymousSessionFile(), KConfig::SimpleConfig);
+ }
+
+ int wCount = cfg->group("Open MainWindows").readEntry("Count", 1);
+
+ for (int i = 0; i < wCount; ++i) {
+ if (i >= KateApp::self()->mainWindowsCount()) {
+ KateApp::self()->newMainWindow(cfg, QString::fromLatin1("MainWindow%1").arg(i));
+ } else {
+ KateApp::self()->mainWindow(i)->readProperties(KConfigGroup(cfg, QString::fromLatin1("MainWindow%1").arg(i)));
+ }
+
+ KateApp::self()->mainWindow(i)->restoreWindowConfig(KConfigGroup(cfg, QString::fromLatin1("MainWindow%1 Settings").arg(i)));
+ }
+
+ if (delete_cfg) {
+ delete cfg;
+ }
+
+ // remove mainwindows we need no longer...
+ if (wCount > 0) {
+ while (wCount < KateApp::self()->mainWindowsCount()) {
+ delete KateApp::self()->mainWindow(KateApp::self()->mainWindowsCount() - 1);
+ }
+ }
}
- }
}
bool KateSessionManager::activateSession(const QString &name, const bool closeAndSaveLast, const bool loadNew)
{
- return activateSession(giveSession(name), closeAndSaveLast, loadNew);
+ return activateSession(giveSession(name), closeAndSaveLast, loadNew);
}
bool KateSessionManager::activateAnonymousSession()
{
- return activateSession(QString(), false);
+ return activateSession(QString(), false);
}
KateSession::Ptr KateSessionManager::giveSession(const QString &name)
{
- if (name.isEmpty()) {
- return KateSession::createAnonymous(anonymousSessionFile());
- }
-
- if (m_sessions.contains(name)) {
- return m_sessions.value(name);
- }
-
- KateSession::Ptr s = KateSession::create(sessionFileForName(name), name);
- saveSessionTo(s->config());
- m_sessions[name] = s;
- return s;
+ if (name.isEmpty()) {
+ return KateSession::createAnonymous(anonymousSessionFile());
+ }
+
+ if (m_sessions.contains(name)) {
+ return m_sessions.value(name);
+ }
+
+ KateSession::Ptr s = KateSession::create(sessionFileForName(name), name);
+ saveSessionTo(s->config());
+ m_sessions[name] = s;
+ return s;
}
void KateSessionManager::deleteSession(KateSession::Ptr session)
{
- QFile::remove(session->file());
- if (session != activeSession()) {
- m_sessions.remove(session->name());
- }
+ QFile::remove(session->file());
+ if (session != activeSession()) {
+ m_sessions.remove(session->name());
+ }
}
bool KateSessionManager::renameSession(KateSession::Ptr session, const QString &newName)
{
- Q_ASSERT(!newName.isEmpty());
+ Q_ASSERT(!newName.isEmpty());
- if (session->name() == newName) {
- return true;
- }
+ if (session->name() == newName) {
+ return true;
+ }
- const QString newFile = sessionFileForName(newName);
+ const QString newFile = sessionFileForName(newName);
- if (QFile::exists(newFile)) {
- KMessageBox::sorry(QApplication::activeWindow(),
- i18n("The session could not be renamed to \"%1\", there already exists another session with the same name", newName),
- i18n("Session Renaming"));
- return false;
- }
+ if (QFile::exists(newFile)) {
+ KMessageBox::sorry(QApplication::activeWindow(),
+ i18n("The session could not be renamed to \"%1\", there already exists another session with the same name", newName),
+ i18n("Session Renaming"));
+ return false;
+ }
- session->config()->sync();
+ session->config()->sync();
- const QUrl srcUrl = QUrl::fromLocalFile(session->file());
- const QUrl dstUrl = QUrl::fromLocalFile(newFile);
- KIO::CopyJob *job = KIO::move(srcUrl, dstUrl, KIO::HideProgressInfo);
+ const QUrl srcUrl = QUrl::fromLocalFile(session->file());
+ const QUrl dstUrl = QUrl::fromLocalFile(newFile);
+ KIO::CopyJob *job = KIO::move(srcUrl, dstUrl, KIO::HideProgressInfo);
- if (!job->exec()) {
- KMessageBox::sorry(QApplication::activeWindow(),
- i18n("The session could not be renamed to \"%1\". Failed to write to \"%2\"", newName, newFile),
- i18n("Session Renaming"));
- return false;
- }
+ if (!job->exec()) {
+ KMessageBox::sorry(QApplication::activeWindow(),
+ i18n("The session could not be renamed to \"%1\". Failed to write to \"%2\"", newName, newFile),
+ i18n("Session Renaming"));
+ return false;
+ }
- m_sessions[newName] = m_sessions.take(session->name());
- session->setName(newName);
- session->setFile(newFile);
+ m_sessions[newName] = m_sessions.take(session->name());
+ session->setName(newName);
+ session->setFile(newFile);
- if (session == activeSession()) {
- emit sessionChanged();
- }
+ if (session == activeSession()) {
+ emit sessionChanged();
+ }
- return true;
+ return true;
}
void KateSessionManager::saveSessionTo(KConfig *sc) const
{
- // save plugin configs and which plugins to load
- KatePluginManager::self()->writeConfig(sc);
-
- // save document configs + which documents to load
- KateDocManager::self()->saveDocumentList (sc);
-
- sc->group("Open MainWindows").writeEntry ("Count", KateApp::self()->mainWindowsCount ());
-
- // save config for all windows around ;)
- bool saveWindowConfig = KConfigGroup(KSharedConfig::openConfig(), "General").readEntry("Restore Window Configuration", true);
- for (int i = 0; i < KateApp::self()->mainWindowsCount (); ++i )
- {
- KConfigGroup cg(sc, QString::fromLatin1("MainWindow%1").arg(i) );
- KateApp::self()->mainWindow(i)->saveProperties (cg);
- if (saveWindowConfig)
- KateApp::self()->mainWindow(i)->saveWindowConfig(KConfigGroup(sc, QString::fromLatin1("MainWindow%1 Settings").arg(i)));
- }
-
- sc->sync();
-
- /**
- * try to sync file to disk
- */
- QFile fileToSync (sc->name());
- if (fileToSync.open (QIODevice::ReadOnly)) {
+ // save plugin configs and which plugins to load
+ KatePluginManager::self()->writeConfig(sc);
+
+ // save document configs + which documents to load
+ KateDocManager::self()->saveDocumentList(sc);
+
+ sc->group("Open MainWindows").writeEntry("Count", KateApp::self()->mainWindowsCount());
+
+ // save config for all windows around ;)
+ bool saveWindowConfig = KConfigGroup(KSharedConfig::openConfig(), "General").readEntry("Restore Window Configuration", true);
+ for (int i = 0; i < KateApp::self()->mainWindowsCount(); ++i) {
+ KConfigGroup cg(sc, QString::fromLatin1("MainWindow%1").arg(i));
+ KateApp::self()->mainWindow(i)->saveProperties(cg);
+ if (saveWindowConfig) {
+ KateApp::self()->mainWindow(i)->saveWindowConfig(KConfigGroup(sc, QString::fromLatin1("MainWindow%1 Settings").arg(i)));
+ }
+ }
+
+ sc->sync();
+
+ /**
+ * try to sync file to disk
+ */
+ QFile fileToSync(sc->name());
+ if (fileToSync.open(QIODevice::ReadOnly)) {
#ifndef Q_OS_WIN
- // ensure that the file is written to disk
+ // ensure that the file is written to disk
#ifdef HAVE_FDATASYNC
- fdatasync (fileToSync.handle());
+ fdatasync(fileToSync.handle());
#else
- fsync (fileToSync.handle());
+ fsync(fileToSync.handle());
#endif
#endif
- }
+ }
}
-bool KateSessionManager::saveActiveSession (bool rememberAsLast)
+bool KateSessionManager::saveActiveSession(bool rememberAsLast)
{
- KConfig *sc = activeSession()->config();
+ KConfig *sc = activeSession()->config();
- saveSessionTo(sc);
+ saveSessionTo(sc);
- if (rememberAsLast) {
- KSharedConfigPtr c = KSharedConfig::openConfig();
- c->group("General").writeEntry("Last Session", activeSession()->name());
- c->sync();
- }
- return true;
+ if (rememberAsLast) {
+ KSharedConfigPtr c = KSharedConfig::openConfig();
+ c->group("General").writeEntry("Last Session", activeSession()->name());
+ c->sync();
+ }
+ return true;
}
-bool KateSessionManager::chooseSession ()
+bool KateSessionManager::chooseSession()
{
- const KConfigGroup c(KSharedConfig::openConfig(), "General");
+ const KConfigGroup c(KSharedConfig::openConfig(), "General");
- // get last used session, default to default session
- const QString lastSession (c.readEntry ("Last Session", QString()));
- const QString sesStart (c.readEntry ("Startup Session", "manual"));
+ // get last used session, default to default session
+ const QString lastSession(c.readEntry("Last Session", QString()));
+ const QString sesStart(c.readEntry("Startup Session", "manual"));
- // uhh, just open last used session, show no chooser
- if (sesStart == QStringLiteral("last")) {
- activateSession(lastSession, false);
- return true;
- }
+ // uhh, just open last used session, show no chooser
+ if (sesStart == QStringLiteral("last")) {
+ activateSession(lastSession, false);
+ return true;
+ }
- // start with empty new session or in case no sessions exist
- if (sesStart == QStringLiteral("new") || sessionList().size() == 0) {
- activateAnonymousSession();
- return true;
- }
+ // start with empty new session or in case no sessions exist
+ if (sesStart == QStringLiteral("new") || sessionList().size() == 0) {
+ activateAnonymousSession();
+ return true;
+ }
- QScopedPointer<KateSessionChooser> chooser(new KateSessionChooser(0, lastSession));
- const int res = chooser->exec();
- bool success = true;
+ QScopedPointer<KateSessionChooser> chooser(new KateSessionChooser(0, lastSession));
+ const int res = chooser->exec();
+ bool success = true;
- switch (res) {
+ switch (res) {
case KateSessionChooser::resultOpen: {
- KateSession::Ptr s = chooser->selectedSession(); // dialog guarantees this to be valid
- success = activateSession(s, false);
- break;
+ KateSession::Ptr s = chooser->selectedSession(); // dialog guarantees this to be valid
+ success = activateSession(s, false);
+ break;
}
case KateSessionChooser::resultCopy: {
- KateSession::Ptr s = chooser->selectedSession(); // dialog guarantees this to be valid
- KateSession::Ptr ns = KateSession::createAnonymousFrom(s, anonymousSessionFile());
- activateSession(ns, false);
- break;
+ KateSession::Ptr s = chooser->selectedSession(); // dialog guarantees this to be valid
+ KateSession::Ptr ns = KateSession::createAnonymousFrom(s, anonymousSessionFile());
+ activateSession(ns, false);
+ break;
}
// exit the app lateron
case KateSessionChooser::resultQuit:
- return false;
+ return false;
case KateSessionChooser::resultNew:
default:
- activateAnonymousSession();
- break;
- }
-
- // write back our nice boolean :)
- if (success && chooser->reopenLastSession())
- {
- KConfigGroup generalConfig(KSharedConfig::openConfig(), QStringLiteral("General"));
-
- if (res == KateSessionChooser::resultOpen) {
- generalConfig.writeEntry ("Startup Session", "last");
- } else if (res == KateSessionChooser::resultNew) {
- generalConfig.writeEntry ("Startup Session", "new");
+ activateAnonymousSession();
+ break;
}
- generalConfig.sync();
- }
+ // write back our nice boolean :)
+ if (success && chooser->reopenLastSession()) {
+ KConfigGroup generalConfig(KSharedConfig::openConfig(), QStringLiteral("General"));
+
+ if (res == KateSessionChooser::resultOpen) {
+ generalConfig.writeEntry("Startup Session", "last");
+ } else if (res == KateSessionChooser::resultNew) {
+ generalConfig.writeEntry("Startup Session", "new");
+ }
+
+ generalConfig.sync();
+ }
- return success;
+ return success;
}
-void KateSessionManager::sessionNew ()
+void KateSessionManager::sessionNew()
{
- activateSession(giveSession(QString()));
+ activateSession(giveSession(QString()));
}
-void KateSessionManager::sessionOpen ()
+void KateSessionManager::sessionOpen()
{
- QScopedPointer<KateSessionOpenDialog> chooser(new KateSessionOpenDialog(0));
+ QScopedPointer<KateSessionOpenDialog> chooser(new KateSessionOpenDialog(0));
- const int res = chooser->exec();
+ const int res = chooser->exec();
- if (res == KateSessionOpenDialog::resultCancel) {
- return;
- }
+ if (res == KateSessionOpenDialog::resultCancel) {
+ return;
+ }
- KateSession::Ptr s = chooser->selectedSession();
+ KateSession::Ptr s = chooser->selectedSession();
- if (s) {
- activateSession (s);
- }
+ if (s) {
+ activateSession(s);
+ }
}
-void KateSessionManager::sessionSave ()
+void KateSessionManager::sessionSave()
{
- saveActiveSession(); // this is the optional point to handle saveSessionAs for anonymous session
+ saveActiveSession(); // this is the optional point to handle saveSessionAs for anonymous session
}
-void KateSessionManager::sessionSaveAs ()
+void KateSessionManager::sessionSaveAs()
{
- if (newSessionName()) {
- saveActiveSession ();
- emit sessionChanged();
- }
+ if (newSessionName()) {
+ saveActiveSession();
+ emit sessionChanged();
+ }
}
bool KateSessionManager::newSessionName()
{
- bool alreadyExists = false;
-
- do {
- bool ok = false;
- const QString name = QInputDialog::getText (QApplication::activeWindow(),
- i18n("Specify New Name for Current Session"),
- alreadyExists ? i18n("There is already an existing session with your chosen name.\nPlease choose a different one\nSession name:") : i18n("Session name:"),
- QLineEdit::Normal, activeSession()->name(), &ok);
-
- if (!ok) {
- return false;
- }
-
- if (name.isEmpty()) {
- KMessageBox::sorry (0, i18n("To save a session, you must specify a name."), i18n ("Missing Session Name"));
- continue;
- }
-
- const QString file = sessionFileForName(name);
- if (QFile::exists(file)) {
- alreadyExists = true;
- continue;
- }
-
- activeSession()->config()->sync();
- KateSession::Ptr ns = KateSession::createFrom(activeSession(), file, name);
- m_activeSession = ns;
-
- emit sessionChanged();
-
- alreadyExists = false;
- }
- while (alreadyExists);
- return true;
+ bool alreadyExists = false;
+
+ do {
+ bool ok = false;
+ const QString name = QInputDialog::getText(QApplication::activeWindow(),
+ i18n("Specify New Name for Current Session"),
+ alreadyExists ? i18n("There is already an existing session with your chosen name.\nPlease choose a different one\nSession name:") : i18n("Session name:"),
+ QLineEdit::Normal, activeSession()->name(), &ok);
+
+ if (!ok) {
+ return false;
+ }
+
+ if (name.isEmpty()) {
+ KMessageBox::sorry(0, i18n("To save a session, you must specify a name."), i18n("Missing Session Name"));
+ continue;
+ }
+
+ const QString file = sessionFileForName(name);
+ if (QFile::exists(file)) {
+ alreadyExists = true;
+ continue;
+ }
+
+ activeSession()->config()->sync();
+ KateSession::Ptr ns = KateSession::createFrom(activeSession(), file, name);
+ m_activeSession = ns;
+
+ emit sessionChanged();
+
+ alreadyExists = false;
+ } while (alreadyExists);
+ return true;
}
-void KateSessionManager::sessionManage ()
+void KateSessionManager::sessionManage()
{
- QScopedPointer<KateSessionManageDialog>(new KateSessionManageDialog(0))->exec();
+ QScopedPointer<KateSessionManageDialog>(new KateSessionManageDialog(0))->exec();
}
QString KateSessionManager::anonymousSessionFile() const
{
- const QString file = m_sessionsDir + QStringLiteral("/../anonymous.katesession");
- return QDir().cleanPath(file);
+ const QString file = m_sessionsDir + QStringLiteral("/../anonymous.katesession");
+ return QDir().cleanPath(file);
}
QString KateSessionManager::sessionFileForName(const QString &name) const
{
- Q_ASSERT(!name.isEmpty());
- const QString sname = QString::fromLatin1(QUrl::toPercentEncoding(name, QByteArray(), QByteArray(".")));
- return m_sessionsDir + QStringLiteral("/") + sname + QStringLiteral(".katesession");
+ Q_ASSERT(!name.isEmpty());
+ const QString sname = QString::fromLatin1(QUrl::toPercentEncoding(name, QByteArray(), QByteArray(".")));
+ return m_sessionsDir + QStringLiteral("/") + sname + QStringLiteral(".katesession");
}
KateSessionList KateSessionManager::sessionList()
{
- return m_sessions.values();
+ return m_sessions.values();
}
//END KateSessionManager
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/session/katesessionmanager.h b/kate/session/katesessionmanager.h
index 6be2593..1bccfcf 100644
--- a/kate/session/katesessionmanager.h
+++ b/kate/session/katesessionmanager.h
@@ -32,7 +32,7 @@ class KATE_TESTS_EXPORT KateSessionManager : public QObject
{
Q_OBJECT
- public:
+public:
KateSessionManager(QObject *parent = 0, const QString &sessionsDir = QString());
~KateSessionManager();
@@ -76,13 +76,17 @@ class KATE_TESTS_EXPORT KateSessionManager : public QObject
* sessionFile == empty means we have no session around for this instance of kate
* @return session active atm
*/
- inline KateSession::Ptr activeSession() { return m_activeSession; }
+ inline KateSession::Ptr activeSession() {
+ return m_activeSession;
+ }
/**
* session dir
* @return global session dir
*/
- inline const QString &sessionsDir() const { return m_sessionsDir; }
+ inline const QString &sessionsDir() const {
+ return m_sessionsDir;
+ }
/**
* initial session chooser, on app start
@@ -90,7 +94,7 @@ class KATE_TESTS_EXPORT KateSessionManager : public QObject
*/
bool chooseSession();
- public Q_SLOTS:
+public Q_SLOTS:
/**
* try to start a new session
* asks user first for name
@@ -117,16 +121,16 @@ class KATE_TESTS_EXPORT KateSessionManager : public QObject
*/
void sessionManage();
- Q_SIGNALS:
+Q_SIGNALS:
/**
* Emitted, whenever the session changes, e.g. when it was renamed.
*/
void sessionChanged();
- /**
- * module internal APIs
- */
- public:
+ /**
+ * module internal APIs
+ */
+public:
/**
* return session with given name
* if no existing session matches, create new one with this name
@@ -156,13 +160,13 @@ class KATE_TESTS_EXPORT KateSessionManager : public QObject
*/
bool activateSession(KateSession::Ptr session, const bool closeAndSaveLast = true, const bool loadNew = true);
- private Q_SLOTS:
+private Q_SLOTS:
/**
* trigger update of session list
*/
void updateSessionList();
- private:
+private:
/**
* Asks the user for a new session name. Used by save as for example.
*/
@@ -188,7 +192,7 @@ class KATE_TESTS_EXPORT KateSessionManager : public QObject
*/
void loadSession(const KateSession::Ptr &session) const;
- private:
+private:
/**
* absolute path to dir in home dir where to store the sessions
*/
@@ -209,4 +213,3 @@ class KATE_TESTS_EXPORT KateSessionManager : public QObject
#endif
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/session/katesessionopendialog.cpp b/kate/session/katesessionopendialog.cpp
index 50cae71..b81358a 100644
--- a/kate/session/katesessionopendialog.cpp
+++ b/kate/session/katesessionopendialog.cpp
@@ -31,86 +31,86 @@
#include <QTreeWidget>
#include <QVBoxLayout>
-KateSessionOpenDialog::KateSessionOpenDialog (QWidget *parent)
- : QDialog(parent)
+KateSessionOpenDialog::KateSessionOpenDialog(QWidget *parent)
+ : QDialog(parent)
{
- setWindowTitle(i18n("Open Session"));
+ setWindowTitle(i18n("Open Session"));
- QVBoxLayout *mainLayout = new QVBoxLayout(this);
- setLayout(mainLayout);
+ QVBoxLayout *mainLayout = new QVBoxLayout(this);
+ setLayout(mainLayout);
- m_sessions = new QTreeWidget (this);
- m_sessions->setMinimumSize(400, 200);
- mainLayout->addWidget(m_sessions);
+ m_sessions = new QTreeWidget(this);
+ m_sessions->setMinimumSize(400, 200);
+ mainLayout->addWidget(m_sessions);
- QStringList header;
- header << i18n("Session Name");
- header << i18nc("The number of open documents", "Open Documents");
- m_sessions->setHeaderLabels(header);
- m_sessions->setRootIsDecorated( false );
- m_sessions->setItemsExpandable( false );
- m_sessions->setAllColumnsShowFocus( true );
- m_sessions->setSelectionBehavior(QAbstractItemView::SelectRows);
- m_sessions->setSelectionMode (QAbstractItemView::SingleSelection);
+ QStringList header;
+ header << i18n("Session Name");
+ header << i18nc("The number of open documents", "Open Documents");
+ m_sessions->setHeaderLabels(header);
+ m_sessions->setRootIsDecorated(false);
+ m_sessions->setItemsExpandable(false);
+ m_sessions->setAllColumnsShowFocus(true);
+ m_sessions->setSelectionBehavior(QAbstractItemView::SelectRows);
+ m_sessions->setSelectionMode(QAbstractItemView::SingleSelection);
- KateSessionList slist = KateSessionManager::self()->sessionList();
- qSort(slist.begin(), slist.end(), KateSession::compareByName);
+ KateSessionList slist = KateSessionManager::self()->sessionList();
+ qSort(slist.begin(), slist.end(), KateSession::compareByName);
- foreach(const KateSession::Ptr &session, slist) {
- new KateSessionChooserItem(m_sessions, session);
- }
+ foreach(const KateSession::Ptr & session, slist) {
+ new KateSessionChooserItem(m_sessions, session);
+ }
- m_sessions->resizeColumnToContents(0);
+ m_sessions->resizeColumnToContents(0);
- connect(m_sessions, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(selectionChanged(QTreeWidgetItem*,QTreeWidgetItem*)));
- connect(m_sessions, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(slotOpen()));
+ connect(m_sessions, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(selectionChanged(QTreeWidgetItem*,QTreeWidgetItem*)));
+ connect(m_sessions, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(slotOpen()));
- // buttons
- QDialogButtonBox *buttons = new QDialogButtonBox(this);
- mainLayout->addWidget(buttons);
+ // buttons
+ QDialogButtonBox *buttons = new QDialogButtonBox(this);
+ mainLayout->addWidget(buttons);
- QPushButton *cancelButton = new QPushButton;
- KGuiItem::assign(cancelButton, KStandardGuiItem::cancel());
- connect(cancelButton, SIGNAL(clicked()), this, SLOT(slotCanceled()));
- buttons->addButton(cancelButton, QDialogButtonBox::RejectRole);
+ QPushButton *cancelButton = new QPushButton;
+ KGuiItem::assign(cancelButton, KStandardGuiItem::cancel());
+ connect(cancelButton, SIGNAL(clicked()), this, SLOT(slotCanceled()));
+ buttons->addButton(cancelButton, QDialogButtonBox::RejectRole);
- m_openButton = new QPushButton(QIcon::fromTheme(QStringLiteral("document-open")), i18n("&Open"));
- m_openButton->setDefault(true);
- m_openButton->setEnabled(false);
- connect(m_openButton, SIGNAL(clicked()), this, SLOT(slotOpen()));
- buttons->addButton(m_openButton, QDialogButtonBox::AcceptRole);
+ m_openButton = new QPushButton(QIcon::fromTheme(QStringLiteral("document-open")), i18n("&Open"));
+ m_openButton->setDefault(true);
+ m_openButton->setEnabled(false);
+ connect(m_openButton, SIGNAL(clicked()), this, SLOT(slotOpen()));
+ buttons->addButton(m_openButton, QDialogButtonBox::AcceptRole);
- setResult (resultCancel);
+ setResult(resultCancel);
}
-KateSessionOpenDialog::~KateSessionOpenDialog ()
+KateSessionOpenDialog::~KateSessionOpenDialog()
{}
-KateSession::Ptr KateSessionOpenDialog::selectedSession ()
+KateSession::Ptr KateSessionOpenDialog::selectedSession()
{
- KateSessionChooserItem *item = static_cast<KateSessionChooserItem *>(m_sessions->currentItem ());
+ KateSessionChooserItem *item = static_cast<KateSessionChooserItem *>(m_sessions->currentItem());
- if (!item)
- return KateSession::Ptr();
+ if (!item) {
+ return KateSession::Ptr();
+ }
- return item->session;
+ return item->session;
}
void KateSessionOpenDialog::slotCanceled()
{
- done(resultCancel);
+ done(resultCancel);
}
void KateSessionOpenDialog::slotOpen()
{
- done(resultOk);
+ done(resultOk);
}
void KateSessionOpenDialog::selectionChanged(QTreeWidgetItem *current, QTreeWidgetItem *)
{
- Q_UNUSED(current);
- m_openButton->setEnabled(true);
+ Q_UNUSED(current);
+ m_openButton->setEnabled(true);
}
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/session/katesessionopendialog.h b/kate/session/katesessionopendialog.h
index f370864..2377175 100644
--- a/kate/session/katesessionopendialog.h
+++ b/kate/session/katesessionopendialog.h
@@ -33,31 +33,30 @@ class KateSessionOpenDialog : public QDialog
{
Q_OBJECT
- public:
- KateSessionOpenDialog (QWidget *parent);
- ~KateSessionOpenDialog ();
+public:
+ KateSessionOpenDialog(QWidget *parent);
+ ~KateSessionOpenDialog();
- KateSession::Ptr selectedSession ();
+ KateSession::Ptr selectedSession();
enum {
- resultOk,
- resultCancel
- };
+ resultOk,
+ resultCancel
+ };
- protected Q_SLOTS:
+protected Q_SLOTS:
void slotCanceled();
void slotOpen();
/**
* selection has changed
*/
- void selectionChanged (QTreeWidgetItem *current, QTreeWidgetItem *previous);
+ void selectionChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
- private:
+private:
QTreeWidget *m_sessions;
QPushButton *m_openButton;
};
#endif
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/session/katesessionsaction.cpp b/kate/session/katesessionsaction.cpp
index 98ed787..64a2a99 100644
--- a/kate/session/katesessionsaction.cpp
+++ b/kate/session/katesessionsaction.cpp
@@ -24,53 +24,52 @@
#include <QMenu>
-KateSessionsAction::KateSessionsAction(const QString& text, QObject* parent, KateSessionManager *manager)
- : KActionMenu(text, parent)
+KateSessionsAction::KateSessionsAction(const QString &text, QObject *parent, KateSessionManager *manager)
+ : KActionMenu(text, parent)
{
- m_manager = manager ? manager : KateSessionManager::self();
+ m_manager = manager ? manager : KateSessionManager::self();
- connect(menu(), SIGNAL(aboutToShow()), this, SLOT(slotAboutToShow()));
+ connect(menu(), SIGNAL(aboutToShow()), this, SLOT(slotAboutToShow()));
- sessionsGroup = new QActionGroup(menu());
+ sessionsGroup = new QActionGroup(menu());
- // reason for Qt::QueuedConnection: when switching session with N mainwindows
- // to e.g. 1 mainwindow, the last N - 1 mainwindows are deleted. Invoking
- // a session switch without queued connection deletes a mainwindow in which
- // the current code path is executed ---> crash. See bug #227008.
- connect(sessionsGroup, SIGNAL(triggered(QAction*)), this, SLOT(openSession(QAction*)), Qt::QueuedConnection);
+ // reason for Qt::QueuedConnection: when switching session with N mainwindows
+ // to e.g. 1 mainwindow, the last N - 1 mainwindows are deleted. Invoking
+ // a session switch without queued connection deletes a mainwindow in which
+ // the current code path is executed ---> crash. See bug #227008.
+ connect(sessionsGroup, SIGNAL(triggered(QAction*)), this, SLOT(openSession(QAction*)), Qt::QueuedConnection);
- connect(m_manager, SIGNAL(sessionChanged()), this, SLOT(slotSessionChanged()));
+ connect(m_manager, SIGNAL(sessionChanged()), this, SLOT(slotSessionChanged()));
- setDisabled(m_manager->sessionList().size() == 0);
+ setDisabled(m_manager->sessionList().size() == 0);
}
void KateSessionsAction::slotAboutToShow()
{
- qDeleteAll(sessionsGroup->actions());
+ qDeleteAll(sessionsGroup->actions());
- KateSessionList slist = m_manager->sessionList();
- qSort(slist.begin(), slist.end(), KateSession::compareByTimeDesc);
+ KateSessionList slist = m_manager->sessionList();
+ qSort(slist.begin(), slist.end(), KateSession::compareByTimeDesc);
- slist = slist.mid(0, 10); // take first 10
+ slist = slist.mid(0, 10); // take first 10
- foreach(const KateSession::Ptr &session, slist) {
- QString sessionName = session->name();
- sessionName.replace(QStringLiteral("&"), QStringLiteral("&&"));
- QAction *action = new QAction(sessionName, sessionsGroup);
- action->setData(QVariant(session->name()));
- menu()->addAction(action);
- }
+ foreach(const KateSession::Ptr & session, slist) {
+ QString sessionName = session->name();
+ sessionName.replace(QStringLiteral("&"), QStringLiteral("&&"));
+ QAction *action = new QAction(sessionName, sessionsGroup);
+ action->setData(QVariant(session->name()));
+ menu()->addAction(action);
+ }
}
-void KateSessionsAction::openSession (QAction *action)
+void KateSessionsAction::openSession(QAction *action)
{
- const QString name = action->data().toString();
- m_manager->activateSession(name);
+ const QString name = action->data().toString();
+ m_manager->activateSession(name);
}
void KateSessionsAction::slotSessionChanged()
{
- setDisabled(m_manager->sessionList().size() == 0);
+ setDisabled(m_manager->sessionList().size() == 0);
}
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/session/katesessionsaction.h b/kate/session/katesessionsaction.h
index 5e1b692..0fd4ea4 100644
--- a/kate/session/katesessionsaction.h
+++ b/kate/session/katesessionsaction.h
@@ -30,18 +30,17 @@ class KATE_TESTS_EXPORT KateSessionsAction : public KActionMenu
{
Q_OBJECT
- public:
- KateSessionsAction(const QString& text, QObject *parent, KateSessionManager *manager = 0);
- ~KateSessionsAction()
- {
+public:
+ KateSessionsAction(const QString &text, QObject *parent, KateSessionManager *manager = 0);
+ ~KateSessionsAction() {
}
- public Q_SLOTS:
+public Q_SLOTS:
void slotAboutToShow();
void openSession(QAction *action);
void slotSessionChanged();
- private:
+private:
friend class KateSessionsActionTest; // tfuj
QActionGroup *sessionsGroup;
KateSessionManager *m_manager;
@@ -49,4 +48,3 @@ class KATE_TESTS_EXPORT KateSessionsAction : public KActionMenu
#endif
-// kate: space-indent on; indent-width 2; replace-tabs on;