From 74dd68ad611d15abf16a65c36a7cfd3f4492930a Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Fri, 9 Nov 2012 16:25:22 +0000 Subject: Made the repo less libbu++-centric. --- c++-libbu++/src/gatscon/filewidget.cpp | 72 ++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 c++-libbu++/src/gatscon/filewidget.cpp (limited to 'c++-libbu++/src/gatscon/filewidget.cpp') diff --git a/c++-libbu++/src/gatscon/filewidget.cpp b/c++-libbu++/src/gatscon/filewidget.cpp new file mode 100644 index 0000000..dbd70fd --- /dev/null +++ b/c++-libbu++/src/gatscon/filewidget.cpp @@ -0,0 +1,72 @@ +#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() +{ +} + -- cgit v1.2.3