summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Cullmann <cullmann@kde.org>2014-01-19 19:30:40 (GMT)
committerChristoph Cullmann <cullmann@kde.org>2014-01-19 19:30:48 (GMT)
commited637dd2ee083efe2cea935309235e8f35a2cdd3 (patch)
tree2924793616165927c5aa0a99911c46b5582cb0b7
parentf743187951e5924d4b8b166e9ad6416a9e7af9e6 (diff)
KTextEditor::Editor is now a singleton itself
-rw-r--r--kwrite/kwriteapp.cpp5
-rw-r--r--kwrite/kwriteapp.h10
-rw-r--r--kwrite/kwritemain.cpp17
3 files changed, 8 insertions, 24 deletions
diff --git a/kwrite/kwriteapp.cpp b/kwrite/kwriteapp.cpp
index ba3e6ba..2994efc 100644
--- a/kwrite/kwriteapp.cpp
+++ b/kwrite/kwriteapp.cpp
@@ -41,11 +41,8 @@ KWriteApp::KWriteApp(const QCommandLineParser &args)
{
s_self = this;
- m_editor = KTextEditor::Editor::instance();
- Q_ASSERT (m_editor);
-
// read from global config once
- m_editor->readConfig(KSharedConfig::openConfig().data());
+ KTextEditor::Editor::instance()->readConfig(KSharedConfig::openConfig().data());
init();
}
diff --git a/kwrite/kwriteapp.h b/kwrite/kwriteapp.h
index fa797e0..1116a8f 100644
--- a/kwrite/kwriteapp.h
+++ b/kwrite/kwriteapp.h
@@ -68,11 +68,6 @@ class KWriteApp : public QObject
*/
void init();
- /**
- * Editor instance
- */
- KTextEditor::Editor *editor () { return m_editor; }
-
private:
/**
* Static instance of KWriteApp
@@ -88,11 +83,6 @@ class KWriteApp : public QObject
* known main windows
*/
QList<KWrite*> m_mainWindows;
-
- /**
- * editor instance
- */
- KTextEditor::Editor *m_editor;
};
#endif
diff --git a/kwrite/kwritemain.cpp b/kwrite/kwritemain.cpp
index 7f20dfe..eea5a06 100644
--- a/kwrite/kwritemain.cpp
+++ b/kwrite/kwritemain.cpp
@@ -76,7 +76,7 @@ KWrite::KWrite (KTextEditor::Document *doc)
{
if ( !doc )
{
- doc = KWriteApp::self()->editor()->createDocument(0);
+ doc = KTextEditor::Editor::instance()->createDocument(0);
// enable the modified on disk warning dialogs if any
if (qobject_cast<KTextEditor::ModificationInterface *>(doc))
@@ -85,7 +85,7 @@ KWrite::KWrite (KTextEditor::Document *doc)
docList.append(doc);
}
- m_view = qobject_cast<KTextEditor::View*>(doc->createView (this));
+ m_view = doc->createView (this);
setCentralWidget(m_view);
@@ -275,7 +275,7 @@ void KWrite::slotNew()
void KWrite::slotOpen()
{
- const KEncodingFileDialog::Result r=KEncodingFileDialog::getOpenUrlsAndEncoding(KWriteApp::self()->editor()->defaultEncoding(), m_view->document()->url(),QString(),this,i18n("Open File"));
+ const KEncodingFileDialog::Result r=KEncodingFileDialog::getOpenUrlsAndEncoding(KTextEditor::Editor::instance()->defaultEncoding(), m_view->document()->url(),QString(),this,i18n("Open File"));
Q_FOREACH (QUrl url, r.URLs) {
encoding = r.encoding;
slotOpen ( url );
@@ -403,7 +403,7 @@ void KWrite::readConfig(KSharedConfigPtr config)
// so only load, if the config is a different one (this is only the case on
// session restore)
if (config != KSharedConfig::openConfig())
- KWriteApp::self()->editor()->readConfig(config.data());
+ KTextEditor::Editor::instance()->readConfig(config.data());
if( m_paShowStatusBar->isChecked() )
statusBar()->show();
@@ -421,7 +421,7 @@ void KWrite::writeConfig(KSharedConfigPtr config)
m_recentFiles->saveEntries(KConfigGroup(config, "Recent Files"));
// Writes into its own group
- KWriteApp::self()->editor()->writeConfig(config.data());
+ KTextEditor::Editor::instance()->writeConfig(config.data());
config->sync ();
}
@@ -493,9 +493,6 @@ void KWrite::restore()
if (!config)
return;
- KTextEditor::Editor *editor = KTextEditor::Editor::instance();
- Q_ASSERT (editor);
-
int docs, windows;
QString buf;
KTextEditor::Document *doc;
@@ -509,7 +506,7 @@ void KWrite::restore()
{
buf = QString::fromLatin1("Document %1").arg(z);
KConfigGroup cg(config, buf);
- doc=editor->createDocument(0);
+ doc=KTextEditor::Editor::instance()->createDocument(0);
if (KTextEditor::SessionConfigInterface *iface = qobject_cast<KTextEditor::SessionConfigInterface *>(doc))
iface->readSessionConfig(cg);
@@ -527,7 +524,7 @@ void KWrite::restore()
void KWrite::aboutEditor()
{
- KAboutApplicationDialog dlg(KWriteApp::self()->editor()->aboutData(), this);
+ KAboutApplicationDialog dlg(KTextEditor::Editor::instance()->aboutData(), this);
dlg.exec();
}