15 void Attribute::setKey (const QString &k, const AttributeType &t)
19 qWarning (QString("Attribute::setKey (%1) No table defined!\n").arg(k).ascii());
25 definition=table->getDef(k);
32 qWarning (QString("Attribute::setKey (%1) attribute already defined!\n").arg(k).ascii());
35 QString Attribute::getKey ()
39 qWarning ("Attribute::getKey () No table defined!");
44 qWarning ("Attribute::getKey () No attribute defined!");
47 return definition->getKey();
50 void Attribute::setValue(const QString &v)
54 qWarning (QString ("Attribute::setValue (%1) No table defined!").arg(v));
59 qWarning (QString ("Attribute::setValue (%1) No attribute defined!").arg(v));
62 definition->setValue (v);
65 QVariant Attribute::getValue()
69 qWarning ("Attribute::getValue No table defined!");
74 qWarning ("Attribute::getValue No attribute defined!");
77 QVariant v= definition->getValue();
81 void Attribute::setType (const AttributeType &t)
85 qWarning ("Attribute::setType No table defined!");
90 qWarning ("Attribute::setType No attribute defined!");
93 definition->setType (t);
96 AttributeType Attribute::getType()
100 qWarning ("Attribute::getType No table defined!");
105 qWarning ("Attribute::getType No attribute defined!");
108 return definition->getType();
111 QString Attribute::getTypeString()
115 qWarning ("Attribute::getTypeString No table defined!");
120 qWarning ("Attribute::getTypeString No attribute defined!");
123 return definition->getTypeString();
126 void Attribute::setTable (AttributeTable *at)
131 qWarning ("Attribute::setTable table==NULL");
135 AttributeTable* Attribute::getTable()
140 QString Attribute::getDataXML()
142 QString a=beginElement ("attribute");
143 a+=attribut ("key",getKey());
144 a+=attribut ("value",getValue().toString() );
145 a+=attribut ("type",getTypeString () );
150 ///////////////////////////////////////////////////////////////
151 AttributeDef::AttributeDef()
155 AttributeDef::~AttributeDef()
159 void AttributeDef::setType (const AttributeType &t)
164 AttributeType AttributeDef::getType ()
169 QString AttributeDef::getTypeString ()
171 if (type==StringList)
173 else if (type==FreeString)
175 else if (type==UniqueString)
176 return "UniqueString";
180 void AttributeDef::setKey (const QString &k)
185 void AttributeDef::setValue (const QString &v)
189 void AttributeDef::setValue (const QVariant &v)
192 qWarning ("AttributeDef::setValue No type defined!");
193 else if (type==StringList)
195 else if (type==UniqueString)
198 qWarning ("AttributeDef::setValue Unknown type???");
202 QVariant AttributeDef::getValue ()
207 QString AttributeDef::getKey ()
212 ///////////////////////////////////////////////////////////////
213 AttributeTable::AttributeTable()
217 AttributeTable::~AttributeTable()
222 void AttributeTable::clear ()
227 AttributeDef* AttributeTable::addKey (const QString &k, const AttributeType &t)
229 for (int i=0; i<attdefs.count();++i)
231 if (attdefs.at(i)->getKey()==k )
233 qWarning (QString ("AttributeTable::addKey (%1) already in table\n").arg(k).ascii());
237 AttributeDef *ad=new AttributeDef;
244 void AttributeTable::removeKey (const QString &k)
246 for (int i=0; i<attdefs.count();++i)
248 if (attdefs.at(i)->getKey()==k )
251 delete (attdefs.at(i));
252 attdefs.removeAt (i);
256 qWarning (QString ("AttributeTable::removeKey (%1) key not in table\n").arg(k).ascii());
259 AttributeDef* AttributeTable::getDef(const QString &k)
261 for (int i=0; i<attdefs.count();++i)
262 if (attdefs.at(i)->getKey()==k ) return attdefs.at(i);
263 qWarning (QString ("AttributeTable::getDef (%1) key not in table\n").arg(k).ascii());
267 int AttributeTable::countKeys()
269 return attdefs.count();
272 QStringList AttributeTable::getKeys ()
275 for (int i=0; i<attdefs.count();i++)
276 kl.append (attdefs.at(i)->getKey());
280 QString AttributeTable::getDataXML()
282 return valueElement ("attributeList","key","value");