Diffstat (limited to 'noncore/net/wellenreiter/gui/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/mainwindow.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/noncore/net/wellenreiter/gui/mainwindow.cpp b/noncore/net/wellenreiter/gui/mainwindow.cpp index 27ecae3..868b0b0 100644 --- a/noncore/net/wellenreiter/gui/mainwindow.cpp +++ b/noncore/net/wellenreiter/gui/mainwindow.cpp | |||
@@ -1,64 +1,65 @@ | |||
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 "gps.h" | ||
17 | #include "logwindow.h" | 18 | #include "logwindow.h" |
18 | #include "hexwindow.h" | 19 | #include "hexwindow.h" |
19 | #include "mainwindow.h" | 20 | #include "mainwindow.h" |
20 | #include "wellenreiter.h" | 21 | #include "wellenreiter.h" |
21 | #include "scanlist.h" | 22 | #include "scanlist.h" |
22 | 23 | ||
23 | #include <qcombobox.h> | 24 | #include <qcombobox.h> |
24 | #include <qdatastream.h> | 25 | #include <qdatastream.h> |
25 | #include <qfile.h> | 26 | #include <qfile.h> |
26 | #include <qfileinfo.h> | 27 | #include <qfileinfo.h> |
27 | #include <qiconset.h> | 28 | #include <qiconset.h> |
28 | #include <qmenubar.h> | 29 | #include <qmenubar.h> |
29 | #include <qmessagebox.h> | 30 | #include <qmessagebox.h> |
30 | #include <qpopupmenu.h> | 31 | #include <qpopupmenu.h> |
31 | #include <qstatusbar.h> | 32 | #include <qstatusbar.h> |
32 | #include <qtextstream.h> | 33 | #include <qtextstream.h> |
33 | #include <qtoolbutton.h> | 34 | #include <qtoolbutton.h> |
34 | 35 | ||
35 | #ifdef QWS | 36 | #ifdef QWS |
36 | #include <qpe/resource.h> | 37 | #include <qpe/resource.h> |
37 | #include <opie/ofiledialog.h> | 38 | #include <opie/ofiledialog.h> |
38 | #else | 39 | #else |
39 | #include "resource.h" | 40 | #include "resource.h" |
40 | #include <qapplication.h> | 41 | #include <qapplication.h> |
41 | #include <qfiledialog.h> | 42 | #include <qfiledialog.h> |
42 | #endif | 43 | #endif |
43 | 44 | ||
44 | WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * name, WFlags f ) | 45 | WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * name, WFlags f ) |
45 | :QMainWindow( parent, name, f ) | 46 | :QMainWindow( parent, name, f ) |
46 | { | 47 | { |
47 | cw = new WellenreiterConfigWindow( this ); | 48 | cw = new WellenreiterConfigWindow( this ); |
48 | mw = new Wellenreiter( this ); | 49 | mw = new Wellenreiter( this ); |
49 | mw->setConfigWindow( cw ); | 50 | mw->setConfigWindow( cw ); |
50 | setCentralWidget( mw ); | 51 | setCentralWidget( mw ); |
51 | 52 | ||
52 | // setup application icon | 53 | // setup application icon |
53 | 54 | ||
54 | #ifndef QWS | 55 | #ifndef QWS |
55 | setIcon( Resource::loadPixmap( "wellenreiter/appicon-trans" ) ); | 56 | setIcon( Resource::loadPixmap( "wellenreiter/appicon-trans" ) ); |
56 | setIconText( "Wellenreiter/X11" ); | 57 | setIconText( "Wellenreiter/X11" ); |
57 | #endif | 58 | #endif |
58 | 59 | ||
59 | // setup icon sets | 60 | // setup icon sets |
60 | 61 | ||
61 | infoIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/InfoIcon" ) ); | 62 | infoIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/InfoIcon" ) ); |
62 | settingsIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SettingsIcon" ) ); | 63 | settingsIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SettingsIcon" ) ); |
63 | startIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SearchIcon" ) ); | 64 | startIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SearchIcon" ) ); |
64 | stopIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/CancelIcon" ) ); | 65 | stopIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/CancelIcon" ) ); |
@@ -173,101 +174,101 @@ void WellenreiterMainWindow::showConfigure() | |||
173 | cw->showMaximized(); | 174 | cw->showMaximized(); |
174 | #endif | 175 | #endif |
175 | int result = cw->exec(); | 176 | int result = cw->exec(); |
176 | 177 | ||
177 | if ( result ) updateToolButtonState(); | 178 | if ( result ) updateToolButtonState(); |
178 | } | 179 | } |
179 | 180 | ||
180 | 181 | ||
181 | 182 | ||
182 | void WellenreiterMainWindow::updateToolButtonState() | 183 | void WellenreiterMainWindow::updateToolButtonState() |
183 | { | 184 | { |
184 | const QString& interface = cw->interfaceName->currentText(); | 185 | const QString& interface = cw->interfaceName->currentText(); |
185 | const int cardtype = cw->driverType(); | 186 | const int cardtype = cw->driverType(); |
186 | 187 | ||
187 | if ( ( interface != "<select>" ) && ( cardtype != 0 ) ) | 188 | if ( ( interface != "<select>" ) && ( cardtype != 0 ) ) |
188 | { | 189 | { |
189 | startButton->setEnabled( true ); | 190 | startButton->setEnabled( true ); |
190 | menuBar()->setItemEnabled( startID, true ); | 191 | menuBar()->setItemEnabled( startID, true ); |
191 | } | 192 | } |
192 | else | 193 | else |
193 | { | 194 | { |
194 | startButton->setEnabled( false ); | 195 | startButton->setEnabled( false ); |
195 | menuBar()->setItemEnabled( startID, false ); | 196 | menuBar()->setItemEnabled( startID, false ); |
196 | } | 197 | } |
197 | } | 198 | } |
198 | 199 | ||
199 | 200 | ||
200 | void WellenreiterMainWindow::changedSniffingState() | 201 | void WellenreiterMainWindow::changedSniffingState() |
201 | { | 202 | { |
202 | startButton->setEnabled( !mw->sniffing ); | 203 | startButton->setEnabled( !mw->sniffing ); |
203 | menuBar()->setItemEnabled( startID, !mw->sniffing ); | 204 | menuBar()->setItemEnabled( startID, !mw->sniffing ); |
204 | stopButton->setEnabled( mw->sniffing ); | 205 | stopButton->setEnabled( mw->sniffing ); |
205 | menuBar()->setItemEnabled( stopID, mw->sniffing ); | 206 | menuBar()->setItemEnabled( stopID, mw->sniffing ); |
206 | } | 207 | } |
207 | 208 | ||
208 | 209 | ||
209 | WellenreiterMainWindow::~WellenreiterMainWindow() | 210 | WellenreiterMainWindow::~WellenreiterMainWindow() |
210 | { | 211 | { |
211 | delete infoIconSet; | 212 | delete infoIconSet; |
212 | delete settingsIconSet; | 213 | delete settingsIconSet; |
213 | delete startIconSet; | 214 | delete startIconSet; |
214 | delete stopIconSet; | 215 | delete stopIconSet; |
215 | }; | 216 | }; |
216 | 217 | ||
217 | void WellenreiterMainWindow::demoAddStations() | 218 | void WellenreiterMainWindow::demoAddStations() |
218 | { | 219 | { |
219 | //mw = 0; // test SIGSGV handling | 220 | //mw = 0; // test SIGSGV handling |
220 | 221 | ||
221 | mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:00:20:EF:A6:43"), true, 6, 80 ); | 222 | mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:00:20:EF:A6:43"), true, 6, 80, GpsLocation( 10.10, 20.20 ) ); |
222 | mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:30:6D:EF:A6:23"), true, 11, 10 ); | 223 | mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:30:6D:EF:A6:23"), true, 11, 10, GpsLocation( 0.0, 0.0 ) ); |
223 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:A0:F8:E7:16:22"), false, 3, 10 ); | 224 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:A0:F8:E7:16:22"), false, 3, 10, GpsLocation( 5.5, 2.3 ) ); |
224 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:AA:01:E7:56:62"), false, 3, 15 ); | 225 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:AA:01:E7:56:62"), false, 3, 15, GpsLocation( 2.3, 5.5 ) ); |
225 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:B0:8E:E7:56:E2"), false, 3, 20 ); | 226 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:B0:8E:E7:56:E2"), false, 3, 20, GpsLocation( -10.0, -20.5 ) ); |
226 | } | 227 | } |
227 | 228 | ||
228 | 229 | ||
229 | QString WellenreiterMainWindow::getFileName( bool save ) | 230 | QString WellenreiterMainWindow::getFileName( bool save ) |
230 | { | 231 | { |
231 | QMap<QString, QStringList> map; | 232 | QMap<QString, QStringList> map; |
232 | map.insert( tr("All"), QStringList() ); | 233 | map.insert( tr("All"), QStringList() ); |
233 | QStringList text; | 234 | QStringList text; |
234 | text << "text/*"; | 235 | text << "text/*"; |
235 | map.insert( tr("Text"), text ); | 236 | map.insert( tr("Text"), text ); |
236 | text << "*"; | 237 | text << "*"; |
237 | map.insert( tr("All"), text ); | 238 | map.insert( tr("All"), text ); |
238 | 239 | ||
239 | QString str; | 240 | QString str; |
240 | if ( save ) | 241 | if ( save ) |
241 | { | 242 | { |
242 | #ifdef QWS | 243 | #ifdef QWS |
243 | str = OFileDialog::getSaveFileName( 2, "/", QString::null, map ); | 244 | str = OFileDialog::getSaveFileName( 2, "/", QString::null, map ); |
244 | #else | 245 | #else |
245 | str = QFileDialog::getSaveFileName(); | 246 | str = QFileDialog::getSaveFileName(); |
246 | #endif | 247 | #endif |
247 | if ( str.isEmpty() /*|| QFileInfo(str).isDir()*/ ) | 248 | if ( str.isEmpty() /*|| QFileInfo(str).isDir()*/ ) |
248 | return ""; | 249 | return ""; |
249 | } | 250 | } |
250 | else | 251 | else |
251 | { | 252 | { |
252 | #ifdef QWS | 253 | #ifdef QWS |
253 | str = OFileDialog::getOpenFileName( 2, "/", QString::null, map ); | 254 | str = OFileDialog::getOpenFileName( 2, "/", QString::null, map ); |
254 | #else | 255 | #else |
255 | str = QFileDialog::getOpenFileName(); | 256 | str = QFileDialog::getOpenFileName(); |
256 | #endif | 257 | #endif |
257 | if ( str.isEmpty() || !QFile(str).exists() || QFileInfo(str).isDir() ) | 258 | if ( str.isEmpty() || !QFile(str).exists() || QFileInfo(str).isDir() ) |
258 | return ""; | 259 | return ""; |
259 | } | 260 | } |
260 | return str; | 261 | return str; |
261 | } | 262 | } |
262 | 263 | ||
263 | 264 | ||
264 | void WellenreiterMainWindow::fileSaveLog() | 265 | void WellenreiterMainWindow::fileSaveLog() |
265 | { | 266 | { |
266 | QString fname = getFileName( true ); | 267 | QString fname = getFileName( true ); |
267 | if ( !fname.isEmpty() ) | 268 | if ( !fname.isEmpty() ) |
268 | { | 269 | { |
269 | QFile f( fname ); | 270 | QFile f( fname ); |
270 | if ( f.open(IO_WriteOnly) ) | 271 | if ( f.open(IO_WriteOnly) ) |
271 | { | 272 | { |
272 | QTextStream t( &f ); | 273 | QTextStream t( &f ); |
273 | t << mw->logWindow()->getLog(); | 274 | t << mw->logWindow()->getLog(); |