1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/attributeitem.cpp Tue Dec 15 09:14:59 2009 +0000
1.3 @@ -0,0 +1,156 @@
1.4 +
1.5 +#include "attributeitem.h"
1.6 +
1.7 +#include <iostream>
1.8 +using namespace std;
1.9 +
1.10 +extern bool debug;
1.11 +
1.12 +AttributeItem::AttributeItem(const QList<QVariant> &data, TreeItem *parent):TreeItem (data,parent)
1.13 +{
1.14 + TreeItem::setType (Attribute);
1.15 + //table=NULL;
1.16 + //definition=NULL;
1.17 + type=Attribute;
1.18 +
1.19 + internal=false;
1.20 +}
1.21 +
1.22 +AttributeItem::~AttributeItem()
1.23 +{
1.24 +}
1.25 +
1.26 +void AttributeItem::setKey (const QString &k, const Type &t)
1.27 +{
1.28 +/*
1.29 + if (!table)
1.30 + {
1.31 + qWarning (QString("AttributeItem::setKey (%1) No table defined!\n").arg(k).ascii());
1.32 + return;
1.33 + }
1.34 +
1.35 + if (!definition)
1.36 + {
1.37 + definition=table->getDef(k);
1.38 + if (!definition)
1.39 + {
1.40 + table->addKey (k,t);
1.41 + return;
1.42 + }
1.43 + }
1.44 + qWarning (QString("AttributeItem::setKey (%1) attribute already defined!\n").arg(k).ascii());
1.45 + */
1.46 +}
1.47 +
1.48 +QString AttributeItem::getKey ()
1.49 +{
1.50 +/*
1.51 + if (!table)
1.52 + {
1.53 + qWarning ("AttributeItem::getKey () No table defined!");
1.54 + return QString();
1.55 + }
1.56 + if (!definition)
1.57 + {
1.58 + qWarning ("AttributeItem::getKey () No attribute defined!");
1.59 + return QString ();
1.60 + }
1.61 + return definition->getKey();
1.62 + */
1.63 +}
1.64 +
1.65 +void AttributeItem::setValue(const QString &v)
1.66 +{
1.67 +/*
1.68 + if (!table)
1.69 + {
1.70 + qWarning (QString ("AttributeItem::setValue (%1) No table defined!").arg(v));
1.71 + return;
1.72 + }
1.73 + if (!definition)
1.74 + {
1.75 + qWarning (QString ("AttributeItem::setValue (%1) No attribute defined!").arg(v));
1.76 + return;
1.77 + }
1.78 + definition->setValue (v);
1.79 +*/
1.80 +}
1.81 +
1.82 +QVariant AttributeItem::getValue()
1.83 +{
1.84 +/*
1.85 + if (!table)
1.86 + {
1.87 + qWarning ("AttributeItem::getValue No table defined!");
1.88 + return QString();
1.89 + }
1.90 + if (!definition)
1.91 + {
1.92 + qWarning ("AttributeItem::getValue No attribute defined!");
1.93 + return QString();
1.94 + }
1.95 + QVariant v= definition->getValue();
1.96 + return v;
1.97 + */
1.98 +}
1.99 +
1.100 +void AttributeItem::setType (const Type &t)
1.101 +{
1.102 +/*
1.103 + if (!table)
1.104 + {
1.105 + qWarning ("AttributeItem::setType No table defined!");
1.106 + return;
1.107 + }
1.108 + if (!definition)
1.109 + {
1.110 + qWarning ("Attribute::setType No attribute defined!");
1.111 + return;
1.112 + }
1.113 + definition->setType (t);
1.114 +*/
1.115 +}
1.116 +
1.117 +AttributeItem::Type AttributeItem::getAttributeType()
1.118 +{
1.119 +/*
1.120 + if (!table)
1.121 + {
1.122 + qWarning ("AttributeItem::getType No table defined!");
1.123 + return Undefined;
1.124 + }
1.125 + if (!definition)
1.126 + {
1.127 + qWarning ("AttributeItem::getType No attribute defined!");
1.128 + return Undefined;
1.129 + }
1.130 + return definition->getType();
1.131 +*/
1.132 +}
1.133 +
1.134 +QString AttributeItem::getTypeString()
1.135 +{
1.136 +/*
1.137 + if (!table)
1.138 + {
1.139 + qWarning ("AttributeItem::getTypeString No table defined!");
1.140 + return "Undefined";
1.141 + }
1.142 + if (!definition)
1.143 + {
1.144 + qWarning ("Attribute::getTypeString No AttributeItem defined!");
1.145 + return "Undefined";
1.146 + }
1.147 + return definition->getTypeString();
1.148 +*/
1.149 +}
1.150 +
1.151 +QString AttributeItem::getDataXML()
1.152 +{
1.153 + QString a=beginElement ("attribute");
1.154 + a+=attribut ("key",getKey());
1.155 + a+=attribut ("value",getValue().toString() );
1.156 + a+=attribut ("type",getTypeString () );
1.157 + return a;
1.158 +}
1.159 +