diff options
Diffstat (limited to 'tikzit/graphelementproperty.cpp')
-rw-r--r-- | tikzit/graphelementproperty.cpp | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/tikzit/graphelementproperty.cpp b/tikzit/graphelementproperty.cpp index 7602b1c..9cc6b00 100644 --- a/tikzit/graphelementproperty.cpp +++ b/tikzit/graphelementproperty.cpp @@ -1,16 +1,19 @@ #include "graphelementproperty.h" -GraphElementProperty::GraphElementProperty(QString key, QString value, - bool atom, bool keyMatch, QObject *parent) : - QObject(parent), _key(key), _value(value), _atom(atom), _keyMatch(keyMatch) +GraphElementProperty::GraphElementProperty (): + _key(""), _value(""), _atom(false), _keyMatch(false) {} -GraphElementProperty::GraphElementProperty(QString key, QString value, QObject *parent) : - QObject(parent), _key(key), _value(value), _atom(false), _keyMatch(false) +GraphElementProperty::GraphElementProperty(QString key, QString value, bool atom, bool keyMatch) : + _key(key), _value(value), _atom(atom), _keyMatch(keyMatch) {} -GraphElementProperty::GraphElementProperty(QString key, QObject *parent) : - QObject(parent), _key(key), _value(""), _atom(true), _keyMatch(false) +GraphElementProperty::GraphElementProperty(QString key, QString value) : + _key(key), _value(value), _atom(false), _keyMatch(false) +{} + +GraphElementProperty::GraphElementProperty(QString key, bool keyMatch) : + _key(key), _value(""), _atom(!keyMatch), _keyMatch(keyMatch) {} QString GraphElementProperty::key() const @@ -19,16 +22,24 @@ QString GraphElementProperty::key() const QString GraphElementProperty::value() const { return _value; } +void GraphElementProperty::setValue(const QString &value) +{ _value = value; } + bool GraphElementProperty::atom() const { return _atom; } bool GraphElementProperty::keyMatch() const { return _keyMatch; } -bool GraphElementProperty::matches(GraphElementProperty *p) +bool GraphElementProperty::matches(const GraphElementProperty &p) +{ + if (p.atom()) return _atom && _key == p.key(); + if (p.keyMatch()) return !_atom && _key == p.key(); + if (_keyMatch) return !p.atom() && _key == p.key(); + return !_atom && _key == p.key() && _value == p.value(); +} + +bool GraphElementProperty::operator==(const GraphElementProperty &p) { - if (p->atom()) return _atom && _key == p->key(); - if (p->keyMatch()) return !_atom && _key == p->key(); - if (_keyMatch) return !p->atom() && _key == p->key(); - return !_atom && _key == p->key() && _value == p->value(); + return matches(p); } |