forked from qt-creator/qt-creator
CppEditor: Reduce visible CppTypeHierarchy interface
... and remove related helpers from the plugin class itself. Change-Id: Ibc6af7518a2c90da93e619dde05edbd1eb7948f0 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -166,7 +166,6 @@ public:
|
|||||||
|
|
||||||
QAction *m_reparseExternallyChangedFiles = nullptr;
|
QAction *m_reparseExternallyChangedFiles = nullptr;
|
||||||
QAction *m_findRefsCategorizedAction = nullptr;
|
QAction *m_findRefsCategorizedAction = nullptr;
|
||||||
QAction *m_openTypeHierarchyAction = nullptr;
|
|
||||||
QAction *m_openIncludeHierarchyAction = nullptr;
|
QAction *m_openIncludeHierarchyAction = nullptr;
|
||||||
|
|
||||||
CppQuickFixSettingsPage m_quickFixSettingsPage;
|
CppQuickFixSettingsPage m_quickFixSettingsPage;
|
||||||
@@ -174,7 +173,6 @@ public:
|
|||||||
QPointer<CppCodeModelInspectorDialog> m_cppCodeModelInspectorDialog;
|
QPointer<CppCodeModelInspectorDialog> m_cppCodeModelInspectorDialog;
|
||||||
|
|
||||||
CppOutlineWidgetFactory m_cppOutlineWidgetFactory;
|
CppOutlineWidgetFactory m_cppOutlineWidgetFactory;
|
||||||
CppTypeHierarchyFactory m_cppTypeHierarchyFactory;
|
|
||||||
CppIncludeHierarchyFactory m_cppIncludeHierarchyFactory;
|
CppIncludeHierarchyFactory m_cppIncludeHierarchyFactory;
|
||||||
CppEditorFactory m_cppEditorFactory;
|
CppEditorFactory m_cppEditorFactory;
|
||||||
|
|
||||||
@@ -353,13 +351,7 @@ void CppEditorPlugin::addPerSymbolActions()
|
|||||||
|
|
||||||
addSymbolActionToMenus(TextEditor::Constants::RENAME_SYMBOL);
|
addSymbolActionToMenus(TextEditor::Constants::RENAME_SYMBOL);
|
||||||
|
|
||||||
ActionBuilder openTypeHierarchy(this, Constants::OPEN_TYPE_HIERARCHY);
|
setupCppTypeHierarchy();
|
||||||
openTypeHierarchy.setText(Tr::tr("Open Type Hierarchy"));
|
|
||||||
openTypeHierarchy.setContext(context);
|
|
||||||
openTypeHierarchy.bindContextAction(&d->m_openTypeHierarchyAction);
|
|
||||||
openTypeHierarchy.setDefaultKeySequence(Tr::tr("Meta+Shift+T"), Tr::tr("Ctrl+Shift+T"));
|
|
||||||
openTypeHierarchy.addToContainers(menus, Constants::G_SYMBOL);
|
|
||||||
openTypeHierarchy.addOnTriggered(this, &CppEditorPlugin::openTypeHierarchy);
|
|
||||||
|
|
||||||
addSymbolActionToMenus(TextEditor::Constants::OPEN_CALL_HIERARCHY);
|
addSymbolActionToMenus(TextEditor::Constants::OPEN_CALL_HIERARCHY);
|
||||||
|
|
||||||
@@ -551,7 +543,6 @@ void CppEditorPluginPrivate::onTaskStarted(Id type)
|
|||||||
ActionManager::command(TextEditor::Constants::FIND_USAGES)->action()->setEnabled(false);
|
ActionManager::command(TextEditor::Constants::FIND_USAGES)->action()->setEnabled(false);
|
||||||
ActionManager::command(TextEditor::Constants::RENAME_SYMBOL)->action()->setEnabled(false);
|
ActionManager::command(TextEditor::Constants::RENAME_SYMBOL)->action()->setEnabled(false);
|
||||||
m_reparseExternallyChangedFiles->setEnabled(false);
|
m_reparseExternallyChangedFiles->setEnabled(false);
|
||||||
m_openTypeHierarchyAction->setEnabled(false);
|
|
||||||
m_openIncludeHierarchyAction->setEnabled(false);
|
m_openIncludeHierarchyAction->setEnabled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -562,7 +553,6 @@ void CppEditorPluginPrivate::onAllTasksFinished(Id type)
|
|||||||
ActionManager::command(TextEditor::Constants::FIND_USAGES)->action()->setEnabled(true);
|
ActionManager::command(TextEditor::Constants::FIND_USAGES)->action()->setEnabled(true);
|
||||||
ActionManager::command(TextEditor::Constants::RENAME_SYMBOL)->action()->setEnabled(true);
|
ActionManager::command(TextEditor::Constants::RENAME_SYMBOL)->action()->setEnabled(true);
|
||||||
m_reparseExternallyChangedFiles->setEnabled(true);
|
m_reparseExternallyChangedFiles->setEnabled(true);
|
||||||
m_openTypeHierarchyAction->setEnabled(true);
|
|
||||||
m_openIncludeHierarchyAction->setEnabled(true);
|
m_openIncludeHierarchyAction->setEnabled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -578,14 +568,6 @@ void CppEditorPluginPrivate::inspectCppCodeModel()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorPlugin::openTypeHierarchy()
|
|
||||||
{
|
|
||||||
if (currentCppEditorWidget()) {
|
|
||||||
emit typeHierarchyRequested();
|
|
||||||
NavigationWidget::activateSubWidget(Constants::TYPE_HIERARCHY_ID, Side::Left);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CppEditorPlugin::openIncludeHierarchy()
|
void CppEditorPlugin::openIncludeHierarchy()
|
||||||
{
|
{
|
||||||
if (currentCppEditorWidget()) {
|
if (currentCppEditorWidget()) {
|
||||||
|
@@ -26,14 +26,12 @@ public:
|
|||||||
static void clearHeaderSourceCache();
|
static void clearHeaderSourceCache();
|
||||||
|
|
||||||
void openDeclarationDefinitionInNextSplit();
|
void openDeclarationDefinitionInNextSplit();
|
||||||
void openTypeHierarchy();
|
|
||||||
void openIncludeHierarchy();
|
void openIncludeHierarchy();
|
||||||
void showPreProcessorDialog();
|
void showPreProcessorDialog();
|
||||||
void renameSymbolUnderCursor();
|
void renameSymbolUnderCursor();
|
||||||
void switchDeclarationDefinition();
|
void switchDeclarationDefinition();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void typeHierarchyRequested();
|
|
||||||
void includeHierarchyRequested();
|
void includeHierarchyRequested();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -6,11 +6,13 @@
|
|||||||
#include "cppeditorconstants.h"
|
#include "cppeditorconstants.h"
|
||||||
#include "cppeditortr.h"
|
#include "cppeditortr.h"
|
||||||
#include "cppeditorwidget.h"
|
#include "cppeditorwidget.h"
|
||||||
#include "cppeditorplugin.h"
|
|
||||||
#include "cppelementevaluator.h"
|
#include "cppelementevaluator.h"
|
||||||
|
|
||||||
#include <coreplugin/find/itemviewfind.h>
|
#include <coreplugin/actionmanager/actionmanager.h>
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
|
#include <coreplugin/find/itemviewfind.h>
|
||||||
|
#include <coreplugin/inavigationwidgetfactory.h>
|
||||||
|
#include <coreplugin/navigationwidget.h>
|
||||||
#include <coreplugin/progressmanager/progressmanager.h>
|
#include <coreplugin/progressmanager/progressmanager.h>
|
||||||
|
|
||||||
#include <texteditor/texteditor.h>
|
#include <texteditor/texteditor.h>
|
||||||
@@ -25,15 +27,14 @@
|
|||||||
#include <QFuture>
|
#include <QFuture>
|
||||||
#include <QFutureWatcher>
|
#include <QFutureWatcher>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QLatin1String>
|
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
#include <QStackedLayout>
|
#include <QStackedLayout>
|
||||||
#include <QStackedWidget>
|
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
|
using namespace Core;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
namespace CppEditor::Internal {
|
namespace CppEditor::Internal {
|
||||||
@@ -195,8 +196,6 @@ CppTypeHierarchyWidget::CppTypeHierarchyWidget()
|
|||||||
showNoTypeHierarchyLabel();
|
showNoTypeHierarchyLabel();
|
||||||
setLayout(m_stackLayout);
|
setLayout(m_stackLayout);
|
||||||
|
|
||||||
connect(CppEditorPlugin::instance(), &CppEditorPlugin::typeHierarchyRequested,
|
|
||||||
this, &CppTypeHierarchyWidget::perform);
|
|
||||||
connect(&m_futureWatcher, &QFutureWatcher<void>::finished,
|
connect(&m_futureWatcher, &QFutureWatcher<void>::finished,
|
||||||
this, &CppTypeHierarchyWidget::displayHierarchy);
|
this, &CppTypeHierarchyWidget::displayHierarchy);
|
||||||
}
|
}
|
||||||
@@ -399,18 +398,63 @@ QMimeData *CppTypeHierarchyModel::mimeData(const QModelIndexList &indexes) const
|
|||||||
|
|
||||||
// CppTypeHierarchyFactory
|
// CppTypeHierarchyFactory
|
||||||
|
|
||||||
CppTypeHierarchyFactory::CppTypeHierarchyFactory()
|
class CppTypeHierarchyFactory final : public INavigationWidgetFactory
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
CppTypeHierarchyFactory()
|
||||||
|
{
|
||||||
setDisplayName(Tr::tr("Type Hierarchy"));
|
setDisplayName(Tr::tr("Type Hierarchy"));
|
||||||
setPriority(700);
|
setPriority(700);
|
||||||
setId(Constants::TYPE_HIERARCHY_ID);
|
setId(Constants::TYPE_HIERARCHY_ID);
|
||||||
|
|
||||||
|
ActionBuilder openTypeHierarchy(this, Constants::OPEN_TYPE_HIERARCHY);
|
||||||
|
openTypeHierarchy.setText(Tr::tr("Open Type Hierarchy"));
|
||||||
|
openTypeHierarchy.setContext(Context(Constants::CPPEDITOR_ID));
|
||||||
|
openTypeHierarchy.bindContextAction(&m_openTypeHierarchyAction);
|
||||||
|
openTypeHierarchy.setDefaultKeySequence(Tr::tr("Meta+Shift+T"), Tr::tr("Ctrl+Shift+T"));
|
||||||
|
openTypeHierarchy.addToContainers({Constants::M_TOOLS_CPP, Constants::M_CONTEXT},
|
||||||
|
Constants::G_SYMBOL);
|
||||||
|
|
||||||
|
connect(m_openTypeHierarchyAction, &QAction::triggered, this, [] {
|
||||||
|
NavigationWidget::activateSubWidget(Constants::TYPE_HIERARCHY_ID, Side::Left);
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(ProgressManager::instance(), &ProgressManager::taskStarted, [this](Id type) {
|
||||||
|
if (type == Constants::TASK_INDEX)
|
||||||
|
m_openTypeHierarchyAction->setEnabled(false);
|
||||||
|
});
|
||||||
|
connect(ProgressManager::instance(), &ProgressManager::allTasksFinished, [this](Id type) {
|
||||||
|
if (type == Constants::TASK_INDEX)
|
||||||
|
m_openTypeHierarchyAction->setEnabled(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
NavigationView createWidget() final
|
||||||
|
{
|
||||||
|
auto w = new CppTypeHierarchyWidget;
|
||||||
|
connect(m_openTypeHierarchyAction, &QAction::triggered, w, &CppTypeHierarchyWidget::perform);
|
||||||
|
w->perform();
|
||||||
|
|
||||||
|
return {w, {}};
|
||||||
|
}
|
||||||
|
|
||||||
|
QAction *m_openTypeHierarchyAction = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
static CppTypeHierarchyFactory &cppTypeHierarchyFactory()
|
||||||
|
{
|
||||||
|
static CppTypeHierarchyFactory theCppTypeHierarchyFactory;
|
||||||
|
return theCppTypeHierarchyFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::NavigationView CppTypeHierarchyFactory::createWidget()
|
void openCppTypeHierarchy()
|
||||||
{
|
{
|
||||||
auto w = new CppTypeHierarchyWidget;
|
cppTypeHierarchyFactory().m_openTypeHierarchyAction->trigger();
|
||||||
w->perform();
|
}
|
||||||
return {w, {}};
|
|
||||||
|
void setupCppTypeHierarchy()
|
||||||
|
{
|
||||||
|
(void) cppTypeHierarchyFactory(); // Trigger instantiation
|
||||||
}
|
}
|
||||||
|
|
||||||
} // CppEditor::Internal
|
} // CppEditor::Internal
|
||||||
|
@@ -3,16 +3,9 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <coreplugin/inavigationwidgetfactory.h>
|
|
||||||
|
|
||||||
namespace CppEditor::Internal {
|
namespace CppEditor::Internal {
|
||||||
|
|
||||||
class CppTypeHierarchyFactory : public Core::INavigationWidgetFactory
|
void openCppTypeHierarchy();
|
||||||
{
|
void setupCppTypeHierarchy();
|
||||||
public:
|
|
||||||
CppTypeHierarchyFactory();
|
|
||||||
|
|
||||||
Core::NavigationView createWidget() override;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // CppEditor::Internal
|
} // CppEditor::Internal
|
||||||
|
@@ -12,6 +12,7 @@
|
|||||||
#include "cppmodelmanager.h"
|
#include "cppmodelmanager.h"
|
||||||
#include "cpptoolsreuse.h"
|
#include "cpptoolsreuse.h"
|
||||||
#include "cpptoolstestcase.h"
|
#include "cpptoolstestcase.h"
|
||||||
|
#include "cpptypehierarchy.h"
|
||||||
#include "cppworkingcopy.h"
|
#include "cppworkingcopy.h"
|
||||||
#include "projectinfo.h"
|
#include "projectinfo.h"
|
||||||
|
|
||||||
@@ -382,7 +383,7 @@ public:
|
|||||||
|
|
||||||
void OpenTypeHierarchyTokenAction::run(CppEditorWidget *)
|
void OpenTypeHierarchyTokenAction::run(CppEditorWidget *)
|
||||||
{
|
{
|
||||||
CppEditorPlugin::instance()->openTypeHierarchy();
|
openCppTypeHierarchy();
|
||||||
QApplication::processEvents();
|
QApplication::processEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user