From 7dcc8be05647ad7cb3f74d149dee7a5c3a46c447 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= <moebius@cs.rwth-aachen.de> Date: Wed, 22 Jun 2022 16:05:02 +0200 Subject: [PATCH 1/6] Ported context to QDomElement --- parser/context.cc | 363 ++++++++++++++++++++++------------------------ parser/context.hh | 18 ++- 2 files changed, 182 insertions(+), 199 deletions(-) diff --git a/parser/context.cc b/parser/context.cc index aba76ce..5a3307c 100644 --- a/parser/context.cc +++ b/parser/context.cc @@ -42,10 +42,6 @@ //== INCLUDES ================================================================= -#include <QBuffer> -#include <QXmlQuery> -#include <QXmlResultItems> - #include "context.hh" #include "input.hh" #include "output.hh" @@ -63,6 +59,7 @@ #include "types/objectId/objectId.hh" #include "types/any.hh" + #define DATA_NAME "DataFlow" //== NAMESPACES =============================================================== @@ -178,57 +175,50 @@ QStringList Context::categories () //------------------------------------------------------------------------------ -/// Parse xml content -void Context::parse (QByteArray _xml) +/// Parse xml file content +void Context::parse (QFile& _xml) { - QBuffer device (&_xml); - device.open(QIODevice::ReadOnly); - - QXmlQuery query; - query.setFocus (&device); - - // for each OpenFlipper/element - query.setQuery ("OpenFlipper//element"); - QXmlResultItems elements; - - if (query.isValid ()) - { - query.evaluateTo (&elements); - QXmlItem item (elements.next ()); - while (!item.isNull ()) - { - QXmlQuery q (query); - q.setFocus (item); - parseElement (q); - item = elements.next (); + QDomDocument doc("OpenFlipper"); + if (!doc.setContent(&_xml)) { + return; } - } + // Iterate over all elements in the file (One Level below the OpenFlipper Tag + QDomElement docElem = doc.documentElement(); + QDomNode n = docElem.firstChild(); + while(!n.isNull()) { + QDomElement e = n.toElement(); // try to convert the node to an element. + if(!e.isNull()) { + parseElement(e); + } + n = n.nextSibling(); + } } //------------------------------------------------------------------------------ -// parse element from xml -void Context::parseElement (QXmlQuery &_xml) +/// parse element from xml +void Context::parseElement (QDomElement &_domElement) { - if (getXmlString (_xml, "string(@name)").isEmpty ()) - return; - Element *e = new Element (this, getXmlString (_xml, "string(@name)")); + // If the element has no name, something is wrong here! + if ( !_domElement.hasAttribute("name")) + return; - elements_.append (e); + // Create element in the database with the new elements name + Element *e = new Element (this, _domElement.attribute("name")); + elements_.append (e); - e->category_ = getXmlString (_xml, "category/string(text())", "Undefined"); + e->category_ = getXmlString (_domElement, "category", "Undefined"); - e->shortDesc_ = getXmlString (_xml, "short/string(text())", e->name ()); - e->longDesc_ = getXmlString (_xml, "long/string(text())", e->shortDesc_); + e->shortDesc_ = getXmlString (_domElement, "short", e->name ()); + e->longDesc_ = getXmlString (_domElement, "long", e->shortDesc_); // scene graph in/output for scenegraph elements - if (strToBool (getXmlString (_xml, "dataflow/string(text())"))) + if (strToBool (getXmlString (_domElement, "dataflow"))) { - e->dataIn_ = new Input (e); e->dataIn_->name_ = "data"; e->dataIn_->type_ = QVariant::Invalid; @@ -245,75 +235,68 @@ void Context::parseElement (QXmlQuery &_xml) e->dataOut_->longDesc_ = DATA_NAME; } - // parse all inputs - _xml.setQuery ("inputs/input"); + // Search through all children of the current element if we have inputs, outputs or functions + for(QDomElement n = _domElement.firstChildElement(); !n.isNull(); n = n.nextSiblingElement() ) + { + // Found an input Tag! + if (n.tagName() == "inputs") { - QXmlResultItems inouts; + // Iterate over all inputs inside it + for(QDomElement inputElement = n.firstChildElement(); !inputElement.isNull(); inputElement = inputElement.nextSiblingElement() ) + { + Input* i =parseInput(inputElement,e); - if (_xml.isValid ()) - { - _xml.evaluateTo (&inouts); - QXmlItem item (inouts.next ()); - while (!item.isNull ()) - { - QXmlQuery q (_xml); - q.setFocus (item); - Input *i = parseInput (q, e); - if (i) - { - e->inputs_.append (i); - } - item = inouts.next (); - } + if (i) { + e->inputs_.append (i); + } + } - } + // Only one input element allowed + break; + } - // parse all outputs - _xml.setQuery ("outputs/output"); + // Found an input Tag! + if (n.tagName() == "outputs") { - if (_xml.isValid ()) - { - _xml.evaluateTo (&inouts); - QXmlItem item (inouts.next ()); - while (!item.isNull ()) - { - QXmlQuery q (_xml); - q.setFocus (item); - Output *o = parseOutput (q, e); - if (o) - { - o->element_ = e; - e->outputs_.append (o); + // Iterate over all outputs inside it + for(QDomElement outputElement = n.firstChildElement(); !outputElement.isNull(); outputElement = outputElement.nextSiblingElement() ) + { + Output *o = parseOutput(outputElement,e); + + if (o) { + o->element_ = e; + e->outputs_.append (o); + } + } + + // Only one output element allowed + break; } - item = inouts.next (); - } - } - // parse all functions - _xml.setQuery ("functions/function"); + // Found an input Tag! + if (n.tagName() == "functions") { - if (_xml.isValid ()) - { - _xml.evaluateTo (&inouts); - QXmlItem item (inouts.next ()); - while (!item.isNull ()) - { - QXmlQuery q (_xml); - q.setFocus (item); - Function *f = parseFunction (q, e); - if (f) - { - e->functions_.append (f); + // Iterate over all outputs inside it + for(QDomElement functionElement = n.firstChildElement(); !functionElement.isNull(); functionElement = functionElement.nextSiblingElement() ) + { + Function *f = parseFunction (functionElement, e); + if (f) + { + e->functions_.append (f); + } + } + + // Only one output element allowed + break; } - item = inouts.next (); - } } + // get code & precode segment - e->precode_ = getXmlString (_xml, "precode/string(text())", ""); - e->code_ = getXmlString (_xml, "code/string(text())", ""); + e->precode_ = getXmlString (_domElement, "precode", ""); + e->code_ = getXmlString (_domElement, "code", ""); if (e->precode_.contains(QRegExp("^\\s*\\t"))) { // precode contains tab symbol @@ -330,56 +313,58 @@ void Context::parseElement (QXmlQuery &_xml) } -//------------------------------------------------------------------------------ +////------------------------------------------------------------------------------ -// parse element input from xml -Input* Context::parseInput (QXmlQuery &_xml, Element *_e) +//// parse element input from xml +Input* Context::parseInput(QDomElement& _domElement, Element *_e) { - Input *i = new Input (_e); + Input *i = new Input (_e); - // common part - if (!parseInOutBase (_xml, i)) - { - delete i; - return NULL; - } + // common part + if (!parseInOutBase (_domElement, i)) + { + delete i; + return NULL; + } + + + + // input states + QString stateStr = _domElement.attribute("external"); + unsigned int state = 0; - // input states - QString stateStr = getXmlString (_xml, "string(@external)"); - unsigned int state = 0; - - if (!stateStr.isEmpty () && !strToBool (stateStr)) - state |= Input::NoExternalInput; + if (!stateStr.isEmpty () && !strToBool (stateStr)) + state |= Input::NoExternalInput; - stateStr = getXmlString (_xml, "string(@user)"); + stateStr = _domElement.attribute("user"); - if (!stateStr.isEmpty () && !strToBool (stateStr)) - state |= Input::NoUserInput; + if (!stateStr.isEmpty () && !strToBool (stateStr)) + state |= Input::NoUserInput; - stateStr = getXmlString (_xml, "string(@runtime)"); + stateStr = _domElement.attribute("runtime"); - if (!stateStr.isEmpty () && !strToBool (stateStr)) - state |= Input::NoRuntimeUserInput; + if (!stateStr.isEmpty () && !strToBool (stateStr)) + state |= Input::NoRuntimeUserInput; - stateStr = getXmlString (_xml, "string(@optional)"); + stateStr = _domElement.attribute("optional"); - if (!stateStr.isEmpty () && strToBool (stateStr)) - state |= Input::Optional; + if (!stateStr.isEmpty () && strToBool (stateStr)) + state |= Input::Optional; - i->state_ = state; + i->state_ = state; - return i; + return i; } -//------------------------------------------------------------------------------ +////------------------------------------------------------------------------------ -// parse element output from xml -Output* Context::parseOutput (QXmlQuery &_xml, Element *_e) +//// parse element output from xml +Output* Context::parseOutput (QDomElement& _domElement, Element *_e) { Output *o = new Output (_e); // common part - if (!parseInOutBase (_xml, o)) + if (!parseInOutBase (_domElement, o)) { delete o; return NULL; @@ -388,29 +373,28 @@ Output* Context::parseOutput (QXmlQuery &_xml, Element *_e) return o; } -//------------------------------------------------------------------------------ +////------------------------------------------------------------------------------ -// parse common input and output parts from xml -bool Context::parseInOutBase (QXmlQuery &_xml, InOut *_io) +//// parse common input and output parts from xml +bool Context::parseInOutBase (QDomElement &_domElement, InOut *_io) { - QString type = getXmlString (_xml, "string(@type)"); + QString type = _domElement.attribute("type",""); - if (getXmlString (_xml, "string(@name)").isEmpty () || - type.isEmpty ()) - return false; + if ( !_domElement.hasAttribute("name") || type.isEmpty() ) + return false; - _io->name_ = getXmlString (_xml, "string(@name)"); - _io->type_ = type; + _io->name_ = _domElement.attribute("name"); + _io->type_ = type; - _io->shortDesc_ = getXmlString (_xml, "short/string(text())", _io->name ()); - _io->longDesc_ = getXmlString (_xml, "long/string(text())", _io->shortDesc_); + _io->shortDesc_ = getXmlString (_domElement,"short", _io->name ()); + _io->longDesc_ = getXmlString (_domElement, "long", _io->shortDesc_); // get type hints for supported types if (typeSupported (type)) { foreach (QString hint, supportedTypes_[type]->supportedHints ()) { - QString value = getXmlString (_xml, hint + "/string(text())", ""); + QString value = getXmlString (_domElement, hint , ""); if (!value.isEmpty ()) _io->hints_[hint] = value; } @@ -419,19 +403,19 @@ bool Context::parseInOutBase (QXmlQuery &_xml, InOut *_io) return true; } -//------------------------------------------------------------------------------ +////------------------------------------------------------------------------------ -// parse element function from xml -Function* Context::parseFunction (QXmlQuery &_xml, Element *_e) +//// parse element function from xml +Function* Context::parseFunction (QDomElement& _domElement, Element *_e) { - QString name = getXmlString (_xml, "string(@name)"); + QString name = _domElement.attribute("name"); if (name.isEmpty ()) return NULL; Function *f = new Function (_e, name); - f->shortDesc_ = getXmlString (_xml, "short/string(text())", f->name ()); - f->longDesc_ = getXmlString (_xml, "long/string(text())", f->shortDesc_); + f->shortDesc_ = getXmlString (_domElement, "short", f->name ()); + f->longDesc_ = getXmlString (_domElement, "long", f->shortDesc_); // add start element f->start_ = new Element (_e->context (), "start_" + _e->name () + "_" + name); @@ -471,53 +455,49 @@ Function* Context::parseFunction (QXmlQuery &_xml, Element *_e) elements_.append (f->end_); - // inputs - _xml.setQuery ("inputs/input"); - QXmlResultItems inouts; - if (_xml.isValid ()) + // Search through all children of the current element if we have inputs, outputs or functions + for(QDomElement n = _domElement.firstChildElement(); !n.isNull(); n = n.nextSiblingElement() ) { - _xml.evaluateTo (&inouts); - QXmlItem item (inouts.next ()); - while (!item.isNull ()) - { - QXmlQuery q (_xml); - q.setFocus (item); - Output *o = new Output (f->start_); - if (parseInOutBase(q, o)) - { - f->start_->outputs_.append (o); + // Found an input Tag! + if (n.tagName() == "inputs") { + + // Iterate over all inputs inside it + for(QDomElement inputElement = n.firstChildElement(); !inputElement.isNull(); inputElement = inputElement.nextSiblingElement() ) + { + Output *o = new Output (f->start_); + if (parseInOutBase(inputElement, o)) + { + f->start_->outputs_.append (o); + } + else + delete o; + } + + // Only one input element allowed + break; } - else - delete o; - item = inouts.next (); - } - - } - // outputs - _xml.setQuery ("outputs/output"); - - if (_xml.isValid ()) - { - _xml.evaluateTo (&inouts); - QXmlItem item (inouts.next ()); - while (!item.isNull ()) - { - QXmlQuery q (_xml); - q.setFocus (item); - Input *i = new Input (f->end_); - if (parseInOutBase(q, i)) - { - i->state_ = Input::NoUserInput | Input::NoRuntimeUserInput; - f->end_->inputs_.append (i); + // Found an input Tag! + if (n.tagName() == "outputs") { + + // Iterate over all outputs inside it + for(QDomElement outputElement = n.firstChildElement(); !outputElement.isNull(); outputElement = outputElement.nextSiblingElement() ) + { + Input *i = new Input (f->end_); + if (parseInOutBase(outputElement, i)) + { + i->state_ = Input::NoUserInput | Input::NoRuntimeUserInput; + f->end_->inputs_.append (i); + } + else + delete i; + } + + // Only one output element allowed + break; } - else - delete i; - item = inouts.next (); - } - } // add end node only if we have outputs @@ -539,17 +519,18 @@ Function* Context::parseFunction (QXmlQuery &_xml, Element *_e) //------------------------------------------------------------------------------ -/// Gets the string of a xml query -QString Context::getXmlString (QXmlQuery &_xml, QString _expr, QString _default) +/// Gets the string of a tag or returns the default +QString Context::getXmlString (QDomElement &_domElement, QString _tag, QString _default) { - QStringList sl; - _xml.setQuery (_expr); - - if (_xml.isValid () && _xml.evaluateTo (&sl) && sl.length () == 1) - return sl[0]; + // Secrh through all children of the current element if it matches the given tag + for(QDomElement n = _domElement.firstChildElement(); !n.isNull(); n = n.nextSiblingElement() ) + { + if (n.tagName() == _tag) + return n.text(); + } - return _default; + return _default; } //------------------------------------------------------------------------------ diff --git a/parser/context.hh b/parser/context.hh index 0c527cd..938246b 100644 --- a/parser/context.hh +++ b/parser/context.hh @@ -47,9 +47,11 @@ //== INCLUDES ================================================================= #include <QVector> #include <QStringList> -#include <QXmlQuery> +#include <QDomDocument> +#include <QFile> #include <OpenFlipper/BasePlugin/LoggingInterface.hh> #include <OpenFlipper/BasePlugin/PythonInterface.hh> +#include <parser/type.hh> #include "element.hh" @@ -76,7 +78,7 @@ class Context { ~Context (); /// Parse xml content - void parse (QByteArray _xml); + void parse (QFile& _xml); /// Returns all available elements const QVector<Element *>& elements () const { return elements_; }; @@ -106,7 +108,7 @@ class Context { static bool strToBool (QString _str); /// Gets the string of a xml query - static QString getXmlString (QXmlQuery &_xml, QString _expr, QString _default = ""); + static QString getXmlString (QDomElement &_element, QString _tag, QString _default = ""); /// Removes trailing spaces from string which are present in each line - relative trailing spaces are not removed static QString removeCommonTrailingSpaces(QString in); @@ -120,19 +122,19 @@ class Context { private: // parse element from xml - void parseElement (QXmlQuery &_xml); + void parseElement (QDomElement &_element); // parse element input from xml - Input *parseInput (QXmlQuery &_xml, Element *_e); + Input *parseInput (QDomElement &_domElement, Element *_e); // parse element output from xml - Output *parseOutput (QXmlQuery &_xml, Element *_e); + Output *parseOutput (QDomElement& _domElement, Element *_e); // parse element function from xml - Function *parseFunction (QXmlQuery &_xml, Element *_e); + Function *parseFunction (QDomElement& _domElement, Element *_e); // parse common input and output parts from xml - bool parseInOutBase (QXmlQuery &_xml, InOut *_io); + bool parseInOutBase (QDomElement &_domElement, InOut *_io); private: QVector <Element *> elements_; -- GitLab From 9544af14a897d110394207220928ea1e6fb57217 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= <moebius@cs.rwth-aachen.de> Date: Wed, 22 Jun 2022 16:06:00 +0200 Subject: [PATCH 2/6] Ported context to QDomElement --- vsiPlugin.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/vsiPlugin.cc b/vsiPlugin.cc index 309681d..113e448 100644 --- a/vsiPlugin.cc +++ b/vsiPlugin.cc @@ -149,11 +149,13 @@ void VsiPlugin::initContext() foreach (QString file, subdir.entryList (QStringList("*.xml"), QDir::Files)) { - QFile f (subdir.filePath (file)); - if (!f.open (QIODevice::ReadOnly)) - continue; + QFile f (subdir.filePath (file)); + if (!f.open (QIODevice::ReadOnly)) + continue; - context_->parse (f.readAll ()); + context_->parse(f); + + f.close(); } } -- GitLab From 27406256431b7db87acc57a3bb767e0b5c335cfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= <moebius@cs.rwth-aachen.de> Date: Wed, 22 Jun 2022 16:29:44 +0200 Subject: [PATCH 3/6] Fixed logic error --- parser/context.cc | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/parser/context.cc b/parser/context.cc index 5a3307c..694554c 100644 --- a/parser/context.cc +++ b/parser/context.cc @@ -250,9 +250,6 @@ void Context::parseElement (QDomElement &_domElement) e->inputs_.append (i); } } - - // Only one input element allowed - break; } // Found an input Tag! @@ -268,9 +265,6 @@ void Context::parseElement (QDomElement &_domElement) e->outputs_.append (o); } } - - // Only one output element allowed - break; } @@ -287,8 +281,6 @@ void Context::parseElement (QDomElement &_domElement) } } - // Only one output element allowed - break; } } @@ -327,8 +319,6 @@ Input* Context::parseInput(QDomElement& _domElement, Element *_e) return NULL; } - - // input states QString stateStr = _domElement.attribute("external"); unsigned int state = 0; -- GitLab From 8a4d50ac0811f4be1a0cb417ba7d216fa4e2a317 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= <moebius@cs.rwth-aachen.de> Date: Wed, 22 Jun 2022 16:55:34 +0200 Subject: [PATCH 4/6] Added test file --- test.ofvs | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 test.ofvs diff --git a/test.ofvs b/test.ofvs new file mode 100644 index 0000000..d10163f --- /dev/null +++ b/test.ofvs @@ -0,0 +1,68 @@ +<!DOCTYPE VisualScript> +<VisualScript> + <transform>1|0|0|0|1|0|0|0|1</transform> + <x>0</x> + <y>0</y> + <elements> + <element name="end"> + <id>0</id> + <x>3620</x> + <y>965</y> + <inputs> + <input name="data"> + <is_set>false</is_set> + <connection element="isotropicremesher_remesh" element_id="0" output="data"/> + </input> + </inputs> + </element> + <element name="start"> + <id>0</id> + <x>5</x> + <y>965</y> + </element> + <element name="isotropicremesher_remesh"> + <id>0</id> + <x>2506</x> + <y>598</y> + <inputs> + <input name="obj"> + <is_set>false</is_set> + <connection element="constant_object_id" element_id="0" output="output"/> + </input> + <input name="eLength"> + <is_set>false</is_set> + <connection element="info_edgeLength" element_id="0" output="meanEdgeLength"/> + </input> + <input name="data"> + <is_set>false</is_set> + <connection element="info_edgeLength" element_id="0" output="data"/> + </input> + </inputs> + </element> + <element name="constant_object_id"> + <id>0</id> + <x>427</x> + <y>207.5</y> + <inputs> + <input name="input"> + <is_set>false</is_set> + </input> + </inputs> + </element> + <element name="info_edgeLength"> + <id>0</id> + <x>1280</x> + <y>811</y> + <inputs> + <input name="obj"> + <is_set>false</is_set> + <connection element="constant_object_id" element_id="0" output="output"/> + </input> + <input name="data"> + <is_set>false</is_set> + <connection element="start" element_id="0" output="data"/> + </input> + </inputs> + </element> + </elements> +</VisualScript> -- GitLab From b242090c32355bff42fcf0c36465c0e81ba9f972 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= <moebius@cs.rwth-aachen.de> Date: Thu, 23 Jun 2022 11:39:17 +0200 Subject: [PATCH 5/6] Finished transition to QDomElement for parsing --- CMakeLists.txt | 3 +- baseWidget.cc | 22 ++---- scene/elementFunction.cc | 4 +- scene/elementFunction.hh | 2 +- scene/elementInput.cc | 8 +- scene/elementInput.hh | 2 +- scene/graphicsScene.cc | 167 +++++++++++++++++++-------------------- scene/graphicsScene.hh | 9 +-- scene/sceneElement.cc | 115 +++++++++++++-------------- scene/sceneElement.hh | 10 ++- test.ofvs | 68 ---------------- 11 files changed, 167 insertions(+), 243 deletions(-) delete mode 100644 test.ofvs diff --git a/CMakeLists.txt b/CMakeLists.txt index a99f45c..b8224ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,4 @@ include (plugin) openflipper_plugin (PYTHONINTERFACE DIRS config parser scene types types/objectId - INSTALLDATA Icons VsiMetadata - QT5ONLY True) + INSTALLDATA Icons VsiMetadata) diff --git a/baseWidget.cc b/baseWidget.cc index 52ef8f6..9e47ae5 100644 --- a/baseWidget.cc +++ b/baseWidget.cc @@ -278,25 +278,17 @@ void VSI::BaseWidget::load() scenes_.pop (); views_->setCurrentWidget (mainScene_->graphicsView()); - QXmlQuery query; - query.setFocus (&f); - query.setQuery ("VisualScript"); + QDomDocument doc("OpenFlipper"); + if (!doc.setContent(&f)) { + return; + } - QXmlResultItems root; + // Iterate over all elements in the file (One Level below the OpenFlipper Tag + QDomElement docElem = doc.documentElement(); + mainScene_->loadFromXml (docElem); - if (query.isValid ()) - { - query.evaluateTo (&root); - QXmlItem item (root.next ()); - if (!item.isNull ()) - { - QXmlQuery q (query); - q.setFocus (item); - mainScene_->loadFromXml (q); - } - } changedContent_ = false; fileName_ = filename; diff --git a/scene/elementFunction.cc b/scene/elementFunction.cc index a726c9d..b294f94 100644 --- a/scene/elementFunction.cc +++ b/scene/elementFunction.cc @@ -92,9 +92,9 @@ void ElementFunction::saveToXml(QDomDocument & _doc, QDomElement & _root) //------------------------------------------------------------------------------ /// Load from xml -void ElementFunction::loadFromXml(QXmlQuery & _xml) +void ElementFunction::loadElementFunctionFromXml(QDomElement& _domElement) { - scene_->loadFromXml (_xml); + scene_->loadFromXml (_domElement); } //------------------------------------------------------------------------------ diff --git a/scene/elementFunction.hh b/scene/elementFunction.hh index 14afb47..f499898 100644 --- a/scene/elementFunction.hh +++ b/scene/elementFunction.hh @@ -88,7 +88,7 @@ class ElementFunction : public QObject{ void saveToXml (QDomDocument &_doc, QDomElement &_root); /// Load from xml - void loadFromXml (QXmlQuery &_xml); + void loadElementFunctionFromXml (QDomElement& _domElement); public slots: diff --git a/scene/elementInput.cc b/scene/elementInput.cc index e97031a..6667497 100644 --- a/scene/elementInput.cc +++ b/scene/elementInput.cc @@ -252,21 +252,21 @@ void ElementInput::saveToXml(QDomDocument & _doc, QDomElement & _root) //------------------------------------------------------------------------------ /// Load from xml -void ElementInput::loadFromXml(QXmlQuery & _xml) +void ElementInput::loadElementInputFromXml(QDomElement& _domElement) { - QString val = Context::getXmlString (_xml, "is_set/string(text())"); + QString val = Context::getXmlString (_domElement, "is_set"); isSet_ = Context::strToBool (val); if (state () & Input::Optional) { - val = Context::getXmlString (_xml, "force_ask/string(text())"); + val = Context::getXmlString (_domElement, "force_ask"); forceAsk_ = Context::strToBool (val); } if (isSet_) { - value_ = Context::getXmlString (_xml, "value/string(text())"); + value_ = Context::getXmlString (_domElement, "value"); } if (isSet ()) diff --git a/scene/elementInput.hh b/scene/elementInput.hh index 3a25ca7..d52b5af 100644 --- a/scene/elementInput.hh +++ b/scene/elementInput.hh @@ -114,7 +114,7 @@ class ElementInput : public ElementInOut { void saveToXml (QDomDocument &_doc, QDomElement &_root); /// Load from xml - void loadFromXml (QXmlQuery &_xml); + void loadElementInputFromXml (QDomElement& _domElement); private: Input *in_; diff --git a/scene/graphicsScene.cc b/scene/graphicsScene.cc index b129248..1de8564 100644 --- a/scene/graphicsScene.cc +++ b/scene/graphicsScene.cc @@ -869,11 +869,11 @@ void GraphicsScene::saveToXml (QDomDocument &_doc, QDomElement &_root) //------------------------------------------------------------------------------ /// Load from xml -void VSI::GraphicsScene::loadFromXml (QXmlQuery &_xml) +void VSI::GraphicsScene::loadFromXml (QDomElement& _domElement) { clearScene (true); - QStringList sl = Context::getXmlString (_xml, "transform/string(text ())").split ("|"); + QStringList sl = Context::getXmlString (_domElement, "transform").split ("|"); qreal m[9]; @@ -894,45 +894,35 @@ void VSI::GraphicsScene::loadFromXml (QXmlQuery &_xml) double x, y; QString val; - val = Context::getXmlString (_xml, "x/string(text())"); + val = Context::getXmlString (_domElement, "x"); x = val.toDouble (&ok1); - val = Context::getXmlString (_xml, "y/string(text())"); + val = Context::getXmlString (_domElement, "y"); y = val.toDouble (&ok2); if (ok1 && ok2) elementArea_->setPos (x, y); - _xml.setQuery ("elements/element"); - QXmlResultItems el; + // To make parsing easier, we collect all connections, while we traverse the element. + std::vector<QString> connections; - if (_xml.isValid ()) + // Search through all children of the current element if we have inputs, outputs or functions + for(QDomElement n = _domElement.firstChildElement(); !n.isNull(); n = n.nextSiblingElement() ) { - _xml.evaluateTo (&el); - QXmlItem item (el.next ()); - while (!item.isNull ()) - { - QXmlQuery q (_xml); - q.setFocus (item); - loadElement (q); - item = el.next (); - } - } + // Found an input Tag! + if (n.tagName() == "elements") { - _xml.setQuery ("elements/element/inputs/input/connection"); + // Iterate over all elements inside it (e.g. this are the algorithm boxes. + for(QDomElement sceneElement = n.firstChildElement(); !sceneElement.isNull(); sceneElement = sceneElement.nextSiblingElement() ) + { + loadElement (sceneElement,connections); + } + } + } - if (_xml.isValid ()) - { - _xml.evaluateTo (&el); - QXmlItem item (el.next ()); - while (!item.isNull ()) - { - QXmlQuery q (_xml); - q.setFocus (item); - loadConnection (q); - item = el.next (); - } + for (auto connection : connections) { + loadConnection(connection); } QTimer::singleShot(0, this, SLOT (updateConnections())); @@ -941,82 +931,89 @@ void VSI::GraphicsScene::loadFromXml (QXmlQuery &_xml) //------------------------------------------------------------------------------ // load element from xml -void GraphicsScene::loadElement(QXmlQuery & _xml) +void GraphicsScene::loadElement(QDomElement & _domElement,std::vector<QString>& _connections) { - QString name = Context::getXmlString (_xml, "string(@name)"); - if (name.isEmpty () || !ctx_->element (name)) - return; + QString name = _domElement.attribute("name"); + if (name.isEmpty () || !ctx_->element (name)) + return; + - SceneElement *e = new SceneElement (this, ctx_->element (name)); - addElement (e); + SceneElement *e = new SceneElement (this, ctx_->element (name)); + addElement (e); - e->loadFromXml (_xml); + e->loadFromXml (_domElement,_connections); } //------------------------------------------------------------------------------ // load connection from xml -void GraphicsScene::loadConnection(QXmlQuery & _xml) +void GraphicsScene::loadConnection(QString& _connection) { - bool ok; - int inId, outId; + bool ok; + int inId, outId; - QString inEl = Context::getXmlString (_xml, "../../../string(@name)"); - QString inElId = Context::getXmlString (_xml, "../../../id/string(text ())"); - QString inIn = Context::getXmlString (_xml, "../string(@name)"); + QStringList connectionInfo = _connection.split(";"); - inId = inElId.toInt (&ok); - if (!ok) - return; + if (connectionInfo.size() != 6 ) { + return; + } - QString outEl = Context::getXmlString (_xml, "string(@element)"); - QString outElId = Context::getXmlString (_xml, "string(@element_id)"); - QString outOut = Context::getXmlString (_xml, "string(@output)"); + QString inEl = connectionInfo[0]; + QString inElId = connectionInfo[1]; + QString inIn = connectionInfo[2]; - outId = outElId.toInt (&ok); - if (!ok) - return; + QString outEl = connectionInfo[3]; + QString outElId = connectionInfo[4]; + QString outOut = connectionInfo[5]; - SceneElement *in = NULL, *out = NULL; + inId = inElId.toInt (&ok); + if (!ok) + return; - foreach (SceneElement *e, elements ()) - { - if (e->element ()->name () == inEl && e->id () == inId) - in = e; - else if (e->element ()->name () == outEl && e->id () == outId) - out = e; - } + outId = outElId.toInt (&ok); + if (!ok) + return; - if (!in || !out) - return; + SceneElement *in = NULL, *out = NULL; - ConnectionPoint *p1 = NULL, *p2 = NULL; + foreach (SceneElement *e, elements ()) + { + if (e->element ()->name () == inEl && e->id () == inId) + in = e; + else if (e->element ()->name () == outEl && e->id () == outId) + out = e; + } - if (in->dataIn () && in->dataIn ()->inOut ()->name () == inIn && - out->dataOut () && out->dataOut ()->inOut ()->name () == outOut) - { - p1 = in->dataIn ()->connectionPointItem (); - p2 = out->dataOut ()->connectionPointItem (); - } - else - { - foreach (ElementInput *i, in->inputs()) - if (i->inOut ()->name () == inIn) - { - p1 = i->connectionPointItem (); - break; - } + if (!in || !out) + return; - foreach (ElementOutput *o, out->outputs()) - if (o->inOut ()->name () == outOut) - { - p2 = o->connectionPointItem (); - break; - } - } + ConnectionPoint *p1 = NULL, *p2 = NULL; + + if (in->dataIn () && in->dataIn ()->inOut ()->name () == inIn && + out->dataOut () && out->dataOut ()->inOut ()->name () == outOut) + { + p1 = in->dataIn ()->connectionPointItem (); + p2 = out->dataOut ()->connectionPointItem (); + } + else + { + foreach (ElementInput *i, in->inputs()) + if (i->inOut ()->name () == inIn) + { + p1 = i->connectionPointItem (); + break; + } + + foreach (ElementOutput *o, out->outputs()) + if (o->inOut ()->name () == outOut) + { + p2 = o->connectionPointItem (); + break; + } + } - if (p1 && p2) - new Connection (p1, p2, this); + if (p1 && p2) + new Connection (p1, p2, this); } //------------------------------------------------------------------------------ diff --git a/scene/graphicsScene.hh b/scene/graphicsScene.hh index faecbf0..1cf0419 100644 --- a/scene/graphicsScene.hh +++ b/scene/graphicsScene.hh @@ -50,7 +50,6 @@ #include <QPointF> #include <QDomDocument> #include <QDomElement> -#include <QXmlQuery> //== FORWARDDECLARATIONS ====================================================== class QGraphicsRectItem; @@ -135,7 +134,7 @@ class GraphicsScene : public QGraphicsScene void saveToXml (QDomDocument &_doc, QDomElement &_root); /// Load from xml - void loadFromXml (QXmlQuery &_xml); + void loadFromXml (QDomElement& _domElement); /// Associated function ElementFunction *function () { return function_; }; @@ -192,10 +191,10 @@ class GraphicsScene : public QGraphicsScene QPoint mimeDataPoint (const QMimeData *); // load element from xml - void loadElement (QXmlQuery &_xml); + void loadElement (QDomElement& _domElement,std::vector<QString>& _connections); - // load connection from xml - void loadConnection (QXmlQuery &_xml); + // load connections from xml + void loadConnection (QString& _connections); // returns all scene elements. Also all elements of sub-functions QList<SceneElement *> getAllElements (); diff --git a/scene/sceneElement.cc b/scene/sceneElement.cc index 4388c14..b3ec26d 100644 --- a/scene/sceneElement.cc +++ b/scene/sceneElement.cc @@ -84,7 +84,6 @@ #define SELECTED_BACKGROUND_BLUE 0x6f #define SELECTED_BACKGROUND_ALPHA 0xff - //== NAMESPACES =============================================================== namespace VSI { @@ -742,14 +741,14 @@ void SceneElement::saveToXml(QDomDocument & _doc, QDomElement & _root) //------------------------------------------------------------------------------ /// Load from xml -void SceneElement::loadFromXml(QXmlQuery & _xml) +void SceneElement::loadFromXml(QDomElement& _domElement,std::vector<QString>& _connections) { bool ok1, ok2; int id; double x, y; QString val; - val = Context::getXmlString (_xml, "visible_name/string(text())"); + val = Context::getXmlString (_domElement, "visible_name"); if (!val.isEmpty ()) name_->setText (val); @@ -761,7 +760,7 @@ void SceneElement::loadFromXml(QXmlQuery & _xml) nameLayout_->invalidate (); - val = Context::getXmlString (_xml, "id/string(text())"); + val = Context::getXmlString (_domElement, "id"); id = val.toUInt (&ok1); @@ -771,79 +770,79 @@ void SceneElement::loadFromXml(QXmlQuery & _xml) element_->setMinId(id + 1); } - val = Context::getXmlString (_xml, "x/string(text())"); + val = Context::getXmlString (_domElement, "x"); x = val.toDouble (&ok1); - val = Context::getXmlString (_xml, "y/string(text())"); + val = Context::getXmlString (_domElement, "y"); y = val.toDouble (&ok2); if (ok1 && ok2) setPos (x, y); - val = Context::getXmlString (_xml, "is_set/string(text())"); - - _xml.setQuery ("inputs/input"); + val = Context::getXmlString (_domElement, "is_set"); - QXmlResultItems i; - if (_xml.isValid ()) + // Search through all children of the current element if we have inputs, outputs or functions + for(QDomElement n = _domElement.firstChildElement(); !n.isNull(); n = n.nextSiblingElement() ) { - _xml.evaluateTo (&i); - QXmlItem item (i.next ()); - while (!item.isNull ()) - { - QXmlQuery q (_xml); - q.setFocus (item); + // Found an input Tag! + if (n.tagName() == "inputs") { - val = Context::getXmlString (q, "string(@name)"); - - if (!val.isEmpty()) - { - if (val == "data" && dataIn_) - dataIn_->loadFromXml (q); - else - { - foreach (ElementInput *i, inputs_) - if (i->inOut()->name () == val) - { - i->loadFromXml (q); - break; - } - } + // Iterate over all inputs inside it + for(QDomElement inputElement = n.firstChildElement(); !inputElement.isNull(); inputElement = inputElement.nextSiblingElement() ) + { + val = inputElement.attribute("name"); + + + if (!val.isEmpty()) + { + if (val == "data" && dataIn_) { + dataIn_->loadElementInputFromXml(inputElement); + } else + { + foreach (ElementInput *i, inputs_) + if (i->inOut()->name () == val) + { + i->loadElementInputFromXml(inputElement); + break; + } + } + + // Iterate over all inputs and read the connection info + for(QDomElement connectionElement = inputElement.firstChildElement(); !connectionElement.isNull(); connectionElement = connectionElement.nextSiblingElement() ) + { + if (connectionElement.tagName() == "connection") { + QString tmp = _domElement.attribute("name") + ";"+ Context::getXmlString (_domElement, "id") + ";" + inputElement.attribute("name") + ";" + connectionElement.attribute("element") + ";" + connectionElement.attribute("element_id") + ";" + connectionElement.attribute("output"); + _connections.push_back(tmp); + } + } + } + } } - item = i.next (); - } - - } - - _xml.setQuery ("functions/function"); - - if (_xml.isValid ()) - { - _xml.evaluateTo (&i); - QXmlItem item (i.next ()); - while (!item.isNull ()) - { - QXmlQuery q (_xml); - q.setFocus (item); - - val = Context::getXmlString (q, "string(@name)"); + // Found an function Tag! + if (n.tagName() == "functions") { - if (!val.isEmpty()) - { - foreach (ElementFunction *ef, functions_) - if (ef->function ()->name () == val) + // Iterate over all functions inside it + for(QDomElement functionElement = n.firstChildElement(); !functionElement.isNull(); functionElement = functionElement.nextSiblingElement() ) { - ef->loadFromXml (q); - break; + val = functionElement.attribute("name"); + + if (!val.isEmpty()) + { + foreach (ElementFunction *ef, functions_) + if (ef->function ()->name () == val) + { + ef->loadElementFunctionFromXml (functionElement); + break; + } + } } - } - item = i.next (); - } + } } + } //------------------------------------------------------------------------------ diff --git a/scene/sceneElement.hh b/scene/sceneElement.hh index f928110..5279fe9 100644 --- a/scene/sceneElement.hh +++ b/scene/sceneElement.hh @@ -126,8 +126,14 @@ class SceneElement : public QGraphicsWidget /// Save to xml void saveToXml (QDomDocument &_doc, QDomElement &_root); - /// Load from xml - void loadFromXml (QXmlQuery &_xml); + /** \brief Load one scene Element from xml + * + * Load one scene element from an xml dom. + * + * @param _domElement The element that should be loaded + * @param _connections Info about the connections returned for this element. The function appends the information to the vector + */ + void loadFromXml (QDomElement& _domElement,std::vector<QString>& _connections); /// Scene GraphicsScene *graphicsScene () { return scene_; }; diff --git a/test.ofvs b/test.ofvs deleted file mode 100644 index d10163f..0000000 --- a/test.ofvs +++ /dev/null @@ -1,68 +0,0 @@ -<!DOCTYPE VisualScript> -<VisualScript> - <transform>1|0|0|0|1|0|0|0|1</transform> - <x>0</x> - <y>0</y> - <elements> - <element name="end"> - <id>0</id> - <x>3620</x> - <y>965</y> - <inputs> - <input name="data"> - <is_set>false</is_set> - <connection element="isotropicremesher_remesh" element_id="0" output="data"/> - </input> - </inputs> - </element> - <element name="start"> - <id>0</id> - <x>5</x> - <y>965</y> - </element> - <element name="isotropicremesher_remesh"> - <id>0</id> - <x>2506</x> - <y>598</y> - <inputs> - <input name="obj"> - <is_set>false</is_set> - <connection element="constant_object_id" element_id="0" output="output"/> - </input> - <input name="eLength"> - <is_set>false</is_set> - <connection element="info_edgeLength" element_id="0" output="meanEdgeLength"/> - </input> - <input name="data"> - <is_set>false</is_set> - <connection element="info_edgeLength" element_id="0" output="data"/> - </input> - </inputs> - </element> - <element name="constant_object_id"> - <id>0</id> - <x>427</x> - <y>207.5</y> - <inputs> - <input name="input"> - <is_set>false</is_set> - </input> - </inputs> - </element> - <element name="info_edgeLength"> - <id>0</id> - <x>1280</x> - <y>811</y> - <inputs> - <input name="obj"> - <is_set>false</is_set> - <connection element="constant_object_id" element_id="0" output="output"/> - </input> - <input name="data"> - <is_set>false</is_set> - <connection element="start" element_id="0" output="data"/> - </input> - </inputs> - </element> - </elements> -</VisualScript> -- GitLab From be907f06284e1641aa4894eec7e979ffde112b18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= <moebius@cs.rwth-aachen.de> Date: Thu, 23 Jun 2022 12:17:02 +0200 Subject: [PATCH 6/6] Removed deprecated things --- baseWidget.cc | 4 ---- parser/context.cc | 14 +++++++------- scene/elementFunction.hh | 4 ++-- scene/elementInput.hh | 1 - scene/graphicsScene.cc | 14 ++++++++------ scene/sceneElement.cc | 22 ++++++++++++++-------- scene/sceneElement.hh | 1 - scene/trash.cc | 3 ++- vsiPlugin.cc | 4 ++++ 9 files changed, 37 insertions(+), 30 deletions(-) diff --git a/baseWidget.cc b/baseWidget.cc index 9e47ae5..b62f1ae 100644 --- a/baseWidget.cc +++ b/baseWidget.cc @@ -53,13 +53,9 @@ #include <QApplication> #include <QClipboard> -#include <QScriptEngine> #include <QDomDocument> -#include <QXmlQuery> -#include <QXmlResultItems> - #include <OpenFlipper/common/GlobalOptions.hh> #include "baseWidget.hh" diff --git a/parser/context.cc b/parser/context.cc index 694554c..bf49d46 100644 --- a/parser/context.cc +++ b/parser/context.cc @@ -59,6 +59,7 @@ #include "types/objectId/objectId.hh" #include "types/any.hh" +#include <QRegularExpression> #define DATA_NAME "DataFlow" @@ -221,7 +222,7 @@ void Context::parseElement (QDomElement &_domElement) { e->dataIn_ = new Input (e); e->dataIn_->name_ = "data"; - e->dataIn_->type_ = QVariant::Invalid; + e->dataIn_->type_ = "---"; e->dataIn_->shortDesc_ = DATA_NAME; e->dataIn_->longDesc_ = DATA_NAME; @@ -229,7 +230,7 @@ void Context::parseElement (QDomElement &_domElement) e->dataOut_ = new Output (e); e->dataOut_->name_ = "data"; - e->dataOut_->type_ = QVariant::Invalid; + e->dataOut_->type_ = "---"; e->dataOut_->shortDesc_ = DATA_NAME; e->dataOut_->longDesc_ = DATA_NAME; @@ -290,11 +291,11 @@ void Context::parseElement (QDomElement &_domElement) e->precode_ = getXmlString (_domElement, "precode", ""); e->code_ = getXmlString (_domElement, "code", ""); - if (e->precode_.contains(QRegExp("^\\s*\\t"))) { + if (e->precode_.contains(QRegularExpression("^\\s*\\t"))) { // precode contains tab symbol emit loggingInterface_->log(LOGWARN, "Precode block of "+e->name()+" contains tab identation"); } - if (e->code_.contains(QRegExp("^\\s*\\t"))) { + if (e->code_.contains(QRegularExpression("^\\s*\\t"))) { // precode contains tab symbol emit loggingInterface_->log(LOGWARN, "Code block of "+e->name()+" contains tab identation"); } @@ -591,7 +592,7 @@ QString Context::removeCommonTrailingSpaces(QString in) { int commonTrailingSpaces = INF; for (int line=0;line<lines.length();line++) { - int lenWithoutTrailingSpaces = QString(lines[line]).replace(QRegExp ("^\\s*"), "").length(); + int lenWithoutTrailingSpaces = QString(lines[line]).replace(QRegularExpression ("^\\s*"), "").length(); if (lenWithoutTrailingSpaces > 0) { // line not empty @@ -620,8 +621,7 @@ QString Context::removeCommonTrailingSpaces(QString in) { lines[line] = QString(""); } else { // remove common trailing whitespaces - QStringRef ref = QStringRef(&lines[line], commonTrailingSpaces, subLength); - lines[line] = ref.toString(); + lines[line] = lines[line].right(subLength); } } diff --git a/scene/elementFunction.hh b/scene/elementFunction.hh index f499898..447beff 100644 --- a/scene/elementFunction.hh +++ b/scene/elementFunction.hh @@ -49,7 +49,7 @@ #include <QDomDocument> #include <QDomElement> -#include <QXmlQuery> +#include <QObject> //== NAMESPACES =============================================================== @@ -63,7 +63,7 @@ class GraphicsScene; /** Class that represents a function of an element. * It holds the VSI::GraphicsScene to edit the function */ -class ElementFunction : public QObject{ +class ElementFunction : public QObject { Q_OBJECT diff --git a/scene/elementInput.hh b/scene/elementInput.hh index d52b5af..f44d079 100644 --- a/scene/elementInput.hh +++ b/scene/elementInput.hh @@ -49,7 +49,6 @@ #include <QDomDocument> #include <QDomElement> -#include <QXmlQuery> #include "elementInOut.hh" #include "../parser/input.hh" diff --git a/scene/graphicsScene.cc b/scene/graphicsScene.cc index 1de8564..815e515 100644 --- a/scene/graphicsScene.cc +++ b/scene/graphicsScene.cc @@ -62,8 +62,6 @@ #include <QPaintEngine> #include <QMimeData> -#include <QXmlResultItems> - #include "../parser/context.hh" #include "../parser/output.hh" #include "../parser/function.hh" @@ -686,13 +684,14 @@ QString GraphicsScene::generateCode (QString &errors, bool _codeOnly) } } - if (e->dataOut ()) + if (e->dataOut ()) { foreach (Connection *c, e->dataOut ()->connections ()) if (c->input ()) { c->input ()->setValid (true); break; } + } } QList<SceneElement *> fixE; @@ -778,13 +777,14 @@ QString GraphicsScene::updateConnections (SceneElement *_from, bool _isStart) } } - if (_from->dataOut ()) + if (_from->dataOut ()) { foreach (Connection *c, _from->dataOut ()->connections ()) if (c->input ()) { c->input ()->setValid (true); break; } + } return rv; } @@ -1077,13 +1077,15 @@ void GraphicsScene::updateConnections() foreach (Connection *c, o->connections ()) c->updatePositions (); - if (e->dataIn ()) + if (e->dataIn ()) { foreach (Connection *c, e->dataIn ()->connections ()) c->updatePositions (); + } - if (e->dataOut ()) + if (e->dataOut ()) { foreach (Connection *c, e->dataOut ()->connections ()) c->updatePositions (); + } } } diff --git a/scene/sceneElement.cc b/scene/sceneElement.cc index b3ec26d..734f458 100644 --- a/scene/sceneElement.cc +++ b/scene/sceneElement.cc @@ -52,9 +52,9 @@ #include <QGraphicsProxyWidget> #include <QGraphicsGridLayout> #include <QGraphicsView> +#include <QRegularExpression> #include <QDomText> -#include <QXmlResultItems> #include "sceneElement.hh" #include "graphicsScene.hh" @@ -541,13 +541,15 @@ void SceneElement::moveEvent (QGraphicsSceneMoveEvent *_event) foreach (Connection *c, e->connections ()) c->updatePositions (); - if (dataIn_) + if (dataIn_) { foreach (Connection *c, dataIn_->connections ()) c->updatePositions (); + } - if (dataOut_) + if (dataOut_) { foreach (Connection *c, dataOut_->connections ()) c->updatePositions (); + } scene_->contentChange (); } @@ -571,7 +573,7 @@ void SceneElement::resetCodeGeneration() void SceneElement::replaceCodeBlock(QString _name, QString _id, QString _value) { QString regex = "\\[\\s*" + _name + "\\s*=\\s*\"" + _id + "\"\\s*\\]"; - code_ = code_.replace (QRegExp (regex), _value); + code_ = code_.replace (QRegularExpression (regex), _value); } //------------------------------------------------------------------------------ @@ -622,7 +624,7 @@ bool SceneElement::isBefore(SceneElement * _e) } } - if (dataOut ()) + if (dataOut ()) { foreach (Connection *c, dataOut ()->connections ()) { if (c->input ()->element () == _e) @@ -631,6 +633,7 @@ bool SceneElement::isBefore(SceneElement * _e) if (rv) return true; } + } return false; } @@ -651,7 +654,7 @@ bool SceneElement::isAfter(SceneElement * _e) } } - if (dataIn ()) + if (dataIn ()) { foreach (Connection *c, dataIn ()->connections ()) { if (c->output ()->element () == _e) @@ -660,6 +663,7 @@ bool SceneElement::isAfter(SceneElement * _e) if (rv) return true; } + } return false; } @@ -677,13 +681,15 @@ void VSI::SceneElement::invalidateConnections() foreach (Connection *c, e->connections ()) c->invalidate (); - if (dataIn_) + if (dataIn_) { foreach (Connection *c, dataIn_->connections ()) c->invalidate (); + } - if (dataOut_) + if (dataOut_) { foreach (Connection *c, dataOut_->connections ()) c->invalidate (); + } } //------------------------------------------------------------------------------ diff --git a/scene/sceneElement.hh b/scene/sceneElement.hh index 5279fe9..22c56e0 100644 --- a/scene/sceneElement.hh +++ b/scene/sceneElement.hh @@ -49,7 +49,6 @@ #include <QString> #include <QDomDocument> #include <QDomElement> -#include <QXmlQuery> //== FORWARDDECLARATIONS ====================================================== class QGraphicsLinearLayout; diff --git a/scene/trash.cc b/scene/trash.cc index 4a1858e..68c9696 100644 --- a/scene/trash.cc +++ b/scene/trash.cc @@ -103,13 +103,14 @@ void Trash::hoverLeaveEvent (QGraphicsSceneHoverEvent * /*_event*/) // delete selected elements on mouse press void Trash::mousePressEvent (QGraphicsSceneMouseEvent * /*_event*/) { - if (!scene_->selectedItems ().isEmpty ()) + if (!scene_->selectedItems ().isEmpty ()) { foreach (QGraphicsItem *e, scene_->selectedItems ()) { SceneElement *se = dynamic_cast<SceneElement *> (e); if (se && scene_->removeElement (se)) delete se; } + } } //------------------------------------------------------------------------------ diff --git a/vsiPlugin.cc b/vsiPlugin.cc index 113e448..3b6cece 100644 --- a/vsiPlugin.cc +++ b/vsiPlugin.cc @@ -201,7 +201,11 @@ QString VsiPlugin::askForInputs(QString _element, QString _inputs) QString result("{"); bool first = true; +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) foreach (QString s, _inputs.split (",", QString::SkipEmptyParts)) { +#else + foreach (QString s, _inputs.split (",", Qt::SkipEmptyParts)) { +#endif QString value(results[s]); if (!first) result += ","; // value.replace("\"", "\\\""); -- GitLab