aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2011-05-17 13:24:19 +0000
committerMike Buland <eichlan@xagasoft.com>2011-05-17 13:24:19 +0000
commitd269a39f27e2dcd57d0e3362ef3a7fd9ad3f3639 (patch)
tree8fa45d8c6dd61e3949ecf1727c6facb78bfe5305 /src
parent6aefa6632023c99c5b91bae0e099df94fa69d890 (diff)
downloadlibgats-d269a39f27e2dcd57d0e3362ef3a7fd9ad3f3639.tar.gz
libgats-d269a39f27e2dcd57d0e3362ef3a7fd9ad3f3639.tar.bz2
libgats-d269a39f27e2dcd57d0e3362ef3a7fd9ad3f3639.tar.xz
libgats-d269a39f27e2dcd57d0e3362ef3a7fd9ad3f3639.zip
GatsCon can read files now, but it can't save them, or edit them yet. That'll
be coming eventually.
Diffstat (limited to 'src')
-rw-r--r--src/gatscon/filewidget.cpp39
-rw-r--r--src/gatscon/filewidget.h22
-rw-r--r--src/gatscon/filewidget.ui40
-rw-r--r--src/gatscon/mainwnd.cpp12
-rw-r--r--src/gatscon/mainwnd.ui31
5 files changed, 141 insertions, 3 deletions
diff --git a/src/gatscon/filewidget.cpp b/src/gatscon/filewidget.cpp
new file mode 100644
index 0000000..b2dd09e
--- /dev/null
+++ b/src/gatscon/filewidget.cpp
@@ -0,0 +1,39 @@
1#include "filewidget.h"
2
3#include "gatstotree.h"
4
5#include <gats/types.h>
6#include <gats/gatsstream.h>
7#include <bu/file.h>
8
9using namespace Bu;
10
11FileWidget::FileWidget( QWidget *pParent ) :
12 QWidget( pParent )
13{
14 setupUi( this );
15}
16
17FileWidget::FileWidget( QWidget *pParent, QString sFile ) :
18 QWidget( pParent )
19{
20 setupUi( this );
21
22 File fIn( sFile.toAscii().constData(), File::Read );
23 Gats::GatsStream gsIn( fIn );
24 Gats::Object *pObj;
25 while( (pObj = gsIn.readObject()) )
26 {
27 QTreeWidgetItem *pNew = new QTreeWidgetItem(
28 twGats->invisibleRootItem()
29 );
30 pNew->setText( 0, "<root>" );
31 gatsToTree( pNew, pObj );
32 delete pObj;
33 }
34}
35
36FileWidget::~FileWidget()
37{
38}
39
diff --git a/src/gatscon/filewidget.h b/src/gatscon/filewidget.h
new file mode 100644
index 0000000..ac46685
--- /dev/null
+++ b/src/gatscon/filewidget.h
@@ -0,0 +1,22 @@
1#ifndef FILE_WIDGET_H
2#define FILE_WIDGET_H
3
4#include "ui_filewidget.h"
5
6namespace Gats
7{
8 class Object;
9};
10
11class FileWidget : public QWidget, protected Ui::FileWidget
12{
13 Q_OBJECT;
14public:
15 FileWidget( QWidget *pParent=NULL );
16 FileWidget( QWidget *pParent, QString sFile );
17 virtual ~FileWidget();
18
19private:
20};
21
22#endif
diff --git a/src/gatscon/filewidget.ui b/src/gatscon/filewidget.ui
new file mode 100644
index 0000000..6557035
--- /dev/null
+++ b/src/gatscon/filewidget.ui
@@ -0,0 +1,40 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<ui version="4.0">
3 <class>FileWidget</class>
4 <widget class="QWidget" name="FileWidget">
5 <property name="geometry">
6 <rect>
7 <x>0</x>
8 <y>0</y>
9 <width>400</width>
10 <height>300</height>
11 </rect>
12 </property>
13 <property name="windowTitle">
14 <string>Form</string>
15 </property>
16 <layout class="QVBoxLayout" name="verticalLayout">
17 <item>
18 <widget class="QTreeWidget" name="twGats">
19 <column>
20 <property name="text">
21 <string>Name</string>
22 </property>
23 </column>
24 <column>
25 <property name="text">
26 <string>Type</string>
27 </property>
28 </column>
29 <column>
30 <property name="text">
31 <string>Value</string>
32 </property>
33 </column>
34 </widget>
35 </item>
36 </layout>
37 </widget>
38 <resources/>
39 <connections/>
40</ui>
diff --git a/src/gatscon/mainwnd.cpp b/src/gatscon/mainwnd.cpp
index f20a531..628988e 100644
--- a/src/gatscon/mainwnd.cpp
+++ b/src/gatscon/mainwnd.cpp
@@ -2,10 +2,13 @@
2 2
3#include "clientwidget.h" 3#include "clientwidget.h"
4#include "proxywidget.h" 4#include "proxywidget.h"
5#include "filewidget.h"
5 6
6#include "connectdlg.h" 7#include "connectdlg.h"
7#include "setupproxydlg.h" 8#include "setupproxydlg.h"
8 9
10#include <QFileDialog>
11
9MainWnd::MainWnd() 12MainWnd::MainWnd()
10{ 13{
11 setupUi( this ); 14 setupUi( this );
@@ -44,5 +47,14 @@ void MainWnd::proxy()
44 47
45void MainWnd::open() 48void MainWnd::open()
46{ 49{
50 QString sFile = QFileDialog::getOpenFileName(
51 this, "GatsCon - open gats file"
52 );
53 if( sFile.isEmpty() )
54 return;
55
56 setCentralWidget(
57 new FileWidget( this, sFile )
58 );
47} 59}
48 60
diff --git a/src/gatscon/mainwnd.ui b/src/gatscon/mainwnd.ui
index e080dd3..dbf5e11 100644
--- a/src/gatscon/mainwnd.ui
+++ b/src/gatscon/mainwnd.ui
@@ -28,6 +28,11 @@
28 <string>&amp;File</string> 28 <string>&amp;File</string>
29 </property> 29 </property>
30 <addaction name="action_Open_gats_file"/> 30 <addaction name="action_Open_gats_file"/>
31 <addaction name="action_New_Gats_File"/>
32 <addaction name="action_Save"/>
33 <addaction name="action_Save_As"/>
34 <addaction name="separator"/>
35 <addaction name="actionE_xit"/>
31 </widget> 36 </widget>
32 <widget class="QMenu" name="menu_Network"> 37 <widget class="QMenu" name="menu_Network">
33 <property name="title"> 38 <property name="title">
@@ -52,7 +57,27 @@
52 </action> 57 </action>
53 <action name="action_Open_gats_file"> 58 <action name="action_Open_gats_file">
54 <property name="text"> 59 <property name="text">
55 <string>&amp;Open gats file...</string> 60 <string>&amp;Open Gats File...</string>
61 </property>
62 </action>
63 <action name="action_New_Gats_File">
64 <property name="text">
65 <string>&amp;New Gats File</string>
66 </property>
67 </action>
68 <action name="action_Save">
69 <property name="text">
70 <string>&amp;Save</string>
71 </property>
72 </action>
73 <action name="action_Save_As">
74 <property name="text">
75 <string>&amp;Save As...</string>
76 </property>
77 </action>
78 <action name="actionE_xit">
79 <property name="text">
80 <string>E&amp;xit</string>
56 </property> 81 </property>
57 </action> 82 </action>
58 </widget> 83 </widget>
@@ -65,8 +90,8 @@
65 <slot>connect()</slot> 90 <slot>connect()</slot>
66 <hints> 91 <hints>
67 <hint type="sourcelabel"> 92 <hint type="sourcelabel">
68 <x>215</x> 93 <x>-1</x>
69 <y>159</y> 94 <y>-1</y>
70 </hint> 95 </hint>
71 <hint type="destinationlabel"> 96 <hint type="destinationlabel">
72 <x>215</x> 97 <x>215</x>