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