diff options
author | Mike Buland <eichlan@xagasoft.com> | 2011-05-17 14:56:28 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2011-05-17 14:56:28 +0000 |
commit | 6d8bc516acf7a5995736423e838c987d08e69c09 (patch) | |
tree | 9db78ee528b26e0d5718b2ac4c987388e1b9c313 /src/gatscon/filewidget.cpp | |
parent | d269a39f27e2dcd57d0e3362ef3a7fd9ad3f3639 (diff) | |
download | libgats-6d8bc516acf7a5995736423e838c987d08e69c09.tar.gz libgats-6d8bc516acf7a5995736423e838c987d08e69c09.tar.bz2 libgats-6d8bc516acf7a5995736423e838c987d08e69c09.tar.xz libgats-6d8bc516acf7a5995736423e838c987d08e69c09.zip |
Ok, you can now open files, save files, save files from proxies and clients,
and add new root items to files. Later I'll add some actual editing
capabilities, should be really easy.
Diffstat (limited to 'src/gatscon/filewidget.cpp')
-rw-r--r-- | src/gatscon/filewidget.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/gatscon/filewidget.cpp b/src/gatscon/filewidget.cpp index b2dd09e..70f7b03 100644 --- a/src/gatscon/filewidget.cpp +++ b/src/gatscon/filewidget.cpp | |||
@@ -1,11 +1,14 @@ | |||
1 | #include "filewidget.h" | 1 | #include "filewidget.h" |
2 | 2 | ||
3 | #include "gatstotree.h" | 3 | #include "gatstotree.h" |
4 | #include "treetogats.h" | ||
4 | 5 | ||
5 | #include <gats/types.h> | 6 | #include <gats/types.h> |
6 | #include <gats/gatsstream.h> | 7 | #include <gats/gatsstream.h> |
7 | #include <bu/file.h> | 8 | #include <bu/file.h> |
8 | 9 | ||
10 | #include <QInputDialog> | ||
11 | |||
9 | using namespace Bu; | 12 | using namespace Bu; |
10 | 13 | ||
11 | FileWidget::FileWidget( QWidget *pParent ) : | 14 | FileWidget::FileWidget( QWidget *pParent ) : |
@@ -37,3 +40,33 @@ FileWidget::~FileWidget() | |||
37 | { | 40 | { |
38 | } | 41 | } |
39 | 42 | ||
43 | void 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 | |||
56 | void FileWidget::addRootItem() | ||
57 | { | ||
58 | QString sText = QInputDialog::getText( this, "GatsCon - 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 | |||
69 | void FileWidget::delRootItem() | ||
70 | { | ||
71 | } | ||
72 | |||