forked from qt-creator/qt-creator
Autotest: Hide TestNavigationWidget implementation
Also, de-Q_OBJECT-ify. Change-Id: I6e527bb36e9f38a702604f9c6c3923e62bf921c9 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
#include "autotestconstants.h"
|
#include "autotestconstants.h"
|
||||||
#include "autotesticons.h"
|
#include "autotesticons.h"
|
||||||
#include "autotesttr.h"
|
#include "autotesttr.h"
|
||||||
|
#include "itemdatacache.h"
|
||||||
#include "testcodeparser.h"
|
#include "testcodeparser.h"
|
||||||
#include "testframeworkmanager.h"
|
#include "testframeworkmanager.h"
|
||||||
#include "testrunner.h"
|
#include "testrunner.h"
|
||||||
@@ -25,6 +26,7 @@
|
|||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
#include <utils/link.h>
|
#include <utils/link.h>
|
||||||
|
#include <utils/navigationtreeview.h>
|
||||||
#include <utils/progressindicator.h>
|
#include <utils/progressindicator.h>
|
||||||
#include <utils/stylehelper.h>
|
#include <utils/stylehelper.h>
|
||||||
#include <utils/utilsicons.h>
|
#include <utils/utilsicons.h>
|
||||||
@@ -35,13 +37,45 @@
|
|||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
|
using namespace Core;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Autotest {
|
namespace Autotest::Internal {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
TestNavigationWidget::TestNavigationWidget(QWidget *parent) :
|
class TestNavigationWidget : public QWidget
|
||||||
QWidget(parent)
|
{
|
||||||
|
public:
|
||||||
|
TestNavigationWidget();
|
||||||
|
|
||||||
|
void contextMenuEvent(QContextMenuEvent *event) override;
|
||||||
|
QList<QToolButton *> 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<bool> m_expandedStateCache;
|
||||||
|
};
|
||||||
|
|
||||||
|
TestNavigationWidget::TestNavigationWidget()
|
||||||
{
|
{
|
||||||
setWindowTitle(Tr::tr("Tests"));
|
setWindowTitle(Tr::tr("Tests"));
|
||||||
m_model = TestTreeModel::instance();
|
m_model = TestTreeModel::instance();
|
||||||
@@ -68,7 +102,7 @@ TestNavigationWidget::TestNavigationWidget(QWidget *parent) :
|
|||||||
layout->setContentsMargins(0, 0, 0, 0);
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
layout->setSpacing(0);
|
layout->setSpacing(0);
|
||||||
layout->addWidget(m_missingFrameworksWidget);
|
layout->addWidget(m_missingFrameworksWidget);
|
||||||
layout->addWidget(Core::ItemViewFind::createSearchableWrapper(m_view));
|
layout->addWidget(ItemViewFind::createSearchableWrapper(m_view));
|
||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
|
|
||||||
connect(m_view, &TestTreeView::activated, this, &TestNavigationWidget::onItemActivated);
|
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 *runAll = ActionManager::command(Constants::ACTION_RUN_ALL_ID)->action();
|
||||||
QAction *runSelected = Core::ActionManager::command(Constants::ACTION_RUN_SELECTED_ID)->action();
|
QAction *runSelected = ActionManager::command(Constants::ACTION_RUN_SELECTED_ID)->action();
|
||||||
QAction *runAllNoDeploy = Core::ActionManager::command(Constants::ACTION_RUN_ALL_NODEPLOY_ID)->action();
|
QAction *runAllNoDeploy = ActionManager::command(Constants::ACTION_RUN_ALL_NODEPLOY_ID)->action();
|
||||||
QAction *runSelectedNoDeploy = Core::ActionManager::command(Constants::ACTION_RUN_SELECTED_NODEPLOY_ID)->action();
|
QAction *runSelectedNoDeploy = ActionManager::command(Constants::ACTION_RUN_SELECTED_NODEPLOY_ID)->action();
|
||||||
QAction *selectAll = new QAction(Tr::tr("Select All"), &menu);
|
QAction *selectAll = new QAction(Tr::tr("Select All"), &menu);
|
||||||
QAction *deselectAll = new QAction(Tr::tr("Deselect All"), &menu);
|
QAction *deselectAll = new QAction(Tr::tr("Deselect All"), &menu);
|
||||||
// TODO remove?
|
// 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(selectAll, &QAction::triggered, m_view, &TestTreeView::selectAll);
|
||||||
connect(deselectAll, &QAction::triggered, m_view, &TestTreeView::deselectAll);
|
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<Link>();
|
const Link link = index.data(LinkRole).value<Link>();
|
||||||
if (link.hasValidTarget())
|
if (link.hasValidTarget())
|
||||||
Core::EditorManager::openEditorAt(link);
|
EditorManager::openEditorAt(link);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestNavigationWidget::onSortClicked()
|
void TestNavigationWidget::onSortClicked()
|
||||||
@@ -326,6 +360,8 @@ void TestNavigationWidget::reapplyCachedExpandedState()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TestNavigationWidgetFactory
|
||||||
|
|
||||||
TestNavigationWidgetFactory::TestNavigationWidgetFactory()
|
TestNavigationWidgetFactory::TestNavigationWidgetFactory()
|
||||||
{
|
{
|
||||||
setDisplayName(Tr::tr("Tests"));
|
setDisplayName(Tr::tr("Tests"));
|
||||||
@@ -333,11 +369,10 @@ TestNavigationWidgetFactory::TestNavigationWidgetFactory()
|
|||||||
setPriority(666);
|
setPriority(666);
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::NavigationView TestNavigationWidgetFactory::createWidget()
|
NavigationView TestNavigationWidgetFactory::createWidget()
|
||||||
{
|
{
|
||||||
TestNavigationWidget *treeViewWidget = new TestNavigationWidget;
|
TestNavigationWidget *treeViewWidget = new TestNavigationWidget;
|
||||||
return {treeViewWidget, treeViewWidget->createToolButtons()};
|
return {treeViewWidget, treeViewWidget->createToolButtons()};
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // Autotest::Internal
|
||||||
} // namespace Autotest
|
|
||||||
|
|||||||
@@ -3,78 +3,17 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "itemdatacache.h"
|
|
||||||
|
|
||||||
#include <coreplugin/inavigationwidgetfactory.h>
|
#include <coreplugin/inavigationwidgetfactory.h>
|
||||||
|
|
||||||
#include <utils/navigationtreeview.h>
|
namespace Autotest::Internal {
|
||||||
|
|
||||||
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<QToolButton *> 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<bool> m_expandedStateCache;
|
|
||||||
};
|
|
||||||
|
|
||||||
class TestNavigationWidgetFactory : public Core::INavigationWidgetFactory
|
class TestNavigationWidgetFactory : public Core::INavigationWidgetFactory
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TestNavigationWidgetFactory();
|
TestNavigationWidgetFactory();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Core::NavigationView createWidget() override;
|
Core::NavigationView createWidget() override;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // Autotest::Internal
|
||||||
} // namespace Autotest
|
|
||||||
|
|||||||
Reference in New Issue
Block a user