author | insilmaril |
Mon, 16 Nov 2009 09:47:10 +0000 | |
changeset 805 | fc7a93ff97c3 |
parent 795 | 6b0a5f4923d3 |
child 822 | c2ce9944148c |
permissions | -rw-r--r-- |
insilmaril@795 | 1 |
|
insilmaril@795 | 2 |
#include "attributeitem.h" |
insilmaril@795 | 3 |
|
insilmaril@795 | 4 |
#include <iostream> |
insilmaril@795 | 5 |
using namespace std; |
insilmaril@795 | 6 |
|
insilmaril@795 | 7 |
extern bool debug; |
insilmaril@795 | 8 |
|
insilmaril@795 | 9 |
AttributeItem::AttributeItem(const QList<QVariant> &data, TreeItem *parent):TreeItem (data,parent) |
insilmaril@795 | 10 |
{ |
insilmaril@795 | 11 |
TreeItem::setType (Attribute); |
insilmaril@795 | 12 |
//table=NULL; |
insilmaril@795 | 13 |
//definition=NULL; |
insilmaril@795 | 14 |
type=Attribute; |
insilmaril@795 | 15 |
|
insilmaril@795 | 16 |
internal=false; |
insilmaril@795 | 17 |
} |
insilmaril@795 | 18 |
|
insilmaril@795 | 19 |
AttributeItem::~AttributeItem() |
insilmaril@795 | 20 |
{ |
insilmaril@795 | 21 |
} |
insilmaril@795 | 22 |
|
insilmaril@795 | 23 |
void AttributeItem::setKey (const QString &k, const Type &t) |
insilmaril@795 | 24 |
{ |
insilmaril@795 | 25 |
/* |
insilmaril@795 | 26 |
if (!table) |
insilmaril@795 | 27 |
{ |
insilmaril@795 | 28 |
qWarning (QString("AttributeItem::setKey (%1) No table defined!\n").arg(k).ascii()); |
insilmaril@795 | 29 |
return; |
insilmaril@795 | 30 |
} |
insilmaril@795 | 31 |
|
insilmaril@795 | 32 |
if (!definition) |
insilmaril@795 | 33 |
{ |
insilmaril@795 | 34 |
definition=table->getDef(k); |
insilmaril@795 | 35 |
if (!definition) |
insilmaril@795 | 36 |
{ |
insilmaril@795 | 37 |
table->addKey (k,t); |
insilmaril@795 | 38 |
return; |
insilmaril@795 | 39 |
} |
insilmaril@795 | 40 |
} |
insilmaril@795 | 41 |
qWarning (QString("AttributeItem::setKey (%1) attribute already defined!\n").arg(k).ascii()); |
insilmaril@795 | 42 |
*/ |
insilmaril@795 | 43 |
} |
insilmaril@795 | 44 |
|
insilmaril@795 | 45 |
QString AttributeItem::getKey () |
insilmaril@795 | 46 |
{ |
insilmaril@795 | 47 |
/* |
insilmaril@795 | 48 |
if (!table) |
insilmaril@795 | 49 |
{ |
insilmaril@795 | 50 |
qWarning ("AttributeItem::getKey () No table defined!"); |
insilmaril@795 | 51 |
return QString(); |
insilmaril@795 | 52 |
} |
insilmaril@795 | 53 |
if (!definition) |
insilmaril@795 | 54 |
{ |
insilmaril@795 | 55 |
qWarning ("AttributeItem::getKey () No attribute defined!"); |
insilmaril@795 | 56 |
return QString (); |
insilmaril@795 | 57 |
} |
insilmaril@795 | 58 |
return definition->getKey(); |
insilmaril@795 | 59 |
*/ |
insilmaril@795 | 60 |
} |
insilmaril@795 | 61 |
|
insilmaril@795 | 62 |
void AttributeItem::setValue(const QString &v) |
insilmaril@795 | 63 |
{ |
insilmaril@795 | 64 |
/* |
insilmaril@795 | 65 |
if (!table) |
insilmaril@795 | 66 |
{ |
insilmaril@795 | 67 |
qWarning (QString ("AttributeItem::setValue (%1) No table defined!").arg(v)); |
insilmaril@795 | 68 |
return; |
insilmaril@795 | 69 |
} |
insilmaril@795 | 70 |
if (!definition) |
insilmaril@795 | 71 |
{ |
insilmaril@795 | 72 |
qWarning (QString ("AttributeItem::setValue (%1) No attribute defined!").arg(v)); |
insilmaril@795 | 73 |
return; |
insilmaril@795 | 74 |
} |
insilmaril@795 | 75 |
definition->setValue (v); |
insilmaril@795 | 76 |
*/ |
insilmaril@795 | 77 |
} |
insilmaril@795 | 78 |
|
insilmaril@795 | 79 |
QVariant AttributeItem::getValue() |
insilmaril@795 | 80 |
{ |
insilmaril@795 | 81 |
/* |
insilmaril@795 | 82 |
if (!table) |
insilmaril@795 | 83 |
{ |
insilmaril@795 | 84 |
qWarning ("AttributeItem::getValue No table defined!"); |
insilmaril@795 | 85 |
return QString(); |
insilmaril@795 | 86 |
} |
insilmaril@795 | 87 |
if (!definition) |
insilmaril@795 | 88 |
{ |
insilmaril@795 | 89 |
qWarning ("AttributeItem::getValue No attribute defined!"); |
insilmaril@795 | 90 |
return QString(); |
insilmaril@795 | 91 |
} |
insilmaril@795 | 92 |
QVariant v= definition->getValue(); |
insilmaril@795 | 93 |
return v; |
insilmaril@795 | 94 |
*/ |
insilmaril@795 | 95 |
} |
insilmaril@795 | 96 |
|
insilmaril@795 | 97 |
void AttributeItem::setType (const Type &t) |
insilmaril@795 | 98 |
{ |
insilmaril@795 | 99 |
/* |
insilmaril@795 | 100 |
if (!table) |
insilmaril@795 | 101 |
{ |
insilmaril@795 | 102 |
qWarning ("AttributeItem::setType No table defined!"); |
insilmaril@795 | 103 |
return; |
insilmaril@795 | 104 |
} |
insilmaril@795 | 105 |
if (!definition) |
insilmaril@795 | 106 |
{ |
insilmaril@795 | 107 |
qWarning ("Attribute::setType No attribute defined!"); |
insilmaril@795 | 108 |
return; |
insilmaril@795 | 109 |
} |
insilmaril@795 | 110 |
definition->setType (t); |
insilmaril@795 | 111 |
*/ |
insilmaril@795 | 112 |
} |
insilmaril@795 | 113 |
|
insilmaril@795 | 114 |
AttributeItem::Type AttributeItem::getAttributeType() |
insilmaril@795 | 115 |
{ |
insilmaril@795 | 116 |
/* |
insilmaril@795 | 117 |
if (!table) |
insilmaril@795 | 118 |
{ |
insilmaril@795 | 119 |
qWarning ("AttributeItem::getType No table defined!"); |
insilmaril@795 | 120 |
return Undefined; |
insilmaril@795 | 121 |
} |
insilmaril@795 | 122 |
if (!definition) |
insilmaril@795 | 123 |
{ |
insilmaril@795 | 124 |
qWarning ("AttributeItem::getType No attribute defined!"); |
insilmaril@795 | 125 |
return Undefined; |
insilmaril@795 | 126 |
} |
insilmaril@795 | 127 |
return definition->getType(); |
insilmaril@795 | 128 |
*/ |
insilmaril@795 | 129 |
} |
insilmaril@795 | 130 |
|
insilmaril@795 | 131 |
QString AttributeItem::getTypeString() |
insilmaril@795 | 132 |
{ |
insilmaril@795 | 133 |
/* |
insilmaril@795 | 134 |
if (!table) |
insilmaril@795 | 135 |
{ |
insilmaril@795 | 136 |
qWarning ("AttributeItem::getTypeString No table defined!"); |
insilmaril@795 | 137 |
return "Undefined"; |
insilmaril@795 | 138 |
} |
insilmaril@795 | 139 |
if (!definition) |
insilmaril@795 | 140 |
{ |
insilmaril@795 | 141 |
qWarning ("Attribute::getTypeString No AttributeItem defined!"); |
insilmaril@795 | 142 |
return "Undefined"; |
insilmaril@795 | 143 |
} |
insilmaril@795 | 144 |
return definition->getTypeString(); |
insilmaril@795 | 145 |
*/ |
insilmaril@795 | 146 |
} |
insilmaril@795 | 147 |
|
insilmaril@795 | 148 |
QString AttributeItem::getDataXML() |
insilmaril@795 | 149 |
{ |
insilmaril@795 | 150 |
QString a=beginElement ("attribute"); |
insilmaril@795 | 151 |
a+=attribut ("key",getKey()); |
insilmaril@795 | 152 |
a+=attribut ("value",getValue().toString() ); |
insilmaril@795 | 153 |
a+=attribut ("type",getTypeString () ); |
insilmaril@795 | 154 |
return a; |
insilmaril@795 | 155 |
} |
insilmaril@795 | 156 |