PropertyStorage <-> QVariantMap
This commit is contained in:
@@ -2,6 +2,23 @@
|
|||||||
#include "qad_types.h"
|
#include "qad_types.h"
|
||||||
|
|
||||||
|
|
||||||
|
PropertyStorage::PropertyStorage(const QVariantMap & pl) {
|
||||||
|
QMapIterator<QString, QVariant> it(pl);
|
||||||
|
while (it.hasNext()) {
|
||||||
|
it.next();
|
||||||
|
props << Property(it.key(), "", it.value());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariantMap PropertyStorage::toVariantMap() const {
|
||||||
|
QVariantMap ret;
|
||||||
|
foreach (const Property & p, props)
|
||||||
|
ret[p.name] = p.value;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool PropertyStorage::isPropertyExists(const QString & _name) const {
|
bool PropertyStorage::isPropertyExists(const QString & _name) const {
|
||||||
for (int i = 0; i < props.size(); ++i)
|
for (int i = 0; i < props.size(); ++i)
|
||||||
if (props[i].name == _name)
|
if (props[i].name == _name)
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
PropertyStorage(const QList<Property> & pl) {props = pl;}
|
PropertyStorage(const QList<Property> & pl) {props = pl;}
|
||||||
|
PropertyStorage(const QVariantMap & pl);
|
||||||
|
|
||||||
typedef QList<Property>::const_iterator const_iterator;
|
typedef QList<Property>::const_iterator const_iterator;
|
||||||
typedef QList<Property>::iterator iterator;
|
typedef QList<Property>::iterator iterator;
|
||||||
@@ -83,6 +84,7 @@ public:
|
|||||||
QList<Property> & properties() {return props;}
|
QList<Property> & properties() {return props;}
|
||||||
const QList<Property> & properties() const {return props;}
|
const QList<Property> & properties() const {return props;}
|
||||||
const PropertyStorage & propertyStorage() const {return *this;}
|
const PropertyStorage & propertyStorage() const {return *this;}
|
||||||
|
QVariantMap toVariantMap() const;
|
||||||
bool isPropertyExists(const QString & _name) const;
|
bool isPropertyExists(const QString & _name) const;
|
||||||
void clearProperties() {props.clear();}
|
void clearProperties() {props.clear();}
|
||||||
void addProperty(const Property & p);
|
void addProperty(const Property & p);
|
||||||
|
|||||||
Reference in New Issue
Block a user