10 Attribute::Attribute()
16 void Attribute::setKey (const QString &k, const AttributeType &t)
20 qWarning ()<< QString("Attribute::setKey (%1) No table defined!\n").arg(k).toUtf8();
26 definition=table->getDef(k);
33 qWarning ()<< QString("Attribute::setKey (%1) attribute already defined!\n").arg(k).toUtf8();
36 QString Attribute::getKey ()
40 qWarning ("Attribute::getKey () No table defined!");
45 qWarning ("Attribute::getKey () No attribute defined!");
48 return definition->getKey();
51 void Attribute::setValue(const QString &v)
55 qWarning ()<<QString ("Attribute::setValue (%1) No table defined!").arg(v);
60 qWarning ()<<QString ("Attribute::setValue (%1) No attribute defined!").arg(v);
63 definition->setValue (v);
66 QVariant Attribute::getValue()
70 qWarning ("Attribute::getValue No table defined!");
75 qWarning()<<"Attribute::getValue No attribute defined!";
78 QVariant v= definition->getValue();
82 void Attribute::setType (const AttributeType &t)
86 qWarning ()<<"Attribute::setType No table defined!";
91 qWarning()<<"Attribute::setType No attribute defined!";
94 definition->setType (t);
97 AttributeType Attribute::getType()
101 qWarning ()<<"Attribute::getType No table defined!";
106 qWarning ()<<"Attribute::getType No attribute defined!";
109 return definition->getType();
112 QString Attribute::getTypeString()
116 qWarning ()<<"Attribute::getTypeString No table defined!";
121 qWarning ()<<"Attribute::getTypeString No attribute defined!";
124 return definition->getTypeString();
127 void Attribute::setTable (AttributeTable *at)
132 qWarning ()<<"Attribute::setTable table==NULL";
136 AttributeTable* Attribute::getTable()
141 QString Attribute::getDataXML()
143 QString a=beginElement ("attribute");
144 a+=attribut ("key",getKey());
145 a+=attribut ("value",getValue().toString() );
146 a+=attribut ("type",getTypeString () );
151 ///////////////////////////////////////////////////////////////
152 AttributeDef::AttributeDef()
156 AttributeDef::~AttributeDef()
160 void AttributeDef::setType (const AttributeType &t)
165 AttributeType AttributeDef::getType ()
170 QString AttributeDef::getTypeString ()
172 if (type==StringList)
174 else if (type==FreeString)
176 else if (type==UniqueString)
177 return "UniqueString";
181 void AttributeDef::setKey (const QString &k)
186 void AttributeDef::setValue (const QString &)
190 void AttributeDef::setValue (const QVariant &v)
193 qWarning ()<<"AttributeDef::setValue No type defined!";
194 else if (type==StringList)
196 else if (type==UniqueString)
199 qWarning ()<<"AttributeDef::setValue Unknown type???";
203 QVariant AttributeDef::getValue ()
208 QString AttributeDef::getKey ()
213 ///////////////////////////////////////////////////////////////
214 AttributeTable::AttributeTable()
225 AttributeTable::~AttributeTable()
230 void AttributeTable::clear ()
235 AttributeDef* AttributeTable::addKey (const QString &k, const AttributeType &t)
237 for (int i=0; i<attdefs.count();++i)
239 if (attdefs.at(i)->getKey()==k )
241 qWarning () << QString ("AttributeTable::addKey (%1) already in table\n").arg(k).toUtf8();
245 AttributeDef *ad=new AttributeDef;
252 void AttributeTable::removeKey (const QString &k)
254 for (int i=0; i<attdefs.count();++i)
256 if (attdefs.at(i)->getKey()==k )
259 delete (attdefs.at(i));
260 attdefs.removeAt (i);
264 qWarning () << QString ("AttributeTable::removeKey (%1) key not in table\n").arg(k).toUtf8();
267 AttributeDef* AttributeTable::getDef(const QString &key)
269 for (int i=0; i<attdefs.count();++i)
270 if (attdefs.at(i)->getKey()==key ) return attdefs.at(i);
271 qWarning () << QString ("AttributeTable::getDef (%1) key not in table\n").arg(key).toUtf8();
275 int AttributeTable::countKeys()
277 return attdefs.count();
280 QStringList AttributeTable::getKeys ()
283 for (int i=0; i<attdefs.count();i++)
284 kl.append (attdefs.at(i)->getKey());
288 QStringList AttributeTable::getTypes ()
293 QString AttributeTable::getDataXML()
295 return valueElement ("attributeList","key","value");