attributeitem.cpp
author insilmaril
Tue, 30 Mar 2010 17:30:39 +0000
changeset 842 bec082472471
parent 840 c13937960f1d
permissions -rw-r--r--
Much improved results in FindResultsWidget
     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 }
    89 
    90 QVariant AttributeItem::getValue()
    91 {
    92 /*
    93 	if (!table)
    94 	{
    95 		qWarning ("AttributeItem::getValue  No table defined!");
    96 		return QString();	
    97 	}
    98 	if (!definition)
    99 	{
   100 		qWarning ("AttributeItem::getValue  No attribute defined!");
   101 		return QString();	
   102 	}	
   103 	QVariant v= definition->getValue();
   104 	return v;
   105 	*/
   106 	return QString();
   107 }
   108 
   109 void AttributeItem::setType (const Type &t)
   110 {
   111 /*
   112 	if (!table)
   113 	{
   114 		qWarning ("AttributeItem::setType  No table defined!");
   115 		return;
   116 	}
   117 	if (!definition)
   118 	{
   119 		qWarning ("Attribute::setType  No attribute defined!");
   120 		return; 
   121 	}	
   122 	definition->setType (t);
   123 */
   124 }
   125 
   126 AttributeItem::Type AttributeItem::getAttributeType()
   127 {
   128 /*
   129 	if (!table)
   130 	{
   131 		qWarning ("AttributeItem::getType  No table defined!");
   132 		return Undefined;	
   133 	}
   134 	if (!definition)
   135 	{
   136 		qWarning ("AttributeItem::getType  No attribute defined!");
   137 		return Undefined;	
   138 	}	
   139 	return definition->getType();
   140 */
   141 	return AttributeItem::Undefined;
   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