From fbcff211c33eb54ae927bd05f0c0cd73269ab643 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Wed, 21 Jan 2015 11:16:34 +0100 Subject: [PATCH] EditorManager: Make placeholder text API 'module-private' Since locator is actually part of coreplugin, and it is the only one supported to set this currently. Change-Id: I7f310a29f6d157f3a494fa774216772e48853dc4 Reviewed-by: David Schulz --- .../editormanager/editormanager.cpp | 31 +++++++++++-------- .../coreplugin/editormanager/editormanager.h | 4 --- .../editormanager/editormanager_p.h | 8 +++++ .../coreplugin/editormanager/editorview.cpp | 4 +-- src/plugins/coreplugin/locator/locator.cpp | 3 +- 5 files changed, 30 insertions(+), 20 deletions(-) diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp index 766ecc175d4..d640bdab7dc 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.cpp +++ b/src/plugins/coreplugin/editormanager/editormanager.cpp @@ -510,6 +510,11 @@ void EditorManagerPrivate::init() }); } +EditorManagerPrivate *EditorManagerPrivate::instance() +{ + return d; +} + EditorArea *EditorManagerPrivate::mainEditorArea() { return d->m_editorAreas.at(0); @@ -1467,6 +1472,19 @@ void EditorManagerPrivate::makeCurrentEditorWritable() makeFileWritable(doc); } +void EditorManagerPrivate::setPlaceholderText(const QString &text) +{ + if (d->m_placeholderText == text) + return; + d->m_placeholderText = text; + emit d->placeholderTextChanged(d->m_placeholderText); +} + +QString EditorManagerPrivate::placeholderText() +{ + return d->m_placeholderText; +} + void EditorManagerPrivate::vcsOpenCurrentEditor() { IDocument *document = EditorManager::currentDocument(); @@ -1987,19 +2005,6 @@ void EditorManager::addNativeDirAndOpenWithActions(QMenu *contextMenu, DocumentM DocumentManager::populateOpenWithMenu(openWith, entry->fileName()); } -void EditorManager::setPlaceholderText(const QString &text) -{ - if (d->m_placeholderText == text) - return; - d->m_placeholderText = text; - emit m_instance->placeholderTextChanged(d->m_placeholderText); -} - -QString EditorManager::placeholderText() -{ - return d->m_placeholderText; -} - void EditorManager::saveDocument() { EditorManagerPrivate::saveDocument(currentDocument()); diff --git a/src/plugins/coreplugin/editormanager/editormanager.h b/src/plugins/coreplugin/editormanager/editormanager.h index f5f8d115475..62181052e88 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.h +++ b/src/plugins/coreplugin/editormanager/editormanager.h @@ -173,9 +173,6 @@ public: IEditor *editor = 0); static void addNativeDirAndOpenWithActions(QMenu *contextMenu, DocumentModel::Entry *entry); - static void setPlaceholderText(const QString &text); - static QString placeholderText(); - signals: void currentEditorChanged(Core::IEditor *editor); void currentDocumentStateChanged(); @@ -184,7 +181,6 @@ signals: void editorAboutToClose(Core::IEditor *editor); void editorsClosed(QList editors); void findOnFileSystemRequest(const QString &path); - void placeholderTextChanged(const QString &text); public slots: static void saveDocument(); diff --git a/src/plugins/coreplugin/editormanager/editormanager_p.h b/src/plugins/coreplugin/editormanager/editormanager_p.h index 7af674c1d08..f40a85afe80 100644 --- a/src/plugins/coreplugin/editormanager/editormanager_p.h +++ b/src/plugins/coreplugin/editormanager/editormanager_p.h @@ -68,6 +68,8 @@ class EditorManagerPrivate : public QObject friend class Core::EditorManager; public: + static EditorManagerPrivate *instance(); + static EditorArea *mainEditorArea(); static EditorView *currentEditorView(); static void setCurrentEditor(IEditor *editor, bool ignoreNavigationHistory = false); @@ -121,6 +123,9 @@ public: static void vcsOpenCurrentEditor(); static void makeCurrentEditorWritable(); + static void setPlaceholderText(const QString &text); + static QString placeholderText(); + public slots: static bool saveDocument(Core::IDocument *document); static bool saveDocumentAs(Core::IDocument *document); @@ -132,6 +137,9 @@ public slots: void handleDocumentStateChange(); static void editorAreaDestroyed(QObject *area); +signals: + void placeholderTextChanged(const QString &text); + private slots: static void gotoNextDocHistory(); static void gotoPreviousDocHistory(); diff --git a/src/plugins/coreplugin/editormanager/editorview.cpp b/src/plugins/coreplugin/editormanager/editorview.cpp index e7f59ecbae6..748df48f402 100644 --- a/src/plugins/coreplugin/editormanager/editorview.cpp +++ b/src/plugins/coreplugin/editormanager/editorview.cpp @@ -126,9 +126,9 @@ EditorView::EditorView(SplitterOrView *parentSplitterOrView, QWidget *parent) : auto emptyLayout = new QGridLayout(empty); empty->setLayout(emptyLayout); m_emptyViewLabel = new QLabel; - connect(EditorManager::instance(), &EditorManager::placeholderTextChanged, + connect(EditorManagerPrivate::instance(), &EditorManagerPrivate::placeholderTextChanged, m_emptyViewLabel, &QLabel::setText); - m_emptyViewLabel->setText(EditorManager::placeholderText()); + m_emptyViewLabel->setText(EditorManagerPrivate::placeholderText()); emptyLayout->addWidget(m_emptyViewLabel); m_container->addWidget(empty); m_widgetEditorMap.insert(empty, 0); diff --git a/src/plugins/coreplugin/locator/locator.cpp b/src/plugins/coreplugin/locator/locator.cpp index c608ef11a96..13d006c378c 100644 --- a/src/plugins/coreplugin/locator/locator.cpp +++ b/src/plugins/coreplugin/locator/locator.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -227,7 +228,7 @@ void Locator::updateEditorManagerPlaceholderText() methods = tr("
- type %1<space><pattern>" " to jump to a function definition
").arg(methodsFilter->shortcutString()); - EditorManager::setPlaceholderText(placeholderText.arg(classes, methods)); + EditorManagerPrivate::setPlaceholderText(placeholderText.arg(classes, methods)); } void Locator::saveSettings()