forked from qt-creator/qt-creator
AutoTest: Remove scan filter capability
The scan filter capability had been added to avoid long scans in bigger projects. Nowadays the scans are done multi-threaded and the filtering is probably barely used. Change-Id: I7d99f5a57bb10deb3d79510db0c7a06bd771c271 Reviewed-by: André Hartmann <aha_1980@gmx.de> Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
This commit is contained in:
@@ -32,90 +32,12 @@
|
||||
#include "autotestplugin.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <utils/fancylineedit.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/utilsicons.h>
|
||||
|
||||
#include <QDialog>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QRegExp>
|
||||
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
|
||||
class TestFilterDialog : public QDialog
|
||||
{
|
||||
public:
|
||||
explicit TestFilterDialog(QWidget *parent = nullptr, Qt::WindowFlags f = nullptr);
|
||||
QString filterPath() const;
|
||||
void setDetailsText(const QString &details) { m_details->setText(details); }
|
||||
void setDefaultFilterPath(const QString &defaultPath);
|
||||
private:
|
||||
static bool validate(Utils::FancyLineEdit *edit, QString * /*errormessage*/);
|
||||
QLabel *m_details;
|
||||
Utils::FancyLineEdit *m_lineEdit;
|
||||
QString m_defaultPath;
|
||||
};
|
||||
|
||||
TestFilterDialog::TestFilterDialog(QWidget *parent, Qt::WindowFlags f)
|
||||
: QDialog(parent, f),
|
||||
m_details(new QLabel),
|
||||
m_lineEdit(new Utils::FancyLineEdit)
|
||||
{
|
||||
setModal(true);
|
||||
auto layout = new QVBoxLayout(this);
|
||||
layout->setSizeConstraint(QLayout::SetFixedSize);
|
||||
layout->addWidget(m_details);
|
||||
m_lineEdit->setValidationFunction(&validate);
|
||||
layout->addWidget(m_lineEdit);
|
||||
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
|
||||
auto okButton = buttonBox->button(QDialogButtonBox::Ok);
|
||||
auto cancelButton = buttonBox->button(QDialogButtonBox::Cancel);
|
||||
okButton->setEnabled(false);
|
||||
layout->addWidget(buttonBox);
|
||||
setLayout(layout);
|
||||
connect(m_lineEdit, &Utils::FancyLineEdit::validChanged, okButton, &QPushButton::setEnabled);
|
||||
connect(okButton, &QPushButton::clicked, this, &QDialog::accept);
|
||||
connect(cancelButton, &QPushButton::clicked, this, &QDialog::reject);
|
||||
}
|
||||
|
||||
QString TestFilterDialog::filterPath() const
|
||||
{
|
||||
static const QRegExp repetition("//+");
|
||||
QString path = m_lineEdit->isValid() ? m_lineEdit->text() : m_defaultPath;
|
||||
path.replace('\\', '/'); // turn windows separators into forward slashes
|
||||
path.replace(repetition, "/"); // avoid duplicated separators
|
||||
if (!path.startsWith('/'))
|
||||
path.prepend('/');
|
||||
if (!path.endsWith('/'))
|
||||
path.append('/');
|
||||
if (path.length() <= 2) // after surrounding with '/' this should be > 2 if valid
|
||||
return QString(); // empty string marks invalid filter
|
||||
return path;
|
||||
}
|
||||
|
||||
void TestFilterDialog::setDefaultFilterPath(const QString &defaultPath)
|
||||
{
|
||||
m_lineEdit->setText(defaultPath);
|
||||
if (m_lineEdit->isValid())
|
||||
m_defaultPath = defaultPath;
|
||||
else
|
||||
m_lineEdit->setText(m_defaultPath);
|
||||
}
|
||||
|
||||
bool TestFilterDialog::validate(Utils::FancyLineEdit *edit, QString *)
|
||||
{
|
||||
if (!edit)
|
||||
return false;
|
||||
const QString &value = edit->text();
|
||||
if (value.isEmpty())
|
||||
return false;
|
||||
// should we distinguish between Windows and UNIX?
|
||||
static const QRegExp valid("(\\|/)?([^?*:;\"\'|<>\t\b]+(\\|/)?)+");
|
||||
return valid.exactMatch(value);
|
||||
}
|
||||
/**************************************************************************************************/
|
||||
|
||||
TestSettingsWidget::TestSettingsWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
@@ -129,17 +51,6 @@ TestSettingsWidget::TestSettingsWidget(QWidget *parent)
|
||||
"having at least one active test framework."));
|
||||
connect(m_ui.frameworkTreeWidget, &QTreeWidget::itemChanged,
|
||||
this, &TestSettingsWidget::onFrameworkItemChanged);
|
||||
connect(m_ui.addFilter, &QPushButton::clicked, this, &TestSettingsWidget::onAddFilterClicked);
|
||||
connect(m_ui.editFilter, &QPushButton::clicked, this, &TestSettingsWidget::onEditFilterClicked);
|
||||
connect(m_ui.filterTreeWidget, &QTreeWidget::activated,
|
||||
this, &TestSettingsWidget::onEditFilterClicked);
|
||||
connect(m_ui.removeFilter, &QPushButton::clicked,
|
||||
this, &TestSettingsWidget::onRemoveFilterClicked);
|
||||
connect(m_ui.filterTreeWidget, &QTreeWidget::itemSelectionChanged, [this] () {
|
||||
const bool enable = m_ui.filterTreeWidget->selectionModel()->hasSelection();
|
||||
m_ui.editFilter->setEnabled(enable);
|
||||
m_ui.removeFilter->setEnabled(enable);
|
||||
});
|
||||
connect(m_ui.resetChoicesButton, &QPushButton::clicked,
|
||||
this, [] { AutotestPlugin::clearChoiceCache(); });
|
||||
}
|
||||
@@ -153,9 +64,7 @@ void TestSettingsWidget::setSettings(const TestSettings &settings)
|
||||
m_ui.autoScrollCB->setChecked(settings.autoScroll);
|
||||
m_ui.processArgsCB->setChecked(settings.processArgs);
|
||||
m_ui.displayAppCB->setChecked(settings.displayApplication);
|
||||
m_ui.filterGroupBox->setChecked(settings.filterScan);
|
||||
populateFrameworksListWidget(settings.frameworks);
|
||||
populateFiltersWidget(settings.whiteListFilters);
|
||||
}
|
||||
|
||||
TestSettings TestSettingsWidget::settings() const
|
||||
@@ -168,9 +77,7 @@ TestSettings TestSettingsWidget::settings() const
|
||||
result.autoScroll = m_ui.autoScrollCB->isChecked();
|
||||
result.processArgs = m_ui.processArgsCB->isChecked();
|
||||
result.displayApplication = m_ui.displayAppCB->isChecked();
|
||||
result.filterScan = m_ui.filterGroupBox->isChecked();
|
||||
frameworkSettings(result);
|
||||
result.whiteListFilters = filters();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -196,12 +103,6 @@ void TestSettingsWidget::populateFrameworksListWidget(const QHash<Core::Id, bool
|
||||
}
|
||||
}
|
||||
|
||||
void TestSettingsWidget::populateFiltersWidget(const QStringList &filters)
|
||||
{
|
||||
for (const QString &filter : filters)
|
||||
new QTreeWidgetItem(m_ui.filterTreeWidget, {filter} );
|
||||
}
|
||||
|
||||
void TestSettingsWidget::frameworkSettings(TestSettings &settings) const
|
||||
{
|
||||
const QAbstractItemModel *model = m_ui.frameworkTreeWidget->model();
|
||||
@@ -216,16 +117,6 @@ void TestSettingsWidget::frameworkSettings(TestSettings &settings) const
|
||||
}
|
||||
}
|
||||
|
||||
QStringList TestSettingsWidget::filters() const
|
||||
{
|
||||
QStringList result;
|
||||
if (QAbstractItemModel *model = m_ui.filterTreeWidget->model()) {
|
||||
for (int row = 0, count = model->rowCount(); row < count; ++row)
|
||||
result.append(model->index(row, 0).data().toString());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void TestSettingsWidget::onFrameworkItemChanged()
|
||||
{
|
||||
if (QAbstractItemModel *model = m_ui.frameworkTreeWidget->model()) {
|
||||
@@ -241,45 +132,6 @@ void TestSettingsWidget::onFrameworkItemChanged()
|
||||
m_ui.frameworksWarnIcon->setVisible(true);
|
||||
}
|
||||
|
||||
void TestSettingsWidget::onAddFilterClicked()
|
||||
{
|
||||
TestFilterDialog dialog;
|
||||
dialog.setWindowTitle(tr("Add Filter"));
|
||||
dialog.setDetailsText("<p>" + tr("Specify a filter expression to be added to the list of filters."
|
||||
"<br/>Wildcards are not supported.") + "</p>");
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
const QString &filter = dialog.filterPath();
|
||||
if (!filter.isEmpty())
|
||||
new QTreeWidgetItem(m_ui.filterTreeWidget, {filter} );
|
||||
}
|
||||
}
|
||||
|
||||
void TestSettingsWidget::onEditFilterClicked()
|
||||
{
|
||||
const QList<QTreeWidgetItem *> &selected = m_ui.filterTreeWidget->selectedItems();
|
||||
QTC_ASSERT(selected.size() == 1, return);
|
||||
const QString &oldFilter = selected.first()->data(0, Qt::DisplayRole).toString();
|
||||
|
||||
TestFilterDialog dialog;
|
||||
dialog.setWindowTitle(tr("Edit Filter"));
|
||||
dialog.setDetailsText("<p>" + tr("Specify a filter expression that will replace \"%1\"."
|
||||
"<br/>Wildcards are not supported.").arg(oldFilter) + "</p>");
|
||||
dialog.setDefaultFilterPath(oldFilter);
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
const QString &edited = dialog.filterPath();
|
||||
if (!edited.isEmpty() && edited != oldFilter)
|
||||
selected.first()->setData(0, Qt::DisplayRole, edited);
|
||||
}
|
||||
}
|
||||
|
||||
void TestSettingsWidget::onRemoveFilterClicked()
|
||||
{
|
||||
const QList<QTreeWidgetItem *> &selected = m_ui.filterTreeWidget->selectedItems();
|
||||
QTC_ASSERT(selected.size() == 1, return);
|
||||
m_ui.filterTreeWidget->removeItemWidget(selected.first(), 0);
|
||||
delete selected.first();
|
||||
}
|
||||
|
||||
TestSettingsPage::TestSettingsPage(const QSharedPointer<TestSettings> &settings)
|
||||
: m_settings(settings)
|
||||
{
|
||||
@@ -306,8 +158,6 @@ void TestSettingsPage::apply()
|
||||
return;
|
||||
const TestSettings newSettings = m_widget->settings();
|
||||
bool frameworkSyncNecessary = newSettings.frameworks != m_settings->frameworks;
|
||||
bool forceReparse = newSettings.filterScan != m_settings->filterScan ||
|
||||
newSettings.whiteListFilters.toSet() != m_settings->whiteListFilters.toSet();
|
||||
const QList<Core::Id> changedIds = Utils::filtered(newSettings.frameworksGrouping.keys(),
|
||||
[newSettings, this] (const Core::Id &id) {
|
||||
return newSettings.frameworksGrouping[id] != m_settings->frameworksGrouping[id];
|
||||
@@ -318,8 +168,6 @@ void TestSettingsPage::apply()
|
||||
frameworkManager->activateFrameworksFromSettings(m_settings);
|
||||
if (frameworkSyncNecessary)
|
||||
TestTreeModel::instance()->syncTestFrameworks();
|
||||
else if (forceReparse)
|
||||
TestTreeModel::instance()->parser()->emitUpdateTestTree();
|
||||
else if (!changedIds.isEmpty())
|
||||
TestTreeModel::instance()->rebuild(changedIds);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user