attribute.cpp
author insilmaril
Fri, 09 Nov 2007 12:07:22 +0000
changeset 625 22955004d512
parent 616 16d63fc9ae42
child 626 96c8e6860e0c
permissions -rw-r--r--
1.11.3 Better windows support
insilmaril@616
     1
#include "attribute.h"
insilmaril@616
     2
insilmaril@616
     3
Attribute::Attribute()
insilmaril@616
     4
{
insilmaril@616
     5
	key="";
insilmaril@616
     6
	value="";
insilmaril@616
     7
}
insilmaril@616
     8
insilmaril@616
     9
void Attribute::setKey (const QString &k)
insilmaril@616
    10
{
insilmaril@616
    11
	key=k;
insilmaril@616
    12
}
insilmaril@616
    13
insilmaril@616
    14
QString Attribute::getKey ()
insilmaril@616
    15
{
insilmaril@616
    16
	return key;
insilmaril@616
    17
}
insilmaril@616
    18
insilmaril@616
    19
void Attribute::setValue(const QString &v)
insilmaril@616
    20
{
insilmaril@616
    21
	value=v;
insilmaril@616
    22
}
insilmaril@616
    23
insilmaril@616
    24
QString Attribute::getValue()
insilmaril@616
    25
{
insilmaril@616
    26
	return value;
insilmaril@616
    27
}
insilmaril@616
    28
insilmaril@616
    29
QString Attribute::getDataXML()
insilmaril@616
    30
{
insilmaril@616
    31
	return valueElement ("attribute",key,value);
insilmaril@616
    32
}
insilmaril@616
    33
insilmaril@616
    34
insilmaril@616
    35
///////////////////////////////////////////////////////////////
insilmaril@616
    36
AttributeTable::AttributeTable()
insilmaril@616
    37
{
insilmaril@616
    38
	clear();
insilmaril@616
    39
}
insilmaril@616
    40
insilmaril@616
    41
AttributeTable::~AttributeTable()
insilmaril@616
    42
{
insilmaril@616
    43
}
insilmaril@616
    44
insilmaril@616
    45
void AttributeTable::clear ()
insilmaril@616
    46
{
insilmaril@616
    47
	keys.clear();
insilmaril@616
    48
	values.clear();
insilmaril@616
    49
}
insilmaril@616
    50
insilmaril@616
    51
void AttributeTable::addKey (const QString &k)
insilmaril@616
    52
{
insilmaril@616
    53
	if (!keys.contains (k) )
insilmaril@616
    54
	{
insilmaril@616
    55
		keys.append (k);
insilmaril@616
    56
		values.append (QStringList() );
insilmaril@616
    57
	}
insilmaril@616
    58
}
insilmaril@616
    59
insilmaril@616
    60
void AttributeTable::removeKey (const QString &k)
insilmaril@616
    61
{
insilmaril@616
    62
	int i=keys.indexOf (k);
insilmaril@616
    63
	if (i>=0)
insilmaril@616
    64
	{
insilmaril@616
    65
		keys.removeAt(i);
insilmaril@616
    66
		values.removeAt(i);
insilmaril@616
    67
	}
insilmaril@616
    68
}
insilmaril@616
    69
insilmaril@616
    70
void AttributeTable::addValue (const QString &k, const QString &v)
insilmaril@616
    71
{
insilmaril@616
    72
	int i=keys.indexOf (k);
insilmaril@616
    73
	if (i<0)
insilmaril@616
    74
	{
insilmaril@616
    75
		keys.append (k);
insilmaril@616
    76
		values.append (QStringList (v));
insilmaril@616
    77
	} else
insilmaril@616
    78
	{
insilmaril@616
    79
		int j=values.at(i).indexOf(k);
insilmaril@616
    80
		if (j<0) values[i].append (QString(v));
insilmaril@616
    81
	}
insilmaril@616
    82
}
insilmaril@616
    83
insilmaril@616
    84
QStringList AttributeTable::getKeys ()
insilmaril@616
    85
{
insilmaril@616
    86
	return keys;
insilmaril@616
    87
}
insilmaril@616
    88
insilmaril@616
    89
QStringList AttributeTable::getValues(const QString &k)
insilmaril@616
    90
{
insilmaril@616
    91
	int i=keys.indexOf (k);
insilmaril@616
    92
	if (i>=0)
insilmaril@616
    93
		return values.at(i);
insilmaril@616
    94
	else
insilmaril@616
    95
		return QStringList();
insilmaril@616
    96
}
insilmaril@616
    97
insilmaril@616
    98
QString AttributeTable::getDataXML()
insilmaril@616
    99
{
insilmaril@616
   100
	return valueElement ("attributeList","key","value");
insilmaril@616
   101
}