forked from qt-creator/qt-creator
ModelEditor: Add JsExpander object for wizards
Change-Id: I4350f667e813efa92a303fb89b637e9e914b7d4d Reviewed-by: Jochen Becher <jochen_becher@gmx.de> Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com>
This commit is contained in:
43
src/plugins/modeleditor/jsextension.cpp
Normal file
43
src/plugins/modeleditor/jsextension.cpp
Normal file
@@ -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 <qmt/controller/namecontroller.h>
|
||||
|
||||
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);
|
||||
}
|
||||
53
src/plugins/modeleditor/jsextension.h
Normal file
53
src/plugins/modeleditor/jsextension.h
Normal file
@@ -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 <QObject>
|
||||
|
||||
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
|
||||
@@ -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 \
|
||||
|
||||
@@ -35,6 +35,8 @@ QtcPlugin {
|
||||
"elementtasks.h",
|
||||
"extdocumentcontroller.cpp",
|
||||
"extdocumentcontroller.h",
|
||||
"jsextension.cpp",
|
||||
"jsextension.h",
|
||||
"modeldocument.cpp",
|
||||
"modeldocument.h",
|
||||
"modeleditor_constants.h",
|
||||
|
||||
@@ -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 <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/icontext.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/jsexpander.h>
|
||||
|
||||
#include <utils/mimetypes/mimedatabase.h>
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user