diff options
author | Mike Buland <eichlan@xagasoft.com> | 2012-11-09 17:20:11 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2012-11-09 17:20:11 +0000 |
commit | d534a56d95bca7bdd812be024d9eacba4734e2b7 (patch) | |
tree | f9b98ee2b80e645a7b54e7934882be6c9f73c165 /c++-libbu++/src/gatscon/filewidget.cpp | |
parent | 61ccc86fdf06f12cb72a8b7e65286f812cf62154 (diff) | |
download | libgats-d534a56d95bca7bdd812be024d9eacba4734e2b7.tar.gz libgats-d534a56d95bca7bdd812be024d9eacba4734e2b7.tar.bz2 libgats-d534a56d95bca7bdd812be024d9eacba4734e2b7.tar.xz libgats-d534a56d95bca7bdd812be024d9eacba4734e2b7.zip |
Many changes: tabconv'd the C++ code, added a license, BSD, and docs.
Diffstat (limited to '')
-rw-r--r-- | c++-libbu++/src/gatscon/filewidget.cpp | 75 |
1 files changed, 41 insertions, 34 deletions
diff --git a/c++-libbu++/src/gatscon/filewidget.cpp b/c++-libbu++/src/gatscon/filewidget.cpp index dbd70fd..23f6839 100644 --- a/c++-libbu++/src/gatscon/filewidget.cpp +++ b/c++-libbu++/src/gatscon/filewidget.cpp | |||
@@ -1,3 +1,10 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007-2012 Xagasoft, All rights reserved. | ||
3 | * | ||
4 | * This file is part of the libgats library and is released under the | ||
5 | * terms of the license contained in the file LICENSE. | ||
6 | */ | ||
7 | |||
1 | #include "filewidget.h" | 8 | #include "filewidget.h" |
2 | 9 | ||
3 | #include "gatstotree.h" | 10 | #include "gatstotree.h" |
@@ -12,28 +19,28 @@ | |||
12 | using namespace Bu; | 19 | using namespace Bu; |
13 | 20 | ||
14 | FileWidget::FileWidget( QWidget *pParent ) : | 21 | FileWidget::FileWidget( QWidget *pParent ) : |
15 | QWidget( pParent ) | 22 | QWidget( pParent ) |
16 | { | 23 | { |
17 | setupUi( this ); | 24 | setupUi( this ); |
18 | } | 25 | } |
19 | 26 | ||
20 | FileWidget::FileWidget( QWidget *pParent, QString sFile ) : | 27 | FileWidget::FileWidget( QWidget *pParent, QString sFile ) : |
21 | QWidget( pParent ) | 28 | QWidget( pParent ) |
22 | { | 29 | { |
23 | setupUi( this ); | 30 | setupUi( this ); |
24 | 31 | ||
25 | File fIn( sFile.toAscii().constData(), File::Read ); | 32 | File fIn( sFile.toAscii().constData(), File::Read ); |
26 | Gats::GatsStream gsIn( fIn ); | 33 | Gats::GatsStream gsIn( fIn ); |
27 | Gats::Object *pObj; | 34 | Gats::Object *pObj; |
28 | while( (pObj = gsIn.readObject()) ) | 35 | while( (pObj = gsIn.readObject()) ) |
29 | { | 36 | { |
30 | QTreeWidgetItem *pNew = new QTreeWidgetItem( | 37 | QTreeWidgetItem *pNew = new QTreeWidgetItem( |
31 | twGats->invisibleRootItem() | 38 | twGats->invisibleRootItem() |
32 | ); | 39 | ); |
33 | pNew->setText( 0, "<root>" ); | 40 | pNew->setText( 0, "<root>" ); |
34 | gatsToTree( pNew, pObj ); | 41 | gatsToTree( pNew, pObj ); |
35 | delete pObj; | 42 | delete pObj; |
36 | } | 43 | } |
37 | } | 44 | } |
38 | 45 | ||
39 | FileWidget::~FileWidget() | 46 | FileWidget::~FileWidget() |
@@ -42,28 +49,28 @@ FileWidget::~FileWidget() | |||
42 | 49 | ||
43 | void FileWidget::saveTo( const QString &sFile ) | 50 | void FileWidget::saveTo( const QString &sFile ) |
44 | { | 51 | { |
45 | File fOut( sFile.toAscii().constData(), File::WriteNew ); | 52 | File fOut( sFile.toAscii().constData(), File::WriteNew ); |
46 | Gats::GatsStream gsOut( fOut ); | 53 | Gats::GatsStream gsOut( fOut ); |
47 | QTreeWidgetItem *pRoot = twGats->invisibleRootItem(); | 54 | QTreeWidgetItem *pRoot = twGats->invisibleRootItem(); |
48 | for( int j = 0; j < pRoot->childCount(); j++ ) | 55 | for( int j = 0; j < pRoot->childCount(); j++ ) |
49 | { | 56 | { |
50 | Gats::Object *pObj = treeToGats( pRoot->child( j ) ); | 57 | Gats::Object *pObj = treeToGats( pRoot->child( j ) ); |
51 | gsOut.writeObject( pObj ); | 58 | gsOut.writeObject( pObj ); |
52 | delete pObj; | 59 | delete pObj; |
53 | } | 60 | } |
54 | } | 61 | } |
55 | 62 | ||
56 | void FileWidget::addRootItem() | 63 | void FileWidget::addRootItem() |
57 | { | 64 | { |
58 | QString sText = QInputDialog::getText( this, "Gats Console - Add Root Item", | 65 | QString sText = QInputDialog::getText( this, "Gats Console - Add Root Item", |
59 | "Gats:"); | 66 | "Gats:"); |
60 | Gats::Object *pObj = Gats::Object::strToGats( sText.toAscii().constData() ); | 67 | Gats::Object *pObj = Gats::Object::strToGats( sText.toAscii().constData() ); |
61 | QTreeWidgetItem *pNew = new QTreeWidgetItem( | 68 | QTreeWidgetItem *pNew = new QTreeWidgetItem( |
62 | twGats->invisibleRootItem() | 69 | twGats->invisibleRootItem() |
63 | ); | 70 | ); |
64 | pNew->setText( 0, "<root>" ); | 71 | pNew->setText( 0, "<root>" ); |
65 | gatsToTree( pNew, pObj ); | 72 | gatsToTree( pNew, pObj ); |
66 | delete pObj; | 73 | delete pObj; |
67 | } | 74 | } |
68 | 75 | ||
69 | void FileWidget::delRootItem() | 76 | void FileWidget::delRootItem() |