aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/scxmleditor
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2023-11-17 17:45:49 +0100
committerhjk <hjk@qt.io>2023-11-22 08:25:48 +0000
commit69b96ff7d2f19227970919d5af11c1483c420c7a (patch)
treeadf99e925ac6c00ee29f1ad0583d693b07f3089d /src/plugins/scxmleditor
parentdb301c1bceccc9931b00abc656e75be1b85d76ee (diff)
ScxmlEditor: Merge editor factory and data files
Currently scxmleditordata.cpp and scxmleditorfactory.h are used to keep the diff small, these will be renamed immediately. Change-Id: I4d4878b7eb2f52fb5f326bde33badd7e31305336 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Diffstat (limited to 'src/plugins/scxmleditor')
-rw-r--r--src/plugins/scxmleditor/CMakeLists.txt4
-rw-r--r--src/plugins/scxmleditor/scxmleditor.qbs4
-rw-r--r--src/plugins/scxmleditor/scxmleditordata.cpp79
-rw-r--r--src/plugins/scxmleditor/scxmleditordata.h50
-rw-r--r--src/plugins/scxmleditor/scxmleditorfactory.cpp58
5 files changed, 77 insertions, 118 deletions
diff --git a/src/plugins/scxmleditor/CMakeLists.txt b/src/plugins/scxmleditor/CMakeLists.txt
index 396a03820e3..4aa4fbad45b 100644
--- a/src/plugins/scxmleditor/CMakeLists.txt
+++ b/src/plugins/scxmleditor/CMakeLists.txt
@@ -86,9 +86,9 @@ add_qtc_plugin(ScxmlEditor
scxmleditor_global.h
scxmleditortr.h
scxmleditorconstants.h
- scxmleditordata.cpp scxmleditordata.h
+ scxmleditordata.cpp
scxmleditordocument.cpp scxmleditordocument.h
- scxmleditorfactory.cpp scxmleditorfactory.h
+ scxmleditorfactory.h
scxmleditorplugin.cpp
scxmleditorstack.cpp scxmleditorstack.h
scxmltexteditor.cpp scxmltexteditor.h
diff --git a/src/plugins/scxmleditor/scxmleditor.qbs b/src/plugins/scxmleditor/scxmleditor.qbs
index 3f8bbad3d03..ae8c69f0d5b 100644
--- a/src/plugins/scxmleditor/scxmleditor.qbs
+++ b/src/plugins/scxmleditor/scxmleditor.qbs
@@ -21,9 +21,9 @@ QtcPlugin {
files: [
"scxmleditor_global.h", "scxmleditortr.h",
"scxmleditorconstants.h",
- "scxmleditordata.cpp", "scxmleditordata.h",
+ "scxmleditordata.cpp",
"scxmleditordocument.cpp", "scxmleditordocument.h",
- "scxmleditorfactory.cpp", "scxmleditorfactory.h",
+ "scxmleditorfactory.h",
"scxmleditorplugin.cpp",
"scxmleditorstack.cpp", "scxmleditorstack.h",
"scxmltexteditor.cpp", "scxmltexteditor.h",
diff --git a/src/plugins/scxmleditor/scxmleditordata.cpp b/src/plugins/scxmleditor/scxmleditordata.cpp
index 6aa5b181d72..f28965ff28a 100644
--- a/src/plugins/scxmleditor/scxmleditordata.cpp
+++ b/src/plugins/scxmleditor/scxmleditordata.cpp
@@ -3,7 +3,6 @@
#include "mainwidget.h"
#include "scxmleditorconstants.h"
-#include "scxmleditordata.h"
#include "scxmleditordocument.h"
#include "scxmleditorstack.h"
#include "scxmleditortr.h"
@@ -11,8 +10,12 @@
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/coreconstants.h>
+#include <coreplugin/coreplugintr.h>
#include <coreplugin/designmode.h>
#include <coreplugin/editormanager/editormanager.h>
+#include <coreplugin/editormanager/ieditorfactory.h>
+#include <coreplugin/editortoolbar.h>
+#include <coreplugin/icontext.h>
#include <coreplugin/icore.h>
#include <coreplugin/idocument.h>
#include <coreplugin/minisplitter.h>
@@ -21,21 +24,24 @@
#include <projectexplorer/projectexplorerconstants.h>
+#include <utils/fsengine/fileiconprovider.h>
#include <utils/icon.h>
#include <utils/infobar.h>
#include <utils/mimeconstants.h>
#include <utils/qtcassert.h>
#include <utils/utilsicons.h>
+#include <QGuiApplication>
#include <QVBoxLayout>
+#include <QToolBar>
+#include <QUndoGroup>
+using namespace Core;
using namespace ScxmlEditor::Common;
using namespace ScxmlEditor::PluginInterface;
using namespace Utils;
-namespace ScxmlEditor {
-
-namespace Internal {
+namespace ScxmlEditor::Internal {
class ScxmlTextEditorWidget : public TextEditor::TextEditorWidget
{
@@ -67,6 +73,32 @@ public:
}
};
+class ScxmlEditorData : public QObject
+{
+public:
+ ScxmlEditorData();
+ ~ScxmlEditorData() override;
+
+ void fullInit();
+ IEditor *createEditor();
+
+private:
+ void updateToolBar();
+ QWidget *createModeWidget();
+ EditorToolBar *createMainToolBar();
+
+ Context m_contexts;
+ QWidget *m_modeWidget = nullptr;
+ ScxmlEditorStack *m_widgetStack = nullptr;
+ QToolBar *m_widgetToolBar = nullptr;
+ EditorToolBar *m_mainToolBar = nullptr;
+ QUndoGroup *m_undoGroup = nullptr;
+ QAction *m_undoAction = nullptr;
+ QAction *m_redoAction = nullptr;
+
+ ScxmlTextEditorFactory *m_xmlEditorFactory = nullptr;
+};
+
ScxmlEditorData::ScxmlEditorData()
{
m_contexts.add(ScxmlEditor::Constants::C_SCXMLEDITOR);
@@ -218,5 +250,40 @@ QWidget *ScxmlEditorData::createModeWidget()
return widget;
}
-} // namespace Internal
-} // namespace ScxmlEditor
+class ScxmlEditorFactory final : public QObject, public Core::IEditorFactory
+{
+public:
+ ScxmlEditorFactory(QObject *guard)
+ : QObject(guard)
+ {
+ setId(Constants::K_SCXML_EDITOR_ID);
+ setDisplayName(::Core::Tr::tr(Constants::C_SCXMLEDITOR_DISPLAY_NAME));
+ addMimeType(Utils::Constants::SCXML_MIMETYPE);
+
+ Utils::FileIconProvider::registerIconOverlayForSuffix(":/projectexplorer/images/fileoverlay_scxml.png", "scxml");
+
+ setEditorCreator([this] {
+ if (!m_editorData) {
+ m_editorData = new ScxmlEditorData;
+ QGuiApplication::setOverrideCursor(Qt::WaitCursor);
+ m_editorData->fullInit();
+ QGuiApplication::restoreOverrideCursor();
+ }
+ return m_editorData->createEditor();
+ });
+ }
+ ~ScxmlEditorFactory()
+ {
+ delete m_editorData;
+ }
+
+private:
+ ScxmlEditorData *m_editorData = nullptr;
+};
+
+void setupScxmlEditor(QObject *guard)
+{
+ (void) new ScxmlEditorFactory(guard);
+}
+
+} // ScxmlEditor::Internal
diff --git a/src/plugins/scxmleditor/scxmleditordata.h b/src/plugins/scxmleditor/scxmleditordata.h
deleted file mode 100644
index b7f1412361b..00000000000
--- a/src/plugins/scxmleditor/scxmleditordata.h
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-
-#pragma once
-
-#include <QToolBar>
-#include <QUndoGroup>
-
-#include <QCoreApplication>
-#include <coreplugin/editortoolbar.h>
-#include <coreplugin/icontext.h>
-
-using namespace Core;
-
-namespace ScxmlEditor {
-namespace Internal {
-
-class ScxmlTextEditorFactory;
-class ScxmlEditorWidget;
-class ScxmlEditorStack;
-
-class ScxmlEditorData : public QObject
-{
- Q_OBJECT
-public:
- ScxmlEditorData();
- ~ScxmlEditorData() override;
-
- void fullInit();
- IEditor *createEditor();
-
-private:
- void updateToolBar();
- QWidget *createModeWidget();
- EditorToolBar *createMainToolBar();
-
- Context m_contexts;
- QWidget *m_modeWidget = nullptr;
- ScxmlEditorStack *m_widgetStack = nullptr;
- QToolBar *m_widgetToolBar = nullptr;
- EditorToolBar *m_mainToolBar = nullptr;
- QUndoGroup *m_undoGroup = nullptr;
- QAction *m_undoAction = nullptr;
- QAction *m_redoAction = nullptr;
-
- ScxmlTextEditorFactory *m_xmlEditorFactory = nullptr;
-};
-
-} // namespace Internal
-} // namespace ScxmlEditor
diff --git a/src/plugins/scxmleditor/scxmleditorfactory.cpp b/src/plugins/scxmleditor/scxmleditorfactory.cpp
deleted file mode 100644
index 5a6f61c9773..00000000000
--- a/src/plugins/scxmleditor/scxmleditorfactory.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-
-#include "scxmleditorfactory.h"
-
-#include "scxmleditorconstants.h"
-#include "scxmleditordata.h"
-
-#include <coreplugin/coreplugintr.h>
-#include <coreplugin/editormanager/editormanager.h>
-#include <coreplugin/editormanager/ieditorfactory.h>
-
-#include <utils/fsengine/fileiconprovider.h>
-#include <utils/mimeconstants.h>
-
-#include <QGuiApplication>
-
-using namespace ScxmlEditor::Constants;
-
-namespace ScxmlEditor::Internal {
-
-class ScxmlEditorFactory final : public QObject, public Core::IEditorFactory
-{
-public:
- ScxmlEditorFactory(QObject *guard)
- : QObject(guard)
- {
- setId(K_SCXML_EDITOR_ID);
- setDisplayName(::Core::Tr::tr(C_SCXMLEDITOR_DISPLAY_NAME));
- addMimeType(Utils::Constants::SCXML_MIMETYPE);
-
- Utils::FileIconProvider::registerIconOverlayForSuffix(":/projectexplorer/images/fileoverlay_scxml.png", "scxml");
-
- setEditorCreator([this] {
- if (!m_editorData) {
- m_editorData = new ScxmlEditorData;
- QGuiApplication::setOverrideCursor(Qt::WaitCursor);
- m_editorData->fullInit();
- QGuiApplication::restoreOverrideCursor();
- }
- return m_editorData->createEditor();
- });
- }
- ~ScxmlEditorFactory()
- {
- delete m_editorData;
- }
-
-private:
- ScxmlEditorData *m_editorData = nullptr;
-};
-
-void setupScxmlEditor(QObject *guard)
-{
- (void) new ScxmlEditorFactory(guard);
-}
-
-} // ScxmlEditorFactory