summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-03-04 14:24:58 (UTC)
committer mickeyl <mickeyl>2003-03-04 14:24:58 (UTC)
commit8642232f4435bc5341037527d1eb12d1f39781f4 (patch) (unidiff)
tree495a20be66433317753e7b98aec57a0de8ca53b3
parent3adca473d5440b00e15781627e00465350e9118b (diff)
downloadopie-8642232f4435bc5341037527d1eb12d1f39781f4.zip
opie-8642232f4435bc5341037527d1eb12d1f39781f4.tar.gz
opie-8642232f4435bc5341037527d1eb12d1f39781f4.tar.bz2
add missing header for x11 standalone build
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/mainwindow.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/noncore/net/wellenreiter/gui/mainwindow.cpp b/noncore/net/wellenreiter/gui/mainwindow.cpp
index 1185f84..d4988af 100644
--- a/noncore/net/wellenreiter/gui/mainwindow.cpp
+++ b/noncore/net/wellenreiter/gui/mainwindow.cpp
@@ -1,312 +1,313 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Opie Environment. 4** This file is part of Opie Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14**********************************************************************/ 14**********************************************************************/
15 15
16#include "configwindow.h" 16#include "configwindow.h"
17#include "logwindow.h" 17#include "logwindow.h"
18#include "mainwindow.h" 18#include "mainwindow.h"
19#include "wellenreiter.h" 19#include "wellenreiter.h"
20 20
21#include "scanlist.h" 21#include "scanlist.h"
22 22
23#include <qcombobox.h> 23#include <qcombobox.h>
24#include <qdatastream.h> 24#include <qdatastream.h>
25#include <qfile.h> 25#include <qfile.h>
26#include <qfileinfo.h> 26#include <qfileinfo.h>
27#include <qiconset.h> 27#include <qiconset.h>
28#include <qmenubar.h> 28#include <qmenubar.h>
29#include <qmessagebox.h> 29#include <qmessagebox.h>
30#include <qpopupmenu.h> 30#include <qpopupmenu.h>
31#include <qstatusbar.h> 31#include <qstatusbar.h>
32#include <qtextstream.h> 32#include <qtextstream.h>
33#include <qtoolbutton.h> 33#include <qtoolbutton.h>
34 34
35#ifdef QWS 35#ifdef QWS
36#include <qpe/resource.h> 36#include <qpe/resource.h>
37#include <opie/ofiledialog.h> 37#include <opie/ofiledialog.h>
38#else 38#else
39#include "resource.h" 39#include "resource.h"
40#include <qapplication.h>
40#include <qfiledialog.h> 41#include <qfiledialog.h>
41#endif 42#endif
42 43
43WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * name, WFlags f ) 44WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * name, WFlags f )
44 :QMainWindow( parent, name, f ) 45 :QMainWindow( parent, name, f )
45{ 46{
46 cw = new WellenreiterConfigWindow( this ); 47 cw = new WellenreiterConfigWindow( this );
47 mw = new Wellenreiter( this ); 48 mw = new Wellenreiter( this );
48 mw->setConfigWindow( cw ); 49 mw->setConfigWindow( cw );
49 setCentralWidget( mw ); 50 setCentralWidget( mw );
50 51
51 // setup application icon 52 // setup application icon
52 53
53 #ifndef QWS 54 #ifndef QWS
54 setIcon( Resource::loadPixmap( "wellenreiter/appicon-trans" ) ); 55 setIcon( Resource::loadPixmap( "wellenreiter/appicon-trans" ) );
55 setIconText( "Wellenreiter/X11" ); 56 setIconText( "Wellenreiter/X11" );
56 #endif 57 #endif
57 58
58 // setup icon sets 59 // setup icon sets
59 60
60 infoIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/InfoIcon" ) ); 61 infoIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/InfoIcon" ) );
61 settingsIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SettingsIcon" ) ); 62 settingsIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SettingsIcon" ) );
62 #ifdef QWS 63 #ifdef QWS
63 searchIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SearchIcon" ) ); 64 searchIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SearchIcon" ) );
64 cancelIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/CancelIcon" ) ); 65 cancelIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/CancelIcon" ) );
65 #else 66 #else
66 startStopIconSet = new QIconSet(); 67 startStopIconSet = new QIconSet();
67 startStopIconSet->setPixmap( Resource::loadPixmap( "wellenreiter/SearchIcon" ), QIconSet::Automatic, QIconSet::Normal, QIconSet::Off ); 68 startStopIconSet->setPixmap( Resource::loadPixmap( "wellenreiter/SearchIcon" ), QIconSet::Automatic, QIconSet::Normal, QIconSet::Off );
68 startStopIconSet->setPixmap( Resource::loadPixmap( "wellenreiter/CancelIcon" ), QIconSet::Automatic, QIconSet::Normal, QIconSet::On ); 69 startStopIconSet->setPixmap( Resource::loadPixmap( "wellenreiter/CancelIcon" ), QIconSet::Automatic, QIconSet::Normal, QIconSet::On );
69 #endif 70 #endif
70 71
71 // setup tool buttons 72 // setup tool buttons
72 73
73 startStopButton = new QToolButton( 0 ); 74 startStopButton = new QToolButton( 0 );
74 #ifdef QWS 75 #ifdef QWS
75 startStopButton->setAutoRaise( true ); 76 startStopButton->setAutoRaise( true );
76 #endif 77 #endif
77 #ifdef QWS 78 #ifdef QWS
78 startStopButton->setOnIconSet( *cancelIconSet ); 79 startStopButton->setOnIconSet( *cancelIconSet );
79 startStopButton->setOffIconSet( *searchIconSet ); 80 startStopButton->setOffIconSet( *searchIconSet );
80 #else 81 #else
81 startStopButton->setIconSet( *startStopIconSet ); 82 startStopButton->setIconSet( *startStopIconSet );
82 #endif 83 #endif
83 startStopButton->setToggleButton( true ); 84 startStopButton->setToggleButton( true );
84 connect( startStopButton, SIGNAL( clicked() ), mw, SLOT( startStopClicked() ) ); 85 connect( startStopButton, SIGNAL( clicked() ), mw, SLOT( startStopClicked() ) );
85 startStopButton->setEnabled( false ); 86 startStopButton->setEnabled( false );
86 87
87 QToolButton* c = new QToolButton( 0 ); 88 QToolButton* c = new QToolButton( 0 );
88 #ifdef QWS 89 #ifdef QWS
89 c->setAutoRaise( true ); 90 c->setAutoRaise( true );
90 #endif 91 #endif
91 c->setIconSet( *infoIconSet ); 92 c->setIconSet( *infoIconSet );
92 c->setEnabled( false ); 93 c->setEnabled( false );
93 94
94 QToolButton* d = new QToolButton( 0 ); 95 QToolButton* d = new QToolButton( 0 );
95 #ifdef QWS 96 #ifdef QWS
96 d->setAutoRaise( true ); 97 d->setAutoRaise( true );
97 #endif 98 #endif
98 d->setIconSet( *settingsIconSet ); 99 d->setIconSet( *settingsIconSet );
99 connect( d, SIGNAL( clicked() ), this, SLOT( showConfigure() ) ); 100 connect( d, SIGNAL( clicked() ), this, SLOT( showConfigure() ) );
100 101
101 // setup menu bar 102 // setup menu bar
102 103
103 int id; 104 int id;
104 105
105 QMenuBar* mb = menuBar(); 106 QMenuBar* mb = menuBar();
106 107
107 QPopupMenu* fileSave = new QPopupMenu( mb ); 108 QPopupMenu* fileSave = new QPopupMenu( mb );
108 fileSave->insertItem( "&Session...", this, SLOT( fileSaveSession() ) ); 109 fileSave->insertItem( "&Session...", this, SLOT( fileSaveSession() ) );
109 fileSave->insertItem( "&Log...", this, SLOT( fileSaveLog() ) ); 110 fileSave->insertItem( "&Log...", this, SLOT( fileSaveLog() ) );
110 111
111 QPopupMenu* fileLoad = new QPopupMenu( mb ); 112 QPopupMenu* fileLoad = new QPopupMenu( mb );
112 fileLoad->insertItem( "&Session...", this, SLOT( fileLoadSession() ) ); 113 fileLoad->insertItem( "&Session...", this, SLOT( fileLoadSession() ) );
113 //fileLoad->insertItem( "&Log", this, SLOT( fileLoadLog() ) ); 114 //fileLoad->insertItem( "&Log", this, SLOT( fileLoadLog() ) );
114 115
115 QPopupMenu* file = new QPopupMenu( mb ); 116 QPopupMenu* file = new QPopupMenu( mb );
116 id = file->insertItem( "&Load", fileLoad ); 117 id = file->insertItem( "&Load", fileLoad );
117 file->insertItem( "&Save", fileSave ); 118 file->insertItem( "&Save", fileSave );
118 file->insertSeparator(); 119 file->insertSeparator();
119 file->insertItem( "&Exit", qApp, SLOT( quit() ) ); 120 file->insertItem( "&Exit", qApp, SLOT( quit() ) );
120 121
121 QPopupMenu* view = new QPopupMenu( mb ); 122 QPopupMenu* view = new QPopupMenu( mb );
122 view->insertItem( "&Configure..." ); 123 view->insertItem( "&Configure..." );
123 124
124 QPopupMenu* sniffer = new QPopupMenu( mb ); 125 QPopupMenu* sniffer = new QPopupMenu( mb );
125 sniffer->insertItem( "&Configure..." ); 126 sniffer->insertItem( "&Configure..." );
126 sniffer->insertSeparator(); 127 sniffer->insertSeparator();
127 128
128 QPopupMenu* demo = new QPopupMenu( mb ); 129 QPopupMenu* demo = new QPopupMenu( mb );
129 demo->insertItem( "&Add something", this, SLOT( demoAddStations() ) ); 130 demo->insertItem( "&Add something", this, SLOT( demoAddStations() ) );
130 131
131 id = mb->insertItem( "&File", file ); 132 id = mb->insertItem( "&File", file );
132 id = mb->insertItem( "&View", view ); 133 id = mb->insertItem( "&View", view );
133 mb->setItemEnabled( id, false ); 134 mb->setItemEnabled( id, false );
134 id = mb->insertItem( "&Sniffer", sniffer ); 135 id = mb->insertItem( "&Sniffer", sniffer );
135 mb->setItemEnabled( id, false ); 136 mb->setItemEnabled( id, false );
136 id = mb->insertItem( "&Demo", demo ); 137 id = mb->insertItem( "&Demo", demo );
137 mb->setItemEnabled( id, true ); 138 mb->setItemEnabled( id, true );
138 139
139 #ifdef QWS 140 #ifdef QWS
140 mb->insertItem( startStopButton ); 141 mb->insertItem( startStopButton );
141 mb->insertItem( c ); 142 mb->insertItem( c );
142 mb->insertItem( d ); 143 mb->insertItem( d );
143 #else // Qt3 changed the insertion order. It's now totally random :( 144 #else // Qt3 changed the insertion order. It's now totally random :(
144 mb->insertItem( d ); 145 mb->insertItem( d );
145 mb->insertItem( c ); 146 mb->insertItem( c );
146 mb->insertItem( startStopButton ); 147 mb->insertItem( startStopButton );
147 #endif 148 #endif
148 149
149 // setup status bar (for now only on X11) 150 // setup status bar (for now only on X11)
150 151
151 #ifndef QWS 152 #ifndef QWS
152 statusBar()->message( "Ready." ); 153 statusBar()->message( "Ready." );
153 #endif 154 #endif
154 155
155}; 156};
156 157
157void WellenreiterMainWindow::showConfigure() 158void WellenreiterMainWindow::showConfigure()
158{ 159{
159 qDebug( "show configure..." ); 160 qDebug( "show configure..." );
160 cw->setCaption( tr( "Configure" ) ); 161 cw->setCaption( tr( "Configure" ) );
161 #ifdef QWS 162 #ifdef QWS
162 cw->showMaximized(); 163 cw->showMaximized();
163 #endif 164 #endif
164 int result = cw->exec(); 165 int result = cw->exec();
165 166
166 if ( result ) 167 if ( result )
167 { 168 {
168 // check configuration from config window 169 // check configuration from config window
169 170
170 const QString& interface = cw->interfaceName->currentText(); 171 const QString& interface = cw->interfaceName->currentText();
171 const int cardtype = cw->daemonDeviceType(); 172 const int cardtype = cw->daemonDeviceType();
172 const int interval = cw->daemonHopInterval(); 173 const int interval = cw->daemonHopInterval();
173 174
174 if ( ( interface != "<select>" ) && ( cardtype != 0 ) ) 175 if ( ( interface != "<select>" ) && ( cardtype != 0 ) )
175 startStopButton->setEnabled( true ); 176 startStopButton->setEnabled( true );
176 //TODO ... 177 //TODO ...
177 else 178 else
178 startStopButton->setEnabled( false ); 179 startStopButton->setEnabled( false );
179 //TODO ... 180 //TODO ...
180 } 181 }
181} 182}
182 183
183WellenreiterMainWindow::~WellenreiterMainWindow() 184WellenreiterMainWindow::~WellenreiterMainWindow()
184{ 185{
185 186
186 delete infoIconSet; 187 delete infoIconSet;
187 delete settingsIconSet; 188 delete settingsIconSet;
188 #ifdef QWS 189 #ifdef QWS
189 delete searchIconSet; 190 delete searchIconSet;
190 delete cancelIconSet; 191 delete cancelIconSet;
191 #else 192 #else
192 delete startStopIconSet; 193 delete startStopIconSet;
193 #endif 194 #endif
194 195
195}; 196};
196 197
197void WellenreiterMainWindow::demoAddStations() 198void WellenreiterMainWindow::demoAddStations()
198{ 199{
199 mw->netView()->addNewItem( "managed", "Vanille", "00:00:20:EF:A6:43", true, 6, 80 ); 200 mw->netView()->addNewItem( "managed", "Vanille", "00:00:20:EF:A6:43", true, 6, 80 );
200 mw->netView()->addNewItem( "managed", "Vanille", "00:30:6D:EF:A6:23", true, 11, 10 ); 201 mw->netView()->addNewItem( "managed", "Vanille", "00:30:6D:EF:A6:23", true, 11, 10 );
201 mw->netView()->addNewItem( "adhoc", "ELAN", "00:A0:F8:E7:16:22", false, 3, 10 ); 202 mw->netView()->addNewItem( "adhoc", "ELAN", "00:A0:F8:E7:16:22", false, 3, 10 );
202 mw->netView()->addNewItem( "adhoc", "ELAN", "00:AA:01:E7:56:62", false, 3, 15 ); 203 mw->netView()->addNewItem( "adhoc", "ELAN", "00:AA:01:E7:56:62", false, 3, 15 );
203 mw->netView()->addNewItem( "adhoc", "ELAN", "00:B0:8E:E7:56:E2", false, 3, 20 ); 204 mw->netView()->addNewItem( "adhoc", "ELAN", "00:B0:8E:E7:56:E2", false, 3, 20 );
204} 205}
205 206
206QString WellenreiterMainWindow::getFileName( bool save ) 207QString WellenreiterMainWindow::getFileName( bool save )
207{ 208{
208 QMap<QString, QStringList> map; 209 QMap<QString, QStringList> map;
209 map.insert( tr("All"), QStringList() ); 210 map.insert( tr("All"), QStringList() );
210 QStringList text; 211 QStringList text;
211 text << "text/*"; 212 text << "text/*";
212 map.insert(tr("Text"), text ); 213 map.insert(tr("Text"), text );
213 text << "*"; 214 text << "*";
214 map.insert(tr("All"), text ); 215 map.insert(tr("All"), text );
215 216
216 QString str; 217 QString str;
217 if ( save ) 218 if ( save )
218 { 219 {
219 #ifdef QWS 220 #ifdef QWS
220 str = OFileDialog::getSaveFileName( 2, "/", QString::null, map ); 221 str = OFileDialog::getSaveFileName( 2, "/", QString::null, map );
221 #else 222 #else
222 str = QFileDialog::getSaveFileName(); 223 str = QFileDialog::getSaveFileName();
223 #endif 224 #endif
224 if ( str.isEmpty() || QFileInfo(str).isDir() ) 225 if ( str.isEmpty() || QFileInfo(str).isDir() )
225 return ""; 226 return "";
226 } 227 }
227 else 228 else
228 { 229 {
229 #ifdef QWS 230 #ifdef QWS
230 str = OFileDialog::getOpenFileName( 2, "/", QString::null, map ); 231 str = OFileDialog::getOpenFileName( 2, "/", QString::null, map );
231 #else 232 #else
232 str = QFileDialog::getOpenFileName(); 233 str = QFileDialog::getOpenFileName();
233 #endif 234 #endif
234 if ( str.isEmpty() || !QFile(str).exists() || QFileInfo(str).isDir() ) 235 if ( str.isEmpty() || !QFile(str).exists() || QFileInfo(str).isDir() )
235 return ""; 236 return "";
236 } 237 }
237 return str; 238 return str;
238} 239}
239 240
240void WellenreiterMainWindow::fileSaveLog() 241void WellenreiterMainWindow::fileSaveLog()
241{ 242{
242 QString fname = getFileName( true ); 243 QString fname = getFileName( true );
243 if ( !fname.isEmpty() ) 244 if ( !fname.isEmpty() )
244 { 245 {
245 QFile f( fname ); 246 QFile f( fname );
246 if ( f.open(IO_WriteOnly) ) 247 if ( f.open(IO_WriteOnly) )
247 { 248 {
248 QTextStream t( &f ); 249 QTextStream t( &f );
249 t << mw->logWindow()->getLog(); 250 t << mw->logWindow()->getLog();
250 f.close(); 251 f.close();
251 qDebug( "Saved log to file '%s'", (const char*) fname ); 252 qDebug( "Saved log to file '%s'", (const char*) fname );
252 } 253 }
253 else 254 else
254 { 255 {
255 qDebug( "Problem saving log to file '%s'", (const char*) fname ); 256 qDebug( "Problem saving log to file '%s'", (const char*) fname );
256 } 257 }
257 } 258 }
258} 259}
259 260
260void WellenreiterMainWindow::fileSaveSession() 261void WellenreiterMainWindow::fileSaveSession()
261{ 262{
262 QString fname = getFileName( true ); 263 QString fname = getFileName( true );
263 if ( !fname.isEmpty() ) 264 if ( !fname.isEmpty() )
264 { 265 {
265 266
266 QFile f( fname ); 267 QFile f( fname );
267 if ( f.open(IO_WriteOnly) ) 268 if ( f.open(IO_WriteOnly) )
268 { 269 {
269 QDataStream t( &f ); 270 QDataStream t( &f );
270 t << *mw->netView(); 271 t << *mw->netView();
271 f.close(); 272 f.close();
272 qDebug( "Saved session to file '%s'", (const char*) fname ); 273 qDebug( "Saved session to file '%s'", (const char*) fname );
273 } 274 }
274 else 275 else
275 { 276 {
276 qDebug( "Problem saving session to file '%s'", (const char*) fname ); 277 qDebug( "Problem saving session to file '%s'", (const char*) fname );
277 } 278 }
278 } 279 }
279} 280}
280 281
281void WellenreiterMainWindow::fileLoadSession() 282void WellenreiterMainWindow::fileLoadSession()
282{ 283{
283 QString fname = getFileName( false ); 284 QString fname = getFileName( false );
284 if ( !fname.isEmpty() ) 285 if ( !fname.isEmpty() )
285 { 286 {
286 QFile f( fname ); 287 QFile f( fname );
287 if ( f.open(IO_ReadOnly) ) 288 if ( f.open(IO_ReadOnly) )
288 { 289 {
289 QDataStream t( &f ); 290 QDataStream t( &f );
290 t >> *mw->netView(); 291 t >> *mw->netView();
291 f.close(); 292 f.close();
292 qDebug( "Loaded session from file '%s'", (const char*) fname ); 293 qDebug( "Loaded session from file '%s'", (const char*) fname );
293 } 294 }
294 else 295 else
295 { 296 {
296 qDebug( "Problem loading session from file '%s'", (const char*) fname ); 297 qDebug( "Problem loading session from file '%s'", (const char*) fname );
297 } 298 }
298 } 299 }
299} 300}
300 301
301void WellenreiterMainWindow::closeEvent( QCloseEvent* e ) 302void WellenreiterMainWindow::closeEvent( QCloseEvent* e )
302{ 303{
303 if ( mw->isDaemonRunning() ) 304 if ( mw->isDaemonRunning() )
304 { 305 {
305 QMessageBox::warning( this, "Wellenreiter/Opie", "Sniffing in progress!\nPlease stop sniffing before closing." ); 306 QMessageBox::warning( this, "Wellenreiter/Opie", "Sniffing in progress!\nPlease stop sniffing before closing." );
306 e->ignore(); 307 e->ignore();
307 } 308 }
308 else 309 else
309 { 310 {
310 QMainWindow::closeEvent( e ); 311 QMainWindow::closeEvent( e );
311 } 312 }
312} 313}