From 44958cad22c0ea57f08d51d777d74d65c2e24f27 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Fri, 11 Dec 2015 12:00:04 +0100 Subject: [PATCH] ModelEditor: Add JsExpander object for wizards Change-Id: I4350f667e813efa92a303fb89b637e9e914b7d4d Reviewed-by: Jochen Becher Reviewed-by: Tim Jenssen --- src/plugins/modeleditor/jsextension.cpp | 43 +++++++++++++++ src/plugins/modeleditor/jsextension.h | 53 +++++++++++++++++++ src/plugins/modeleditor/modeleditor.pro | 2 + src/plugins/modeleditor/modeleditor.qbs | 2 + .../modeleditor/modeleditor_plugin.cpp | 4 ++ 5 files changed, 104 insertions(+) create mode 100644 src/plugins/modeleditor/jsextension.cpp create mode 100644 src/plugins/modeleditor/jsextension.h diff --git a/src/plugins/modeleditor/jsextension.cpp b/src/plugins/modeleditor/jsextension.cpp new file mode 100644 index 00000000000..00652f9f99d --- /dev/null +++ b/src/plugins/modeleditor/jsextension.cpp @@ -0,0 +1,43 @@ +/*************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "jsextension.h" + +#include + +QString ModelEditor::Internal::JsExtension::fileNameToElementName(const QString &file) +{ + return qmt::NameController::convertFileNameToElementName(file); +} + +QString ModelEditor::Internal::JsExtension::elementNameToFileName(const QString &element) +{ + return qmt::NameController::convertElementNameToBaseFileName(element); +} diff --git a/src/plugins/modeleditor/jsextension.h b/src/plugins/modeleditor/jsextension.h new file mode 100644 index 00000000000..a374d824552 --- /dev/null +++ b/src/plugins/modeleditor/jsextension.h @@ -0,0 +1,53 @@ +/*************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef JSEXTENSION_H +#define JSEXTENSION_H + +#include + +namespace ModelEditor { +namespace Internal { + +class JsExtension : public QObject +{ + Q_OBJECT + +public: + JsExtension(QObject *parent = 0) : QObject(parent) { } + + Q_INVOKABLE QString fileNameToElementName(const QString &file); + Q_INVOKABLE QString elementNameToFileName(const QString &element); +}; + +} // namespace Internal +} // namespace ModelEditor + +#endif // JSEXTENSION_H diff --git a/src/plugins/modeleditor/modeleditor.pro b/src/plugins/modeleditor/modeleditor.pro index a58bf9bee9c..74f9a08ce8f 100644 --- a/src/plugins/modeleditor/modeleditor.pro +++ b/src/plugins/modeleditor/modeleditor.pro @@ -35,6 +35,7 @@ SOURCES += \ editordiagramview.cpp \ elementtasks.cpp \ extdocumentcontroller.cpp \ + jsextension.cpp \ modeldocument.cpp \ modeleditor.cpp \ modeleditorfactory.cpp \ @@ -57,6 +58,7 @@ HEADERS += \ editordiagramview.h \ elementtasks.h \ extdocumentcontroller.h \ + jsextension.h \ modeldocument.h \ modeleditor_constants.h \ modeleditorfactory.h \ diff --git a/src/plugins/modeleditor/modeleditor.qbs b/src/plugins/modeleditor/modeleditor.qbs index 47ba97441fe..4da4a5e4ec4 100644 --- a/src/plugins/modeleditor/modeleditor.qbs +++ b/src/plugins/modeleditor/modeleditor.qbs @@ -35,6 +35,8 @@ QtcPlugin { "elementtasks.h", "extdocumentcontroller.cpp", "extdocumentcontroller.h", + "jsextension.cpp", + "jsextension.h", "modeldocument.cpp", "modeldocument.h", "modeleditor_constants.h", diff --git a/src/plugins/modeleditor/modeleditor_plugin.cpp b/src/plugins/modeleditor/modeleditor_plugin.cpp index 65e5e7315e1..d676b29f4b4 100644 --- a/src/plugins/modeleditor/modeleditor_plugin.cpp +++ b/src/plugins/modeleditor/modeleditor_plugin.cpp @@ -36,6 +36,7 @@ #include "modeleditor_constants.h" #include "modeleditor_file_wizard.h" #include "uicontroller.h" +#include "jsextension.h" #include "qmt/infrastructure/uid.h" @@ -46,6 +47,7 @@ #include #include #include +#include #include @@ -111,6 +113,8 @@ bool ModelEditorPlugin::initialize(const QStringList &arguments, QString *errorS d->settingsController = new SettingsController(this); addAutoReleasedObject(d->settingsController); + Core::JsExpander::registerQObjectForJs(QLatin1String("Modeling"), new JsExtension(this)); + connect(d->settingsController, &SettingsController::saveSettings, d->uiController, &UiController::saveSettings); connect(d->settingsController, &SettingsController::loadSettings,