aboutsummaryrefslogtreecommitdiff
path: root/c++-libbu++/src/gatscon/filewidget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'c++-libbu++/src/gatscon/filewidget.cpp')
-rw-r--r--c++-libbu++/src/gatscon/filewidget.cpp72
1 files changed, 72 insertions, 0 deletions
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 @@
1#include "filewidget.h"
2
3#include "gatstotree.h"
4#include "treetogats.h"
5
6#include <gats/types.h>
7#include <gats/gatsstream.h>
8#include <bu/file.h>
9
10#include <QInputDialog>
11
12using namespace Bu;
13
14FileWidget::FileWidget( QWidget *pParent ) :
15 QWidget( pParent )
16{
17 setupUi( this );
18}
19
20FileWidget::FileWidget( QWidget *pParent, QString sFile ) :
21 QWidget( pParent )
22{
23 setupUi( this );
24
25 File fIn( sFile.toAscii().constData(), File::Read );
26 Gats::GatsStream gsIn( fIn );
27 Gats::Object *pObj;
28 while( (pObj = gsIn.readObject()) )
29 {
30 QTreeWidgetItem *pNew = new QTreeWidgetItem(
31 twGats->invisibleRootItem()
32 );
33 pNew->setText( 0, "<root>" );
34 gatsToTree( pNew, pObj );
35 delete pObj;
36 }
37}
38
39FileWidget::~FileWidget()
40{
41}
42
43void FileWidget::saveTo( const QString &sFile )
44{
45 File fOut( sFile.toAscii().constData(), File::WriteNew );
46 Gats::GatsStream gsOut( fOut );
47 QTreeWidgetItem *pRoot = twGats->invisibleRootItem();
48 for( int j = 0; j < pRoot->childCount(); j++ )
49 {
50 Gats::Object *pObj = treeToGats( pRoot->child( j ) );
51 gsOut.writeObject( pObj );
52 delete pObj;
53 }
54}
55
56void FileWidget::addRootItem()
57{
58 QString sText = QInputDialog::getText( this, "Gats Console - Add Root Item",
59 "Gats:");
60 Gats::Object *pObj = Gats::Object::strToGats( sText.toAscii().constData() );
61 QTreeWidgetItem *pNew = new QTreeWidgetItem(
62 twGats->invisibleRootItem()
63 );
64 pNew->setText( 0, "<root>" );
65 gatsToTree( pNew, pObj );
66 delete pObj;
67}
68
69void FileWidget::delRootItem()
70{
71}
72