Commit 21e50b2f authored by Nikolai Kosjar's avatar Nikolai Kosjar

CppEditor: Make CppEditorOutline independent of CppEditor plugin

Change-Id: I1cafcd8daf93ffc2f672bf7e2ba5d1c8ea5e8652
Reviewed-by: default avatarMarco Bubke <marco.bubke@theqtcompany.com>
parent db57fa89
......@@ -34,6 +34,7 @@
#include <cpptools/cppmodelmanager.h>
#include <cpptools/cpptoolsreuse.h>
#include <cpptools/cpptoolssettings.h>
#include <texteditor/texteditor.h>
#include <cplusplus/OverviewModel.h>
......@@ -104,7 +105,7 @@ CppEditorOutline::CppEditorOutline(TextEditor::TextEditorWidget *editorWidget)
, m_proxyModel(new OverviewProxyModel(m_model, this))
{
// Set up proxy model
if (CppEditorPlugin::instance()->sortedOutline())
if (CppTools::CppToolsSettings::instance()->sortedEditorDocumentOutline())
m_proxyModel->sort(0, Qt::AscendingOrder);
else
m_proxyModel->sort(-1, Qt::AscendingOrder); // don't sort yet, but set column for sortedOutline()
......@@ -124,8 +125,9 @@ CppEditorOutline::CppEditorOutline(TextEditor::TextEditorWidget *editorWidget)
m_sortAction = new QAction(tr("Sort Alphabetically"), m_combo);
m_sortAction->setCheckable(true);
m_sortAction->setChecked(isSorted());
connect(m_sortAction, SIGNAL(toggled(bool)),
CppEditorPlugin::instance(), SLOT(setSortedOutline(bool)));
connect(m_sortAction, &QAction::toggled,
CppTools::CppToolsSettings::instance(),
&CppTools::CppToolsSettings::setSortedEditorDocumentOutline);
m_combo->addAction(m_sortAction);
connect(m_combo, SIGNAL(activated(int)), this, SLOT(gotoSymbolInEditor()));
......
......@@ -123,7 +123,6 @@ public:
CppEditorPlugin *CppEditorPlugin::m_instance = 0;
CppEditorPlugin::CppEditorPlugin() :
m_sortedOutline(true),
m_renameSymbolUnderCursorAction(0),
m_findUsagesAction(0),
m_reparseExternallyChangedFiles(0),
......@@ -144,17 +143,6 @@ CppEditorPlugin *CppEditorPlugin::instance()
return m_instance;
}
void CppEditorPlugin::setSortedOutline(bool sorted)
{
m_sortedOutline = sorted;
emit outlineSortingChanged(sorted);
}
bool CppEditorPlugin::sortedOutline() const
{
return m_sortedOutline;
}
CppQuickFixAssistProvider *CppEditorPlugin::quickFixProvider() const
{
return m_quickFixProvider;
......@@ -284,27 +272,15 @@ bool CppEditorPlugin::initialize(const QStringList & /*arguments*/, QString *err
connect(ProgressManager::instance(), SIGNAL(allTasksFinished(Core::Id)),
this, SLOT(onAllTasksFinished(Core::Id)));
readSettings();
return true;
}
void CppEditorPlugin::readSettings()
{
m_sortedOutline = ICore::settings()->value(QLatin1String("CppTools/SortedMethodOverview"), true).toBool();
}
void CppEditorPlugin::writeSettings()
{
ICore::settings()->setValue(QLatin1String("CppTools/SortedMethodOverview"), m_sortedOutline);
}
void CppEditorPlugin::extensionsInitialized()
{
}
ExtensionSystem::IPlugin::ShutdownFlag CppEditorPlugin::aboutToShutdown()
{
writeSettings();
return SynchronousShutdown;
}
......
......@@ -63,8 +63,6 @@ public:
void extensionsInitialized();
ShutdownFlag aboutToShutdown();
bool sortedOutline() const;
CppQuickFixAssistProvider *quickFixProvider() const;
signals:
......@@ -81,8 +79,6 @@ public slots:
void renameSymbolUnderCursor();
void switchDeclarationDefinition();
void setSortedOutline(bool sorted);
private slots:
void onTaskStarted(Core::Id type);
void onAllTasksFinished(Core::Id type);
......@@ -227,12 +223,9 @@ private slots:
private:
Core::IEditor *createEditor(QWidget *parent);
void writeSettings();
void readSettings();
static CppEditorPlugin *m_instance;
bool m_sortedOutline;
QAction *m_renameSymbolUnderCursorAction;
QAction *m_findUsagesAction;
QAction *m_reparseExternallyChangedFiles;
......
......@@ -52,6 +52,7 @@ const char CPP_HEADER_MIMETYPE[] = "text/x-c++hdr";
const char CPPTOOLS_SETTINGSGROUP[] = "CppTools";
const char LOWERCASE_CPPFILES_KEY[] = "LowerCaseFiles";
enum { lowerCaseFilesDefault = 1 };
const char CPPTOOLS_SORT_EDITOR_DOCUMENT_OUTLINE[] = "SortedMethodOverview";
const char CPPTOOLS_MODEL_MANAGER_SUPPORTERS_KEY[] = "ModelManagerSupporters";
const char CPPTOOLS_MODEL_MANAGER_PCH_USAGE[] = "PCHUsage";
......
......@@ -49,6 +49,7 @@
static const char idKey[] = "CppGlobal";
using namespace Core;
using namespace CppTools;
using namespace CppTools::Internal;
using namespace TextEditor;
......@@ -262,3 +263,21 @@ void CppToolsSettings::setCommentsSettings(const CommentsSettings &commentsSetti
d->m_commentsSettings.toSettings(QLatin1String(Constants::CPPTOOLS_SETTINGSGROUP),
Core::ICore::settings());
}
static QString sortEditorDocumentOutlineKey()
{
return QLatin1String(CppTools::Constants::CPPTOOLS_SETTINGSGROUP)
+ QLatin1Char('/')
+ QLatin1String(CppTools::Constants::CPPTOOLS_SORT_EDITOR_DOCUMENT_OUTLINE);
}
bool CppToolsSettings::sortedEditorDocumentOutline() const
{
return ICore::settings()->value(sortEditorDocumentOutlineKey(), true).toBool();
}
void CppToolsSettings::setSortedEditorDocumentOutline(bool sorted)
{
ICore::settings()->setValue(sortEditorDocumentOutlineKey(), sorted);
emit editorDocumentOutlineSortingChanged(sorted);
}
......@@ -63,6 +63,12 @@ public:
const CommentsSettings &commentsSettings() const;
void setCommentsSettings(const CommentsSettings &commentsSettings);
bool sortedEditorDocumentOutline() const;
void setSortedEditorDocumentOutline(bool sorted);
signals:
void editorDocumentOutlineSortingChanged(bool isSorted);
private:
Internal::CppToolsSettingsPrivate *d;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment