forked from qt-creator/qt-creator
ClangTools: Inline filterdialog.ui
Change-Id: I6304ac50b34e43ab4b5c26b7dc2b7ab7f77618f7 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -39,7 +39,7 @@ add_qtc_plugin(ClangTools
|
|||||||
documentclangtoolrunner.cpp documentclangtoolrunner.h
|
documentclangtoolrunner.cpp documentclangtoolrunner.h
|
||||||
documentquickfixfactory.cpp documentquickfixfactory.h
|
documentquickfixfactory.cpp documentquickfixfactory.h
|
||||||
executableinfo.cpp executableinfo.h
|
executableinfo.cpp executableinfo.h
|
||||||
filterdialog.cpp filterdialog.h filterdialog.ui
|
filterdialog.cpp filterdialog.h
|
||||||
runsettingswidget.cpp runsettingswidget.h runsettingswidget.ui
|
runsettingswidget.cpp runsettingswidget.h runsettingswidget.ui
|
||||||
settingswidget.cpp settingswidget.h settingswidget.ui
|
settingswidget.cpp settingswidget.h settingswidget.ui
|
||||||
tidychecks.ui
|
tidychecks.ui
|
||||||
|
@@ -69,7 +69,6 @@ QtcPlugin {
|
|||||||
"executableinfo.h",
|
"executableinfo.h",
|
||||||
"filterdialog.cpp",
|
"filterdialog.cpp",
|
||||||
"filterdialog.h",
|
"filterdialog.h",
|
||||||
"filterdialog.ui",
|
|
||||||
"runsettingswidget.cpp",
|
"runsettingswidget.cpp",
|
||||||
"runsettingswidget.h",
|
"runsettingswidget.h",
|
||||||
"runsettingswidget.ui",
|
"runsettingswidget.ui",
|
||||||
|
@@ -2,15 +2,20 @@
|
|||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||||
|
|
||||||
#include "filterdialog.h"
|
#include "filterdialog.h"
|
||||||
#include "ui_filterdialog.h"
|
|
||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
|
#include <utils/layoutbuilder.h>
|
||||||
#include <utils/treemodel.h>
|
#include <utils/treemodel.h>
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QDialogButtonBox>
|
||||||
|
#include <QHeaderView>
|
||||||
#include <QItemSelectionModel>
|
#include <QItemSelectionModel>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QTreeView>
|
||||||
|
|
||||||
namespace ClangTools {
|
namespace ClangTools::Internal {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
enum Columns { CheckName, Count };
|
enum Columns { CheckName, Count };
|
||||||
|
|
||||||
@@ -59,61 +64,76 @@ public:
|
|||||||
|
|
||||||
FilterDialog::FilterDialog(const Checks &checks, QWidget *parent)
|
FilterDialog::FilterDialog(const Checks &checks, QWidget *parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
, m_ui(new Ui::FilterDialog)
|
|
||||||
{
|
{
|
||||||
m_ui->setupUi(this);
|
resize(400, 400);
|
||||||
|
setWindowTitle(tr("Filter Diagnostics"));
|
||||||
|
|
||||||
|
auto selectAll = new QPushButton(tr("Select All"));
|
||||||
|
auto selectWithFixits = new QPushButton(tr("Select All with Fixits"));
|
||||||
|
auto selectNone = new QPushButton(tr("Clear Selection"));
|
||||||
|
|
||||||
|
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
|
||||||
|
|
||||||
m_model = new FilterChecksModel(checks);
|
m_model = new FilterChecksModel(checks);
|
||||||
|
|
||||||
// View
|
m_view = new QTreeView(this);
|
||||||
m_ui->view->setModel(m_model);
|
m_view->setModel(m_model);
|
||||||
m_ui->view->header()->setStretchLastSection(false);
|
m_view->header()->setStretchLastSection(false);
|
||||||
m_ui->view->header()->setSectionResizeMode(Columns::CheckName, QHeaderView::Stretch);
|
m_view->header()->setSectionResizeMode(Columns::CheckName, QHeaderView::Stretch);
|
||||||
m_ui->view->header()->setSectionResizeMode(Columns::Count, QHeaderView::ResizeToContents);
|
m_view->header()->setSectionResizeMode(Columns::Count, QHeaderView::ResizeToContents);
|
||||||
m_ui->view->setSelectionMode(QAbstractItemView::MultiSelection);
|
m_view->setSelectionMode(QAbstractItemView::MultiSelection);
|
||||||
m_ui->view->setSelectionBehavior(QAbstractItemView::SelectRows);
|
m_view->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||||
m_ui->view->setIndentation(0);
|
m_view->setIndentation(0);
|
||||||
connect(m_ui->view->selectionModel(), &QItemSelectionModel::selectionChanged, this, [&](){
|
|
||||||
const bool hasSelection = !m_ui->view->selectionModel()->selectedRows().isEmpty();
|
using namespace Utils::Layouting;
|
||||||
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(hasSelection);
|
|
||||||
|
Column {
|
||||||
|
tr("Select the diagnostics to display."),
|
||||||
|
Row { selectAll, selectWithFixits, selectNone, st },
|
||||||
|
m_view,
|
||||||
|
buttonBox,
|
||||||
|
}.attachTo(this);
|
||||||
|
|
||||||
|
connect(m_view->selectionModel(), &QItemSelectionModel::selectionChanged, this, [&] {
|
||||||
|
const bool hasSelection = !m_view->selectionModel()->selectedRows().isEmpty();
|
||||||
|
buttonBox->button(QDialogButtonBox::Ok)->setEnabled(hasSelection);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||||
|
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||||
|
|
||||||
// Buttons
|
// Buttons
|
||||||
connect(m_ui->selectNone, &QPushButton::clicked, m_ui->view, &QTreeView::clearSelection);
|
connect(selectNone, &QPushButton::clicked, m_view, &QTreeView::clearSelection);
|
||||||
connect(m_ui->selectAll, &QPushButton::clicked, m_ui->view, &QTreeView::selectAll);
|
connect(selectAll, &QPushButton::clicked, m_view, &QTreeView::selectAll);
|
||||||
connect(m_ui->selectWithFixits, &QPushButton::clicked, m_ui->view, [this] {
|
connect(selectWithFixits, &QPushButton::clicked, m_view, [this] {
|
||||||
m_ui->view->clearSelection();
|
m_view->clearSelection();
|
||||||
m_model->forItemsAtLevel<1>([&](CheckItem *item) {
|
m_model->forItemsAtLevel<1>([&](CheckItem *item) {
|
||||||
if (item->check.hasFixit)
|
if (item->check.hasFixit)
|
||||||
m_ui->view->selectionModel()->select(item->index(), selectionFlags());
|
m_view->selectionModel()->select(item->index(), selectionFlags());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
m_ui->selectWithFixits->setEnabled(
|
selectWithFixits->setEnabled(
|
||||||
Utils::anyOf(checks, [](const Check &c) { return c.hasFixit; }));
|
Utils::anyOf(checks, [](const Check &c) { return c.hasFixit; }));
|
||||||
|
|
||||||
// Select checks that are not filtered out
|
// Select checks that are not filtered out
|
||||||
m_model->forItemsAtLevel<1>([this](CheckItem *item) {
|
m_model->forItemsAtLevel<1>([this](CheckItem *item) {
|
||||||
if (item->check.isShown)
|
if (item->check.isShown)
|
||||||
m_ui->view->selectionModel()->select(item->index(), selectionFlags());
|
m_view->selectionModel()->select(item->index(), selectionFlags());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
FilterDialog::~FilterDialog()
|
FilterDialog::~FilterDialog() = default;
|
||||||
{
|
|
||||||
delete m_ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
QSet<QString> FilterDialog::selectedChecks() const
|
QSet<QString> FilterDialog::selectedChecks() const
|
||||||
{
|
{
|
||||||
QSet<QString> checks;
|
QSet<QString> checks;
|
||||||
m_model->forItemsAtLevel<1>([&](CheckItem *item) {
|
m_model->forItemsAtLevel<1>([&](CheckItem *item) {
|
||||||
if (m_ui->view->selectionModel()->isSelected(item->index()))
|
if (m_view->selectionModel()->isSelected(item->index()))
|
||||||
checks << item->check.name;
|
checks << item->check.name;
|
||||||
});
|
});
|
||||||
return checks;
|
return checks;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // ClangTools::Internal
|
||||||
} // namespace ClangTools
|
|
||||||
|
|
||||||
#include "filterdialog.moc"
|
#include "filterdialog.moc"
|
||||||
|
@@ -5,14 +5,16 @@
|
|||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
namespace ClangTools {
|
QT_BEGIN_NAMESPACE
|
||||||
namespace Internal {
|
class QTreeView;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Ui { class FilterDialog; }
|
namespace ClangTools::Internal {
|
||||||
|
|
||||||
class FilterChecksModel;
|
class FilterChecksModel;
|
||||||
|
|
||||||
class Check {
|
class Check
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
QString name;
|
QString name;
|
||||||
QString displayName;
|
QString displayName;
|
||||||
@@ -33,9 +35,8 @@ public:
|
|||||||
QSet<QString> selectedChecks() const;
|
QSet<QString> selectedChecks() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::FilterDialog *m_ui;
|
|
||||||
FilterChecksModel *m_model;
|
FilterChecksModel *m_model;
|
||||||
|
QTreeView *m_view;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // ClangTools::Internal
|
||||||
} // namespace ClangTools
|
|
||||||
|
@@ -1,99 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>ClangTools::Internal::FilterDialog</class>
|
|
||||||
<widget class="QDialog" name="ClangTools::Internal::FilterDialog">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>400</width>
|
|
||||||
<height>400</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Filter Diagnostics</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="text">
|
|
||||||
<string>Select the diagnostics to display.</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="selectAll">
|
|
||||||
<property name="text">
|
|
||||||
<string>Select All</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="selectWithFixits">
|
|
||||||
<property name="text">
|
|
||||||
<string>Select All with Fixits</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="selectNone">
|
|
||||||
<property name="text">
|
|
||||||
<string>Clear Selection</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QTreeView" name="view"/>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="standardButtons">
|
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>accepted()</signal>
|
|
||||||
<receiver>ClangTools::Internal::FilterDialog</receiver>
|
|
||||||
<slot>accept()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>248</x>
|
|
||||||
<y>254</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>157</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>rejected()</signal>
|
|
||||||
<receiver>ClangTools::Internal::FilterDialog</receiver>
|
|
||||||
<slot>reject()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>316</x>
|
|
||||||
<y>260</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>286</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
|
Reference in New Issue
Block a user