From 2596e6acd2a520353c1c341ed036ba73a6a9da11 Mon Sep 17 00:00:00 2001 From: BogdanKl Date: Thu, 9 Oct 2014 15:03:56 +0400 Subject: [PATCH 01/19] changed transfer method of qml files from name to source --- plugins/editorsSdk/editorsCommon.pri | 2 +- qrgui/editorPluginInterface/elementImpl.h | 3 +- qrgui/mainwindow/mainWindow.cpp | 2 +- qrgui/mainwindow/startWidget/startWidget.cpp | 7 ++-- qrgui/mainwindow/startWidget/startWidget.h | 6 ++- .../details/interpreterElementImpl.cpp | 24 ++++++------ .../details/interpreterElementImpl.h | 10 ++++- qrgui/pluginManager/editorManager.cpp | 20 +++++++++- .../interpreterEditorManager.cpp | 39 +++++++++++++------ .../pluginManager/interpreterEditorManager.h | 8 +++- qrgui/umllib/nodeElement.cpp | 3 +- qrgui/umllib/qmlIconLoader.cpp | 39 ++++++++----------- qrgui/umllib/qmlIconLoader.h | 6 +-- qrxc/edgeType.cpp | 3 +- qrxc/nodeType.cpp | 2 +- qrxc/xmlCompiler.cpp | 1 + 16 files changed, 111 insertions(+), 64 deletions(-) diff --git a/plugins/editorsSdk/editorsCommon.pri b/plugins/editorsSdk/editorsCommon.pri index 8a9fca46ba..ed02553c6c 100644 --- a/plugins/editorsSdk/editorsCommon.pri +++ b/plugins/editorsSdk/editorsCommon.pri @@ -16,7 +16,7 @@ win32 { QRXC = $$ROOT/bin/qrxc } -LIBS += -L$$ROOT/bin -lqrkernel +LIBS += -L$$ROOT/bin -lqrkernel -lqrutils !macx { #QMAKE_LFLAGS += "-Wl,-O1,-rpath,$(PWD)/../../../bin/" diff --git a/qrgui/editorPluginInterface/elementImpl.h b/qrgui/editorPluginInterface/elementImpl.h index 9f7f054b23..c9f187c50d 100644 --- a/qrgui/editorPluginInterface/elementImpl.h +++ b/qrgui/editorPluginInterface/elementImpl.h @@ -8,6 +8,7 @@ #include #include +#include #include "editorPluginInterface/labelInterface.h" #include "editorPluginInterface/labelFactoryInterface.h" @@ -49,7 +50,7 @@ class ElementImpl { virtual void init(LabelFactoryInterface &factory , QList &titles) = 0; - virtual QUrl qmlUrl() const = 0; + virtual QString qmlString() const = 0; virtual void updateData(ElementRepoInterface *repo) const = 0; virtual bool isNode() const = 0; diff --git a/qrgui/mainwindow/mainWindow.cpp b/qrgui/mainwindow/mainWindow.cpp index 37150cfe6f..f9e1e82227 100644 --- a/qrgui/mainwindow/mainWindow.cpp +++ b/qrgui/mainwindow/mainWindow.cpp @@ -2282,7 +2282,7 @@ void MainWindow::setVersion(QString const &version) void MainWindow::openStartTab() { - mStartWidget = new StartWidget(this, mProjectManager); + mStartWidget = new StartWidget(this, mProjectManager, mQmlEngine); int const index = mUi->tabs->addTab(mStartWidget, tr("Getting Started")); mUi->tabs->setTabUnclosable(index); mStartWidget->setVisibleForInterpreterButton(mToolManager.customizer()->showInterpeterButton()); diff --git a/qrgui/mainwindow/startWidget/startWidget.cpp b/qrgui/mainwindow/startWidget/startWidget.cpp index 0148fa5352..c45f63a968 100644 --- a/qrgui/mainwindow/startWidget/startWidget.cpp +++ b/qrgui/mainwindow/startWidget/startWidget.cpp @@ -12,7 +12,7 @@ using namespace qReal; -StartWidget::StartWidget(MainWindow *mainWindow, ProjectManager *projectManager) +StartWidget::StartWidget(MainWindow *mainWindow, ProjectManager *projectManager, QDeclarativeEngine * const qmlEngine) : mMainWindow(mainWindow) , mProjectManager(projectManager) , mProjectListSize(5) // TODO: Why 5? @@ -20,6 +20,7 @@ StartWidget::StartWidget(MainWindow *mainWindow, ProjectManager *projectManager) , mOpenProjectButton(nullptr) , mOpenInterpreterButton(nullptr) , mCreateInterpreterButton(nullptr) + , mQmlEngine(qmlEngine) { setStyleSheet(BrandManager::styles()->startTabSubstrateBackgroundStyle()); QWidget * const mainWidget = createMainWidget(); @@ -273,7 +274,7 @@ void StartWidget::openInterpretedDiagram() ProxyEditorManager &editorManagerProxy = mMainWindow->editorManagerProxy(); if (!fileName.isEmpty() && mProjectManager->open(fileName)) { - editorManagerProxy.setProxyManager(new InterpreterEditorManager(fileName)); + editorManagerProxy.setProxyManager(new InterpreterEditorManager(fileName, mQmlEngine)); QStringList interpreterDiagramsList; foreach (Id const &editor, editorManagerProxy.editors()) { foreach (Id const &diagram, editorManagerProxy.diagrams(editor)) { @@ -304,7 +305,7 @@ void StartWidget::createInterpretedDiagram() { hide(); ProxyEditorManager &editorManagerProxy = mMainWindow->editorManagerProxy(); - editorManagerProxy.setProxyManager(new InterpreterEditorManager("")); + editorManagerProxy.setProxyManager(new InterpreterEditorManager("", mQmlEngine)); bool ok = false; QString name = QInputDialog::getText(this, tr("Enter the diagram name:"), tr("diagram name:") , QLineEdit::Normal, "", &ok); diff --git a/qrgui/mainwindow/startWidget/startWidget.h b/qrgui/mainwindow/startWidget/startWidget.h index 8fa688e3d3..0350ae45f4 100644 --- a/qrgui/mainwindow/startWidget/startWidget.h +++ b/qrgui/mainwindow/startWidget/startWidget.h @@ -6,6 +6,9 @@ #include "mainwindow/projectManager/projectManager.h" +class QDeclarativeItem; +class QDeclarativeEngine; + namespace qReal { class MainWindow; @@ -19,7 +22,7 @@ class StartWidget : public QWidget Q_OBJECT public: - StartWidget(MainWindow *mainWindow, ProjectManager *projectManager); + StartWidget(MainWindow *mainWindow, ProjectManager *projectManager, QDeclarativeEngine * const qmlEngine); /// Shows or hides interpreter buttons. Also this method can change layout of the /// buttons on start tab. @@ -56,6 +59,7 @@ private slots: QPushButton *mOpenProjectButton; // Has ownership. QPushButton *mOpenInterpreterButton; // Has ownership. QPushButton *mCreateInterpreterButton; // Has ownership. + QDeclarativeEngine *mQmlEngine; }; } diff --git a/qrgui/pluginManager/details/interpreterElementImpl.cpp b/qrgui/pluginManager/details/interpreterElementImpl.cpp index ba67265a01..9a741d7420 100644 --- a/qrgui/pluginManager/details/interpreterElementImpl.cpp +++ b/qrgui/pluginManager/details/interpreterElementImpl.cpp @@ -1,15 +1,19 @@ #include "interpreterElementImpl.h" +#include +#include + #include #include +#include #include "pluginManager/details/interpreterPortImpl.h" using namespace qReal; using namespace utils; -InterpreterElementImpl::InterpreterElementImpl(qrRepo::RepoApi *repo, Id const &metaId) - : mEditorRepoApi(repo), mId(metaId) +InterpreterElementImpl::InterpreterElementImpl(qrRepo::RepoApi *repo, Id const &metaId, QDeclarativeEngine * const qmlEngine) + : mEditorRepoApi(repo), mId(metaId), mQmlEngine(qmlEngine) { } @@ -186,10 +190,10 @@ void InterpreterElementImpl::init(LabelFactoryInterface &labelFactory, QList InterpreterElementImpl::border() const void InterpreterElementImpl::updateRendererContent(QString const &shape) { - QDomDocument classDoc; - mGraphics.setContent(shape); - QDomElement qmlElement = mGraphics.firstChildElement("graphics").firstChildElement("picture"); - classDoc.appendChild(classDoc.importNode(qmlElement, true)); - if (!classDoc.childNodes().isEmpty()) { -// mRenderer->load(classDoc); - } + QDeclarativeComponent component(mQmlEngine); + component.setData(shape.toLocal8Bit(),QUrl()); + mQmlItem = qobject_cast(component.create()); +// qobject_cast(mQmlItem)->setParentItem(this); +// mQmlItem->setFlag(QGraphicsItem::ItemStacksBehindParent); } QStringList InterpreterElementImpl::bonusContextMenuFields() const diff --git a/qrgui/pluginManager/details/interpreterElementImpl.h b/qrgui/pluginManager/details/interpreterElementImpl.h index 6a1fa7ac86..18c92c2218 100644 --- a/qrgui/pluginManager/details/interpreterElementImpl.h +++ b/qrgui/pluginManager/details/interpreterElementImpl.h @@ -2,12 +2,16 @@ #include #include +#include #include #include #include #include #include +#include +#include + #include #include @@ -45,12 +49,12 @@ struct NodeLabel { class InterpreterElementImpl : public ElementImpl { public: - InterpreterElementImpl(qrRepo::RepoApi *repo, Id const &metaId); + InterpreterElementImpl(qrRepo::RepoApi *repo, Id const &metaId, QDeclarativeEngine * const qmlEngine); void init(QRectF &contents, PortFactoryInterface const &portFactory, QList &ports , LabelFactoryInterface &labelFactory, QList &labels) override; void init(LabelFactoryInterface &labelFactory, QList &labels) override; - QUrl qmlUrl() const override; + QString qmlString() const override; void updateData(ElementRepoInterface *repo) const override; bool isNode() const override; @@ -103,6 +107,8 @@ class InterpreterElementImpl : public ElementImpl qrRepo::RepoApi *mEditorRepoApi; // Doesn't have ownership. Id mId; + QDeclarativeEngine *mQmlEngine; + QDeclarativeItem *mQmlItem; QDomDocument mGraphics; QList mNodeLabels; QList mEdgeLabels; diff --git a/qrgui/pluginManager/editorManager.cpp b/qrgui/pluginManager/editorManager.cpp index 505c0f3102..fd905e4e0d 100644 --- a/qrgui/pluginManager/editorManager.cpp +++ b/qrgui/pluginManager/editorManager.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include "umllib/nodeElement.h" #include "umllib/edgeElement.h" @@ -252,14 +253,29 @@ QString EditorManager::mouseGesture(const Id &id) const QIcon EditorManager::icon(Id const &id) const { + if (QFile(":/generated/shapes/" + id.element() + "Class.qml").exists()) + { Q_ASSERT(mPluginsLoaded.contains(id.editor())); - return QmlIconLoader::iconOf("qrc:/generated/shapes/" + id.element() + "Class.qml"); + return utils::InFile::readAll(":/generated/shapes/" + id.element() + "Class.qml") != "" + ? QmlIconLoader::iconOf(utils::InFile::readAll(":/generated/shapes/" + id.element() + "Class.qml")) + : QIcon(":/icons/default.svg"); + } else { + return QIcon(":/icons/default.svg"); + } + } QSize EditorManager::iconSize(Id const &id) const { + if (QFile(":/generated/shapes/" + id.element() + "Class.qml").exists()) + { Q_ASSERT(mPluginsLoaded.contains(id.editor())); - return QmlIconLoader::preferedSizeOf("qrc:/generated/shapes/" + id.element() + "Class.qml"); + return utils::InFile::readAll(":/generated/shapes/" + id.element() + "Class.qml") != "" + ? QmlIconLoader::preferedSizeOf(utils::InFile::readAll(":/generated/shapes/" + id.element() + "Class.qml")) + : QSize(50, 50); + } else { + return QSize(50, 50); + } } ElementImpl *EditorManager::elementImpl(const Id &id) const diff --git a/qrgui/pluginManager/interpreterEditorManager.cpp b/qrgui/pluginManager/interpreterEditorManager.cpp index 7739fda65b..979dfdd459 100644 --- a/qrgui/pluginManager/interpreterEditorManager.cpp +++ b/qrgui/pluginManager/interpreterEditorManager.cpp @@ -12,15 +12,17 @@ #include "pluginManager/interpreterEditorManager.h" #include "umllib/nodeElement.h" #include "umllib/edgeElement.h" +#include "umllib/qmlIconLoader.h" #include "pluginManager/details/interpreterElementImpl.h" #include "mainwindow/mainWindow.h" using namespace qReal; using namespace utils; -InterpreterEditorManager::InterpreterEditorManager(QString const &fileName, QObject *parent) +InterpreterEditorManager::InterpreterEditorManager(QString const &fileName, QDeclarativeEngine * const qmlEngine, QObject *parent) : QObject(parent) , mMetamodelFile(fileName) + , mQmlEngine(qmlEngine) { qrRepo::RepoApi * const repo = new qrRepo::RepoApi(fileName); mEditorRepoApi.insert("test", repo); @@ -417,10 +419,23 @@ QIcon InterpreterEditorManager::icon(Id const &id) const QPair const repoAndMetaIdPair = repoAndMetaId(id); qrRepo::RepoApi const * const repo = repoAndMetaIdPair.first; Id const metaId = repoAndMetaIdPair.second; - QDomDocument classDoc; - QDomElement sdfElement; + QString const source; + //QDomDocument classDoc; + //QDomElement sdfElement; + if (metaId.element() == "MetaEntityEdge") { - sdfElement = classDoc.createElement("picture"); + source.arg("import QtQuick 1.1 \n") + .arg("import CustomComponents 1.0 \n") + .arg("Rectangle { \n") + .arg("\t width : 100; height : 60 \n") + .arg("\t Line{ \n") + .arg("\t\t x1 : 0; y1 : 0 \n") + .arg("\t\t x2 : 100; y2:60 \n") + .arg("\t\t width : 2 \n") + .arg("\t\t style:\"solid""\"\n") + .arg("\t} \n") + .arg("}\n"); + /*sdfElement = classDoc.createElement("picture"); sdfElement.setAttribute("sizex", 100); sdfElement.setAttribute("sizey", 60); QDomElement lineElement = classDoc.createElement("line"); @@ -434,27 +449,27 @@ QIcon InterpreterEditorManager::icon(Id const &id) const lineElement.setAttribute("stroke-width", 2); lineElement.setAttribute("x2", 100); lineElement.setAttribute("fill-style", "solid"); - sdfElement.appendChild(lineElement); + sdfElement.appendChild(lineElement);*/ } else { - QDomDocument graphics; - graphics.setContent(repo->stringProperty(metaId, "shape")); - sdfElement = graphics.firstChildElement("graphics").firstChildElement("picture"); + // содержимое кода на qml + source.arg(repo->stringProperty(metaId, "shape")); } - if (sdfElement.isNull()) { + if (source.compare("")) { return QIcon(); } - classDoc.appendChild(classDoc.importNode(sdfElement, true)); +// classDoc.appendChild(classDoc.importNode(sdfElement, true)); // SdfIconEngineV2 * const engine = new SdfIconEngineV2(classDoc); // return QIcon(engine); - return QIcon(); + return QmlIconLoader::iconOf(source); + //return QIcon(); } ElementImpl *InterpreterEditorManager::elementImpl(Id const &id) const { QPair const repoAndMetaIdPair = repoAndMetaId(id); - InterpreterElementImpl * const impl = new InterpreterElementImpl(repoAndMetaIdPair.first, repoAndMetaIdPair.second); + InterpreterElementImpl * const impl = new InterpreterElementImpl(repoAndMetaIdPair.first, repoAndMetaIdPair.second, mQmlEngine); if (!impl) { return 0; } diff --git a/qrgui/pluginManager/interpreterEditorManager.h b/qrgui/pluginManager/interpreterEditorManager.h index 10ecf70451..304f9cd07b 100644 --- a/qrgui/pluginManager/interpreterEditorManager.h +++ b/qrgui/pluginManager/interpreterEditorManager.h @@ -8,6 +8,7 @@ #include #include + #include #include #include @@ -18,6 +19,9 @@ #include "editorPluginInterface/editorInterface.h" #include "pluginManager/editorManagerInterface.h" +class QDeclarativeEngine; +class QDeclarativeItem; + namespace qReal { class Element; @@ -27,7 +31,7 @@ class InterpreterEditorManager : public QObject, public EditorManagerInterface Q_OBJECT public: - explicit InterpreterEditorManager(QString const &fileName, QObject *parent = NULL); + explicit InterpreterEditorManager(QString const &fileName, QDeclarativeEngine * const qmlEngine, QObject *parent = NULL); ~InterpreterEditorManager(); IdList editors() const override; @@ -160,6 +164,8 @@ class InterpreterEditorManager : public QObject, public EditorManagerInterface , CheckPropertyForParent const &checker) const; QString valueOfProperty(Id const &id, QString const &propertyName, QString const &value) const; void deletePropertyInElement(qrRepo::RepoApi *repo, Id const &diagram, QString const &propDisplayedName) const; + + QDeclarativeEngine *mQmlEngine; }; } diff --git a/qrgui/umllib/nodeElement.cpp b/qrgui/umllib/nodeElement.cpp index a3a26ec7a7..8e9636356f 100644 --- a/qrgui/umllib/nodeElement.cpp +++ b/qrgui/umllib/nodeElement.cpp @@ -122,7 +122,8 @@ NodeElement::~NodeElement() void NodeElement::initQml() { - QDeclarativeComponent component(mQmlEngine, mElementImpl->qmlUrl()); + QDeclarativeComponent component(mQmlEngine); + component.setData(mElementImpl->qmlString().toLocal8Bit(),QUrl()); if (component.isReady()) { mQmlItem = qobject_cast(component.create()); } else { diff --git a/qrgui/umllib/qmlIconLoader.cpp b/qrgui/umllib/qmlIconLoader.cpp index b1f973ca74..88e495d61c 100644 --- a/qrgui/umllib/qmlIconLoader.cpp +++ b/qrgui/umllib/qmlIconLoader.cpp @@ -21,15 +21,15 @@ void QmlIconLoader::setQmlEngine(QDeclarativeEngine * const engine) instance()->mQmlEngine = engine; } -QIcon QmlIconLoader::iconOf(QString const &fileName) +QIcon QmlIconLoader::iconOf(QString const &qmlString) { - return loadPixmap(fileName); + return loadPixmap(qmlString); } -QSize QmlIconLoader::preferedSizeOf(QString const &fileName) +QSize QmlIconLoader::preferedSizeOf(QString const &qmlString) { - loadPixmap(fileName); - return instance()->mPreferedSizes[fileName]; + loadPixmap(qmlString); + return instance()->mPreferedSizes[qmlString]; } QmlIconLoader *QmlIconLoader::instance() @@ -38,23 +38,16 @@ QmlIconLoader *QmlIconLoader::instance() return &instance; } -QIcon QmlIconLoader::loadPixmap(QString const &fileName) +QIcon QmlIconLoader::loadPixmap(QString const &qmlString) { - if (!instance()->mLoadedIcons.contains(fileName)) { - QDeclarativeComponent component(instance()->mQmlEngine, QUrl(fileName)); - if (component.isReady()) { - QDeclarativeItem * const item = qobject_cast(component.create()); - QIcon const icon = graphicsUtils::ItemRenderer::renderRecursively(item - , item->width(), item->height(), QColor(Qt::white)); - - instance()->mLoadedIcons[fileName] = icon; - instance()->mPreferedSizes[fileName] = QSize(item->width(), item->height()); - } else { - QIcon const icon(":/icons/default.svg"); - instance()->mLoadedIcons[fileName] = icon; - instance()->mPreferedSizes[fileName] = QSize(50, 50); - } - } - - return instance()->mLoadedIcons[fileName]; + QDeclarativeComponent component(instance()->mQmlEngine); + component.setData(qmlString.toLocal8Bit(), QUrl()); + QDeclarativeItem * const item = qobject_cast(component.create()); + QIcon const icon = graphicsUtils::ItemRenderer::renderRecursively(item + , item->width(), item->height(), QColor(Qt::white)); + + instance()->mLoadedIcons[qmlString] = icon; + instance()->mPreferedSizes[qmlString] = QSize(item->width(), item->height()); + + return instance()->mLoadedIcons[qmlString]; } diff --git a/qrgui/umllib/qmlIconLoader.h b/qrgui/umllib/qmlIconLoader.h index a9c073d52e..ec864943e7 100644 --- a/qrgui/umllib/qmlIconLoader.h +++ b/qrgui/umllib/qmlIconLoader.h @@ -15,14 +15,14 @@ class QmlIconLoader static void setQmlEngine(QDeclarativeEngine * const engine); /// Returns a pixmap of element in specified qml-file - static QIcon iconOf(QString const &fileName); + static QIcon iconOf(QString const &qmlString); /// Returns a size of the pixmap of element in specified qml-file - static QSize preferedSizeOf(QString const &fileName); + static QSize preferedSizeOf(QString const &qmlString); private: static QmlIconLoader *instance(); - static QIcon loadPixmap(QString const &fileName); + static QIcon loadPixmap(QString const &qmlString); QmlIconLoader(); ~QmlIconLoader(); diff --git a/qrxc/edgeType.cpp b/qrxc/edgeType.cpp index 6fd6b4c696..e4e99b51f7 100644 --- a/qrxc/edgeType.cpp +++ b/qrxc/edgeType.cpp @@ -3,6 +3,7 @@ #include #include +#include #include "association.h" #include "xmlCompiler.h" @@ -247,7 +248,7 @@ void EdgeType::generateCode(OutFile &out) out() << "\t\t}\n\n" << "\t\tvirtual ~" << className << "() {}\n\n" << "\t\tvoid paint(QPainter *, QRectF &){}\n" - << "\t\tQUrl qmlUrl() const { return QUrl(\"qrc:/generated/shapes/" + resourceName("Class") + "\"); }\n" + << "\t\tQString qmlString() const { return utils::InFile::readAll(\":/generated/shapes/" + resourceName("Class") + "\"); }\n" << "\t\tbool isNode() const { return false; }\n" << "\t\tbool isResizeable() const { return true; }\n" << "\t\tbool isContainer() const { return false; }\n" diff --git a/qrxc/nodeType.cpp b/qrxc/nodeType.cpp index 4957028ec4..94be31ea31 100644 --- a/qrxc/nodeType.cpp +++ b/qrxc/nodeType.cpp @@ -211,7 +211,7 @@ void NodeType::generateCode(OutFile &out) out() << "\t\t~" << className << "() {}\n\n"; out() - << "\t\tQUrl qmlUrl() const { return QUrl(\"qrc:/generated/shapes/" + resourceName("Class") + "\"); }\n" + << "\t\tQString qmlString() const { return utils::InFile::readAll(\":/generated/shapes/" + resourceName("Class") + "\"); }\n" << "\t\tQt::PenStyle getPenStyle() const { return Qt::SolidLine; }\n\n" << "\t\tint getPenWidth() const { return 0; }\n\n" << "\t\tQColor getPenColor() const { return QColor(); }\n\n" diff --git a/qrxc/xmlCompiler.cpp b/qrxc/xmlCompiler.cpp index b46f4eea6f..312a9d3640 100644 --- a/qrxc/xmlCompiler.cpp +++ b/qrxc/xmlCompiler.cpp @@ -126,6 +126,7 @@ void XmlCompiler::generateElementClasses() OutFile outElements("generated/elements.h"); outElements() << "#pragma once\n\n" << "#include \n" + << "#include \n" << "#include \n\n" << "#include \"../" << mSourcesRootFolder << "/qrgui/editorPluginInterface/elementImpl.h\"\n" << "#include \"../" << mSourcesRootFolder << "/qrgui/editorPluginInterface/elementRepoInterface.h\"\n" From b476504823b04d48591631ca8ca1786f05795aa8 Mon Sep 17 00:00:00 2001 From: BogdanKl Date: Thu, 16 Oct 2014 17:06:06 +0400 Subject: [PATCH 02/19] change some details --- .../interpreterEditorManager.cpp | 26 +++++++++---------- qrrepo/private/repository.cpp | 1 - 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/qrgui/pluginManager/interpreterEditorManager.cpp b/qrgui/pluginManager/interpreterEditorManager.cpp index 979dfdd459..10590e0266 100644 --- a/qrgui/pluginManager/interpreterEditorManager.cpp +++ b/qrgui/pluginManager/interpreterEditorManager.cpp @@ -419,22 +419,22 @@ QIcon InterpreterEditorManager::icon(Id const &id) const QPair const repoAndMetaIdPair = repoAndMetaId(id); qrRepo::RepoApi const * const repo = repoAndMetaIdPair.first; Id const metaId = repoAndMetaIdPair.second; - QString const source; + QString source = ""; //QDomDocument classDoc; //QDomElement sdfElement; if (metaId.element() == "MetaEntityEdge") { - source.arg("import QtQuick 1.1 \n") - .arg("import CustomComponents 1.0 \n") - .arg("Rectangle { \n") - .arg("\t width : 100; height : 60 \n") - .arg("\t Line{ \n") - .arg("\t\t x1 : 0; y1 : 0 \n") - .arg("\t\t x2 : 100; y2:60 \n") - .arg("\t\t width : 2 \n") - .arg("\t\t style:\"solid""\"\n") - .arg("\t} \n") - .arg("}\n"); + source += QString("import QtQuick 1.1 \n") + + QString("import CustomComponents 1.0 \n") + + QString("Rectangle { \n") + + QString("\t width : 100; height : 60 \n") + + QString("\t Line{ \n") + + QString("\t\t x1 : 0; y1 : 0 \n") + + QString("\t\t x2 : 100; y2:60 \n") + + QString("\t\t width : 2 \n") + + QString("\t\t style:\"solid""\"\n") + + QString("\t} \n") + + QString("}\n"); /*sdfElement = classDoc.createElement("picture"); sdfElement.setAttribute("sizex", 100); sdfElement.setAttribute("sizey", 60); @@ -452,7 +452,7 @@ QIcon InterpreterEditorManager::icon(Id const &id) const sdfElement.appendChild(lineElement);*/ } else { // содержимое кода на qml - source.arg(repo->stringProperty(metaId, "shape")); + source = (repo->stringProperty(metaId, "shape")); } if (source.compare("")) { diff --git a/qrrepo/private/repository.cpp b/qrrepo/private/repository.cpp index c5bff88e29..eafde3aec7 100644 --- a/qrrepo/private/repository.cpp +++ b/qrrepo/private/repository.cpp @@ -448,7 +448,6 @@ void Repository::saveDiagramsById(QHash const &diagramIds) void Repository::remove(IdList const &list) const { foreach(Id const &id, list) { - qDebug() << id.toString(); mSerializer.removeFromDisk(id); } } From d4ef7bd7d44bca8d255b59f7eab2ae90a3e1c543 Mon Sep 17 00:00:00 2001 From: BogdanKl Date: Tue, 18 Nov 2014 15:51:39 +0300 Subject: [PATCH 03/19] edit metaEditor, add declarativeImage declarativePath --- plugins/metaEditor/editor/metaEditor.xml | 76 ++--- .../metaEditor/editor/qml/ListenerClass.qml | 15 + .../editor/qml/MetaEditorDiagramNodeClass.qml | 64 +++++ .../editor/qml/MetaEntity AttributeClass.qml | 6 + .../editor/qml/MetaEntityAssociationClass.qml | 51 ++++ .../editor/qml/MetaEntityConnectionClass.qml | 33 +++ .../qml/MetaEntityContextMenuFieldClass.qml | 26 ++ .../editor/qml/MetaEntityEdgeClass.qml | 51 ++++ .../editor/qml/MetaEntityEnumClass.qml | 51 ++++ .../editor/qml/MetaEntityImportClass.qml | 26 ++ .../editor/qml/MetaEntityNodeClass.qml | 51 ++++ .../editor/qml/MetaEntityPortClass.qml | 52 ++++ .../qml/MetaEntityPossibleEdgeClass.qml | 26 ++ .../MetaEntityPropertiesAsContainerClass.qml | 51 ++++ .../editor/qml/MetaEntityUsageClass.qml | 33 +++ .../editor/qml/MetaEntityValueClass.qml | 6 + .../editor/qml/MetamodelDiagramClass.qml | 37 +++ .../editor/qml/PackageDiagramClass.qml | 69 +++++ qrgui/mainwindow/mainWindow.cpp | 8 +- .../details/interpreterElementImpl.cpp | 2 - qrgui/pluginManager/editorManager.cpp | 18 +- .../interpreterEditorManager.cpp | 24 +- .../pluginManager/interpreterEditorManager.h | 1 - qrgui/qmlType/declarativeArc.cpp | 145 ++++++++++ qrgui/qmlType/declarativeArc.h | 81 ++++++ qrgui/qmlType/declarativeImage.cpp | 199 +++++++++++++ qrgui/qmlType/declarativeImage.h | 102 +++++++ qrgui/qmlType/declarativeLine.cpp | 2 +- qrgui/qmlType/declarativePath.cpp | 261 ++++++++++++++++++ qrgui/qmlType/declarativePath.h | 56 ++++ qrgui/qmlType/qmlType.pri | 6 + qrgui/umllib/nodeElement.cpp | 2 +- 32 files changed, 1533 insertions(+), 98 deletions(-) create mode 100644 plugins/metaEditor/editor/qml/ListenerClass.qml create mode 100644 plugins/metaEditor/editor/qml/MetaEditorDiagramNodeClass.qml create mode 100644 plugins/metaEditor/editor/qml/MetaEntity AttributeClass.qml create mode 100644 plugins/metaEditor/editor/qml/MetaEntityAssociationClass.qml create mode 100644 plugins/metaEditor/editor/qml/MetaEntityConnectionClass.qml create mode 100644 plugins/metaEditor/editor/qml/MetaEntityContextMenuFieldClass.qml create mode 100644 plugins/metaEditor/editor/qml/MetaEntityEdgeClass.qml create mode 100644 plugins/metaEditor/editor/qml/MetaEntityEnumClass.qml create mode 100644 plugins/metaEditor/editor/qml/MetaEntityImportClass.qml create mode 100644 plugins/metaEditor/editor/qml/MetaEntityNodeClass.qml create mode 100644 plugins/metaEditor/editor/qml/MetaEntityPortClass.qml create mode 100644 plugins/metaEditor/editor/qml/MetaEntityPossibleEdgeClass.qml create mode 100644 plugins/metaEditor/editor/qml/MetaEntityPropertiesAsContainerClass.qml create mode 100644 plugins/metaEditor/editor/qml/MetaEntityUsageClass.qml create mode 100644 plugins/metaEditor/editor/qml/MetaEntityValueClass.qml create mode 100644 plugins/metaEditor/editor/qml/MetamodelDiagramClass.qml create mode 100644 plugins/metaEditor/editor/qml/PackageDiagramClass.qml create mode 100644 qrgui/qmlType/declarativeArc.cpp create mode 100644 qrgui/qmlType/declarativeArc.h create mode 100644 qrgui/qmlType/declarativeImage.cpp create mode 100644 qrgui/qmlType/declarativeImage.h create mode 100644 qrgui/qmlType/declarativePath.cpp create mode 100644 qrgui/qmlType/declarativePath.h diff --git a/plugins/metaEditor/editor/metaEditor.xml b/plugins/metaEditor/editor/metaEditor.xml index 25fb8f318c..2fd3e3e748 100644 --- a/plugins/metaEditor/editor/metaEditor.xml +++ b/plugins/metaEditor/editor/metaEditor.xml @@ -37,13 +37,7 @@ - - - - - - - +