forked from qt-creator/qt-creator
Core: Hide part of OpenEditors implementation
Change-Id: I4c7a2a62e9395450b44b96a5333135fbed773992 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -8,18 +8,64 @@
|
|||||||
#include "ieditor.h"
|
#include "ieditor.h"
|
||||||
#include "../actionmanager/command.h"
|
#include "../actionmanager/command.h"
|
||||||
#include "../coreplugintr.h"
|
#include "../coreplugintr.h"
|
||||||
|
#include "../opendocumentstreeview.h"
|
||||||
|
|
||||||
#include <utils/fsengine/fileiconprovider.h>
|
#include <utils/fsengine/fileiconprovider.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
|
#include <QAbstractProxyModel>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
||||||
namespace Core::Internal {
|
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
|
// 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()
|
OpenEditorsWidget::OpenEditorsWidget()
|
||||||
{
|
{
|
||||||
|
@@ -4,60 +4,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <coreplugin/inavigationwidgetfactory.h>
|
#include <coreplugin/inavigationwidgetfactory.h>
|
||||||
#include <coreplugin/opendocumentstreeview.h>
|
|
||||||
|
|
||||||
#include <QAbstractProxyModel>
|
namespace Core::Internal {
|
||||||
#include <QCoreApplication>
|
|
||||||
|
|
||||||
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;
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpenEditorsViewFactory : public INavigationWidgetFactory
|
class OpenEditorsViewFactory : public INavigationWidgetFactory
|
||||||
{
|
{
|
||||||
@@ -67,5 +15,4 @@ public:
|
|||||||
NavigationView createWidget() override;
|
NavigationView createWidget() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // Core::Internal
|
||||||
} // namespace Core
|
|
||||||
|
Reference in New Issue
Block a user