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