attributeitem.cpp
author insilmaril
Thu, 18 Mar 2010 11:38:14 +0000
changeset 838 e4a44912646c
parent 823 0bba81dde1bc
child 840 c13937960f1d
permissions -rw-r--r--
Added missing return values
     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 	return QString();
    71 }
    72 
    73 void AttributeItem::setValue(const QString &v)
    74 {
    75 /*
    76 	if (!table)
    77 	{
    78 		qWarning (QString ("AttributeItem::setValue (%1)  No table defined!").arg(v));
    79 		return;	
    80 	}
    81 	if (!definition)
    82 	{
    83 		qWarning (QString ("AttributeItem::setValue (%1)  No attribute defined!").arg(v));
    84 		return;	
    85 	}	
    86 	definition->setValue (v);
    87 */
    88 	return QString();
    89 }
    90 
    91 QVariant AttributeItem::getValue()
    92 {
    93 /*
    94 	if (!table)
    95 	{
    96 		qWarning ("AttributeItem::getValue  No table defined!");
    97 		return QString();	
    98 	}
    99 	if (!definition)
   100 	{
   101 		qWarning ("AttributeItem::getValue  No attribute defined!");
   102 		return QString();	
   103 	}	
   104 	QVariant v= definition->getValue();
   105 	return v;
   106 	*/
   107 	return QString();
   108 }
   109 
   110 void AttributeItem::setType (const Type &t)
   111 {
   112 /*
   113 	if (!table)
   114 	{
   115 		qWarning ("AttributeItem::setType  No table defined!");
   116 		return;
   117 	}
   118 	if (!definition)
   119 	{
   120 		qWarning ("Attribute::setType  No attribute defined!");
   121 		return; 
   122 	}	
   123 	definition->setType (t);
   124 */
   125 }
   126 
   127 AttributeItem::Type AttributeItem::getAttributeType()
   128 {
   129 /*
   130 	if (!table)
   131 	{
   132 		qWarning ("AttributeItem::getType  No table defined!");
   133 		return Undefined;	
   134 	}
   135 	if (!definition)
   136 	{
   137 		qWarning ("AttributeItem::getType  No attribute defined!");
   138 		return Undefined;	
   139 	}	
   140 	return definition->getType();
   141 */
   142 }
   143 
   144 QString AttributeItem::getTypeString()
   145 {
   146 /*
   147 	if (!table)
   148 	{
   149 		qWarning ("AttributeItem::getTypeString  No table defined!");
   150 		return "Undefined";	
   151 	}
   152 	if (!definition)
   153 	{
   154 		qWarning ("Attribute::getTypeString  No AttributeItem defined!");
   155 		return "Undefined";	
   156 	}	
   157 	return definition->getTypeString();
   158 */	
   159 	return QString();
   160 }
   161 
   162 void AttributeItem::setInternal(bool b)
   163 {
   164 	internal=b;
   165 }
   166 
   167 bool AttributeItem::isInternal()
   168 {
   169 	return internal;
   170 }
   171 
   172 QString AttributeItem::getDataXML()
   173 {
   174 	QString a=beginElement ("attribute");
   175 	a+=attribut ("key",getKey());
   176 	a+=attribut ("value",getValue().toString() );
   177 	a+=attribut ("type",getTypeString () );
   178 	return a;
   179 }
   180