forked from qt-creator/qt-creator
AutoTest: Turn frameworks widget from list to tree
Preparation for adding more settings to the frameworks. We need more columns for this purpose, so use a tree instead of a list. Change-Id: I73a1bb09625957986e857e4926009118a7ccaa32 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -126,7 +126,7 @@ TestSettingsWidget::TestSettingsWidget(QWidget *parent)
|
|||||||
m_ui.frameworksWarn->setText(tr("No active test frameworks."));
|
m_ui.frameworksWarn->setText(tr("No active test frameworks."));
|
||||||
m_ui.frameworksWarn->setToolTip(tr("You will not be able to use the AutoTest plugin without "
|
m_ui.frameworksWarn->setToolTip(tr("You will not be able to use the AutoTest plugin without "
|
||||||
"having at least one active test framework."));
|
"having at least one active test framework."));
|
||||||
connect(m_ui.frameworkListWidget, &QListWidget::itemChanged,
|
connect(m_ui.frameworkTreeWidget, &QTreeWidget::itemChanged,
|
||||||
this, &TestSettingsWidget::onFrameworkItemChanged);
|
this, &TestSettingsWidget::onFrameworkItemChanged);
|
||||||
connect(m_ui.addFilter, &QPushButton::clicked, this, &TestSettingsWidget::onAddFilterClicked);
|
connect(m_ui.addFilter, &QPushButton::clicked, this, &TestSettingsWidget::onAddFilterClicked);
|
||||||
connect(m_ui.editFilter, &QPushButton::clicked, this, &TestSettingsWidget::onEditFilterClicked);
|
connect(m_ui.editFilter, &QPushButton::clicked, this, &TestSettingsWidget::onEditFilterClicked);
|
||||||
@@ -173,13 +173,13 @@ void TestSettingsWidget::populateFrameworksListWidget(const QHash<Core::Id, bool
|
|||||||
{
|
{
|
||||||
TestFrameworkManager *frameworkManager = TestFrameworkManager::instance();
|
TestFrameworkManager *frameworkManager = TestFrameworkManager::instance();
|
||||||
const QList<Core::Id> ®istered = frameworkManager->sortedRegisteredFrameworkIds();
|
const QList<Core::Id> ®istered = frameworkManager->sortedRegisteredFrameworkIds();
|
||||||
m_ui.frameworkListWidget->clear();
|
m_ui.frameworkTreeWidget->clear();
|
||||||
for (const Core::Id &id : registered) {
|
for (const Core::Id &id : registered) {
|
||||||
QListWidgetItem *item = new QListWidgetItem(frameworkManager->frameworkNameForId(id),
|
auto *item = new QTreeWidgetItem(m_ui.frameworkTreeWidget,
|
||||||
m_ui.frameworkListWidget);
|
QStringList(frameworkManager->frameworkNameForId(id)));
|
||||||
item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
|
item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
|
||||||
item->setCheckState(frameworks.value(id) ? Qt::Checked : Qt::Unchecked);
|
item->setCheckState(0, frameworks.value(id) ? Qt::Checked : Qt::Unchecked);
|
||||||
item->setData(Qt::UserRole, id.toSetting());
|
item->setData(0, Qt::UserRole, id.toSetting());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,13 +191,14 @@ void TestSettingsWidget::populateFiltersWidget(const QStringList &filters)
|
|||||||
|
|
||||||
QHash<Core::Id, bool> TestSettingsWidget::frameworks() const
|
QHash<Core::Id, bool> TestSettingsWidget::frameworks() const
|
||||||
{
|
{
|
||||||
const int itemCount = m_ui.frameworkListWidget->count();
|
|
||||||
QHash<Core::Id, bool> frameworks;
|
QHash<Core::Id, bool> frameworks;
|
||||||
|
const QAbstractItemModel *model = m_ui.frameworkTreeWidget->model();
|
||||||
|
QTC_ASSERT(model, return frameworks);
|
||||||
|
const int itemCount = model->rowCount();
|
||||||
for (int row = 0; row < itemCount; ++row) {
|
for (int row = 0; row < itemCount; ++row) {
|
||||||
if (QListWidgetItem *item = m_ui.frameworkListWidget->item(row)) {
|
const QModelIndex index = model->index(row, 0);
|
||||||
frameworks.insert(Core::Id::fromSetting(item->data(Qt::UserRole)),
|
frameworks.insert(Core::Id::fromSetting(index.data(Qt::UserRole)),
|
||||||
item->checkState() == Qt::Checked);
|
index.data(Qt::CheckStateRole) == Qt::Checked);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return frameworks;
|
return frameworks;
|
||||||
}
|
}
|
||||||
@@ -214,11 +215,13 @@ QStringList TestSettingsWidget::filters() const
|
|||||||
|
|
||||||
void TestSettingsWidget::onFrameworkItemChanged()
|
void TestSettingsWidget::onFrameworkItemChanged()
|
||||||
{
|
{
|
||||||
for (int row = 0, count = m_ui.frameworkListWidget->count(); row < count; ++row) {
|
if (QAbstractItemModel *model = m_ui.frameworkTreeWidget->model()) {
|
||||||
if (m_ui.frameworkListWidget->item(row)->checkState() == Qt::Checked) {
|
for (int row = 0, count = model->rowCount(); row < count; ++row) {
|
||||||
m_ui.frameworksWarn->setVisible(false);
|
if (model->index(row, 0).data(Qt::CheckStateRole) == Qt::Checked) {
|
||||||
m_ui.frameworksWarnIcon->setVisible(false);
|
m_ui.frameworksWarn->setVisible(false);
|
||||||
return;
|
m_ui.frameworksWarnIcon->setVisible(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_ui.frameworksWarn->setVisible(true);
|
m_ui.frameworksWarn->setVisible(true);
|
||||||
|
@@ -175,10 +175,21 @@ Warning: this is an experimental feature and might lead to failing to execute th
|
|||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QListWidget" name="frameworkListWidget">
|
<widget class="QTreeWidget" name="frameworkTreeWidget">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Selects the test frameworks to be handled by the AutoTest plugin.</string>
|
<string>Selects the test frameworks to be handled by the AutoTest plugin.</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="rootIsDecorated">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="headerHidden">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>Framework</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
Reference in New Issue
Block a user