Diffstat (limited to 'noncore/net/wellenreiter/gui/mainwindow.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/mainwindow.cpp | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/noncore/net/wellenreiter/gui/mainwindow.cpp b/noncore/net/wellenreiter/gui/mainwindow.cpp index 95a8294..6f57a7f 100644 --- a/noncore/net/wellenreiter/gui/mainwindow.cpp +++ b/noncore/net/wellenreiter/gui/mainwindow.cpp | |||
@@ -1,16 +1,16 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. | 2 | ** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Opie Environment. | 4 | ** This file is part of Wellenreiter II. |
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" |
@@ -28,78 +28,83 @@ | |||
28 | #include <qlabel.h> | 28 | #include <qlabel.h> |
29 | #include <qlayout.h> | 29 | #include <qlayout.h> |
30 | #include <qlineedit.h> | 30 | #include <qlineedit.h> |
31 | #include <qiconset.h> | 31 | #include <qiconset.h> |
32 | #include <qmenubar.h> | 32 | #include <qmenubar.h> |
33 | #include <qmessagebox.h> | 33 | #include <qmessagebox.h> |
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | #include <qpushbutton.h> | 35 | #include <qpushbutton.h> |
36 | #include <qstatusbar.h> | 36 | #include <qstatusbar.h> |
37 | #include <qspinbox.h> | 37 | #include <qspinbox.h> |
38 | #include <qtextstream.h> | 38 | #include <qtextstream.h> |
39 | #include <qtoolbutton.h> | 39 | #include <qtoolbutton.h> |
40 | #include <qwhatsthis.h> | ||
40 | 41 | ||
41 | #ifdef QWS | 42 | #ifdef QWS |
42 | #include <qpe/resource.h> | 43 | #include <qpe/resource.h> |
43 | #include <opie2/ofiledialog.h> | 44 | #include <opie2/ofiledialog.h> |
44 | using namespace Opie; | 45 | using namespace Opie; |
45 | #else | 46 | #else |
46 | #include "resource.h" | 47 | #include "resource.h" |
47 | #include <qapplication.h> | 48 | #include <qapplication.h> |
48 | #include <qfiledialog.h> | 49 | #include <qfiledialog.h> |
49 | #endif | 50 | #endif |
50 | 51 | ||
51 | #include <unistd.h> | 52 | #include <unistd.h> |
52 | 53 | ||
53 | WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * name, WFlags f ) | 54 | WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * name, WFlags f ) |
54 | :QMainWindow( parent, name, f ) | 55 | :QMainWindow( parent, name, f ) |
55 | { | 56 | { |
56 | cw = new WellenreiterConfigWindow( this ); | 57 | cw = new WellenreiterConfigWindow( this ); |
57 | mw = new Wellenreiter( this ); | 58 | mw = new Wellenreiter( this ); |
58 | mw->setConfigWindow( cw ); | 59 | mw->setConfigWindow( cw ); |
59 | setCentralWidget( mw ); | 60 | setCentralWidget( mw ); |
60 | 61 | ||
61 | // setup application icon | 62 | // setup application icon |
62 | 63 | ||
63 | #ifndef QWS | ||
64 | setIcon( Resource::loadPixmap( "wellenreiter/appicon-trans" ) ); | 64 | setIcon( Resource::loadPixmap( "wellenreiter/appicon-trans" ) ); |
65 | #ifndef QWS | ||
65 | setIconText( "Wellenreiter/X11" ); | 66 | setIconText( "Wellenreiter/X11" ); |
66 | #endif | 67 | #endif |
67 | 68 | ||
68 | // setup tool buttons | 69 | // setup tool buttons |
69 | 70 | ||
70 | startButton = new QToolButton( 0 ); | 71 | startButton = new QToolButton( 0 ); |
72 | QWhatsThis::add( startButton, tr( "Click here to start scanning." ) ); | ||
71 | #ifdef QWS | 73 | #ifdef QWS |
72 | startButton->setAutoRaise( true ); | 74 | startButton->setAutoRaise( true ); |
73 | #endif | 75 | #endif |
74 | startButton->setIconSet( Resource::loadIconSet( "wellenreiter/SearchIcon" ) ); | 76 | startButton->setIconSet( Resource::loadIconSet( "wellenreiter/SearchIcon" ) ); |
75 | startButton->setEnabled( false ); | 77 | startButton->setEnabled( false ); |
76 | connect( startButton, SIGNAL( clicked() ), mw, SLOT( startClicked() ) ); | 78 | connect( startButton, SIGNAL( clicked() ), mw, SLOT( startClicked() ) ); |
77 | 79 | ||
78 | stopButton = new QToolButton( 0 ); | 80 | stopButton = new QToolButton( 0 ); |
81 | QWhatsThis::add( stopButton, tr( "Click here to stop scanning." ) ); | ||
79 | #ifdef QWS | 82 | #ifdef QWS |
80 | stopButton->setAutoRaise( true ); | 83 | stopButton->setAutoRaise( true ); |
81 | #endif | 84 | #endif |
82 | stopButton->setIconSet( Resource::loadIconSet( "wellenreiter/CancelIcon" ) ); | 85 | stopButton->setIconSet( Resource::loadIconSet( "wellenreiter/CancelIcon" ) ); |
83 | stopButton->setEnabled( false ); | 86 | stopButton->setEnabled( false ); |
84 | connect( stopButton, SIGNAL( clicked() ), mw, SLOT( stopClicked() ) ); | 87 | connect( stopButton, SIGNAL( clicked() ), mw, SLOT( stopClicked() ) ); |
85 | 88 | ||
86 | QToolButton* d = new QToolButton( 0 ); | 89 | QToolButton* d = new QToolButton( 0 ); |
90 | QWhatsThis::add( d, tr( "Click here to open the configure dialog." ) ), | ||
87 | #ifdef QWS | 91 | #ifdef QWS |
88 | d->setAutoRaise( true ); | 92 | d->setAutoRaise( true ); |
89 | #endif | 93 | #endif |
90 | d->setIconSet( Resource::loadIconSet( "wellenreiter/SettingsIcon" ) ); | 94 | d->setIconSet( Resource::loadIconSet( "wellenreiter/SettingsIcon" ) ); |
91 | connect( d, SIGNAL( clicked() ), this, SLOT( showConfigure() ) ); | 95 | connect( d, SIGNAL( clicked() ), this, SLOT( showConfigure() ) ); |
92 | 96 | ||
93 | uploadButton = new QToolButton( 0 ); | 97 | uploadButton = new QToolButton( 0 ); |
98 | QWhatsThis::add( uploadButton, tr( "Click here to upload a capture session." ) ); | ||
94 | #ifdef QWS | 99 | #ifdef QWS |
95 | uploadButton->setAutoRaise( true ); | 100 | uploadButton->setAutoRaise( true ); |
96 | #endif | 101 | #endif |
97 | uploadButton->setIconSet( Resource::loadIconSet( "up" ) ); | 102 | uploadButton->setIconSet( Resource::loadIconSet( "up" ) ); |
98 | uploadButton->setEnabled( false ); | 103 | uploadButton->setEnabled( false ); |
99 | //uploadButton->setEnabled( true ); // DEBUGGING | 104 | //uploadButton->setEnabled( true ); // DEBUGGING |
100 | connect( uploadButton, SIGNAL( clicked() ), this, SLOT( uploadSession() ) ); | 105 | connect( uploadButton, SIGNAL( clicked() ), this, SLOT( uploadSession() ) ); |
101 | 106 | ||
102 | // setup menu bar | 107 | // setup menu bar |
103 | 108 | ||
104 | int id; | 109 | int id; |
105 | 110 | ||
@@ -114,42 +119,45 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n | |||
114 | fileLoad->insertItem( tr( "&Session..." ), this, SLOT( fileLoadSession() ) ); | 119 | fileLoad->insertItem( tr( "&Session..." ), this, SLOT( fileLoadSession() ) ); |
115 | //fileLoad->insertItem( "&Log", this, SLOT( fileLoadLog() ) ); | 120 | //fileLoad->insertItem( "&Log", this, SLOT( fileLoadLog() ) ); |
116 | 121 | ||
117 | QPopupMenu* file = new QPopupMenu( mb ); | 122 | QPopupMenu* file = new QPopupMenu( mb ); |
118 | file->insertItem( tr( "&New" ), this, SLOT( fileNew() ) ); | 123 | file->insertItem( tr( "&New" ), this, SLOT( fileNew() ) ); |
119 | id = file->insertItem( tr( "&Load" ), fileLoad ); | 124 | id = file->insertItem( tr( "&Load" ), fileLoad ); |
120 | file->insertItem( tr( "&Save" ), fileSave ); | 125 | file->insertItem( tr( "&Save" ), fileSave ); |
121 | file->insertSeparator(); | 126 | file->insertSeparator(); |
122 | uploadID = file->insertItem( tr( "&Upload Session" ), this, SLOT( uploadSession() ) ); | 127 | uploadID = file->insertItem( tr( "&Upload Session" ), this, SLOT( uploadSession() ) ); |
123 | file->insertSeparator(); | 128 | file->insertSeparator(); |
124 | file->insertItem( tr( "&Exit" ), qApp, SLOT( quit() ) ); | 129 | file->insertItem( tr( "&Exit" ), qApp, SLOT( quit() ) ); |
125 | 130 | ||
126 | QPopupMenu* view = new QPopupMenu( mb ); | ||
127 | view->insertItem( tr( "&Configure..." ) ); | ||
128 | |||
129 | QPopupMenu* sniffer = new QPopupMenu( mb ); | 131 | QPopupMenu* sniffer = new QPopupMenu( mb ); |
130 | sniffer->insertItem( tr( "&Configure..." ), this, SLOT( showConfigure() ) ); | 132 | sniffer->insertItem( tr( "&Configure..." ), this, SLOT( showConfigure() ) ); |
131 | sniffer->insertSeparator(); | 133 | sniffer->insertSeparator(); |
132 | startID = sniffer->insertItem( tr( "&Start" ), mw, SLOT( startClicked() ) ); | 134 | startID = sniffer->insertItem( tr( "&Start" ), mw, SLOT( startClicked() ) ); |
133 | sniffer->setItemEnabled( startID, false ); | 135 | sniffer->setItemEnabled( startID, false ); |
134 | stopID = sniffer->insertItem( tr( "Sto&p" ), mw, SLOT( stopClicked() ) ); | 136 | stopID = sniffer->insertItem( tr( "Sto&p" ), mw, SLOT( stopClicked() ) ); |
135 | sniffer->setItemEnabled( stopID, false ); | 137 | sniffer->setItemEnabled( stopID, false ); |
136 | 138 | ||
139 | QPopupMenu* view = new QPopupMenu( mb ); | ||
140 | view->insertItem( tr( "&Expand All" ), this, SLOT( viewExpandAll() ) ); | ||
141 | view->insertItem( tr( "&Collapse All" ), this, SLOT( viewCollapseAll() ) ); | ||
142 | |||
137 | QPopupMenu* demo = new QPopupMenu( mb ); | 143 | QPopupMenu* demo = new QPopupMenu( mb ); |
138 | demo->insertItem( tr( "&Add something" ), this, SLOT( demoAddStations() ) ); | 144 | demo->insertItem( tr( "&Add something" ), this, SLOT( demoAddStations() ) ); |
139 | //demo->insertItem( tr( "&Read from GPSd" ), this, SLOT( demoReadFromGps() ) ); | 145 | //demo->insertItem( tr( "&Read from GPSd" ), this, SLOT( demoReadFromGps() ) ); |
140 | 146 | ||
141 | id = mb->insertItem( tr( "&File" ), file ); | 147 | id = mb->insertItem( tr( "&File" ), file ); |
142 | //id = mb->insertItem( tr( "&View" ), view ); | 148 | |
149 | id = mb->insertItem( tr( "&View" ), view ); | ||
143 | //mb->setItemEnabled( id, false ); | 150 | //mb->setItemEnabled( id, false ); |
151 | |||
144 | id = mb->insertItem( tr( "&Sniffer" ), sniffer ); | 152 | id = mb->insertItem( tr( "&Sniffer" ), sniffer ); |
145 | 153 | ||
146 | id = mb->insertItem( tr( "&Demo" ), demo ); | 154 | id = mb->insertItem( tr( "&Demo" ), demo ); |
147 | mb->setItemEnabled( id, true ); | 155 | mb->setItemEnabled( id, true ); |
148 | mb->setItemEnabled( uploadID, false ); | 156 | mb->setItemEnabled( uploadID, false ); |
149 | 157 | ||
150 | #ifdef QWS | 158 | #ifdef QWS |
151 | mb->insertItem( startButton ); | 159 | mb->insertItem( startButton ); |
152 | mb->insertItem( stopButton ); | 160 | mb->insertItem( stopButton ); |
153 | mb->insertItem( uploadButton ); | 161 | mb->insertItem( uploadButton ); |
154 | mb->insertItem( d ); | 162 | mb->insertItem( d ); |
155 | #else // Qt3 changed the insertion order. It's now totally random :( | 163 | #else // Qt3 changed the insertion order. It's now totally random :( |
@@ -544,12 +552,22 @@ void WellenreiterMainWindow::uploadSession() | |||
544 | } | 552 | } |
545 | } | 553 | } |
546 | ::close ( sock ); | 554 | ::close ( sock ); |
547 | } | 555 | } |
548 | if ( ok ) | 556 | if ( ok ) |
549 | QMessageBox::information( 0, tr( "Success" ), | 557 | QMessageBox::information( 0, tr( "Success" ), |
550 | QString ( "<p>%1</p>" ).arg( tr( "Capture Dump was uploaded to %1" ) ).arg( CAP_hostname ) ); | 558 | QString ( "<p>%1</p>" ).arg( tr( "Capture Dump was uploaded to %1" ) ).arg( CAP_hostname ) ); |
551 | else | 559 | else |
552 | QMessageBox::warning( 0, tr( "Error" ), | 560 | QMessageBox::warning( 0, tr( "Error" ), |
553 | QString ( "<p>%1</p>" ).arg ( tr( "Connection to %1 failed" ) ).arg( CAP_hostname ) ); | 561 | QString ( "<p>%1</p>" ).arg ( tr( "Connection to %1 failed" ) ).arg( CAP_hostname ) ); |
554 | } | 562 | } |
555 | 563 | ||
564 | |||
565 | void WellenreiterMainWindow::viewExpandAll() | ||
566 | { | ||
567 | mw->netView()->expand(); | ||
568 | } | ||
569 | |||
570 | void WellenreiterMainWindow::viewCollapseAll() | ||
571 | { | ||
572 | mw->netView()->collapse(); | ||
573 | } | ||