attribute.cpp
author insilmaril
Tue, 04 Dec 2007 12:32:59 +0000
changeset 628 d7d0708b1c60
parent 626 96c8e6860e0c
child 636 f83abc1f75b4
permissions -rw-r--r--
Fixed HideExport bug, changed pre- and postscript in XHTML export dialog
     1 #include "attribute.h"
     2 
     3 Attribute::Attribute()
     4 {
     5 	key="";
     6 	value="";
     7 }
     8 
     9 void Attribute::setKey (const QString &k)
    10 {
    11 	key=k;
    12 }
    13 
    14 QString Attribute::getKey ()
    15 {
    16 	return key;
    17 }
    18 
    19 void Attribute::setValue(const QString &v)
    20 {
    21 	value=v;
    22 }
    23 
    24 QString Attribute::getValue()
    25 {
    26 	return value;
    27 }
    28 
    29 void Attribute::setTable (AttributeTable *at)
    30 {
    31 	table=at;
    32 }
    33 
    34 AttributeTable* Attribute::getTable()
    35 {
    36 	return table;
    37 }
    38 
    39 QString Attribute::getDataXML()
    40 {
    41 	return valueElement ("attribute",key,value);
    42 }
    43 
    44 
    45 ///////////////////////////////////////////////////////////////
    46 AttributeTable::AttributeTable()
    47 {
    48 	clear();
    49 }
    50 
    51 AttributeTable::~AttributeTable()
    52 {
    53 }
    54 
    55 void AttributeTable::clear ()
    56 {
    57 	keys.clear();
    58 	values.clear();
    59 }
    60 
    61 void AttributeTable::addKey (const QString &k)
    62 {
    63 	if (!keys.contains (k) )
    64 	{
    65 		keys.append (k);
    66 		values.append (QStringList() );
    67 	}
    68 }
    69 
    70 void AttributeTable::removeKey (const QString &k)
    71 {
    72 	int i=keys.indexOf (k);
    73 	if (i>=0)
    74 	{
    75 		keys.removeAt(i);
    76 		values.removeAt(i);
    77 	}
    78 }
    79 
    80 int AttributeTable::countKeys()
    81 {
    82 	return keys.count();
    83 }
    84 
    85 void AttributeTable::addValue (const QString &k, const QString &v)
    86 {
    87 	int i=keys.indexOf (k);
    88 	if (i<0)
    89 	{
    90 		keys.append (k);
    91 		values.append (QStringList (v));
    92 	} else
    93 	{
    94 		int j=values.at(i).indexOf(k);
    95 		if (j<0) values[i].append (QString(v));
    96 	}
    97 }
    98 
    99 QStringList AttributeTable::getKeys ()
   100 {
   101 	return keys;
   102 }
   103 
   104 QStringList AttributeTable::getValues(const QString &k)
   105 {
   106 	int i=keys.indexOf (k);
   107 	if (i>=0)
   108 		return values.at(i);
   109 	else
   110 		return QStringList();
   111 }
   112 
   113 QString AttributeTable::getDataXML()
   114 {
   115 	return valueElement ("attributeList","key","value");
   116 }