CppEditor: Rework CppIncludeHierarchy model

Use a Utils::TreeModel as base for the model. Avoid excessive
expansion of items during incremental search.

Change-Id: Ic2f51c7e467ea127ccf69ef7d122cec4a63be2f5
Task-number: QTCREATORBUG-15834
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2016-07-26 10:52:03 +02:00
committed by hjk
parent 5c5197d19d
commit 80b402403a
13 changed files with 395 additions and 898 deletions

View File

@@ -26,83 +26,46 @@
#pragma once
#include <coreplugin/inavigationwidgetfactory.h>
#include <utils/treemodel.h>
#include <QString>
#include <QStackedWidget>
#include <QWidget>
QT_BEGIN_NAMESPACE
class QStandardItemModel;
class QStandardItem;
class QModelIndex;
class QLabel;
QT_END_NAMESPACE
namespace Core { class IEditor; }
namespace TextEditor {
class BaseTextEditor;
class TextEditorLinkLabel;
}
namespace Utils {
class AnnotatedItemDelegate;
class FileName;
}
#include <QSet>
namespace CppEditor {
namespace Internal {
class CppEditor;
class CppEditorWidget;
class CppInclude;
class CppIncludeHierarchyModel;
class CppIncludeHierarchyTreeView;
class CppIncludeHierarchyItem;
class CppIncludeHierarchyWidget : public QWidget
class CppIncludeHierarchyModel : public Utils::UniformTreeModel<CppIncludeHierarchyItem>
{
Q_OBJECT
public:
CppIncludeHierarchyWidget();
virtual ~CppIncludeHierarchyWidget();
void perform();
public:
CppIncludeHierarchyModel();
Qt::DropActions supportedDragActions() const override;
QStringList mimeTypes() const override;
QMimeData *mimeData(const QModelIndexList &indexes) const override;
void buildHierarchy(const QString &filePath);
QString editorFilePath() const { return m_editorFilePath; }
void setSearching(bool on);
QString toString() const;
private:
void onItemActivated(const QModelIndex &index);
void editorsClosed(QList<Core::IEditor *> editors);
void showNoIncludeHierarchyLabel();
void showIncludeHierarchy();
CppEditorWidget *m_cppEditor;
CppIncludeHierarchyTreeView *m_treeView;
CppIncludeHierarchyModel *m_model;
Utils::AnnotatedItemDelegate *m_delegate;
TextEditor::TextEditorLinkLabel *m_inspectedFile;
QLabel *m_includeHierarchyInfoLabel;
TextEditor::BaseTextEditor *m_editor;
};
// @todo: Pretty much the same design as the OutlineWidgetStack. Maybe we can generalize the
// outline factory so that it works for different widgets that support the same editor.
class CppIncludeHierarchyStackedWidget : public QStackedWidget
{
Q_OBJECT
public:
CppIncludeHierarchyStackedWidget(QWidget *parent = 0);
virtual ~CppIncludeHierarchyStackedWidget();
private:
CppIncludeHierarchyWidget *m_typeHiearchyWidgetInstance;
friend class CppIncludeHierarchyItem;
QString m_editorFilePath;
QSet<QString> m_seen;
bool m_searching = false;
};
class CppIncludeHierarchyFactory : public Core::INavigationWidgetFactory
{
Q_OBJECT
public:
CppIncludeHierarchyFactory();
Core::NavigationView createWidget();
Core::NavigationView createWidget() override;
};
} // namespace Internal