forked from qt-creator/qt-creator
Display progress indicator on navigation view...
...if parsing takes longer. Change-Id: Ib311c031ae0af72b2f923d93578099687d9af91a Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
@@ -620,6 +620,8 @@ void TestCodeParser::scanForTests(const QStringList &fileList)
|
||||
Autotest::Constants::TASK_PARSE);
|
||||
connect(progress, &Core::FutureProgress::finished,
|
||||
this, &TestCodeParser::onFinished);
|
||||
|
||||
emit parsingStarted();
|
||||
}
|
||||
|
||||
void TestCodeParser::clearCache()
|
||||
|
||||
@@ -70,6 +70,7 @@ signals:
|
||||
void unnamedQuickTestsUpdated(const QString &filePath, const QString &mainFile,
|
||||
const QMap<QString, TestCodeLocationAndType> &functions);
|
||||
void unnamedQuickTestsRemoved(const QString &filePath);
|
||||
void parsingStarted();
|
||||
void parsingFinished();
|
||||
void partialParsingFinished();
|
||||
|
||||
|
||||
@@ -29,7 +29,9 @@
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <texteditor/texteditor.h>
|
||||
#include <utils/progressindicator.h>
|
||||
|
||||
#include <QTimer>
|
||||
#include <QToolButton>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
@@ -55,6 +57,21 @@ TestNavigationWidget::TestNavigationWidget(QWidget *parent) :
|
||||
setLayout(layout);
|
||||
|
||||
connect(m_view, &TestTreeView::activated, this, &TestNavigationWidget::onItemActivated);
|
||||
|
||||
m_progressIndicator = new Utils::ProgressIndicator(Utils::ProgressIndicator::Medium, this);
|
||||
m_progressIndicator->attachToWidget(m_view);
|
||||
m_progressIndicator->hide();
|
||||
|
||||
m_progressTimer = new QTimer(this);
|
||||
m_progressTimer->setSingleShot(true);
|
||||
m_progressTimer->setInterval(100); // don't display indicator if progress takes less than 100ms
|
||||
|
||||
connect(m_model->parser(), &TestCodeParser::parsingStarted,
|
||||
this, &TestNavigationWidget::onParsingStarted);
|
||||
connect(m_model->parser(), &TestCodeParser::parsingFinished,
|
||||
this, &TestNavigationWidget::onParsingFinished);
|
||||
connect(m_progressTimer, &QTimer::timeout,
|
||||
m_progressIndicator, &Utils::ProgresssIndicator::show);
|
||||
}
|
||||
|
||||
TestNavigationWidget::~TestNavigationWidget()
|
||||
@@ -178,6 +195,17 @@ void TestNavigationWidget::onFilterMenuTriggered(QAction *action)
|
||||
TestTreeSortFilterModel::toFilterMode(action->data().value<int>()));
|
||||
}
|
||||
|
||||
void TestNavigationWidget::onParsingStarted()
|
||||
{
|
||||
m_progressTimer->start();
|
||||
}
|
||||
|
||||
void TestNavigationWidget::onParsingFinished()
|
||||
{
|
||||
m_progressTimer->stop();
|
||||
m_progressIndicator->hide();
|
||||
}
|
||||
|
||||
void TestNavigationWidget::initializeFilterMenu()
|
||||
{
|
||||
QAction *action = new QAction(m_filterMenu);
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QAction;
|
||||
class QMenu;
|
||||
class QTimer;
|
||||
class QToolButton;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
@@ -33,6 +34,10 @@ namespace Core {
|
||||
class IContext;
|
||||
}
|
||||
|
||||
namespace Utils {
|
||||
class ProgressIndicator;
|
||||
}
|
||||
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
|
||||
@@ -60,6 +65,8 @@ private slots:
|
||||
void onRunSelectedTriggered();
|
||||
void onSortClicked();
|
||||
void onFilterMenuTriggered(QAction *action);
|
||||
void onParsingStarted();
|
||||
void onParsingFinished();
|
||||
|
||||
private:
|
||||
void initializeFilterMenu();
|
||||
@@ -71,7 +78,8 @@ private:
|
||||
QToolButton *m_filterButton;
|
||||
QMenu *m_filterMenu;
|
||||
bool m_sortAlphabetically;
|
||||
|
||||
Utils::ProgressIndicator *m_progressIndicator;
|
||||
QTimer *m_progressTimer;
|
||||
};
|
||||
|
||||
class TestNavigationWidgetFactory : public Core::INavigationWidgetFactory
|
||||
|
||||
Reference in New Issue
Block a user