[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [rocs/dataUseOnlyDynamicProperties] src: Do not use fix encoded data names and values but use proper
From: Andreas Cord-Landwehr <cola () uni-paderborn ! de>
Date: 2012-09-22 18:48:58
Message-ID: 20120922184858.1BD4CA6094 () git ! kde ! org
[Download RAW message or body]
Git commit c6f1a92e69bae8b1e15ff928f7f6b97b5c2fefad by Andreas Cord-Landwehr.
Committed on 21/09/2012 at 22:02.
Pushed by cordlandwehr into branch 'dataUseOnlyDynamicProperties'.
Do not use fix encoded data names and values but use properties.
With this commit the value/name elements of data elements are removed.
Instead from now on those values have to be saved by properties.
M +0 -18 src/Core/ConcurrentHelpClasses.h
M +34 -74 src/Core/Data.cpp
M +20 -31 src/Core/Data.h
M +11 -27 src/Core/DataStructure.cpp
M +2 -18 src/Core/DataStructure.h
M +68 -2 src/Core/DataType.cpp
M +44 -0 src/Core/DataType.h
M +6 -6 src/Core/Modifiers/ValueModifier.cpp
M +111 -59 src/GraphicsItem/DataItem.cpp
M +12 -6 src/GraphicsItem/DataItem.h
M +3 -3 src/GraphicsItem/GraphicsLayout.cpp
M +4 -4 src/Interface/DataPropertiesWidget.cpp
M +3 -3 src/Interface/VisualEditor/GraphScene.cpp
M +1 -1 src/LoadSave/Plugins/dotFileFormat/DotFileFormatPlugin.cpp
M +1 -1 src/LoadSave/Plugins/dotFileFormat/DotGraphParsingHelper.cpp
M +3 -3 src/LoadSave/Plugins/gmlFileFormat/GmlFileFormatPlugin.cpp
M +2 -2 src/LoadSave/Plugins/kmlFileFormat/KmlFileFormatPlugin.cpp
M +1 -1 src/LoadSave/Plugins/tgfFileFormat/Tests/TestTgfFileFormatPlugin.cpp
M +1 -1 src/LoadSave/Plugins/tgfFileFormat/TgfFileFormatPlugin.cpp
M +2 -2 src/LoadSave/Plugins/tikzFileFormat/TikzFileFormatPlugin.cpp
M +0 -1 src/LoadSave/RocsGraphFileFormatPlugin.cpp
M +2 -3 src/Models/model_GraphProperties.cpp
M +3 -3 src/Plugins/DataStructure/Graph/GraphStructure.cpp
M +2 -2 src/Plugins/DataStructure/LinkedList/ListPlugin.cpp
M +4 -4 src/Plugins/DataStructure/LinkedList/ListStructure.cpp
M +1 -1 src/Plugins/DataStructure/RootedTree/RootedTreePlugin.cpp
M +5 -5 src/Plugins/DataStructure/RootedTree/RootedTreeStructure.cpp
http://commits.kde.org/rocs/c6f1a92e69bae8b1e15ff928f7f6b97b5c2fefad
diff --git a/src/Core/ConcurrentHelpClasses.h b/src/Core/ConcurrentHelpClasses.h
index 32ff823..c9cdf6e 100644
--- a/src/Core/ConcurrentHelpClasses.h
+++ b/src/Core/ConcurrentHelpClasses.h
@@ -42,15 +42,6 @@ struct PointerColorSetted {
const QColor& m_color;
};
-struct DataNameVisibilitySetted {
- DataNameVisibilitySetted(bool visibility) : m_visibility(visibility) {}
- typedef void result_type;
- void operator()(DataPtr d) {
- d->setNameVisible(m_visibility);
- }
- bool m_visibility;
-};
-
struct PointerNameVisibilitySetted {
PointerNameVisibilitySetted(bool visibility) : m_visibility(visibility) {}
typedef void result_type;
@@ -60,15 +51,6 @@ struct PointerNameVisibilitySetted {
bool m_visibility;
};
-struct DataValueVisibilitySetted {
- DataValueVisibilitySetted(bool visibility) : m_visibility(visibility) {}
- typedef void result_type;
- void operator()(DataPtr d) {
- d->setValueVisible(m_visibility);
- }
- bool m_visibility;
-};
-
struct PointerValueVisibilitySetted {
PointerValueVisibilitySetted(bool visibility) : m_visibility(visibility) {}
typedef void result_type;
diff --git a/src/Core/Data.cpp b/src/Core/Data.cpp
index 9823fef..f33a4b3 100644
--- a/src/Core/Data.cpp
+++ b/src/Core/Data.cpp
@@ -44,18 +44,14 @@ public:
qreal _x;
qreal _y;
qreal _width;
- bool _showName;
- bool _showValue;
bool _visible;
bool _colored;
DataStructurePtr _dataStructure;
int _uniqueIdentifier;
- int _dataType;
- QString _name;
+ DataTypePtr _dataType;
QColor _color;
- QVariant _value;
QScriptValue _scriptvalue;
QScriptEngine *_engine;
@@ -76,16 +72,13 @@ DataPrivate::DataPrivate(DataStructurePtr parent, int \
uniqueIdentifier, int data : _x(0)
, _y(0)
, _width(0.3)
- , _showName(parent->isDataNameVisible(dataType))
- , _showValue(parent->isDataValueVisible(dataType))
, _visible(parent->isDataVisible(dataType))
, _colored(false)
, _dataStructure(parent)
, _uniqueIdentifier(uniqueIdentifier)
- , _dataType(dataType)
, _color(parent->document()->dataType(dataType)->defaultColor())
- , _value(0)
{
+ _dataType = _dataStructure->document()->dataType(dataType);
_inPointers = PointerList();
_outPointers = PointerList();
}
@@ -126,6 +119,17 @@ void Data::setQpointer(DataPtr q)
d->q = q;
}
+void Data::initialize()
+{
+ installEventFilter(this);
+ foreach(QString property, d->_dataType->properties()) {
+ addDynamicProperty(property, d->_dataType->propertyDefaultValue(property));
+ }
+
+ connect(d->_dataType.get(), SIGNAL(propertyAdded(QString, QVariant)),
+ this, SLOT(addDynamicProperty(QString,QVariant)));
+}
+
DataPtr Data::getData() const
{
DataPtr px(d->q);
@@ -148,25 +152,19 @@ Data::~Data()
}
}
-DataStructurePtr Data::dataStructure() const
-{
- return d->_dataStructure;
-}
-
-void Data::setNameVisible(bool visible)
-{
- if (d->_showName != visible) {
- d->_showName = visible;
- emit nameVisibilityChanged(visible);
+bool Data::eventFilter(QObject *obj, QEvent *event){
+ if (event->type() == QEvent::DynamicPropertyChange) {
+ if (QDynamicPropertyChangeEvent* const dynEvent = \
dynamic_cast<QDynamicPropertyChangeEvent*>(event)) { + event->accept();
+ emit(propertyChanged(dynEvent->propertyName()));
+ }
}
+ return QObject::eventFilter(obj, event);
}
-void Data::setValueVisible(bool visible)
+DataStructurePtr Data::dataStructure() const
{
- if (d->_showValue != visible) {
- d->_showValue = visible;
- emit valueVisibilityChanged(visible);
- }
+ return d->_dataStructure;
}
void Data::setColored(bool b)
@@ -191,7 +189,7 @@ void Data::setVisible(bool visible)
void Data::setDataType(int dataType)
{
Q_ASSERT(d->_dataStructure->document()->dataTypeList().contains(dataType));
- d->_dataType = dataType;
+ d->_dataType = d->_dataStructure->document()->dataType(dataType);
d->_dataStructure->updateData(getData());
emit dataTypeChanged(dataType);
}
@@ -312,16 +310,6 @@ void Data::remove()
emit removed();
}
-const QVariant Data::value() const
-{
- return d->_value;
-}
-
-const QString& Data::name() const
-{
- return d->_name;
-}
-
const QVariant Data::color() const
{
return d->_color;
@@ -344,7 +332,12 @@ qreal Data::width() const
QString Data::icon() const
{
- return d->_dataStructure->document()->dataType(d->_dataType)->iconName();
+ return d->_dataType->iconName();
+}
+
+QList< QString > Data::properties() const
+{
+ return d->_dataType->properties();
}
PointerList& Data::inPointerList() const
@@ -357,16 +350,6 @@ PointerList& Data::outPointerList() const
return d->_outPointers;
}
-bool Data::isNameVisible() const
-{
- return d->_showName;
-}
-
-bool Data::isValueVisible() const
-{
- return d->_showValue;
-}
-
bool Data::isColored() const
{
return d->_colored;
@@ -379,7 +362,7 @@ int Data::identifier() const
int Data::dataType() const
{
- return d->_dataType;
+ return d->_dataType->identifier();
}
void Data::setX(int x)
@@ -424,42 +407,19 @@ void Data::setColor(const QVariant& s)
}
}
-void Data::setName(const QString& s)
-{
- if (d->_name != s) {
- d->_name = s;
- emit nameChanged(s);
- }
-}
-
-void Data::setValue(const QVariant& s)
-{
- if (d->_value != s) {
- d->_value = s;
- emit valueChanged(s);
- }
-}
-
-void Data::setValue(const QString& s)
-{
- QVariant v(s);
- if (d->_value != v) {
- d->_value = v;
- emit valueChanged(v);
- }
-}
-
void Data::addDynamicProperty(QString property, QVariant value)
{
- if (! setProperty(property.toUtf8(), value) && value.isValid()) {
+ if (!setProperty(property.toUtf8(), value) && value.isValid()) {
DynamicPropertiesList::New()->addProperty(this, property);
}
+ emit(propertyAdded(property));
}
void Data::removeDynamicProperty(QString property)
{
addDynamicProperty(property.toUtf8(), QVariant::Invalid);
DynamicPropertiesList::New()->removeProperty(this, property);
+ emit(propertyRemoved(property));
}
QScriptValue Data::scriptValue() const
@@ -485,7 +445,7 @@ QScriptValue Data::set_type(int dataType)
QScriptValue Data::type()
{
- return d->_dataStructure->engine()->newVariant(d->_dataType);
+ return d->_dataStructure->engine()->newVariant(d->_dataType->identifier());
}
void Data::add_property(QString name, QString value)
diff --git a/src/Core/Data.h b/src/Core/Data.h
index 3b5b401..14e2714 100644
--- a/src/Core/Data.h
+++ b/src/Core/Data.h
@@ -46,10 +46,8 @@ class ROCSLIB_EXPORT Data : public QObject
Q_PROPERTY(qreal x READ x WRITE setX)
Q_PROPERTY(qreal y READ y WRITE setY)
Q_PROPERTY(qreal width READ width WRITE setWidth)
- Q_PROPERTY(QString name READ name WRITE setName)
Q_PROPERTY(int id READ identifier)
Q_PROPERTY(QVariant color READ color WRITE setColor)
- Q_PROPERTY(QVariant value READ value WRITE setValue)
public:
/**
@@ -152,15 +150,7 @@ public:
*/
QString icon() const;
- /**
- * \return true if data name is visible, otherwise false
- */
- bool isNameVisible() const;
-
- /**
- * \return true if data value is visible, otherwise false
- */
- bool isValueVisible() const;
+ QList<QString> properties() const;
/**
* \return true if data element is visible, otherwise false
@@ -207,6 +197,17 @@ public:
*/
PointerList& outPointerList() const;
+public slots:
+ void remove();
+ void setX(int x);
+ void setY(int y);
+ void setWidth(double w);
+ void setPos(qreal x, qreal y);
+ void setColor(const QVariant& s);
+ void setColored(bool b = true);
+ void setVisible(bool visible);
+ void setDataType(int dataType);
+
/**
* Add new dynamic property with identifier \p property to this data element and
* sets it to \p value.
@@ -223,22 +224,6 @@ public:
*/
void removeDynamicProperty(QString property);
-public slots:
- void remove();
- void setX(int x);
- void setY(int y);
- void setWidth(double w);
- void setPos(qreal x, qreal y);
- void setColor(const QVariant& s);
- void setName(const QString& s);
- void setValue(const QVariant& v);
- void setNameVisible(bool visible);
- void setValueVisible(bool visible);
- void setColored(bool b = true);
- void setVisible(bool visible);
- void setValue(const QString& v);
- void setDataType(int dataType);
-
/**
* FIXME proof of concept implementation: since each Pointer emits a changed \
direction signal,
* there are unnecessary many updates.
@@ -264,14 +249,13 @@ signals:
void posChanged(const QPointF p);
void widthChanged(double w);
void colorChanged(const QColor& c);
- void nameChanged(const QString& name);
- void valueChanged(const QVariant& v);
- void nameVisibilityChanged(bool b);
- void valueVisibilityChanged(bool b);
void visibilityChanged(bool visible);
void useColorChanged(bool b);
void dataTypeChanged(int dataType);
void pointerListChanged();
+ void propertyAdded(QString name);
+ void propertyRemoved(QString name);
+ void propertyChanged(QString name);
protected:
/**
@@ -286,9 +270,12 @@ protected:
static DataPtr create(DataStructurePtr parent, int uniqueIdentifier, int \
dataType) { DataPtr pi(new T(parent, uniqueIdentifier, dataType));
pi->setQpointer(pi);
+ pi->initialize();
return pi;
}
+ bool eventFilter(QObject *obj, QEvent *event);
+
private:
/**
* \internal
@@ -301,6 +288,8 @@ private:
* Set q-pointer in private data object.
*/
void setQpointer(DataPtr q);
+
+ void initialize();
Data(Data const &, int uniqueIdentifier, int dataType);
Data & operator=(Data const &);
};
diff --git a/src/Core/DataStructure.cpp b/src/Core/DataStructure.cpp
index 5195ec2..fd4e3d5 100644
--- a/src/Core/DataStructure.cpp
+++ b/src/Core/DataStructure.cpp
@@ -139,9 +139,9 @@ void DataStructure::importStructure(DataStructurePtr other)
QHash <Data*, DataPtr > dataTodata;
foreach(DataPtr n, other->dataList()) {
- DataPtr newdata = addData(n->name());
+ DataPtr newdata = addData(n->property("name").toString());
newdata->setColor(n->color());
- newdata->setValue(n->value());
+ //FIXME all dynamic properties must be set
newdata->setX(n->x());
newdata->setY(n->y());
newdata->setWidth(n->width());
@@ -366,7 +366,11 @@ DataPtr DataStructure::addData(QString name, int dataType)
}
DataPtr n = Data::create(this->getDataStructure(), generateUniqueIdentifier(), \
dataType);
- n->setName(name);
+
+ if (n->property("name") == QVariant::Invalid) {
+ document()->dataType(dataType)->addProperty("name");
+ }
+ n->setProperty("name", name);
return addData(n, dataType);
}
@@ -384,12 +388,9 @@ DataPtr DataStructure::addData(DataPtr data, int dataType)
emit changed();
// connect(data.get(), SIGNAL(removed()), this, \
SIGNAL(changed())); //FIXME removed for now
- connect(data.get(), SIGNAL(nameChanged(QString)), this, \
SIGNAL(changed()));
- connect(data.get(), SIGNAL(valueChanged(QVariant)), this, \
SIGNAL(changed())); + connect(data.get(), SIGNAL(propertyChanged(QString)), \
this, SIGNAL(changed()));
connect(data.get(), SIGNAL(colorChanged(QColor)), this, \
SIGNAL(changed()));
connect(data.get(), SIGNAL(posChanged(QPointF)), this, \
SIGNAL(changed()));
- connect(data.get(), SIGNAL(nameVisibilityChanged(bool)), this, \
SIGNAL(changed()));
- connect(data.get(), SIGNAL(valueVisibilityChanged(bool)), this, \
SIGNAL(changed()));
connect(data.get(), SIGNAL(useColorChanged(bool)), this, \
SIGNAL(changed())); return data;
}
@@ -402,12 +403,9 @@ DataList DataStructure::addDataList(DataList dataList, int \
dataType) d->_dataTypeLists[dataType].append(n);
emit dataCreated(n);
// connect(n.get(), SIGNAL(removed()), this, \
SIGNAL(changed())); //FIXME removed for now
- connect(n.get(), SIGNAL(nameChanged(QString)), this, \
SIGNAL(changed()));
- connect(n.get(), SIGNAL(valueChanged(QVariant)), this, \
SIGNAL(changed())); + connect(n.get(), SIGNAL(propertyChanged(QString)), \
this, SIGNAL(changed()));
connect(n.get(), SIGNAL(colorChanged(QColor)), this, \
SIGNAL(changed()));
connect(n.get(), SIGNAL(posChanged(QPointF)), this, \
SIGNAL(changed()));
- connect(n.get(), SIGNAL(nameVisibilityChanged(bool)), this, \
SIGNAL(changed()));
- connect(n.get(), SIGNAL(valueVisibilityChanged(bool)), this, \
SIGNAL(changed()));
connect(n.get(), SIGNAL(useColorChanged(bool)), this, \
SIGNAL(changed())); }
emit changed();
@@ -641,29 +639,15 @@ void DataStructure::setPointerColor(QColor color, int \
pointerType) }
-void DataStructure::setDataNameVisibility(bool visible, int dataType)
-{
- d->_dataTypeNameVisibility[dataType] = visible;
- QtConcurrent::blockingMap(d->_dataTypeLists[dataType], \
DataNameVisibilitySetted(visible));
-}
-
-
void DataStructure::toggleDataNameVisibility(int dataType)
{
- setDataNameVisibility(!isDataNameVisible(dataType), dataType);
-}
-
-
-void DataStructure::setDataValueVisibility(bool visible, int dataType)
-{
- d->_dataTypeValueVisibility[dataType] = visible;
- QtConcurrent::blockingMap(d->_dataTypeLists[dataType], \
DataValueVisibilitySetted(visible)); + kFatal() << "must be ported";
}
void DataStructure::toggleDataValueVisibility(int dataType)
{
- setDataValueVisibility(!isDataValueVisible(dataType), dataType);
+ kFatal() << "must be ported";
}
diff --git a/src/Core/DataStructure.h b/src/Core/DataStructure.h
index 10ace45..aa4cafc 100644
--- a/src/Core/DataStructure.h
+++ b/src/Core/DataStructure.h
@@ -227,26 +227,10 @@ public slots:
*/
void setDataColor(QColor color, int dataType);
- /**
- * Set all names of all data elements of given \param dataType to the given \
value of \param visible.
- * This is a fast implementation that starts several threads for updating all \
data elements in parallel.
- *
- * \param visible must be true if data names shall be shown, false if hidden
- * \param dataType is the identifier of the data type for that this function has \
affect.
- */
- void setDataNameVisibility(bool visible, int dataType);
-
+ //FIXME remove
void toggleDataNameVisibility(int dataType);
- /**
- * Set all values of all data of given \param dataType to the given value of \
\param visible.
- * This is a fast implementation that starts several threads for updating all \
data types in parallel.
- *
- * \param visible must be true if data values shall be shown, false if hidden
- * \param dataType is the identifier of the data type for that this function has \
affect.
- */
- void setDataValueVisibility(bool visible, int dataType);
-
+ //FIXME remove
void toggleDataValueVisibility(int dataType);
/**
diff --git a/src/Core/DataType.cpp b/src/Core/DataType.cpp
index d73051d..a18005b 100644
--- a/src/Core/DataType.cpp
+++ b/src/Core/DataType.cpp
@@ -29,15 +29,20 @@
class DataTypePrivate
{
public:
+ struct Property {
+ QString name;
+ QVariant defaultValue;
+ bool visible;
+ };
+
DataTypePrivate() {}
boost::weak_ptr<DataType> q; // self pointer
+ QList<Property> _properties;
QString _name;
QString _icon;
QColor _defaultColor;
int _identifier;
- bool _valueVisibility;
- bool _nameVisibility;
bool _visibility;
Document* _document;
};
@@ -47,6 +52,7 @@ DataTypePtr DataType::create(Document* document, int identifier)
{
DataTypePtr pi(new DataType(document, identifier));
pi->d->q = pi;
+ pi->addProperty("name", "");
return pi;
}
@@ -144,6 +150,66 @@ const QColor& DataType::defaultColor() const
return d->_defaultColor;
}
+void DataType::addProperty(QString name, QString defaultValue)
+{
+ DataTypePrivate::Property newProperty;
+ newProperty.name = name;
+ newProperty.defaultValue = defaultValue;
+ newProperty.visible = true;
+ d->_properties.append(newProperty);
+ emit(propertyAdded(newProperty.name, newProperty.defaultValue));
+}
+
+QList<QString> DataType::properties() const
+{
+ QList<QString> properties;
+ QList<DataTypePrivate::Property>::const_iterator iter = \
d->_properties.constBegin(); + while (iter != d->_properties.constEnd()) {
+ properties.append(iter->name);
+ ++iter;
+ }
+ return properties;
+}
+
+QVariant DataType::propertyDefaultValue(QString name) const
+{
+ //FIXME very inefficient with this implementation, but working
+ QList<QString> properties;
+ QList<DataTypePrivate::Property>::const_iterator iter = \
d->_properties.constBegin(); + while (iter != d->_properties.constEnd()) {
+ if (name == iter->name) {
+ return iter->defaultValue;
+ }
+ }
+ return false;
+}
+
+bool DataType::isPropertyVisible(QString name) const
+{
+ //FIXME very inefficient with this implementation, but working
+ QList<QString> properties;
+ QList<DataTypePrivate::Property>::const_iterator iter = \
d->_properties.constBegin(); + while (iter != d->_properties.constEnd()) {
+ if (name == iter->name) {
+ return iter->visible;
+ }
+ }
+ return false;
+}
+
+void DataType::setPropertyVisible(QString name, bool visible)
+{
+ //FIXME very inefficient with this implementation, but working
+ QList<QString> properties;
+ QList<DataTypePrivate::Property>::iterator iter = d->_properties.begin();
+ while (iter != d->_properties.end()) {
+ if (name == iter->name) {
+ iter->visible = visible;
+ return;
+ }
+ }
+}
+
void DataType::remove()
{
d->_document->removeDataType(identifier());
diff --git a/src/Core/DataType.h b/src/Core/DataType.h
index 339c6b1..95b0d90 100644
--- a/src/Core/DataType.h
+++ b/src/Core/DataType.h
@@ -21,6 +21,7 @@
#define DATATYPE_H
#include <QString>
+#include <QVariant>
#include <QColor>
#include <KIcon>
@@ -84,6 +85,34 @@ public:
*/
const QColor& defaultColor() const;
+ /**
+ * Add a new dynamic property to all data elements of this data type.
+ *
+ * \param name is the unique name of the property
+ * \param defaultValue is the default value that is set initially
+ */
+ void addProperty(QString name, QString defaultValue = "");
+
+ /**
+ * \return list of all properties, ordered in display order
+ */
+ QList<QString> properties() const;
+
+ /**
+ * \return default value for property \p name
+ */
+ QVariant propertyDefaultValue(QString name) const;
+
+ /**
+ * \return true if this property is visible, otherwise false.
+ */
+ bool isPropertyVisible(QString name) const;
+
+ /**
+ * Set visibility of property \p name to \p visible.
+ */
+ void setPropertyVisible(QString name, bool visible);
+
public slots:
/**
* Set name of the data type.
@@ -128,6 +157,21 @@ signals:
*/
void nameChanged(const QString& name);
+ /**
+ * Emitted when new property was created.
+ */
+ void propertyAdded(const QString& name, const QVariant& defaultValue);
+
+ /**
+ * Emitted when property was removed.
+ */
+ void propertyRemoved(const QString& name);
+
+ /**
+ * Emitted when either the visibility or the order of propeties was changed.
+ */
+ void propertyListChanged();
+
protected:
/**
* \internal
diff --git a/src/Core/Modifiers/ValueModifier.cpp \
b/src/Core/Modifiers/ValueModifier.cpp index d0427fe..6bf21fe 100644
--- a/src/Core/Modifiers/ValueModifier.cpp
+++ b/src/Core/Modifiers/ValueModifier.cpp
@@ -41,9 +41,9 @@ ValueModifier::~ValueModifier()
void ValueModifier::enumerate(QList<DataPtr> dataList, int start, bool \
overrideValues = true) {
for (int i = 0; i < dataList.size(); i++) {
- if (!overrideValues && !dataList[i]->value().isNull())
+ if (!overrideValues && !dataList[i]->property("value").isNull())
return;
- dataList[i]->setValue(QString::number(start++));
+ dataList[i]->setProperty("value", QString::number(start++));
}
}
@@ -70,9 +70,9 @@ void ValueModifier::assignRandomIntegers(QList<DataPtr> dataList, \
int lowerLimit
boost::variate_generator<boost::mt19937&, boost::uniform_int<> > die(gen, \
distribution);
for (int i = 0; i < dataList.size(); i++) {
- if (!overrideValues && !dataList[i]->value().isNull())
+ if (!overrideValues && !dataList[i]->property("value").isNull())
return;
- dataList[i]->setValue(QString::number(die()));
+ dataList[i]->setProperty("value", QString::number(die()));
}
}
@@ -108,9 +108,9 @@ void ValueModifier::assignRandomReals(QList<DataPtr> dataList, \
qreal lowerLimit,
boost::variate_generator<boost::mt19937&, boost::uniform_real<> > die(gen, \
distribution);
for (int i = 0; i < dataList.size(); i++) {
- if (!overrideValues && !dataList[i]->value().isNull())
+ if (!overrideValues && !dataList[i]->property("value").isNull())
return;
- dataList[i]->setValue(QString::number(die()));
+ dataList[i]->setProperty("value", QString::number(die()));
}
}
diff --git a/src/GraphicsItem/DataItem.cpp b/src/GraphicsItem/DataItem.cpp
index 4584204..77a504f 100644
--- a/src/GraphicsItem/DataItem.cpp
+++ b/src/GraphicsItem/DataItem.cpp
@@ -28,6 +28,7 @@
#include <QFont>
#include <QGraphicsColorizeEffect>
#include <QGraphicsScene>
+#include <QGraphicsItem>
#include <QSvgRenderer>
QMap<QString, QSvgRenderer*> DataItem::_sharedRenderers;
@@ -58,33 +59,29 @@ void DataItem::removeSharedRenderer(QString iconPackage)
DataItem::DataItem(DataPtr n)
: QGraphicsSvgItem(0)
, _data(n)
- , _name(0)
- , _value(0)
, _colorizer(0)
, _font(QFont("Helvetica [Cronyx]", 12))
, _oldStyle(GraphicsLayout::self()->viewStyleDataNode())
+ , _item(new QGraphicsItemGroup())
, _originalWidth(n->width())
, _oldDataType(n->dataStructure()->document()->dataType(n->dataType()))
{
connect(n.get(), SIGNAL(removed()), this, SLOT(deleteLater()));
connect(_oldDataType.get(), SIGNAL(iconChanged(QString)), this, \
SLOT(updateIcon()));
- connect(n.get(), SIGNAL(nameChanged(QString)), this, SLOT(updateName()));
- connect(n.get(), SIGNAL(valueChanged(QVariant)), this, SLOT(updateValue()));
+
+ connect(n.get(), SIGNAL(propertyAdded(QString)), this, \
SLOT(registerProperty(QString))); + connect(n.get(), \
SIGNAL(propertyRemoved(QString)), this, SLOT(removeProperty(QString))); + \
connect(n.get(), SIGNAL(propertyChanged(QString)), this, \
SLOT(updateProperty(QString))); + connect(GraphicsLayout::self(), \
SIGNAL(changed()), this, SLOT(updatePropertyList())); +
connect(n.get(), SIGNAL(colorChanged(QColor)), this, SLOT(updateColor()));
connect(n.get(), SIGNAL(posChanged(QPointF)), this, SLOT(updatePos()));
- connect(n.get(), SIGNAL(nameVisibilityChanged(bool)), this, SLOT(updateName()));
- connect(n.get(), SIGNAL(valueVisibilityChanged(bool)), this, \
SLOT(updateValue()));
connect(n.get(), SIGNAL(visibilityChanged(bool)), this, \
SLOT(updateVisibility(bool)));
connect(n.get(), SIGNAL(useColorChanged(bool)), this, SLOT(updateColor()));
connect(n.get(), SIGNAL(widthChanged(double)), this, SLOT(updateSize()));
connect(n.get(), SIGNAL(dataTypeChanged(int)), this, SLOT(setupNode()));
- connect(GraphicsLayout::self(), SIGNAL(changed()), this, SLOT(updateName()));
- connect(GraphicsLayout::self(), SIGNAL(changed()), this, SLOT(updateValue()));
- connect(n.get(), SIGNAL(valueVisibilityChanged(bool)), this, \
SLOT(updateName()));
- connect(n.get(), SIGNAL(nameVisibilityChanged(bool)), this, \
SLOT(updateValue()));
-
setCacheMode(QGraphicsItem::DeviceCoordinateCache);
setZValue(1);
setFlag(ItemIsSelectable, true);
@@ -93,8 +90,11 @@ DataItem::DataItem(DataPtr n)
DataItem::~DataItem()
{
- delete _name;
- delete _value;
+ foreach (QString name, _propertyValues.keys()) {
+ delete _propertyValues[name];
+ }
+ _propertyValues.clear();
+ delete _item;
}
void DataItem::setupNode()
@@ -105,13 +105,15 @@ void DataItem::setupNode()
connect(_oldDataType.get(), SIGNAL(iconChanged(QString)), this, \
SLOT(updateIcon())); }
- updateName();
- updateValue();
+ foreach (QString name, _data->properties()) {
+ updateProperty(name);
+ }
updateRenderer();
updateIcon();
updateColor();
updateSize();
updatePos();
+ updatePropertyList();
update();
}
@@ -119,8 +121,6 @@ void DataItem::updatePos()
{
int fixPos = boundingRect().width() / 2;
setPos(_data->x() - fixPos, _data->y() - fixPos);
- updateName();
- updateValue();
}
void DataItem::updateSize()
@@ -131,8 +131,6 @@ void DataItem::updateSize()
resetTransform();
_width = _data->width();
setScale(_data->width());
- updateName();
- updateValue();
}
void DataItem::updateRenderer()
@@ -160,12 +158,18 @@ void DataItem::updateVisibility(bool visible)
{
if (visible == true) {
this->show();
- _name->setVisible(_data->isNameVisible());
- _value->setVisible(_data->isValueVisible());
+ QMap<QString, QGraphicsSimpleTextItem*>::const_iterator iter = \
_propertyValues.constBegin(); + while (iter != _propertyValues.constEnd()) {
+ (*iter)->setVisible(true);
+ ++iter;
+ }
} else {
this->hide();
- _value->setVisible(false);
- _name->setVisible(false);
+ QMap<QString, QGraphicsSimpleTextItem*>::const_iterator iter = \
_propertyValues.constBegin(); + while (iter != _propertyValues.constEnd()) {
+ (*iter)->setVisible(false);
+ ++iter;
+ }
}
}
@@ -176,8 +180,6 @@ void DataItem::updateColor()
if (!_data->isColored()) {
delete _colorizer;
setGraphicsEffect(0);
- _name->setBrush(QBrush(Qt::black));
- _value->setBrush(QBrush(Qt::black));
_colorizer = 0;
return;
}
@@ -186,54 +188,104 @@ void DataItem::updateColor()
_colorizer = new QGraphicsColorizeEffect();
_colorizer->setColor(c);
setGraphicsEffect(_colorizer);
- _name->setBrush(QBrush(c));
- _value->setBrush(QBrush(c));
}
-void DataItem::updateName()
+void DataItem::updateProperty(QString name)
{
- if (!_name) {
- _name = new QGraphicsSimpleTextItem(i18n("%1", _data->name()));
- _name->setFlags(ItemIgnoresTransformations);
- _name->setFont(_font);
- _name->setZValue(zValue() + 1);
- } else if (_name->text() != _data->name()) {
- _name->setText(i18n("%1", _data->name()));
- }
-
- int style = GraphicsLayout::self()->viewStyleDataNode();
-
- qreal dataWidth = boundingRect().width() * scale();
-
- qreal x = pos().x();
- if (style == ConfigureDefaultProperties::CENTER) {
- x += ((dataWidth > _name->boundingRect().width() + 10)
- ? ((dataWidth - _name->boundingRect().width()) / 4)
- : dataWidth + 30);
+ if (!_propertyValues.contains(name)) {
+ registerProperty(name);
+ return;
}
+ _propertyValues[name]->setText(data()->property(name.toStdString().c_str()).toString());
+ _propertyValues[name]->update();
+}
- qreal y = pos().y() + ((style == ConfigureDefaultProperties::ABOVE) ? + 15 - \
(dataWidth / 2)
- : (style == ConfigureDefaultProperties::BELOW) ? 25 + \
(dataWidth / 2)
- : 0);
-
- _name->setVisible(_data->isNameVisible());
+QGraphicsItem* DataItem::propertyListItem() const
+{
+ return _item;
+}
- if (_value && _value->isVisible()) {
- y += ((style == ConfigureDefaultProperties::ABOVE) ? -20 : 20);
+void DataItem::updatePropertyList()
+{
+ qreal offset = 0;
+ foreach (QString property, data()->properties()) {
+ if (!_propertyValues.contains(property)) {
+ kError() << "Cannot update unknown property : " << property;
+ continue;
+ }
+ _propertyValues[property]->setPos(data()->x()+20, data()->y() + offset);
+ _propertyValues[property]->setVisible(true);
+ _propertyValues[property]->update();
+
+ offset += 20;
}
- _name->setPos(x, y);
}
-QGraphicsSimpleTextItem* DataItem::name() const
+void DataItem::registerProperty(QString name)
{
- return _name;
+ if (_propertyValues.contains(name)) {
+ return;
+ }
+ // do not show property if it is not a type property
+ if (!_data->properties().contains(name)) {
+ return;
+ }
+ _propertyValues.insert(name, new \
QGraphicsSimpleTextItem(data()->property(name.toStdString().c_str()).toString())); + \
_propertyValues[name]->setFlags(ItemIgnoresTransformations); + \
_propertyValues[name]->setFont(_font); + _propertyValues[name]->setZValue(zValue() \
+ 1); + _item->addToGroup(_propertyValues[name]);
+
+ updatePropertyList();
}
-QGraphicsSimpleTextItem* DataItem::value() const
+void DataItem::removeProperty(QString name)
{
- return _value;
+ if (_propertyValues.contains(name)) {
+ kWarning() << "Property not removed: not registered at DataItem.";
+ return;
+ }
+ delete _propertyValues[name];
+ _propertyValues.remove(name);
+ _item->removeFromGroup(_propertyValues[name]);
+
+ updatePropertyList();
}
+// void DataItem::updateName()
+// {
+// if (!_name) {
+// _name = new QGraphicsSimpleTextItem(i18n("%1", _data->name()));
+// _name->setFlags(ItemIgnoresTransformations);
+// _name->setFont(_font);
+// _name->setZValue(zValue() + 1);
+// } else if (_name->text() != _data->name()) {
+// _name->setText(i18n("%1", _data->name()));
+// }
+//
+// int style = GraphicsLayout::self()->viewStyleDataNode();
+//
+// qreal dataWidth = boundingRect().width() * scale();
+//
+// qreal x = pos().x();
+// if (style == ConfigureDefaultProperties::CENTER) {
+// x += ((dataWidth > _name->boundingRect().width() + 10)
+// ? ((dataWidth - _name->boundingRect().width()) / 4)
+// : dataWidth + 30);
+// }
+//
+// qreal y = pos().y() + ((style == ConfigureDefaultProperties::ABOVE) ? + 15 - \
(dataWidth / 2) +// : (style == \
ConfigureDefaultProperties::BELOW) ? 25 + (dataWidth / 2) +// \
: 0); +//
+// _name->setVisible(_data->isNameVisible());
+//
+// if (_value && _value->isVisible()) {
+// y += ((style == ConfigureDefaultProperties::ABOVE) ? -20 : 20);
+// }
+// _name->setPos(x, y);
+// }
+/*
void DataItem::updateValue()
{
if (!_value) {
@@ -266,4 +318,4 @@ void DataItem::updateValue()
_value->setPos(x, y);
_value->setVisible(_data->isValueVisible());
-}
+}*/
diff --git a/src/GraphicsItem/DataItem.h b/src/GraphicsItem/DataItem.h
index 62529ad..94cfc25 100644
--- a/src/GraphicsItem/DataItem.h
+++ b/src/GraphicsItem/DataItem.h
@@ -31,6 +31,7 @@
class Data;
class QGraphicsColorizeEffect;
class QSvgRenderer;
+class QGraphicsItem;
class QGraphicsSimpleTextItem;
class ROCSLIB_EXPORT DataItem : public QGraphicsSvgItem
@@ -46,30 +47,35 @@ public:
static QSvgRenderer* sharedRenderer(QString iconPackage);
static QSvgRenderer* registerSharedRenderer(QString iconPackage);
static void removeSharedRenderer(QString iconPackage);
- QGraphicsSimpleTextItem *name() const;
- QGraphicsSimpleTextItem *value() const;
+
+ /**
+ * \return the graphics item to be displayed at the scene
+ */
+ QGraphicsItem *propertyListItem() const;
void remove();
private slots:
void setupNode();
void updateRenderer();
void updateIcon();
- void updateName();
- void updateValue();
+ void updateProperty(QString name);
+ void updatePropertyList();
void updateColor();
void updateVisibility(bool visible);
void updatePos();
void updateSize();
+ void registerProperty(QString name);
+ void removeProperty(QString name);
private:
static QMap<QString, QSvgRenderer*> _sharedRenderers;
DataPtr _data;
- QGraphicsSimpleTextItem *_name;
- QGraphicsSimpleTextItem *_value;
+ QMap<QString, QGraphicsSimpleTextItem*> _propertyValues;
QGraphicsColorizeEffect *_colorizer;
QGraphicsRectItem *_boundingRect;
QFont _font;
int _oldStyle;
+ QGraphicsItemGroup* _item;
qreal _originalWidth;
qreal _width;
diff --git a/src/GraphicsItem/GraphicsLayout.cpp \
b/src/GraphicsItem/GraphicsLayout.cpp index e11faa6..ea54dd0 100644
--- a/src/GraphicsItem/GraphicsLayout.cpp
+++ b/src/GraphicsItem/GraphicsLayout.cpp
@@ -50,9 +50,9 @@ void GraphicsLayout::setViewStyleDataNode(int style)
_viewStyleDataNode = style;
QList< DataStructurePtr > dsList = \
DocumentManager::self()->activeDocument()->dataStructures(); \
foreach(DataStructurePtr ds, dsList) {
- foreach(int identifier, ds->document()->dataTypeList()) {
- // update all data elements
- ds->setDataNameVisibility(ds->isDataNameVisible(identifier), \
identifier); + foreach(int identifier, ds->document()->pointerTypeList()) {
+ // update all pointers
+ ds->setDataVisibility(ds->isDataVisible(identifier), identifier);
}
}
emit changed();
diff --git a/src/Interface/DataPropertiesWidget.cpp \
b/src/Interface/DataPropertiesWidget.cpp index 9cf459a..03811c1 100644
--- a/src/Interface/DataPropertiesWidget.cpp
+++ b/src/Interface/DataPropertiesWidget.cpp
@@ -125,10 +125,10 @@ void DataPropertiesWidget::reflectAttributes()
}
ui->_color->setColor(_data->color().value<QColor>());
- ui->_name->setText(_data->name());
- ui->_value->setText(_data->value().toString());
- ui->_showName->setChecked(_data->isNameVisible());
- ui->_showValue->setChecked(_data->isValueVisible());
+// ui->_name->setText(_data->name());
+// ui->_value->setText(_data->value().toString());
+// ui->_showName->setChecked(_data->isNameVisible());
+// ui->_showValue->setChecked(_data->isValueVisible());
ui->_enableColor->setChecked(_data->isColored());
DataTypePtr dataType = \
_data->dataStructure()->document()->dataType(_data->dataType());
diff --git a/src/Interface/VisualEditor/GraphScene.cpp \
b/src/Interface/VisualEditor/GraphScene.cpp index 956cde4..841bfc8 100644
--- a/src/Interface/VisualEditor/GraphScene.cpp
+++ b/src/Interface/VisualEditor/GraphScene.cpp
@@ -190,8 +190,7 @@ QGraphicsItem *GraphScene::createData(DataPtr n)
{
DataItem *nItem = (DataItem*)(DataStructurePluginManager::self()->dataItem(n));
addItem(nItem);
- addItem(nItem->name());
- addItem(nItem->value());
+ addItem(nItem->propertyListItem());
return nItem;
}
@@ -279,8 +278,9 @@ void GraphScene::contextMenuEvent(QGraphicsSceneContextMenuEvent* \
event)
void GraphScene::updateGraph(DataStructurePtr g)
{
+ //FIXME this is a workaround to trigger updates
foreach(DataPtr n, g->dataList()) {
- n->setName(n->name());
+ n->setColor(n->color());
}
foreach(PointerPtr e, g->pointers()) {
diff --git a/src/LoadSave/Plugins/dotFileFormat/DotFileFormatPlugin.cpp \
b/src/LoadSave/Plugins/dotFileFormat/DotFileFormatPlugin.cpp index fdeba16..267ad07 \
100644
--- a/src/LoadSave/Plugins/dotFileFormat/DotFileFormatPlugin.cpp
+++ b/src/LoadSave/Plugins/dotFileFormat/DotFileFormatPlugin.cpp
@@ -181,7 +181,7 @@ QString const DotFileFormatPlugin::processNode(DataPtr node) \
const
// use identifier for unique identification, store name as argument "label"
nodeStr = QString("%1").arg(node->identifier());
- nodeStr.append(QString(" [label=%1 ").arg(node->name()));
+ nodeStr.append(QString(" [label=%1 ").arg(node->property("name").toString()));
foreach(const QByteArray& property, node->dynamicPropertyNames()) {
nodeStr.append(", ");
diff --git a/src/LoadSave/Plugins/dotFileFormat/DotGraphParsingHelper.cpp \
b/src/LoadSave/Plugins/dotFileFormat/DotGraphParsingHelper.cpp index 00bc231..fe6588d \
100644
--- a/src/LoadSave/Plugins/dotFileFormat/DotGraphParsingHelper.cpp
+++ b/src/LoadSave/Plugins/dotFileFormat/DotGraphParsingHelper.cpp
@@ -202,7 +202,7 @@ void DotGraphParsingHelper::createPointers()
DataPtr to = dataMap[toId];
currentPointerPtr = dataStructure->addPointer(from, to);
- kDebug() << "Creating new pointer: " << from->name() << " -> " << \
to->name(); + kDebug() << "Creating new pointer: " << from->identifier() << " \
-> " << to->identifier(); setPointerAttributes();
fromId = toId;
diff --git a/src/LoadSave/Plugins/gmlFileFormat/GmlFileFormatPlugin.cpp \
b/src/LoadSave/Plugins/gmlFileFormat/GmlFileFormatPlugin.cpp index 6cd9d41..02e3066 \
100644
--- a/src/LoadSave/Plugins/gmlFileFormat/GmlFileFormatPlugin.cpp
+++ b/src/LoadSave/Plugins/gmlFileFormat/GmlFileFormatPlugin.cpp
@@ -108,7 +108,7 @@ void GmlFileFormatPlugin::writeFile(Document& document)
out << QString("id \"%1\" \n").arg(graph->name());
foreach(DataPtr n, graph->dataListAll()) {
- out << QString("node [\n id \"%1\" \n").arg(n->name());
+ out << QString("node [\n id \"%1\" \
\n").arg(n->property("name").toString()); // foreach (QByteArray p, \
n->dynamicPropertyNames()){ // out << p << " " << \
n->property(p).toString() << "\n"; // }
@@ -135,7 +135,7 @@ void GmlFileFormatPlugin::writeFile(Document& document)
QString const GmlFileFormatPlugin::processEdge(PointerPtr e) const
{
QString edge;
- edge.append(QString("source \"%1\"\n target \"%2\"\n").arg(e->from()->name(), \
e->to()->name())); + edge.append(QString("source \"%1\"\n target \
\"%2\"\n").arg(e->from()->property("name").toString(), \
e->to()->property("name").toString())); if (!e->name().isEmpty()) {
edge.append(QString(" id \"%1\"\n").arg(e->name()));
}
@@ -158,7 +158,7 @@ QString const GmlFileFormatPlugin::processNode(DataPtr n) const
node.append(QString(" x %1 \n y %2 \n").arg(n->x()).arg(n->y()));
node.append(QString(" width %1\n").arg(n->width()));
// node.append (QString(" color \"%1\"\n").arg(n->color())); //Problem with \
comments (both starts by '#')
- node.append(QString(" value \"%1\"\n").arg(n->value().toString()));
+ node.append(QString(" value \"%1\"\n").arg(n->property("value").toString()));
node.append(QString(" iconPackage \
\"%1\"\n").arg(n->dataStructure()->document()->iconPackage())); \
node.append(QString(" icon \"%1\"\n").arg(n->icon()));
diff --git a/src/LoadSave/Plugins/kmlFileFormat/KmlFileFormatPlugin.cpp \
b/src/LoadSave/Plugins/kmlFileFormat/KmlFileFormatPlugin.cpp index fcd647d..095519e \
100644
--- a/src/LoadSave/Plugins/kmlFileFormat/KmlFileFormatPlugin.cpp
+++ b/src/LoadSave/Plugins/kmlFileFormat/KmlFileFormatPlugin.cpp
@@ -82,7 +82,7 @@ void KmlFileFormatPlugin::writeFile(Document& document)
foreach(DataPtr n, graph->dataList()) {
xmlWriter.writeStartElement("Placemark");
xmlWriter.writeStartElement("name");
- xmlWriter.writeCharacters(n->name());
+ xmlWriter.writeCharacters(n->property("name").toString());
if (n->property("description").isValid()) {
xmlWriter.writeCharacters(n->property("description").toString());
}
@@ -103,7 +103,7 @@ void KmlFileFormatPlugin::writeFile(Document& document)
xmlWriter.writeStartElement("Placemark");
xmlWriter.writeStartElement("name");
{
- QString s = graph->dataList().at(0)->name();
+ QString s = graph->dataList().at(0)->property("name").toString();
s.chop(2);
xmlWriter.writeCharacters(s);
}
diff --git a/src/LoadSave/Plugins/tgfFileFormat/Tests/TestTgfFileFormatPlugin.cpp \
b/src/LoadSave/Plugins/tgfFileFormat/Tests/TestTgfFileFormatPlugin.cpp index \
5253f55..eae383e 100644
--- a/src/LoadSave/Plugins/tgfFileFormat/Tests/TestTgfFileFormatPlugin.cpp
+++ b/src/LoadSave/Plugins/tgfFileFormat/Tests/TestTgfFileFormatPlugin.cpp
@@ -75,7 +75,7 @@ void TestTgfFileFormatPlugin::serializeUnserializeTest()
QVERIFY2(n->adjacentDataList().size() == 2, "ERROR: Number of Adjacent Nodes \
is not 2");
QVERIFY2(n->pointerList().size() == 2, "ERROR: Number of adjacent pointers \
is not 2"); }
- QVERIFY(ds->dataList().at(0)->name() == "first node");
+ QVERIFY(ds->dataList().at(0)->property("name").toString() == "first node");
QVERIFY(ds->pointers().at(0)->value() == "test value");
}
diff --git a/src/LoadSave/Plugins/tgfFileFormat/TgfFileFormatPlugin.cpp \
b/src/LoadSave/Plugins/tgfFileFormat/TgfFileFormatPlugin.cpp index bf0c4e0..dd123d2 \
100644
--- a/src/LoadSave/Plugins/tgfFileFormat/TgfFileFormatPlugin.cpp
+++ b/src/LoadSave/Plugins/tgfFileFormat/TgfFileFormatPlugin.cpp
@@ -134,7 +134,7 @@ void TgfFileFormatPlugin::writeFile(Document &graph )
foreach(DataPtr n, g->dataList()) {
out << n->identifier();
out << " ";
- out << n->name();
+ out << n->property("name").toString(); //TODO change to selectable property
out << '\n';
}
out << "#\n";
diff --git a/src/LoadSave/Plugins/tikzFileFormat/TikzFileFormatPlugin.cpp \
b/src/LoadSave/Plugins/tikzFileFormat/TikzFileFormatPlugin.cpp index 378116b..e70f065 \
100644
--- a/src/LoadSave/Plugins/tikzFileFormat/TikzFileFormatPlugin.cpp
+++ b/src/LoadSave/Plugins/tikzFileFormat/TikzFileFormatPlugin.cpp
@@ -114,8 +114,8 @@ void TikzFileFormatPlugin::writeFile(Document &graph)
arg(n->identifier()).
arg(n->x()/resize).
arg(n->y()*(-1)/resize).
- arg(n->name()).
- arg(n->value().toString());
+ arg(n->property("name").toString()).
+ arg(n->property("value").toString());
out << dataStr;
out << '\n';
}
diff --git a/src/LoadSave/RocsGraphFileFormatPlugin.cpp \
b/src/LoadSave/RocsGraphFileFormatPlugin.cpp index a3acb1c..06d0eef 100644
--- a/src/LoadSave/RocsGraphFileFormatPlugin.cpp
+++ b/src/LoadSave/RocsGraphFileFormatPlugin.cpp
@@ -206,7 +206,6 @@ void RocsGraphFileFormatPlugin::readFile()
tmpData = tmpDataStructure->addData(name, 0);
}
if (tmpData) {
- tmpData->setValue(value);
tmpData->setColor(color);
tmpData->setPos(posX, posY);
diff --git a/src/Models/model_GraphProperties.cpp \
b/src/Models/model_GraphProperties.cpp index ea0182a..c05199e 100644
--- a/src/Models/model_GraphProperties.cpp
+++ b/src/Models/model_GraphProperties.cpp
@@ -40,7 +40,6 @@ int GraphPropertiesModel::rowCount(const QModelIndex &parent) const
if (_dataSource == 0) {
return 0;
}
- kDebug() << _dataSource->dynamicPropertyNames().size();
return _dataSource->dynamicPropertyNames().size();
}
@@ -138,8 +137,8 @@ bool GraphPropertiesModel::setData(const QModelIndex &index, \
const QVariant &val const char* propertyName = \
_dataSource->dynamicPropertyNames()[index.row()]; if (index.column() == 0 && \
value.toString() == QString(propertyName) ){ return false;
- }
-
+ }
+
switch (index.column()) {
/* Change name. DinamicPropertiesList take part" name \
new name object */
case 0: DynamicPropertiesList::New()->changePropertyName(QString(_dataSource->dynamicPropertyNames()[index.row()]), \
value.toString(), _dataSource); break;
diff --git a/src/Plugins/DataStructure/Graph/GraphStructure.cpp \
b/src/Plugins/DataStructure/Graph/GraphStructure.cpp index 34e2ce2..7e1985d 100644
--- a/src/Plugins/DataStructure/Graph/GraphStructure.cpp
+++ b/src/Plugins/DataStructure/Graph/GraphStructure.cpp
@@ -61,9 +61,9 @@ void Rocs::GraphStructure::importStructure(DataStructurePtr other)
setGraphType(Graph);
QHash <Data*, DataPtr> dataTodata;
foreach(DataPtr n, other->dataList()) {
- DataPtr newdata = addData(n->name());
+ DataPtr newdata = addData(""); //n->name());
newdata->setColor(n->color());
- newdata->setValue(n->value());
+ newdata->setProperty("value", n->property("value").toString());
newdata->setX(n->x());
newdata->setY(n->y());
newdata->setWidth(n->width());
@@ -373,7 +373,7 @@ DataPtr Rocs::GraphStructure::addData(QString name, int dataType)
boost::shared_ptr<GraphNode> n = boost::static_pointer_cast<GraphNode>(
GraphNode::create(getDataStructure(), \
generateUniqueIdentifier(), dataType) );
- n->setName(name);
+ n->setProperty("name", name);
return addData(n, dataType);
}
diff --git a/src/Plugins/DataStructure/LinkedList/ListPlugin.cpp \
b/src/Plugins/DataStructure/LinkedList/ListPlugin.cpp index 4ef3f0d..c72f5d9 100644
--- a/src/Plugins/DataStructure/LinkedList/ListPlugin.cpp
+++ b/src/Plugins/DataStructure/LinkedList/ListPlugin.cpp
@@ -83,7 +83,7 @@ QLayout* Rocs::ListPlugin::nodeExtraProperties(DataPtr node, \
QWidget* parentWidg KLineEdit *_valueLine = new KLineEdit(parentWidget);
_valueLine->setReadOnly(true);
if (node->outPointerList().count() == 1) {
- _valueLine->setText(node->outPointerList().at(0)->to()->value().toString());
+ _valueLine->setText(node->outPointerList().at(0)->to()->property("value").toString());
}
lay->addWidget(_value, 0, 0);
lay->addWidget(_valueLine, 0, 1);
@@ -97,7 +97,7 @@ bool ListPlugin::canConvertFrom(Document* doc) const
foreach(DataStructurePtr ds, doc->dataStructures()) {
foreach(DataPtr data, ds->dataList()) {
if (data->outPointerList().count() > 1)
- errors.append(i18n("Data \'%1\' has more than one out pointer.", \
data->name())); + errors.append(i18n("Data \'%1\' has more than one \
out pointer.", data->identifier())); }
}
diff --git a/src/Plugins/DataStructure/LinkedList/ListStructure.cpp \
b/src/Plugins/DataStructure/LinkedList/ListStructure.cpp index a18cdc1..43e8186 \
100644
--- a/src/Plugins/DataStructure/LinkedList/ListStructure.cpp
+++ b/src/Plugins/DataStructure/LinkedList/ListStructure.cpp
@@ -55,9 +55,9 @@ void Rocs::ListStructure::importStructure(DataStructurePtr other)
m_building = true;
QHash < Data*, DataPtr > dataTodata;
foreach(DataPtr n, other->dataList()) {
- DataPtr newdata = addData(n->name());
+ DataPtr newdata = addData(""); //n->name());
newdata->setColor(n->color());
- newdata->setValue(n->value());
+ newdata->setProperty("value", n->property("value").toString());
newdata->setX(n->x());
newdata->setY(n->y());
newdata->setWidth(n->width());
@@ -109,7 +109,7 @@ DataPtr Rocs::ListStructure::addData(QString name, int dataType)
boost::shared_ptr<ListNode> n = boost::static_pointer_cast<ListNode>(
ListNode::create(getDataStructure(), \
generateUniqueIdentifier(), dataType) );
- n->setName(name);
+ n->setProperty("name", name);
if (m_building) {
return addData(n, dataType);;
@@ -167,7 +167,7 @@ QScriptValue Rocs::ListStructure::createNode(const QString & \
name) boost::shared_ptr<ListNode> n = boost::static_pointer_cast<ListNode>(
\
DataStructure::addData(ListNode::create(getDataStructure(), \
generateUniqueIdentifier(), 0)) );
- n->setName(name);
+ n->setProperty("name", name);
n->setEngine(engine());
arrangeNodes();
return n->scriptValue();
diff --git a/src/Plugins/DataStructure/RootedTree/RootedTreePlugin.cpp \
b/src/Plugins/DataStructure/RootedTree/RootedTreePlugin.cpp index 82348ca..1821b90 \
100644
--- a/src/Plugins/DataStructure/RootedTree/RootedTreePlugin.cpp
+++ b/src/Plugins/DataStructure/RootedTree/RootedTreePlugin.cpp
@@ -112,7 +112,7 @@ bool RootedTreePlugin::canConvertFrom(Document* doc) const
foreach ( DataPtr n, c->adjacentDataList()){
if (visited.contains(n.get())){
if (!cycles.contains(n.get())){
- errors << i18n("There are cycles at node %1. Data will \
be lost by conversion.", n->isNameVisible()); + errors << \
i18n("There are cycles at node %1. Data will be lost by conversion.", \
n->identifier()); cycles.insert(n.get());
}
}else{
diff --git a/src/Plugins/DataStructure/RootedTree/RootedTreeStructure.cpp \
b/src/Plugins/DataStructure/RootedTree/RootedTreeStructure.cpp index 76c0183..07642c2 \
100644
--- a/src/Plugins/DataStructure/RootedTree/RootedTreeStructure.cpp
+++ b/src/Plugins/DataStructure/RootedTree/RootedTreeStructure.cpp
@@ -78,9 +78,9 @@ void RootedTreeStructure::importStructure(DataStructurePtr other)
queue.enqueue(dataOther);
// add data element to tree and register mapping
- DataPtr dataTree = addData(dataOther->name(), 0);
+ DataPtr dataTree = addData(dataOther->property("name").toString(), 0);
dataTree->setColor(dataOther->color());
- dataTree->setValue(dataOther->value());
+ dataTree->setProperty("value", dataOther->property("value").toString());
dataTree->setX(dataOther->x());
dataTree->setY(dataOther->y());
dataTree->setWidth(dataOther->width());
@@ -106,9 +106,9 @@ void RootedTreeStructure::importStructure(DataStructurePtr other)
if (!visited.contains(adjacentData.get())){
visited.insert(adjacentData.get());
queue.enqueue(adjacentData);
- DataPtr childdata = addData(adjacentData->name(), 0);
+ DataPtr childdata = \
addData(adjacentData->property("name").toString(), 0); \
childdata->setColor(adjacentData->color());
- childdata->setValue(adjacentData->value());
+ childdata->setProperty("value", \
adjacentData->property("value").toString()); childdata->setX(adjacentData->x());
childdata->setY(adjacentData->y());
childdata->setWidth(adjacentData->width());
@@ -198,7 +198,7 @@ DataPtr RootedTreeStructure::addData(QString name, int dataType)
{
boost::shared_ptr<RootedTreeNode> n = \
boost::static_pointer_cast<RootedTreeNode>(
RootedTreeNode::create(getDataStructure(), generateUniqueIdentifier(), dataType) \
);
- n->setName(name);
+ n->setProperty("name", name);
return addData(n);
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic