#include "gatstotree.h" #include #include void gatsToTree( QTreeWidgetItem *p, Gats::Object *pObj ) { switch( pObj->getType() ) { case Gats::typeInteger: gatsToTree( p, dynamic_cast( pObj ) ); break; case Gats::typeString: gatsToTree( p, dynamic_cast( pObj ) ); break; case Gats::typeFloat: gatsToTree( p, dynamic_cast( pObj ) ); break; case Gats::typeBoolean: gatsToTree( p, dynamic_cast( pObj ) ); break; case Gats::typeList: gatsToTree( p, dynamic_cast( pObj ) ); break; case Gats::typeDictionary: gatsToTree( p, dynamic_cast( pObj ) ); break; } } void gatsToTree( QTreeWidgetItem *p, Gats::Integer *pObj ) { p->setText( 1, "int"); p->setText( 2, QString("%1").arg( pObj->getValue() ) ); } void gatsToTree( QTreeWidgetItem *p, Gats::String *pObj ) { p->setText( 1, "str"); p->setText( 2, QString("%1").arg( pObj->getStr() ) ); } void gatsToTree( QTreeWidgetItem *p, Gats::Float *pObj ) { p->setText( 1, "float"); p->setText( 2, QString("%1").arg( pObj->getValue() ) ); } void gatsToTree( QTreeWidgetItem *p, Gats::Boolean *pObj ) { p->setText( 1, "bool"); p->setText( 2, pObj->getValue()?"true":"false" ); } void gatsToTree( QTreeWidgetItem *p, Gats::List *pObj ) { p->setText( 1, "list"); int j = 0; for( Gats::List::iterator i = pObj->begin(); i; i++ ) { QTreeWidgetItem *pIt = new QTreeWidgetItem( p ); pIt->setText( 0, QString("%1").arg( j++ ) ); gatsToTree( pIt, *i ); } } void gatsToTree( QTreeWidgetItem *p, Gats::Dictionary *pObj ) { p->setText( 1, "dict"); for( Gats::Dictionary::iterator i = pObj->begin(); i; i++ ) { QTreeWidgetItem *pIt = new QTreeWidgetItem( p ); pIt->setText( 0, QString( i.getKey().getStr() ) ); gatsToTree( pIt, *i ); } }