diff options
author | Christian Stenger <christian.stenger@qt.io> | 2020-05-27 12:37:03 +0200 |
---|---|---|
committer | Christian Stenger <christian.stenger@qt.io> | 2020-06-05 05:23:08 +0000 |
commit | 65ced9733bd0520695286dc99230e6cdebfe75cc (patch) | |
tree | 3731236afb728df0412350602dfa2f9ffff7ce23 /src/plugins/cppeditor/cppoutline.cpp | |
parent | d4b915e00184fb1faac221df66b4d982f15557d3 (diff) | |
download | qt-creator-65ced9733bd0520695286dc99230e6cdebfe75cc.tar.gz |
CppEditor: Support sorting of outline
Change-Id: Icf31991327800dbcb2c5c2e8076011dfa85d6f2a
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/plugins/cppeditor/cppoutline.cpp')
-rw-r--r-- | src/plugins/cppeditor/cppoutline.cpp | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/plugins/cppeditor/cppoutline.cpp b/src/plugins/cppeditor/cppoutline.cpp index 137e73292a..c071f61a43 100644 --- a/src/plugins/cppeditor/cppoutline.cpp +++ b/src/plugins/cppeditor/cppoutline.cpp @@ -101,7 +101,8 @@ CppOutlineWidget::CppOutlineWidget(CppEditorWidget *editor) : m_editor(editor), m_treeView(new CppOutlineTreeView(this)), m_enableCursorSync(true), - m_blockCursorSync(false) + m_blockCursorSync(false), + m_sorted(false) { CppTools::AbstractOverviewModel *model = m_editor->outline()->model(); m_proxyModel = new CppOutlineFilterModel(*model, this); @@ -114,6 +115,7 @@ CppOutlineWidget::CppOutlineWidget(CppEditorWidget *editor) : setLayout(layout); m_treeView->setModel(m_proxyModel); + m_treeView->setSortingEnabled(true); setFocusProxy(m_treeView); connect(model, &QAbstractItemModel::modelReset, this, &CppOutlineWidget::modelUpdated); @@ -137,6 +139,27 @@ void CppOutlineWidget::setCursorSynchronization(bool syncWithCursor) updateSelectionInTree(m_editor->outline()->modelIndex()); } +bool CppOutlineWidget::isSorted() const +{ + return m_sorted; +} + +void CppOutlineWidget::setSorted(bool sorted) +{ + m_sorted = sorted; + m_proxyModel->sort(m_sorted ? 0 : -1); +} + +void CppOutlineWidget::restoreSettings(const QVariantMap &map) +{ + setSorted(map.value(QString("CppOutline.Sort"), false).toBool()); +} + +QVariantMap CppOutlineWidget::settings() const +{ + return {{QString("CppOutline.Sort"), m_sorted}}; +} + void CppOutlineWidget::modelUpdated() { m_treeView->expandAll(); |