diff options
Diffstat (limited to 'src/gatscon/gatstotree.cpp')
-rw-r--r-- | src/gatscon/gatstotree.cpp | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/src/gatscon/gatstotree.cpp b/src/gatscon/gatstotree.cpp index af94fa5..d01e4b8 100644 --- a/src/gatscon/gatstotree.cpp +++ b/src/gatscon/gatstotree.cpp | |||
@@ -1,8 +1,83 @@ | |||
1 | #include "gatstotree.h" | ||
2 | |||
1 | #include <gats/types.h> | 3 | #include <gats/types.h> |
2 | 4 | ||
3 | #include <QTreeWidgetItem> | 5 | #include <QTreeWidgetItem> |
4 | 6 | ||
5 | void gatsToTree( QTreeWidgetItem *p, Gats::Object *pObj ) | 7 | void gatsToTree( QTreeWidgetItem *p, Gats::Object *pObj ) |
6 | { | 8 | { |
9 | switch( pObj->getType() ) | ||
10 | { | ||
11 | case Gats::typeInteger: | ||
12 | gatsToTree( p, dynamic_cast<Gats::Integer *>( pObj ) ); | ||
13 | break; | ||
14 | |||
15 | case Gats::typeString: | ||
16 | gatsToTree( p, dynamic_cast<Gats::String *>( pObj ) ); | ||
17 | break; | ||
18 | |||
19 | case Gats::typeFloat: | ||
20 | gatsToTree( p, dynamic_cast<Gats::Float *>( pObj ) ); | ||
21 | break; | ||
22 | |||
23 | case Gats::typeBoolean: | ||
24 | gatsToTree( p, dynamic_cast<Gats::Boolean *>( pObj ) ); | ||
25 | break; | ||
26 | |||
27 | case Gats::typeList: | ||
28 | gatsToTree( p, dynamic_cast<Gats::List *>( pObj ) ); | ||
29 | break; | ||
30 | |||
31 | case Gats::typeDictionary: | ||
32 | gatsToTree( p, dynamic_cast<Gats::Dictionary *>( pObj ) ); | ||
33 | break; | ||
34 | } | ||
35 | } | ||
36 | |||
37 | void gatsToTree( QTreeWidgetItem *p, Gats::Integer *pObj ) | ||
38 | { | ||
39 | p->setText( 1, "int"); | ||
40 | p->setText( 2, QString("%1").arg( pObj->getValue() ) ); | ||
41 | } | ||
42 | |||
43 | void gatsToTree( QTreeWidgetItem *p, Gats::String *pObj ) | ||
44 | { | ||
45 | p->setText( 1, "str"); | ||
46 | p->setText( 2, QString("%1").arg( pObj->getStr() ) ); | ||
47 | } | ||
48 | |||
49 | void gatsToTree( QTreeWidgetItem *p, Gats::Float *pObj ) | ||
50 | { | ||
51 | p->setText( 1, "float"); | ||
52 | p->setText( 2, QString("%1").arg( pObj->getValue() ) ); | ||
53 | } | ||
54 | |||
55 | void gatsToTree( QTreeWidgetItem *p, Gats::Boolean *pObj ) | ||
56 | { | ||
57 | p->setText( 1, "bool"); | ||
58 | p->setText( 2, pObj->getValue()?"true":"false" ); | ||
59 | } | ||
60 | |||
61 | void gatsToTree( QTreeWidgetItem *p, Gats::List *pObj ) | ||
62 | { | ||
63 | p->setText( 1, "list"); | ||
64 | int j = 0; | ||
65 | for( Gats::List::iterator i = pObj->begin(); i; i++ ) | ||
66 | { | ||
67 | QTreeWidgetItem *pIt = new QTreeWidgetItem( p ); | ||
68 | pIt->setText( 0, QString("%1").arg( j++ ) ); | ||
69 | gatsToTree( pIt, *i ); | ||
70 | } | ||
71 | } | ||
72 | |||
73 | void gatsToTree( QTreeWidgetItem *p, Gats::Dictionary *pObj ) | ||
74 | { | ||
75 | p->setText( 1, "dict"); | ||
76 | for( Gats::Dictionary::iterator i = pObj->begin(); i; i++ ) | ||
77 | { | ||
78 | QTreeWidgetItem *pIt = new QTreeWidgetItem( p ); | ||
79 | pIt->setText( 0, QString( i.getKey().getStr() ) ); | ||
80 | gatsToTree( pIt, *i ); | ||
81 | } | ||
7 | } | 82 | } |
8 | 83 | ||