diff --git a/src/plugins/clangtools/CMakeLists.txt b/src/plugins/clangtools/CMakeLists.txt index 0db257697b3..9527f9b2758 100644 --- a/src/plugins/clangtools/CMakeLists.txt +++ b/src/plugins/clangtools/CMakeLists.txt @@ -16,7 +16,7 @@ add_qtc_plugin(ClangTools SOURCES clangfileinfo.h clangfixitsrefactoringchanges.cpp clangfixitsrefactoringchanges.h - clangselectablefilesdialog.cpp clangselectablefilesdialog.h clangselectablefilesdialog.ui + clangselectablefilesdialog.cpp clangselectablefilesdialog.h clangtidyclazyrunner.cpp clangtidyclazyrunner.h clangtool.cpp clangtool.h clangtoolruncontrol.cpp clangtoolruncontrol.h diff --git a/src/plugins/clangtools/clangselectablefilesdialog.cpp b/src/plugins/clangtools/clangselectablefilesdialog.cpp index 1d2c680e921..9031fab870b 100644 --- a/src/plugins/clangtools/clangselectablefilesdialog.cpp +++ b/src/plugins/clangtools/clangselectablefilesdialog.cpp @@ -25,8 +25,6 @@ #include "clangselectablefilesdialog.h" -#include "ui_clangselectablefilesdialog.h" - #include #include #include @@ -34,8 +32,10 @@ #include #include +#include #include +#include #include #include #include @@ -268,56 +268,68 @@ SelectableFilesDialog::SelectableFilesDialog(Project *project, const FileInfoProviders &fileInfoProviders, int initialProviderIndex) : QDialog(nullptr) - , m_ui(new Ui::SelectableFilesDialog) , m_filesModel(new SelectableFilesModel) , m_fileInfoProviders(fileInfoProviders) , m_project(project) - , m_analyzeButton(new QPushButton(tr("Analyze"), this)) { - m_ui->setupUi(this); + setWindowTitle(tr("Files to Analyze")); + resize(700, 600); + + m_fileFilterComboBox = new QComboBox(this); + m_fileFilterComboBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); // Files View // Make find actions available in this dialog, e.g. Strg+F for the view. addAction(Core::ActionManager::command(Core::Constants::FIND_IN_DOCUMENT)->action()); addAction(Core::ActionManager::command(Core::Constants::FIND_NEXT)->action()); addAction(Core::ActionManager::command(Core::Constants::FIND_PREVIOUS)->action()); + m_fileView = new QTreeView; m_fileView->setHeaderHidden(true); m_fileView->setModel(m_filesModel.get()); - m_ui->verticalLayout->addWidget( - Core::ItemViewFind::createSearchableWrapper(m_fileView, Core::ItemViewFind::LightColored)); // Filter combo box for (const FileInfoProvider &provider : m_fileInfoProviders) { - m_ui->fileFilterComboBox->addItem(provider.displayName); + m_fileFilterComboBox->addItem(provider.displayName); // Disable item if it has no file infos - auto *model = qobject_cast(m_ui->fileFilterComboBox->model()); - QStandardItem *item = model->item(m_ui->fileFilterComboBox->count() - 1); + auto *model = qobject_cast(m_fileFilterComboBox->model()); + QStandardItem *item = model->item(m_fileFilterComboBox->count() - 1); item->setFlags(provider.fileInfos.empty() ? item->flags() & ~Qt::ItemIsEnabled : item->flags() | Qt::ItemIsEnabled); } + int providerIndex = initialProviderIndex; if (m_fileInfoProviders[providerIndex].fileInfos.empty()) providerIndex = 0; - m_ui->fileFilterComboBox->setCurrentIndex(providerIndex); + m_fileFilterComboBox->setCurrentIndex(providerIndex); + onFileFilterChanged(providerIndex); - connect(m_ui->fileFilterComboBox, - QOverload::of(&QComboBox::currentIndexChanged), - this, - &SelectableFilesDialog::onFileFilterChanged); + connect(m_fileFilterComboBox, &QComboBox::currentIndexChanged, + this, &SelectableFilesDialog::onFileFilterChanged); + + auto analyzeButton = new QPushButton(tr("Analyze"), this); + analyzeButton->setEnabled(m_filesModel->hasCheckedFiles()); // Buttons - m_buttons = new QDialogButtonBox; - m_buttons->setStandardButtons(QDialogButtonBox::Cancel); - m_buttons->addButton(m_analyzeButton, QDialogButtonBox::AcceptRole);\ - connect(m_buttons, &QDialogButtonBox::accepted, this, &QDialog::accept); - connect(m_buttons, &QDialogButtonBox::rejected, this, &QDialog::reject); - m_analyzeButton->setEnabled(m_filesModel->hasCheckedFiles()); - connect(m_filesModel.get(), &QAbstractItemModel::dataChanged, [this]() { - m_analyzeButton->setEnabled(m_filesModel->hasCheckedFiles()); + auto buttons = new QDialogButtonBox; + buttons->setStandardButtons(QDialogButtonBox::Cancel); + buttons->addButton(analyzeButton, QDialogButtonBox::AcceptRole); + + connect(m_filesModel.get(), &QAbstractItemModel::dataChanged, [this, analyzeButton] { + analyzeButton->setEnabled(m_filesModel->hasCheckedFiles()); }); - m_ui->verticalLayout->addWidget(m_buttons); + + connect(buttons, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(buttons, &QDialogButtonBox::rejected, this, &QDialog::reject); + + using namespace Layouting; + + Column { + m_fileFilterComboBox, + Core::ItemViewFind::createSearchableWrapper(m_fileView, Core::ItemViewFind::LightColored), + buttons + }.attachTo(this); } SelectableFilesDialog::~SelectableFilesDialog() = default; @@ -329,7 +341,7 @@ FileInfos SelectableFilesDialog::fileInfos() const int SelectableFilesDialog::currentProviderIndex() const { - return m_ui->fileFilterComboBox->currentIndex(); + return m_fileFilterComboBox->currentIndex(); } void SelectableFilesDialog::onFileFilterChanged(int index) @@ -360,7 +372,7 @@ void SelectableFilesDialog::accept() { FileInfoSelection selection; m_filesModel->minimalSelection(selection); - FileInfoProvider &provider = m_fileInfoProviders[m_ui->fileFilterComboBox->currentIndex()]; + FileInfoProvider &provider = m_fileInfoProviders[m_fileFilterComboBox->currentIndex()]; provider.onSelectionAccepted(selection); QDialog::accept(); diff --git a/src/plugins/clangtools/clangselectablefilesdialog.h b/src/plugins/clangtools/clangselectablefilesdialog.h index a7214086e8b..ad1e624964b 100644 --- a/src/plugins/clangtools/clangselectablefilesdialog.h +++ b/src/plugins/clangtools/clangselectablefilesdialog.h @@ -30,16 +30,12 @@ #include QT_BEGIN_NAMESPACE -class QDialogButtonBox; -class QPushButton; +class QComboBox; QT_END_NAMESPACE -namespace CppEditor { class ProjectInfo; } - namespace ClangTools { namespace Internal { -namespace Ui { class SelectableFilesDialog; } class SelectableFilesModel; class SelectableFilesDialog : public QDialog @@ -59,16 +55,14 @@ private: void onFileFilterChanged(int index); void accept() override; - std::unique_ptr m_ui; QTreeView *m_fileView = nullptr; - QDialogButtonBox *m_buttons = nullptr; std::unique_ptr m_filesModel; FileInfoProviders m_fileInfoProviders; int m_previousProviderIndex = -1; ProjectExplorer::Project *m_project; - QPushButton *m_analyzeButton = nullptr; + QComboBox *m_fileFilterComboBox; }; } // namespace Internal diff --git a/src/plugins/clangtools/clangselectablefilesdialog.ui b/src/plugins/clangtools/clangselectablefilesdialog.ui deleted file mode 100644 index f78460e84c2..00000000000 --- a/src/plugins/clangtools/clangselectablefilesdialog.ui +++ /dev/null @@ -1,31 +0,0 @@ - - - ClangTools::Internal::SelectableFilesDialog - - - - 0 - 0 - 700 - 600 - - - - Files to Analyze - - - - - - - 0 - 0 - - - - - - - - - diff --git a/src/plugins/clangtools/clangtools.qbs b/src/plugins/clangtools/clangtools.qbs index bf9161c6f04..9be1d720a18 100644 --- a/src/plugins/clangtools/clangtools.qbs +++ b/src/plugins/clangtools/clangtools.qbs @@ -28,7 +28,6 @@ QtcPlugin { "clangfixitsrefactoringchanges.h", "clangselectablefilesdialog.cpp", "clangselectablefilesdialog.h", - "clangselectablefilesdialog.ui", "clangtidyclazyrunner.cpp", "clangtidyclazyrunner.h", "clangtool.cpp",