From 15f83efa6a44056ccade602b0c42bcf0600141d1 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Tue, 16 Apr 2024 17:27:05 +0200 Subject: ModelEditor: Inline addrelatedelementsdialog.ui Change-Id: I53f9ec87030c4ac41ff34f61a54dd10a866b8c33 Reviewed-by: hjk Reviewed-by: Reviewed-by: Leena Miettinen Reviewed-by: Jochen Becher --- src/libs/modelinglib/CMakeLists.txt | 1 - src/libs/modelinglib/modelinglib.qbs | 1 - .../model_widgets_ui/addrelatedelementsdialog.cpp | 90 +++++++--- .../model_widgets_ui/addrelatedelementsdialog.h | 5 - .../model_widgets_ui/addrelatedelementsdialog.ui | 190 --------------------- 5 files changed, 69 insertions(+), 218 deletions(-) delete mode 100644 src/libs/modelinglib/qmt/model_widgets_ui/addrelatedelementsdialog.ui (limited to 'src/libs/modelinglib') diff --git a/src/libs/modelinglib/CMakeLists.txt b/src/libs/modelinglib/CMakeLists.txt index 65bd5e7140a..e966b39459a 100644 --- a/src/libs/modelinglib/CMakeLists.txt +++ b/src/libs/modelinglib/CMakeLists.txt @@ -133,7 +133,6 @@ add_qtc_library(Modeling qmt/model_ui/treemodel.cpp qmt/model_ui/treemodel.h qmt/model_ui/treemodelmanager.cpp qmt/model_ui/treemodelmanager.h qmt/model_widgets_ui/addrelatedelementsdialog.h qmt/model_widgets_ui/addrelatedelementsdialog.cpp - 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/modeltreeview.cpp qmt/model_widgets_ui/modeltreeview.h diff --git a/src/libs/modelinglib/modelinglib.qbs b/src/libs/modelinglib/modelinglib.qbs index 250fd5cfc05..9929bf33c03 100644 --- a/src/libs/modelinglib/modelinglib.qbs +++ b/src/libs/modelinglib/modelinglib.qbs @@ -251,7 +251,6 @@ QtcLibrary { "model_ui/treemodelmanager.h", "model_widgets_ui/addrelatedelementsdialog.h", "model_widgets_ui/addrelatedelementsdialog.cpp", - "model_widgets_ui/addrelatedelementsdialog.ui", "model_widgets_ui/classmembersedit.cpp", "model_widgets_ui/classmembersedit.h", "model_widgets_ui/modeltreefilter.cpp", diff --git a/src/libs/modelinglib/qmt/model_widgets_ui/addrelatedelementsdialog.cpp b/src/libs/modelinglib/qmt/model_widgets_ui/addrelatedelementsdialog.cpp index 35bfeda6c7d..40499e28398 100644 --- a/src/libs/modelinglib/qmt/model_widgets_ui/addrelatedelementsdialog.cpp +++ b/src/libs/modelinglib/qmt/model_widgets_ui/addrelatedelementsdialog.cpp @@ -2,7 +2,6 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "addrelatedelementsdialog.h" -#include "ui_addrelatedelementsdialog.h" #include #include @@ -15,8 +14,14 @@ #include #include -#include +#include "../../modelinglibtr.h" + +#include +#include +#include +#include +#include namespace qmt { @@ -270,26 +275,69 @@ public: QStringListModel m_elementTypeModel; QStringListModel m_elementStereotypesModel; Filter m_filter; + + QComboBox *RelationTypeCombobox; + QComboBox *DirectionCombobox; + QComboBox *StereotypesCombobox; + QComboBox *ElementStereotypesCombobox; + QComboBox *ElementTypeComboBox; + QLabel *NumberOfMatchingElementsValue; + QDialogButtonBox *buttonBox; }; AddRelatedElementsDialog::AddRelatedElementsDialog(QWidget *parent) : QDialog(parent), - ui(new Ui::AddRelatedElementsDialog), d(new Private) { - ui->setupUi(this); - connect(ui->RelationTypeCombobox, &QComboBox::currentIndexChanged, this, &AddRelatedElementsDialog::updateNumberOfElements); - connect(ui->DirectionCombobox, &QComboBox::currentIndexChanged, this, &AddRelatedElementsDialog::updateNumberOfElements); - connect(ui->StereotypesCombobox, &QComboBox::currentTextChanged, this, &AddRelatedElementsDialog::updateNumberOfElements); - connect(ui->ElementTypeComboBox, &QComboBox::currentIndexChanged, this, &AddRelatedElementsDialog::updateNumberOfElements); - connect(ui->ElementStereotypesCombobox, &QComboBox::currentTextChanged, this, &AddRelatedElementsDialog::updateNumberOfElements); + setMinimumWidth(500); + + d->RelationTypeCombobox = new QComboBox; + d->DirectionCombobox = new QComboBox; + d->StereotypesCombobox = new QComboBox; + d->StereotypesCombobox->setEditable(true); + d->ElementTypeComboBox = new QComboBox; + d->ElementStereotypesCombobox = new QComboBox; + d->ElementStereotypesCombobox->setEditable(true); + d->NumberOfMatchingElementsValue = new QLabel; + d->buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel|QDialogButtonBox::Ok); + + using namespace Layouting; + Column { + Group { + title(Tr::tr("Relation Attributes")), + Form { + Tr::tr("Type"), d->RelationTypeCombobox, br, + Tr::tr("Direction"), d->DirectionCombobox, br, + Tr::tr("Stereotypes"), d->StereotypesCombobox, br, + }, + }, + Group { + title(Tr::tr("Other Element Attributes")), + Form { + Tr::tr("Type"), d->ElementTypeComboBox, br, + Tr::tr("Stereotypes"), d->ElementStereotypesCombobox, br, + }, + }, + Row { + Tr::tr("Number of matching elements: "), d->NumberOfMatchingElementsValue, st, + }, + st, + d->buttonBox, + }.attachTo(this); + + connect(d->RelationTypeCombobox, &QComboBox::currentIndexChanged, this, &AddRelatedElementsDialog::updateNumberOfElements); + connect(d->DirectionCombobox, &QComboBox::currentIndexChanged, this, &AddRelatedElementsDialog::updateNumberOfElements); + connect(d->StereotypesCombobox, &QComboBox::currentTextChanged, this, &AddRelatedElementsDialog::updateNumberOfElements); + connect(d->ElementTypeComboBox, &QComboBox::currentIndexChanged, this, &AddRelatedElementsDialog::updateNumberOfElements); + connect(d->ElementStereotypesCombobox, &QComboBox::currentTextChanged, this, &AddRelatedElementsDialog::updateNumberOfElements); + connect(d->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(d->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); connect(this, &QDialog::accepted, this, &AddRelatedElementsDialog::onAccepted); } AddRelatedElementsDialog::~AddRelatedElementsDialog() { delete d; - delete ui; } void AddRelatedElementsDialog::setDiagramSceneController(qmt::DiagramSceneController *diagramSceneController) @@ -303,19 +351,19 @@ void AddRelatedElementsDialog::setElements(const qmt::DSelection &selection, qmt d->m_diagramUid = diagram->uid(); QStringList relationTypes = {"Any", "Dependency", "Association", "Inheritance"}; d->m_relationTypeModel.setStringList(relationTypes); - ui->RelationTypeCombobox->setModel(&d->m_relationTypeModel); + d->RelationTypeCombobox->setModel(&d->m_relationTypeModel); QStringList relationDirections = {"Any", "Outgoing (->)", "Incoming (<-)", "Bidirectional (<->)"}; d->m_relationDirectionModel.setStringList(relationDirections); - ui->DirectionCombobox->setModel(&d->m_relationDirectionModel); + d->DirectionCombobox->setModel(&d->m_relationDirectionModel); QStringList relationStereotypes = { }; d->m_relationStereotypesModel.setStringList(relationStereotypes); - ui->StereotypesCombobox->setModel(&d->m_relationStereotypesModel); + d->StereotypesCombobox->setModel(&d->m_relationStereotypesModel); QStringList elementTypes = {"Any", "Package", "Component", "Class", "Diagram", "Item"}; d->m_elementTypeModel.setStringList(elementTypes); - ui->ElementTypeComboBox->setModel(&d->m_elementTypeModel); + d->ElementTypeComboBox->setModel(&d->m_elementTypeModel); QStringList elementStereotypes = { }; d->m_elementStereotypesModel.setStringList(elementStereotypes); - ui->ElementStereotypesCombobox->setModel(&d->m_elementStereotypesModel); + d->ElementStereotypesCombobox->setModel(&d->m_elementStereotypesModel); updateNumberOfElements(); } @@ -335,11 +383,11 @@ void AddRelatedElementsDialog::onAccepted() void AddRelatedElementsDialog::updateFilter() { - d->m_filter.setRelationType((RelationType) ui->RelationTypeCombobox->currentIndex()); - d->m_filter.setRelationDirection((RelationDirection) ui->DirectionCombobox->currentIndex()); - d->m_filter.setRelationStereotypes(ui->StereotypesCombobox->currentText().split(',', Qt::SkipEmptyParts)); - d->m_filter.setElementType((ElementType) ui->ElementTypeComboBox->currentIndex()); - d->m_filter.setElementStereotypes(ui->ElementStereotypesCombobox->currentText().split(',', Qt::SkipEmptyParts)); + d->m_filter.setRelationType((RelationType) d->RelationTypeCombobox->currentIndex()); + d->m_filter.setRelationDirection((RelationDirection) d->DirectionCombobox->currentIndex()); + d->m_filter.setRelationStereotypes(d->StereotypesCombobox->currentText().split(',', Qt::SkipEmptyParts)); + d->m_filter.setElementType((ElementType) d->ElementTypeComboBox->currentIndex()); + d->m_filter.setElementStereotypes(d->ElementStereotypesCombobox->currentText().split(',', Qt::SkipEmptyParts)); } bool AddRelatedElementsDialog::filter(qmt::DObject *dobject, qmt::MObject *mobject, qmt::MRelation *relation) @@ -366,7 +414,7 @@ void AddRelatedElementsDialog::updateNumberOfElements() qmt::MDiagram *diagram = d->m_diagramSceneController->modelController()->findElement(d->m_diagramUid); if (diagram) { updateFilter(); - ui->NumberOfMatchingElementsValue->setText(QString::number(d->m_diagramSceneController->countRelatedElements( + d->NumberOfMatchingElementsValue->setText(QString::number(d->m_diagramSceneController->countRelatedElements( d->m_selection, diagram, [this](qmt::DObject *dobject, qmt::MObject *mobject, qmt::MRelation *relation) -> bool { diff --git a/src/libs/modelinglib/qmt/model_widgets_ui/addrelatedelementsdialog.h b/src/libs/modelinglib/qmt/model_widgets_ui/addrelatedelementsdialog.h index 1c7edb1d574..e0fefa1c6cc 100644 --- a/src/libs/modelinglib/qmt/model_widgets_ui/addrelatedelementsdialog.h +++ b/src/libs/modelinglib/qmt/model_widgets_ui/addrelatedelementsdialog.h @@ -17,10 +17,6 @@ class MRelation; class DiagramSceneController; } -namespace Ui { -class AddRelatedElementsDialog; -} - namespace qmt { class QMT_EXPORT AddRelatedElementsDialog : public QDialog @@ -41,7 +37,6 @@ private: bool filter(qmt::DObject *dobject, qmt::MObject *mobject, qmt::MRelation *relation); void updateNumberOfElements(); - Ui::AddRelatedElementsDialog *ui = nullptr; Private *d = nullptr; }; diff --git a/src/libs/modelinglib/qmt/model_widgets_ui/addrelatedelementsdialog.ui b/src/libs/modelinglib/qmt/model_widgets_ui/addrelatedelementsdialog.ui deleted file mode 100644 index 0dc2cf04ca4..00000000000 --- a/src/libs/modelinglib/qmt/model_widgets_ui/addrelatedelementsdialog.ui +++ /dev/null @@ -1,190 +0,0 @@ - - - AddRelatedElementsDialog - - - - 0 - 0 - - - - - 500 - 0 - - - - Dialog - - - - - - Relation Attributes - - - - - - - - Type - - - - - - - - - - Direction - - - - - - - - - - Stereotypes - - - - - - - true - - - - - - - - - - - - Other Element Attributes - - - - - - - - Type - - - - - - - Stereotypes - - - - - - - true - - - - - - - false - - - - - - - - - - - - - - Number of matching elements: - - - - - - - 0 - - - - - - - - - Qt::Vertical - - - QSizePolicy::MinimumExpanding - - - - 0 - 0 - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - buttonBox - accepted() - AddRelatedElementsDialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - AddRelatedElementsDialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - - -- cgit v1.2.3