author | zecke <zecke> | 2004-10-22 15:11:42 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-10-22 15:11:42 (UTC) |
commit | 0a3ab70a5be70bb04691a2a566ce63719e57f83e (patch) (unidiff) | |
tree | 7160371d37d8ca5afff098ae183957795b620677 | |
parent | 0ad51ab1359feaf04c3be229250a4e2e93892564 (diff) | |
download | opie-0a3ab70a5be70bb04691a2a566ce63719e57f83e.zip opie-0a3ab70a5be70bb04691a2a566ce63719e57f83e.tar.gz opie-0a3ab70a5be70bb04691a2a566ce63719e57f83e.tar.bz2 |
Open the Context-Menu on rightButtonPress instead of clicked.
This makes wellenreiter behave like other RoH capable applications
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp index fa1d724..8c2015e 100644 --- a/noncore/net/wellenreiter/gui/scanlist.cpp +++ b/noncore/net/wellenreiter/gui/scanlist.cpp | |||
@@ -1,217 +1,217 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2002-2004 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 Wellenreiter II. | 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 "scanlist.h" | 16 | #include "scanlist.h" |
17 | #include "configwindow.h" | 17 | #include "configwindow.h" |
18 | #include "logwindow.h" | 18 | #include "logwindow.h" |
19 | 19 | ||
20 | /* OPIE */ | 20 | /* OPIE */ |
21 | #ifdef QWS | 21 | #ifdef QWS |
22 | #include <opie2/odebug.h> | 22 | #include <opie2/odebug.h> |
23 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
24 | #include <qpe/resource.h> | 24 | #include <qpe/resource.h> |
25 | #else | 25 | #else |
26 | #include "resource.h" | 26 | #include "resource.h" |
27 | #endif | 27 | #endif |
28 | 28 | ||
29 | 29 | ||
30 | /* QT */ | 30 | /* QT */ |
31 | #include <qcursor.h> | 31 | #include <qcursor.h> |
32 | #include <qdatetime.h> | 32 | #include <qdatetime.h> |
33 | #include <qpopupmenu.h> | 33 | #include <qpopupmenu.h> |
34 | #include <qcheckbox.h> | 34 | #include <qcheckbox.h> |
35 | 35 | ||
36 | /* STD */ | 36 | /* STD */ |
37 | #include <assert.h> | 37 | #include <assert.h> |
38 | 38 | ||
39 | using namespace Opie::Core; | 39 | using namespace Opie::Core; |
40 | using namespace Opie::Ui; | 40 | using namespace Opie::Ui; |
41 | using namespace Opie::Net; | 41 | using namespace Opie::Net; |
42 | 42 | ||
43 | const int col_type = 0; | 43 | const int col_type = 0; |
44 | const int col_essid = 0; | 44 | const int col_essid = 0; |
45 | const int col_sig = 1; | 45 | const int col_sig = 1; |
46 | const int col_ap = 2; | 46 | const int col_ap = 2; |
47 | const int col_channel = 3; | 47 | const int col_channel = 3; |
48 | const int col_wep = 4; | 48 | const int col_wep = 4; |
49 | const int col_traffic = 5; | 49 | const int col_traffic = 5; |
50 | const int col_ip = 6; | 50 | const int col_ip = 6; |
51 | const int col_manuf = 7; | 51 | const int col_manuf = 7; |
52 | const int col_firstseen = 8; | 52 | const int col_firstseen = 8; |
53 | const int col_lastseen = 9; | 53 | const int col_lastseen = 9; |
54 | const int col_location = 10; | 54 | const int col_location = 10; |
55 | 55 | ||
56 | #define DEBUG | 56 | #define DEBUG |
57 | 57 | ||
58 | MScanListView::MScanListView( QWidget* parent, const char* name ) | 58 | MScanListView::MScanListView( QWidget* parent, const char* name ) |
59 | :OListView( parent, name ) | 59 | :OListView( parent, name ) |
60 | { | 60 | { |
61 | setFrameShape( QListView::StyledPanel ); | 61 | setFrameShape( QListView::StyledPanel ); |
62 | setFrameShadow( QListView::Sunken ); | 62 | setFrameShadow( QListView::Sunken ); |
63 | 63 | ||
64 | addColumn( tr( "Net/Station" ) ); | 64 | addColumn( tr( "Net/Station" ) ); |
65 | setColumnAlignment( col_essid, AlignLeft || AlignVCenter ); | 65 | setColumnAlignment( col_essid, AlignLeft || AlignVCenter ); |
66 | addColumn( tr( "#" ) ); | 66 | addColumn( tr( "#" ) ); |
67 | setColumnAlignment( col_sig, AlignCenter ); | 67 | setColumnAlignment( col_sig, AlignCenter ); |
68 | addColumn( tr( "MAC" ) ); | 68 | addColumn( tr( "MAC" ) ); |
69 | setColumnAlignment( col_ap, AlignCenter ); | 69 | setColumnAlignment( col_ap, AlignCenter ); |
70 | addColumn( tr( "Chn" ) ); | 70 | addColumn( tr( "Chn" ) ); |
71 | setColumnAlignment( col_channel, AlignCenter ); | 71 | setColumnAlignment( col_channel, AlignCenter ); |
72 | addColumn( tr( "W" ) ); | 72 | addColumn( tr( "W" ) ); |
73 | setColumnAlignment( col_wep, AlignCenter ); | 73 | setColumnAlignment( col_wep, AlignCenter ); |
74 | addColumn( tr( "T" ) ); | 74 | addColumn( tr( "T" ) ); |
75 | setColumnAlignment( col_traffic, AlignCenter ); | 75 | setColumnAlignment( col_traffic, AlignCenter ); |
76 | addColumn( tr( "IP" ) ); | 76 | addColumn( tr( "IP" ) ); |
77 | setColumnAlignment( col_ip, AlignCenter ); | 77 | setColumnAlignment( col_ip, AlignCenter ); |
78 | addColumn( tr( "Manufacturer" ) ); | 78 | addColumn( tr( "Manufacturer" ) ); |
79 | setColumnAlignment( col_manuf, AlignCenter ); | 79 | setColumnAlignment( col_manuf, AlignCenter ); |
80 | addColumn( tr( "First Seen" ) ); | 80 | addColumn( tr( "First Seen" ) ); |
81 | setColumnAlignment( col_firstseen, AlignCenter ); | 81 | setColumnAlignment( col_firstseen, AlignCenter ); |
82 | addColumn( tr( "Last Seen" ) ); | 82 | addColumn( tr( "Last Seen" ) ); |
83 | setColumnAlignment( col_lastseen, AlignCenter ); | 83 | setColumnAlignment( col_lastseen, AlignCenter ); |
84 | addColumn( tr( "Location" ) ); | 84 | addColumn( tr( "Location" ) ); |
85 | setColumnAlignment( col_location, AlignCenter ); | 85 | setColumnAlignment( col_location, AlignCenter ); |
86 | setRootIsDecorated( true ); | 86 | setRootIsDecorated( true ); |
87 | setAllColumnsShowFocus( true ); | 87 | setAllColumnsShowFocus( true ); |
88 | 88 | ||
89 | connect( this, SIGNAL( rightButtonClicked(QListViewItem*,const QPoint&,int) ), | 89 | connect( this, SIGNAL( rightButtonPressed(QListViewItem*,const QPoint&,int) ), |
90 | this, SLOT( contextMenuRequested(QListViewItem*,const QPoint&,int) ) ); | 90 | this, SLOT( contextMenuRequested(QListViewItem*,const QPoint&,int) ) ); |
91 | 91 | ||
92 | #ifdef QWS | 92 | #ifdef QWS |
93 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 93 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
94 | #endif | 94 | #endif |
95 | 95 | ||
96 | }; | 96 | }; |
97 | 97 | ||
98 | 98 | ||
99 | MScanListView::~MScanListView() | 99 | MScanListView::~MScanListView() |
100 | { | 100 | { |
101 | }; | 101 | }; |
102 | 102 | ||
103 | 103 | ||
104 | OListViewItem* MScanListView::childFactory() | 104 | OListViewItem* MScanListView::childFactory() |
105 | { | 105 | { |
106 | return new MScanListItem( this ); | 106 | return new MScanListItem( this ); |
107 | } | 107 | } |
108 | 108 | ||
109 | 109 | ||
110 | void MScanListView::serializeTo( QDataStream& s) const | 110 | void MScanListView::serializeTo( QDataStream& s) const |
111 | { | 111 | { |
112 | odebug << "serializing MScanListView" << oendl; | 112 | odebug << "serializing MScanListView" << oendl; |
113 | OListView::serializeTo( s ); | 113 | OListView::serializeTo( s ); |
114 | } | 114 | } |
115 | 115 | ||
116 | 116 | ||
117 | void MScanListView::serializeFrom( QDataStream& s) | 117 | void MScanListView::serializeFrom( QDataStream& s) |
118 | { | 118 | { |
119 | odebug << "serializing MScanListView" << oendl; | 119 | odebug << "serializing MScanListView" << oendl; |
120 | OListView::serializeFrom( s ); | 120 | OListView::serializeFrom( s ); |
121 | } | 121 | } |
122 | 122 | ||
123 | 123 | ||
124 | void MScanListView::addNewItem( const QString& type, | 124 | void MScanListView::addNewItem( const QString& type, |
125 | const QString& essid, | 125 | const QString& essid, |
126 | const OMacAddress& mac, | 126 | const OMacAddress& mac, |
127 | bool wep, | 127 | bool wep, |
128 | int channel, | 128 | int channel, |
129 | int signal, | 129 | int signal, |
130 | const GpsLocation& loc, | 130 | const GpsLocation& loc, |
131 | bool probe ) | 131 | bool probe ) |
132 | { | 132 | { |
133 | QString macaddr = mac.toString(true); | 133 | QString macaddr = mac.toString(true); |
134 | 134 | ||
135 | #ifdef DEBUG | 135 | #ifdef DEBUG |
136 | odebug << "MScanList::addNewItem( " << type << " / " | 136 | odebug << "MScanList::addNewItem( " << type << " / " |
137 | << essid << " / " << macaddr | 137 | << essid << " / " << macaddr |
138 | << " [" << channel << "]" << oendl; | 138 | << " [" << channel << "]" << oendl; |
139 | #endif | 139 | #endif |
140 | 140 | ||
141 | // search, if we already have seen this net | 141 | // search, if we already have seen this net |
142 | 142 | ||
143 | QString s; | 143 | QString s; |
144 | MScanListItem* network; | 144 | MScanListItem* network; |
145 | MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); | 145 | MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); |
146 | 146 | ||
147 | while ( item && ( item->text( col_essid ) != essid ) ) | 147 | while ( item && ( item->text( col_essid ) != essid ) ) |
148 | { | 148 | { |
149 | #ifdef DEBUG | 149 | #ifdef DEBUG |
150 | odebug << "itemtext: " << item->text( col_essid ) << "" << oendl; | 150 | odebug << "itemtext: " << item->text( col_essid ) << "" << oendl; |
151 | #endif | 151 | #endif |
152 | item = static_cast<MScanListItem*> ( item->nextSibling() ); | 152 | item = static_cast<MScanListItem*> ( item->nextSibling() ); |
153 | } | 153 | } |
154 | if ( item ) | 154 | if ( item ) |
155 | { | 155 | { |
156 | // we have already seen this net, check all childs if MAC exists | 156 | // we have already seen this net, check all childs if MAC exists |
157 | 157 | ||
158 | network = item; | 158 | network = item; |
159 | 159 | ||
160 | item = static_cast<MScanListItem*> ( item->firstChild() ); | 160 | item = static_cast<MScanListItem*> ( item->firstChild() ); |
161 | assert( item ); // this shouldn't fail | 161 | assert( item ); // this shouldn't fail |
162 | 162 | ||
163 | while ( item && ( item->text( col_ap ) != macaddr ) ) | 163 | while ( item && ( item->text( col_ap ) != macaddr ) ) |
164 | { | 164 | { |
165 | #ifdef DEBUG | 165 | #ifdef DEBUG |
166 | odebug << "subitemtext: " << item->text( col_ap ) << "" << oendl; | 166 | odebug << "subitemtext: " << item->text( col_ap ) << "" << oendl; |
167 | #endif | 167 | #endif |
168 | item = static_cast<MScanListItem*> ( item->nextSibling() ); | 168 | item = static_cast<MScanListItem*> ( item->nextSibling() ); |
169 | } | 169 | } |
170 | 170 | ||
171 | if ( item ) | 171 | if ( item ) |
172 | { | 172 | { |
173 | // we have already seen this item, it's a dupe | 173 | // we have already seen this item, it's a dupe |
174 | #ifdef DEBUG | 174 | #ifdef DEBUG |
175 | odebug << "" << macaddr << " is a dupe - ignoring..." << oendl; | 175 | odebug << "" << macaddr << " is a dupe - ignoring..." << oendl; |
176 | #endif | 176 | #endif |
177 | item->receivedBeacon(); | 177 | item->receivedBeacon(); |
178 | return; | 178 | return; |
179 | } | 179 | } |
180 | } | 180 | } |
181 | else | 181 | else |
182 | { | 182 | { |
183 | s = QString( "(i) New network: ESSID '%1'" ).arg( essid ); | 183 | s = QString( "(i) New network: ESSID '%1'" ).arg( essid ); |
184 | MLogWindow::logwindow()->log( s ); | 184 | MLogWindow::logwindow()->log( s ); |
185 | network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0, probe ); | 185 | network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0, probe ); |
186 | } | 186 | } |
187 | 187 | ||
188 | 188 | ||
189 | // insert new station as child from network | 189 | // insert new station as child from network |
190 | // no essid to reduce clutter, maybe later we have a nick or stationname to display!? | 190 | // no essid to reduce clutter, maybe later we have a nick or stationname to display!? |
191 | 191 | ||
192 | #ifdef DEBUG | 192 | #ifdef DEBUG |
193 | odebug << "inserting new station " << macaddr << "" << oendl; | 193 | odebug << "inserting new station " << macaddr << "" << oendl; |
194 | #endif | 194 | #endif |
195 | 195 | ||
196 | MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); | 196 | MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); |
197 | station->setManufacturer( mac.manufacturer() ); | 197 | station->setManufacturer( mac.manufacturer() ); |
198 | station->setLocation( loc.dmsPosition() ); | 198 | station->setLocation( loc.dmsPosition() ); |
199 | 199 | ||
200 | if ( type == "managed" ) | 200 | if ( type == "managed" ) |
201 | { | 201 | { |
202 | s = QString( "(i) New Access Point in '%1' [%2]" ).arg( essid ).arg( channel ); | 202 | s = QString( "(i) New Access Point in '%1' [%2]" ).arg( essid ).arg( channel ); |
203 | } | 203 | } |
204 | else | 204 | else |
205 | { | 205 | { |
206 | s = QString( "(i) New AdHoc station in '%1' [%2]" ).arg( essid ).arg( channel ); | 206 | s = QString( "(i) New AdHoc station in '%1' [%2]" ).arg( essid ).arg( channel ); |
207 | } | 207 | } |
208 | MLogWindow::logwindow()->log( s ); | 208 | MLogWindow::logwindow()->log( s ); |
209 | } | 209 | } |
210 | 210 | ||
211 | 211 | ||
212 | void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type ) | 212 | void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type ) |
213 | { | 213 | { |
214 | MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); | 214 | MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); |
215 | 215 | ||
216 | while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) ) | 216 | while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) ) |
217 | { | 217 | { |