ModelEditor: Use namespace Core

Less noise

Change-Id: I3b1d42f1d269b7659be0a73ca5cec6bd5a835702
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Eike Ziller
2024-01-26 10:23:51 +01:00
parent 4900ce90e3
commit a0716261a8

View File

@@ -86,6 +86,7 @@
#include <algorithm> #include <algorithm>
using namespace Core;
using namespace Utils; using namespace Utils;
namespace ModelEditor { namespace ModelEditor {
@@ -101,7 +102,7 @@ public:
ActionHandler *actionHandler = nullptr; ActionHandler *actionHandler = nullptr;
ModelDocument *document = nullptr; ModelDocument *document = nullptr;
qmt::PropertiesView *propertiesView = nullptr; qmt::PropertiesView *propertiesView = nullptr;
Core::MiniSplitter *rightSplitter = nullptr; MiniSplitter *rightSplitter = nullptr;
QWidget *leftGroup = nullptr; QWidget *leftGroup = nullptr;
QHBoxLayout *leftGroupLayout = nullptr; QHBoxLayout *leftGroupLayout = nullptr;
QToolBox *leftToolBox = nullptr; QToolBox *leftToolBox = nullptr;
@@ -109,7 +110,7 @@ public:
EditorDiagramView *diagramView = nullptr; EditorDiagramView *diagramView = nullptr;
QLabel *noDiagramLabel = nullptr; QLabel *noDiagramLabel = nullptr;
DiagramsViewManager *diagramsViewManager = nullptr; DiagramsViewManager *diagramsViewManager = nullptr;
Core::MiniSplitter *rightHorizSplitter = nullptr; MiniSplitter *rightHorizSplitter = nullptr;
qmt::ModelTreeView *modelTreeView = nullptr; qmt::ModelTreeView *modelTreeView = nullptr;
qmt::TreeModelManager *modelTreeViewServant = nullptr; qmt::TreeModelManager *modelTreeViewServant = nullptr;
QScrollArea *propertiesScrollArea = nullptr; QScrollArea *propertiesScrollArea = nullptr;
@@ -126,7 +127,7 @@ public:
ModelEditor::ModelEditor(UiController *uiController, ActionHandler *actionHandler) ModelEditor::ModelEditor(UiController *uiController, ActionHandler *actionHandler)
: d(new ModelEditorPrivate) : d(new ModelEditorPrivate)
{ {
setContext(Core::Context(Constants::MODEL_EDITOR_ID)); setContext(Context(Constants::MODEL_EDITOR_ID));
d->uiController = uiController; d->uiController = uiController;
d->actionHandler = actionHandler; d->actionHandler = actionHandler;
d->document = new ModelDocument(this); d->document = new ModelDocument(this);
@@ -141,7 +142,7 @@ ModelEditor::~ModelEditor()
delete d; delete d;
} }
Core::IDocument *ModelEditor::document() const IDocument *ModelEditor::document() const
{ {
return d->document; return d->document;
} }
@@ -191,7 +192,7 @@ void ModelEditor::init()
d->propertiesView = new qmt::PropertiesView(this); d->propertiesView = new qmt::PropertiesView(this);
// create and configure editor ui // create and configure editor ui
d->rightSplitter = new Core::MiniSplitter; d->rightSplitter = new MiniSplitter;
connect(d->rightSplitter, &QSplitter::splitterMoved, connect(d->rightSplitter, &QSplitter::splitterMoved,
this, &ModelEditor::onRightSplitterMoved); this, &ModelEditor::onRightSplitterMoved);
connect(d->uiController, &UiController::rightSplitterChanged, connect(d->uiController, &UiController::rightSplitterChanged,
@@ -253,7 +254,7 @@ void ModelEditor::init()
d->leftGroupLayout->addWidget(frame, 0); d->leftGroupLayout->addWidget(frame, 0);
d->leftGroupLayout->addWidget(d->diagramStack, 1); d->leftGroupLayout->addWidget(d->diagramStack, 1);
d->rightHorizSplitter = new Core::MiniSplitter(d->rightSplitter); d->rightHorizSplitter = new MiniSplitter(d->rightSplitter);
d->rightHorizSplitter->setOrientation(Qt::Vertical); d->rightHorizSplitter->setOrientation(Qt::Vertical);
connect(d->rightHorizSplitter, &QSplitter::splitterMoved, connect(d->rightHorizSplitter, &QSplitter::splitterMoved,
this, &ModelEditor::onRightHorizSplitterMoved); this, &ModelEditor::onRightHorizSplitterMoved);
@@ -296,7 +297,7 @@ void ModelEditor::init()
toolbarLayout->setContentsMargins(0, 0, 0, 0); toolbarLayout->setContentsMargins(0, 0, 0, 0);
toolbarLayout->setSpacing(0); toolbarLayout->setSpacing(0);
auto openParentButton = new Core::CommandButton(Constants::OPEN_PARENT_DIAGRAM, d->toolbar); auto openParentButton = new CommandButton(Constants::OPEN_PARENT_DIAGRAM, d->toolbar);
openParentButton->setDefaultAction(d->actionHandler->openParentDiagramAction()); openParentButton->setDefaultAction(d->actionHandler->openParentDiagramAction());
toolbarLayout->addWidget(openParentButton); toolbarLayout->addWidget(openParentButton);
@@ -306,15 +307,12 @@ void ModelEditor::init()
toolbarLayout->addWidget(d->diagramSelector, 1); toolbarLayout->addWidget(d->diagramSelector, 1);
toolbarLayout->addStretch(1); toolbarLayout->addStretch(1);
toolbarLayout->addWidget(createToolbarCommandButton(Core::Constants::ZOOM_RESET, toolbarLayout->addWidget(createToolbarCommandButton(
[this] { resetZoom(); }, Core::Constants::ZOOM_RESET, [this] { resetZoom(); }, d->toolbar));
d->toolbar)); toolbarLayout->addWidget(createToolbarCommandButton(
toolbarLayout->addWidget(createToolbarCommandButton(Core::Constants::ZOOM_IN, Core::Constants::ZOOM_IN, [this] { zoomIn(); }, d->toolbar));
[this] { zoomIn(); }, toolbarLayout->addWidget(createToolbarCommandButton(
d->toolbar)); Core::Constants::ZOOM_OUT, [this] { zoomOut(); }, d->toolbar));
toolbarLayout->addWidget(createToolbarCommandButton(Core::Constants::ZOOM_OUT,
[this] { zoomOut(); },
d->toolbar));
toolbarLayout->addWidget(createToolbarCommandButton(Constants::ACTION_ADD_PACKAGE, toolbarLayout->addWidget(createToolbarCommandButton(Constants::ACTION_ADD_PACKAGE,
[this] { onAddPackage(); }, [this] { onAddPackage(); },
d->toolbar)); d->toolbar));
@@ -329,7 +327,7 @@ void ModelEditor::init()
d->toolbar)); d->toolbar));
toolbarLayout->addSpacing(20); toolbarLayout->addSpacing(20);
auto syncToggleButton = new Core::CommandButton(Constants::ACTION_SYNC_BROWSER, d->toolbar); auto syncToggleButton = new CommandButton(Constants::ACTION_SYNC_BROWSER, d->toolbar);
syncToggleButton->setDefaultAction(d->actionHandler->synchronizeBrowserAction()); syncToggleButton->setDefaultAction(d->actionHandler->synchronizeBrowserAction());
QMenu *syncMenu = new QMenu(syncToggleButton); QMenu *syncMenu = new QMenu(syncToggleButton);
QActionGroup *syncGroup = new QActionGroup(syncMenu); QActionGroup *syncGroup = new QActionGroup(syncMenu);
@@ -399,8 +397,11 @@ void ModelEditor::initDocument()
connect(documentController->diagramSceneController(), &qmt::DiagramSceneController::newElementCreated, connect(documentController->diagramSceneController(), &qmt::DiagramSceneController::newElementCreated,
this, &ModelEditor::onNewElementCreated, Qt::QueuedConnection); this, &ModelEditor::onNewElementCreated, Qt::QueuedConnection);
connect(Core::EditorManager::instance(), &Core::EditorManager::currentEditorChanged, connect(EditorManager::instance(),
this, &ModelEditor::onCurrentEditorChanged, Qt::QueuedConnection); &EditorManager::currentEditorChanged,
this,
&ModelEditor::onCurrentEditorChanged,
Qt::QueuedConnection);
connect(d->diagramView, &EditorDiagramView::zoomIn, connect(d->diagramView, &EditorDiagramView::zoomIn,
this, &ModelEditor::zoomInAtPos); this, &ModelEditor::zoomInAtPos);
@@ -602,11 +603,16 @@ void ModelEditor::exportToImage(bool selectedElements)
if (success) if (success)
d->lastExportDirPath = QFileInfo(fileName).canonicalPath(); d->lastExportDirPath = QFileInfo(fileName).canonicalPath();
else if (selectedElements) else if (selectedElements)
QMessageBox::critical(Core::ICore::dialogParent(), Tr::tr("Exporting Selected Elements Failed"), QMessageBox::critical(ICore::dialogParent(),
Tr::tr("Exporting the selected elements of the current diagram into file<br>\"%1\"<br>failed.").arg(fileName)); Tr::tr("Exporting Selected Elements Failed"),
Tr::tr("Exporting the selected elements of the current "
"diagram into file<br>\"%1\"<br>failed.")
.arg(fileName));
else else
QMessageBox::critical(Core::ICore::dialogParent(), Tr::tr("Exporting Diagram Failed"), QMessageBox::critical(ICore::dialogParent(),
Tr::tr("Exporting the diagram into file<br>\"%1\"<br>failed.").arg(fileName)); Tr::tr("Exporting Diagram Failed"),
Tr::tr("Exporting the diagram into file<br>\"%1\"<br>failed.")
.arg(fileName));
} }
} }
} }
@@ -827,12 +833,12 @@ QToolButton *ModelEditor::createToolbarCommandButton(const Utils::Id &id,
const std::function<void()> &slot, const std::function<void()> &slot,
QWidget *parent) QWidget *parent)
{ {
Core::Command *command = Core::ActionManager::command(id); Command *command = ActionManager::command(id);
QTC_CHECK(command); QTC_CHECK(command);
const QString text = command ? command->description() : QString(); const QString text = command ? command->description() : QString();
auto action = new QAction(text, this); auto action = new QAction(text, this);
action->setIcon(command ? command->action()->icon() : QIcon()); action->setIcon(command ? command->action()->icon() : QIcon());
auto button = Core::Command::toolButtonWithAppendedShortcut(action, command); auto button = Command::toolButtonWithAppendedShortcut(action, command);
button->setParent(parent); button->setParent(parent);
connect(button, &QToolButton::clicked, this, slot); connect(button, &QToolButton::clicked, this, slot);
return button; return button;
@@ -901,7 +907,7 @@ void ModelEditor::onAddCanvasDiagram()
QTimer::singleShot(0, this, [this] { onEditSelectedElement(); }); QTimer::singleShot(0, this, [this] { onEditSelectedElement(); });
} }
void ModelEditor::onCurrentEditorChanged(Core::IEditor *editor) void ModelEditor::onCurrentEditorChanged(IEditor *editor)
{ {
if (this == editor) { if (this == editor) {
QUndoStack *undoStack = d->document->documentController()->undoController()->undoStack(); QUndoStack *undoStack = d->document->documentController()->undoController()->undoStack();
@@ -914,13 +920,13 @@ void ModelEditor::onCurrentEditorChanged(Core::IEditor *editor)
void ModelEditor::onCanUndoChanged(bool canUndo) void ModelEditor::onCanUndoChanged(bool canUndo)
{ {
if (this == Core::EditorManager::currentEditor()) if (this == EditorManager::currentEditor())
d->actionHandler->undoAction()->setEnabled(canUndo); d->actionHandler->undoAction()->setEnabled(canUndo);
} }
void ModelEditor::onCanRedoChanged(bool canRedo) void ModelEditor::onCanRedoChanged(bool canRedo)
{ {
if (this == Core::EditorManager::currentEditor()) if (this == EditorManager::currentEditor())
d->actionHandler->redoAction()->setEnabled(canRedo); d->actionHandler->redoAction()->setEnabled(canRedo);
} }
@@ -975,7 +981,7 @@ void ModelEditor::onDiagramClipboardChanged(bool isEmpty)
{ {
Q_UNUSED(isEmpty) Q_UNUSED(isEmpty)
if (this == Core::EditorManager::currentEditor()) if (this == EditorManager::currentEditor())
updateSelectedArea(d->selectedArea); updateSelectedArea(d->selectedArea);
} }
@@ -1358,9 +1364,9 @@ void ModelEditor::storeToolbarIdInDiagram(qmt::MDiagram *diagram)
void ModelEditor::addToNavigationHistory(const qmt::MDiagram *diagram) void ModelEditor::addToNavigationHistory(const qmt::MDiagram *diagram)
{ {
if (Core::EditorManager::currentEditor() == this) { if (EditorManager::currentEditor() == this) {
Core::EditorManager::cutForwardNavigationHistory(); EditorManager::cutForwardNavigationHistory();
Core::EditorManager::addCurrentPositionToNavigationHistory(saveState(diagram)); EditorManager::addCurrentPositionToNavigationHistory(saveState(diagram));
} }
} }