From f625c2682c2bf186c56f9e8f0b92a4d24ac0da59 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Wed, 17 Apr 2024 11:54:30 +0200 Subject: ModelEditor: Inline modeltreefilter.ui Change-Id: I03925b708ac1741f6342023b455b0280a8bce584 Reviewed-by: Jochen Becher Reviewed-by: Reviewed-by: hjk --- src/libs/modelinglib/CMakeLists.txt | 1 - src/libs/modelinglib/modelinglib.qbs | 1 - .../qmt/model_widgets_ui/modeltreefilter.cpp | 131 +++++++-- .../qmt/model_widgets_ui/modeltreefilter.h | 5 - .../qmt/model_widgets_ui/modeltreefilter.ui | 312 --------------------- 5 files changed, 102 insertions(+), 348 deletions(-) delete mode 100644 src/libs/modelinglib/qmt/model_widgets_ui/modeltreefilter.ui (limited to 'src/libs/modelinglib') diff --git a/src/libs/modelinglib/CMakeLists.txt b/src/libs/modelinglib/CMakeLists.txt index 1189ed35b3e..65bd5e7140a 100644 --- a/src/libs/modelinglib/CMakeLists.txt +++ b/src/libs/modelinglib/CMakeLists.txt @@ -136,7 +136,6 @@ add_qtc_library(Modeling qmt/model_widgets_ui/addrelatedelementsdialog.ui qmt/model_widgets_ui/classmembersedit.cpp qmt/model_widgets_ui/classmembersedit.h qmt/model_widgets_ui/modeltreefilter.h qmt/model_widgets_ui/modeltreefilter.cpp - qmt/model_widgets_ui/modeltreefilter.ui qmt/model_widgets_ui/modeltreeview.cpp qmt/model_widgets_ui/modeltreeview.h qmt/model_widgets_ui/palettebox.cpp qmt/model_widgets_ui/palettebox.h qmt/model_widgets_ui/propertiesview.cpp qmt/model_widgets_ui/propertiesview.h diff --git a/src/libs/modelinglib/modelinglib.qbs b/src/libs/modelinglib/modelinglib.qbs index fd137e603db..250fd5cfc05 100644 --- a/src/libs/modelinglib/modelinglib.qbs +++ b/src/libs/modelinglib/modelinglib.qbs @@ -256,7 +256,6 @@ QtcLibrary { "model_widgets_ui/classmembersedit.h", "model_widgets_ui/modeltreefilter.cpp", "model_widgets_ui/modeltreefilter.h", - "model_widgets_ui/modeltreefilter.ui", "model_widgets_ui/modeltreeview.cpp", "model_widgets_ui/modeltreeview.h", "model_widgets_ui/palettebox.cpp", diff --git a/src/libs/modelinglib/qmt/model_widgets_ui/modeltreefilter.cpp b/src/libs/modelinglib/qmt/model_widgets_ui/modeltreefilter.cpp index 59a61df3c4e..3fa671283af 100644 --- a/src/libs/modelinglib/qmt/model_widgets_ui/modeltreefilter.cpp +++ b/src/libs/modelinglib/qmt/model_widgets_ui/modeltreefilter.cpp @@ -2,8 +2,17 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "modeltreefilter.h" -#include "ui_modeltreefilter.h" +#include "../../modelinglibtr.h" + +#include + +#include +#include +#include +#include +#include +#include #include namespace qmt { @@ -13,25 +22,90 @@ public: QStringListModel m_typeModel; QStringListModel m_stereotypesModel; QStringListModel m_directionModel; + + QPushButton *resetViewButton; + QCheckBox *relationsCheckBox; + QCheckBox *diagramElementsCheckBox; + QPushButton *clearFilterButton; + QComboBox *typeComboBox; + QComboBox *stereotypesComboBox; + QLineEdit *nameLineEdit; + QComboBox *directionComboBox; }; ModelTreeFilter::ModelTreeFilter(QWidget *parent) : QWidget(parent), - ui(new Ui::ModelTreeFilter), d(new Private) { - ui->setupUi(this); - connect(ui->resetViewButton, &QPushButton::clicked, this, &ModelTreeFilter::resetView); - connect(ui->relationsCheckBox, &QCheckBox::clicked, this, &ModelTreeFilter::onViewChanged); - connect(ui->diagramElementsCheckBox, &QCheckBox::clicked, this, &ModelTreeFilter::onViewChanged); - connect(ui->clearFilterButton, &QPushButton::clicked, this, &ModelTreeFilter::clearFilter); - connect(ui->typeComboBox, &QComboBox::currentIndexChanged, this, [this](int index) { - ui->directionComboBox->setDisabled(index != (int) ModelTreeFilterData::Type::Dependency); + d->resetViewButton = new QPushButton(Tr::tr("Reset")); + d->relationsCheckBox = new QCheckBox(Tr::tr("Relations")); + d->diagramElementsCheckBox = new QCheckBox(Tr::tr("Diagram Elements")); + d->diagramElementsCheckBox->setMaximumHeight(0); + d->clearFilterButton = new QPushButton(Tr::tr("Clear")); + d->typeComboBox = new QComboBox; + d->stereotypesComboBox = new QComboBox; + d->stereotypesComboBox->setEditable(true); + d->nameLineEdit = new QLineEdit; + d->directionComboBox = new QComboBox; + + const auto boldLabel = [] (const QString &title) -> QLabel * { + auto label = new QLabel(title); + QFont boldFont = label->font(); + boldFont.setWeight(QFont::Bold); + label->setFont(boldFont); + return label; + }; + + const auto line = [] () -> QFrame * { + auto line = new QFrame; + line->setFrameShadow(QFrame::Plain); + line->setFrameShape(QFrame::HLine); + return line; + }; + + const int margin = 9; + + using namespace Layouting; + Column { + Column { + Row { + boldLabel(Tr::tr("View")), st, d->resetViewButton + }, + d->relationsCheckBox, + d->diagramElementsCheckBox, + customMargin({margin, 0, margin, 0}), + }, + Space(10), + line(), + Column { + Row { + boldLabel(Tr::tr("Filter")), st, d->clearFilterButton + }, + Space(10), + Form { + Tr::tr("Type:"), d->typeComboBox, br, + Tr::tr("Stereotypes:"), d->stereotypesComboBox, br, + Tr::tr("Name:"), d->nameLineEdit, br, + Tr::tr("Direction:"), d->directionComboBox, br, + }, + customMargin({margin, 0, margin, 0}), + }, + st, + line(), + customMargin({0, margin, 0, 0}), + }.attachTo(this); + + connect(d->resetViewButton, &QPushButton::clicked, this, &ModelTreeFilter::resetView); + connect(d->relationsCheckBox, &QCheckBox::clicked, this, &ModelTreeFilter::onViewChanged); + connect(d->diagramElementsCheckBox, &QCheckBox::clicked, this, &ModelTreeFilter::onViewChanged); + connect(d->clearFilterButton, &QPushButton::clicked, this, &ModelTreeFilter::clearFilter); + connect(d->typeComboBox, &QComboBox::currentIndexChanged, this, [this](int index) { + d->directionComboBox->setDisabled(index != (int) ModelTreeFilterData::Type::Dependency); }); - connect(ui->typeComboBox, &QComboBox::currentIndexChanged, this, &ModelTreeFilter::onFilterChanged); - connect(ui->stereotypesComboBox, &QComboBox::currentTextChanged, this, &ModelTreeFilter::onFilterChanged); - connect(ui->nameLineEdit, &QLineEdit::textChanged, this, &ModelTreeFilter::onFilterChanged); - connect(ui->directionComboBox, &QComboBox::currentTextChanged, this, &ModelTreeFilter::onFilterChanged); + connect(d->typeComboBox, &QComboBox::currentIndexChanged, this, &ModelTreeFilter::onFilterChanged); + connect(d->stereotypesComboBox, &QComboBox::currentTextChanged, this, &ModelTreeFilter::onFilterChanged); + connect(d->nameLineEdit, &QLineEdit::textChanged, this, &ModelTreeFilter::onFilterChanged); + connect(d->directionComboBox, &QComboBox::currentTextChanged, this, &ModelTreeFilter::onFilterChanged); setupFilter(); resetView(); clearFilter(); @@ -40,7 +114,6 @@ ModelTreeFilter::ModelTreeFilter(QWidget *parent) : ModelTreeFilter::~ModelTreeFilter() { delete d; - delete ui; } void ModelTreeFilter::setupFilter() @@ -48,50 +121,50 @@ void ModelTreeFilter::setupFilter() QStringList types = {"Any", "Package", "Component", "Class", "Diagram", "Item", "Dependency", "Association", "Inheritance", "Connection"}; d->m_typeModel.setStringList(types); - ui->typeComboBox->setModel(&d->m_typeModel); + d->typeComboBox->setModel(&d->m_typeModel); QStringList stereotypes = { }; d->m_stereotypesModel.setStringList(stereotypes); - ui->stereotypesComboBox->setModel(&d->m_stereotypesModel); + d->stereotypesComboBox->setModel(&d->m_stereotypesModel); QStringList directions = {"Any", "Outgoing (->)", "Incoming (<-)", "Bidirectional (<->)"}; d->m_directionModel.setStringList(directions); - ui->directionComboBox->setModel(&d->m_directionModel); + d->directionComboBox->setModel(&d->m_directionModel); } void ModelTreeFilter::resetView() { - ui->relationsCheckBox->setChecked(true); - ui->diagramElementsCheckBox->setChecked(false); + d->relationsCheckBox->setChecked(true); + d->diagramElementsCheckBox->setChecked(false); onViewChanged(); } void ModelTreeFilter::clearFilter() { - ui->typeComboBox->setCurrentIndex(0); - ui->stereotypesComboBox->clearEditText(); - ui->nameLineEdit->clear(); - ui->directionComboBox->setCurrentIndex(0); + d->typeComboBox->setCurrentIndex(0); + d->stereotypesComboBox->clearEditText(); + d->nameLineEdit->clear(); + d->directionComboBox->setCurrentIndex(0); onFilterChanged(); } void ModelTreeFilter::onViewChanged() { ModelTreeViewData modelTreeViewData; - modelTreeViewData.setShowRelations(ui->relationsCheckBox->isChecked()); - modelTreeViewData.setShowDiagramElements(ui->diagramElementsCheckBox->isChecked()); + modelTreeViewData.setShowRelations(d->relationsCheckBox->isChecked()); + modelTreeViewData.setShowDiagramElements(d->diagramElementsCheckBox->isChecked()); emit viewDataChanged(modelTreeViewData); } void ModelTreeFilter::onFilterChanged() { ModelTreeFilterData modelTreeFilterData; - modelTreeFilterData.setType((ModelTreeFilterData::Type) ui->typeComboBox->currentIndex()); + modelTreeFilterData.setType((ModelTreeFilterData::Type) d->typeComboBox->currentIndex()); modelTreeFilterData.setCustomId(QString()); - modelTreeFilterData.setStereotypes(ui->stereotypesComboBox->currentText().split(',', Qt::SkipEmptyParts)); - modelTreeFilterData.setName(ui->nameLineEdit->text().trimmed()); + modelTreeFilterData.setStereotypes(d->stereotypesComboBox->currentText().split(',', Qt::SkipEmptyParts)); + modelTreeFilterData.setName(d->nameLineEdit->text().trimmed()); if (modelTreeFilterData.type() == ModelTreeFilterData::Type::Dependency) - modelTreeFilterData.setDirection((ModelTreeFilterData::Direction) ui->directionComboBox->currentIndex()); + modelTreeFilterData.setDirection((ModelTreeFilterData::Direction) d->directionComboBox->currentIndex()); else modelTreeFilterData.setDirection(ModelTreeFilterData::Direction::Any); emit filterDataChanged(modelTreeFilterData); diff --git a/src/libs/modelinglib/qmt/model_widgets_ui/modeltreefilter.h b/src/libs/modelinglib/qmt/model_widgets_ui/modeltreefilter.h index 323a75f17f2..1de7237c6ee 100644 --- a/src/libs/modelinglib/qmt/model_widgets_ui/modeltreefilter.h +++ b/src/libs/modelinglib/qmt/model_widgets_ui/modeltreefilter.h @@ -10,10 +10,6 @@ namespace qmt { -namespace Ui { -class ModelTreeFilter; -} - class QMT_EXPORT ModelTreeFilter : public QWidget { Q_OBJECT @@ -36,7 +32,6 @@ private: void onFilterChanged(); private: - Ui::ModelTreeFilter *ui = nullptr; Private *d = nullptr; }; diff --git a/src/libs/modelinglib/qmt/model_widgets_ui/modeltreefilter.ui b/src/libs/modelinglib/qmt/model_widgets_ui/modeltreefilter.ui deleted file mode 100644 index 15cdd4437b0..00000000000 --- a/src/libs/modelinglib/qmt/model_widgets_ui/modeltreefilter.ui +++ /dev/null @@ -1,312 +0,0 @@ - - - qmt::ModelTreeFilter - - - - 0 - 0 - 307 - 370 - - - - Form - - - - 6 - - - 0 - - - 9 - - - 0 - - - 0 - - - - - - 9 - - - 0 - - - 9 - - - 0 - - - - - - - - true - - - - View - - - - - - - Qt::Horizontal - - - - 0 - 0 - - - - - - - - - false - - - - Reset - - - - - - - - - - false - - - - Relations - - - - - - - - 16777215 - 0 - - - - - false - - - - Diagram Elements - - - - - - - - - - Qt::Vertical - - - - 0 - 10 - - - - - - - - false - - - QFrame::Plain - - - Qt::Horizontal - - - - - - - - 9 - - - 0 - - - 9 - - - 0 - - - - - - - - true - - - - Filter - - - - - - - Qt::Horizontal - - - - 0 - 0 - - - - - - - - - false - - - - Clear - - - - - - - - - Qt::Vertical - - - - 0 - 10 - - - - - - - - - - - false - - - - Type: - - - - - - - - false - - - - Stereotypes: - - - - - - - - - - true - - - - - - - Name: - - - - - - - - - - - false - - - - Direction: - - - - - - - - - - - - - - - Qt::Vertical - - - - 0 - 0 - - - - - - - - false - - - QFrame::Plain - - - Qt::Horizontal - - - - - - - - -- cgit v1.2.3