#include "filewidget.h" #include "gatstotree.h" #include "treetogats.h" #include #include #include #include using namespace Bu; FileWidget::FileWidget( QWidget *pParent ) : QWidget( pParent ) { setupUi( this ); } FileWidget::FileWidget( QWidget *pParent, QString sFile ) : QWidget( pParent ) { setupUi( this ); File fIn( sFile.toAscii().constData(), File::Read ); Gats::GatsStream gsIn( fIn ); Gats::Object *pObj; while( (pObj = gsIn.readObject()) ) { QTreeWidgetItem *pNew = new QTreeWidgetItem( twGats->invisibleRootItem() ); pNew->setText( 0, "" ); gatsToTree( pNew, pObj ); delete pObj; } } FileWidget::~FileWidget() { } void FileWidget::saveTo( const QString &sFile ) { File fOut( sFile.toAscii().constData(), File::WriteNew ); Gats::GatsStream gsOut( fOut ); QTreeWidgetItem *pRoot = twGats->invisibleRootItem(); for( int j = 0; j < pRoot->childCount(); j++ ) { Gats::Object *pObj = treeToGats( pRoot->child( j ) ); gsOut.writeObject( pObj ); delete pObj; } } void FileWidget::addRootItem() { QString sText = QInputDialog::getText( this, "Gats Console - Add Root Item", "Gats:"); Gats::Object *pObj = Gats::Object::strToGats( sText.toAscii().constData() ); QTreeWidgetItem *pNew = new QTreeWidgetItem( twGats->invisibleRootItem() ); pNew->setText( 0, "" ); gatsToTree( pNew, pObj ); delete pObj; } void FileWidget::delRootItem() { }