From 68cdbd9cd0fa8156ff97a59437e0ff221cbdbc32 Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 1 Sep 2023 17:20:10 +0200 Subject: [PATCH] Core: Hide part of OpenEditors implementation Change-Id: I4c7a2a62e9395450b44b96a5333135fbed773992 Reviewed-by: Christian Stenger --- .../editormanager/openeditorsview.cpp | 50 +++++++++++++++- .../editormanager/openeditorsview.h | 57 +------------------ 2 files changed, 50 insertions(+), 57 deletions(-) diff --git a/src/plugins/coreplugin/editormanager/openeditorsview.cpp b/src/plugins/coreplugin/editormanager/openeditorsview.cpp index 3cbc9b4aec8..ebf2d751ec9 100644 --- a/src/plugins/coreplugin/editormanager/openeditorsview.cpp +++ b/src/plugins/coreplugin/editormanager/openeditorsview.cpp @@ -8,18 +8,64 @@ #include "ieditor.h" #include "../actionmanager/command.h" #include "../coreplugintr.h" +#include "../opendocumentstreeview.h" #include #include +#include #include #include namespace Core::Internal { -//// +class ProxyModel : public QAbstractProxyModel +{ +public: + explicit ProxyModel(QObject *parent = nullptr); + + QModelIndex mapFromSource(const QModelIndex & sourceIndex) const override; + QModelIndex mapToSource(const QModelIndex & proxyIndex) const override; + + QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; + QModelIndex parent(const QModelIndex &child) const override; + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + int columnCount(const QModelIndex &parent = QModelIndex()) const override; + + void setSourceModel(QAbstractItemModel *sourceModel) override; + + QVariant data(const QModelIndex &index, int role) const override; + + // QAbstractProxyModel::sibling is broken in Qt 5 + QModelIndex sibling(int row, int column, const QModelIndex &idx) const override; + // QAbstractProxyModel::supportedDragActions delegation is missing in Qt 5 + Qt::DropActions supportedDragActions() const override; + +private: + void sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); + void sourceRowsRemoved(const QModelIndex &parent, int start, int end); + void sourceRowsInserted(const QModelIndex &parent, int start, int end); + void sourceRowsAboutToBeRemoved(const QModelIndex &parent, int start, int end); + void sourceRowsAboutToBeInserted(const QModelIndex &parent, int start, int end); +}; + // OpenEditorsWidget -//// + +class OpenEditorsWidget : public OpenDocumentsTreeView +{ +public: + OpenEditorsWidget(); + ~OpenEditorsWidget() override; + +private: + void handleActivated(const QModelIndex &); + void updateCurrentItem(IEditor*); + void contextMenuRequested(QPoint pos); + void activateEditor(const QModelIndex &index); + void closeDocument(const QModelIndex &index); + + ProxyModel *m_model; +}; OpenEditorsWidget::OpenEditorsWidget() { diff --git a/src/plugins/coreplugin/editormanager/openeditorsview.h b/src/plugins/coreplugin/editormanager/openeditorsview.h index 0634e45f7d2..0ba5a41961c 100644 --- a/src/plugins/coreplugin/editormanager/openeditorsview.h +++ b/src/plugins/coreplugin/editormanager/openeditorsview.h @@ -4,60 +4,8 @@ #pragma once #include -#include -#include -#include - -namespace Core { -class IEditor; - -namespace Internal { - -class ProxyModel : public QAbstractProxyModel -{ -public: - explicit ProxyModel(QObject *parent = nullptr); - QModelIndex mapFromSource(const QModelIndex & sourceIndex) const override; - QModelIndex mapToSource(const QModelIndex & proxyIndex) const override; - - QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; - QModelIndex parent(const QModelIndex &child) const override; - int rowCount(const QModelIndex &parent = QModelIndex()) const override; - int columnCount(const QModelIndex &parent = QModelIndex()) const override; - - void setSourceModel(QAbstractItemModel *sourceModel) override; - - QVariant data(const QModelIndex &index, int role) const override; - - // QAbstractProxyModel::sibling is broken in Qt 5 - QModelIndex sibling(int row, int column, const QModelIndex &idx) const override; - // QAbstractProxyModel::supportedDragActions delegation is missing in Qt 5 - Qt::DropActions supportedDragActions() const override; - -private: - void sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); - void sourceRowsRemoved(const QModelIndex &parent, int start, int end); - void sourceRowsInserted(const QModelIndex &parent, int start, int end); - void sourceRowsAboutToBeRemoved(const QModelIndex &parent, int start, int end); - void sourceRowsAboutToBeInserted(const QModelIndex &parent, int start, int end); -}; - -class OpenEditorsWidget : public OpenDocumentsTreeView -{ -public: - OpenEditorsWidget(); - ~OpenEditorsWidget() override; - -private: - void handleActivated(const QModelIndex &); - void updateCurrentItem(IEditor*); - void contextMenuRequested(QPoint pos); - void activateEditor(const QModelIndex &index); - void closeDocument(const QModelIndex &index); - - ProxyModel *m_model; -}; +namespace Core::Internal { class OpenEditorsViewFactory : public INavigationWidgetFactory { @@ -67,5 +15,4 @@ public: NavigationView createWidget() override; }; -} // namespace Internal -} // namespace Core +} // Core::Internal