diff --git a/src/plugins/autotest/testnavigationwidget.cpp b/src/plugins/autotest/testnavigationwidget.cpp index 431f5a3af89..d7f26e655fa 100644 --- a/src/plugins/autotest/testnavigationwidget.cpp +++ b/src/plugins/autotest/testnavigationwidget.cpp @@ -6,6 +6,7 @@ #include "autotestconstants.h" #include "autotesticons.h" #include "autotesttr.h" +#include "itemdatacache.h" #include "testcodeparser.h" #include "testframeworkmanager.h" #include "testrunner.h" @@ -25,6 +26,7 @@ #include #include +#include #include #include #include @@ -35,13 +37,45 @@ #include #include +using namespace Core; using namespace Utils; -namespace Autotest { -namespace Internal { +namespace Autotest::Internal { -TestNavigationWidget::TestNavigationWidget(QWidget *parent) : - QWidget(parent) +class TestNavigationWidget : public QWidget +{ +public: + TestNavigationWidget(); + + void contextMenuEvent(QContextMenuEvent *event) override; + QList createToolButtons(); + + void updateExpandedStateCache(); + +private: + void onItemActivated(const QModelIndex &index); + void onSortClicked(); + void onFilterMenuTriggered(QAction *action); + void onParsingStarted(); + void onParsingFinished(); + void initializeFilterMenu(); + void onRunThisTestTriggered(TestRunMode runMode); + void reapplyCachedExpandedState(); + + TestTreeModel *m_model; + TestTreeSortFilterModel *m_sortFilterModel; + TestTreeView *m_view; + QToolButton *m_sort; + QToolButton *m_filterButton; + QMenu *m_filterMenu; + bool m_sortAlphabetically; + Utils::ProgressIndicator *m_progressIndicator; + QTimer *m_progressTimer; + QFrame *m_missingFrameworksWidget; + ItemDataCache m_expandedStateCache; +}; + +TestNavigationWidget::TestNavigationWidget() { setWindowTitle(Tr::tr("Tests")); m_model = TestTreeModel::instance(); @@ -68,7 +102,7 @@ TestNavigationWidget::TestNavigationWidget(QWidget *parent) : layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); layout->addWidget(m_missingFrameworksWidget); - layout->addWidget(Core::ItemViewFind::createSearchableWrapper(m_view)); + layout->addWidget(ItemViewFind::createSearchableWrapper(m_view)); setLayout(layout); connect(m_view, &TestTreeView::activated, this, &TestNavigationWidget::onItemActivated); @@ -150,14 +184,14 @@ void TestNavigationWidget::contextMenuEvent(QContextMenuEvent *event) } } - QAction *runAll = Core::ActionManager::command(Constants::ACTION_RUN_ALL_ID)->action(); - QAction *runSelected = Core::ActionManager::command(Constants::ACTION_RUN_SELECTED_ID)->action(); - QAction *runAllNoDeploy = Core::ActionManager::command(Constants::ACTION_RUN_ALL_NODEPLOY_ID)->action(); - QAction *runSelectedNoDeploy = Core::ActionManager::command(Constants::ACTION_RUN_SELECTED_NODEPLOY_ID)->action(); + QAction *runAll = ActionManager::command(Constants::ACTION_RUN_ALL_ID)->action(); + QAction *runSelected = ActionManager::command(Constants::ACTION_RUN_SELECTED_ID)->action(); + QAction *runAllNoDeploy = ActionManager::command(Constants::ACTION_RUN_ALL_NODEPLOY_ID)->action(); + QAction *runSelectedNoDeploy = ActionManager::command(Constants::ACTION_RUN_SELECTED_NODEPLOY_ID)->action(); QAction *selectAll = new QAction(Tr::tr("Select All"), &menu); QAction *deselectAll = new QAction(Tr::tr("Deselect All"), &menu); // TODO remove? - QAction *rescan = Core::ActionManager::command(Constants::ACTION_SCAN_ID)->action(); + QAction *rescan = ActionManager::command(Constants::ACTION_SCAN_ID)->action(); connect(selectAll, &QAction::triggered, m_view, &TestTreeView::selectAll); connect(deselectAll, &QAction::triggered, m_view, &TestTreeView::deselectAll); @@ -247,7 +281,7 @@ void TestNavigationWidget::onItemActivated(const QModelIndex &index) { const Link link = index.data(LinkRole).value(); if (link.hasValidTarget()) - Core::EditorManager::openEditorAt(link); + EditorManager::openEditorAt(link); } void TestNavigationWidget::onSortClicked() @@ -326,6 +360,8 @@ void TestNavigationWidget::reapplyCachedExpandedState() } } +// TestNavigationWidgetFactory + TestNavigationWidgetFactory::TestNavigationWidgetFactory() { setDisplayName(Tr::tr("Tests")); @@ -333,11 +369,10 @@ TestNavigationWidgetFactory::TestNavigationWidgetFactory() setPriority(666); } -Core::NavigationView TestNavigationWidgetFactory::createWidget() +NavigationView TestNavigationWidgetFactory::createWidget() { TestNavigationWidget *treeViewWidget = new TestNavigationWidget; return {treeViewWidget, treeViewWidget->createToolButtons()}; } -} // namespace Internal -} // namespace Autotest +} // Autotest::Internal diff --git a/src/plugins/autotest/testnavigationwidget.h b/src/plugins/autotest/testnavigationwidget.h index 53c2bb293d6..3b598a670fc 100644 --- a/src/plugins/autotest/testnavigationwidget.h +++ b/src/plugins/autotest/testnavigationwidget.h @@ -3,78 +3,17 @@ #pragma once -#include "itemdatacache.h" - #include -#include - -QT_BEGIN_NAMESPACE -class QAction; -class QMenu; -class QTimer; -class QToolButton; -QT_END_NAMESPACE - -namespace Utils { -class ProgressIndicator; -} - -namespace Autotest { - -class TestTreeModel; - -namespace Internal { - -class TestRunner; -class TestTreeSortFilterModel; -class TestTreeView; - -class TestNavigationWidget : public QWidget -{ - Q_OBJECT - -public: - explicit TestNavigationWidget(QWidget *parent = nullptr); - void contextMenuEvent(QContextMenuEvent *event) override; - QList createToolButtons(); - - void updateExpandedStateCache(); - -private: - void onItemActivated(const QModelIndex &index); - void onSortClicked(); - void onFilterMenuTriggered(QAction *action); - void onParsingStarted(); - void onParsingFinished(); - void initializeFilterMenu(); - void onRunThisTestTriggered(TestRunMode runMode); - void reapplyCachedExpandedState(); - - TestTreeModel *m_model; - TestTreeSortFilterModel *m_sortFilterModel; - TestTreeView *m_view; - QToolButton *m_sort; - QToolButton *m_filterButton; - QMenu *m_filterMenu; - bool m_sortAlphabetically; - Utils::ProgressIndicator *m_progressIndicator; - QTimer *m_progressTimer; - QFrame *m_missingFrameworksWidget; - ItemDataCache m_expandedStateCache; -}; +namespace Autotest::Internal { class TestNavigationWidgetFactory : public Core::INavigationWidgetFactory { - Q_OBJECT - public: TestNavigationWidgetFactory(); private: Core::NavigationView createWidget() override; - }; -} // namespace Internal -} // namespace Autotest +} // Autotest::Internal