author | mickeyl <mickeyl> | 2003-03-02 16:38:17 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-03-02 16:38:17 (UTC) |
commit | d0e64d0c7961de1c3ecb886ae76c6701f268d767 (patch) (unidiff) | |
tree | 2ea00b7cd496bb0720b9730bbf993f2013a87d3e /noncore/net/wellenreiter/gui/mainwindow.cpp | |
parent | a0ae7d2b8cfef3f643c4aa536bdf25d7da510142 (diff) | |
download | opie-d0e64d0c7961de1c3ecb886ae76c6701f268d767.zip opie-d0e64d0c7961de1c3ecb886ae76c6701f268d767.tar.gz opie-d0e64d0c7961de1c3ecb886ae76c6701f268d767.tar.bz2 |
first attempt to add session persistence
Diffstat (limited to 'noncore/net/wellenreiter/gui/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/mainwindow.cpp | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/noncore/net/wellenreiter/gui/mainwindow.cpp b/noncore/net/wellenreiter/gui/mainwindow.cpp index e388fc5..0ef89d4 100644 --- a/noncore/net/wellenreiter/gui/mainwindow.cpp +++ b/noncore/net/wellenreiter/gui/mainwindow.cpp | |||
@@ -22,4 +22,5 @@ | |||
22 | 22 | ||
23 | #include <qcombobox.h> | 23 | #include <qcombobox.h> |
24 | #include <qdatastream.h> | ||
24 | #include <qfile.h> | 25 | #include <qfile.h> |
25 | #include <qiconset.h> | 26 | #include <qiconset.h> |
@@ -45,4 +46,11 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n | |||
45 | setCentralWidget( mw ); | 46 | setCentralWidget( mw ); |
46 | 47 | ||
48 | // setup application icon | ||
49 | |||
50 | #ifndef QWS | ||
51 | setIcon( Resource::loadPixmap( "wellenreiter/appicon-trans" ) ); | ||
52 | setIconText( "Wellenreiter/X11" ); | ||
53 | #endif | ||
54 | |||
47 | // setup icon sets | 55 | // setup icon sets |
48 | 56 | ||
@@ -100,9 +108,8 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n | |||
100 | QPopupMenu* fileLoad = new QPopupMenu( mb ); | 108 | QPopupMenu* fileLoad = new QPopupMenu( mb ); |
101 | fileLoad->insertItem( "&Session", this, SLOT( fileLoadSession() ) ); | 109 | fileLoad->insertItem( "&Session", this, SLOT( fileLoadSession() ) ); |
102 | fileLoad->insertItem( "&Log", this, SLOT( fileLoadLog() ) ); | 110 | //fileLoad->insertItem( "&Log", this, SLOT( fileLoadLog() ) ); |
103 | 111 | ||
104 | QPopupMenu* file = new QPopupMenu( mb ); | 112 | QPopupMenu* file = new QPopupMenu( mb ); |
105 | id = file->insertItem( "&Load", fileLoad ); | 113 | id = file->insertItem( "&Load", fileLoad ); |
106 | file->setItemEnabled( id, false ); | ||
107 | file->insertItem( "&Save", fileSave ); | 114 | file->insertItem( "&Save", fileSave ); |
108 | 115 | ||
@@ -186,5 +193,5 @@ void WellenreiterMainWindow::demoAddStations() | |||
186 | { | 193 | { |
187 | mw->netView()->addNewItem( "managed", "Vanille", "00:00:20:EF:A6:43", true, 6, 80 ); | 194 | mw->netView()->addNewItem( "managed", "Vanille", "00:00:20:EF:A6:43", true, 6, 80 ); |
188 | mw->netView()->addNewItem( "managed", "Vanille", "00:00:1c:EF:A6:23", true, 11, 10 ); | 195 | mw->netView()->addNewItem( "managed", "Vanille", "00:30:6D:EF:A6:23", true, 11, 10 ); |
189 | mw->netView()->addNewItem( "adhoc", "ELAN", "00:A0:F8:E7:16:22", false, 3, 10 ); | 196 | mw->netView()->addNewItem( "adhoc", "ELAN", "00:A0:F8:E7:16:22", false, 3, 10 ); |
190 | mw->netView()->addNewItem( "adhoc", "ELAN", "00:AA:01:E7:56:62", false, 3, 15 ); | 197 | mw->netView()->addNewItem( "adhoc", "ELAN", "00:AA:01:E7:56:62", false, 3, 15 ); |
@@ -216,6 +223,6 @@ void WellenreiterMainWindow::fileSaveSession() | |||
216 | if ( f.open(IO_WriteOnly) ) | 223 | if ( f.open(IO_WriteOnly) ) |
217 | { | 224 | { |
218 | QTextStream t( &f ); | 225 | QDataStream t( &f ); |
219 | mw->netView()->dump( t ); | 226 | t << *mw->netView(); |
220 | f.close(); | 227 | f.close(); |
221 | qDebug( "Saved session to file '%s'", (const char*) fname ); | 228 | qDebug( "Saved session to file '%s'", (const char*) fname ); |
@@ -227,4 +234,23 @@ void WellenreiterMainWindow::fileSaveSession() | |||
227 | } | 234 | } |
228 | 235 | ||
236 | void WellenreiterMainWindow::fileLoadSession() | ||
237 | { | ||
238 | const QString fname( "/tmp/session.xml" ); | ||
239 | QFile f( fname ); | ||
240 | |||
241 | if ( f.open(IO_ReadOnly) ) | ||
242 | { | ||
243 | QDataStream t( &f ); | ||
244 | t >> *mw->netView(); | ||
245 | f.close(); | ||
246 | qDebug( "Loaded session from file '%s'", (const char*) fname ); | ||
247 | } | ||
248 | else | ||
249 | { | ||
250 | qDebug( "Problem loading session from file '%s'", (const char*) fname ); | ||
251 | } | ||
252 | |||
253 | } | ||
254 | |||
229 | void WellenreiterMainWindow::closeEvent( QCloseEvent* e ) | 255 | void WellenreiterMainWindow::closeEvent( QCloseEvent* e ) |
230 | { | 256 | { |