summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/cornucopia/olistview.cpp14
-rw-r--r--noncore/net/wellenreiter/cornucopia/olistview.h26
-rw-r--r--noncore/net/wellenreiter/gui/scanlist.cpp33
-rw-r--r--noncore/net/wellenreiter/gui/scanlist.h26
4 files changed, 68 insertions, 31 deletions
diff --git a/noncore/net/wellenreiter/cornucopia/olistview.cpp b/noncore/net/wellenreiter/cornucopia/olistview.cpp
index f2d3730..c292eb9 100644
--- a/noncore/net/wellenreiter/cornucopia/olistview.cpp
+++ b/noncore/net/wellenreiter/cornucopia/olistview.cpp
@@ -1,407 +1,417 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 3
4              Copyright (C) 2003 Michael 'Mickey' Lauer 4              Copyright (C) 2003 Michael 'Mickey' Lauer
5 <mickey@tm.informatik.uni-frankfurt.de> 5 <mickey@tm.informatik.uni-frankfurt.de>
6 =. 6 =.
7 .=l. 7 .=l.
8           .>+-= 8           .>+-=
9 _;:,     .>    :=|. This program is free software; you can 9 _;:,     .>    :=|. This program is free software; you can
10.> <`_,   >  .   <= redistribute it and/or modify it under 10.> <`_,   >  .   <= redistribute it and/or modify it under
11:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 11:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
12.="- .-=="i,     .._ License as published by the Free Software 12.="- .-=="i,     .._ License as published by the Free Software
13 - .   .-<_>     .<> Foundation; either version 2 of the License, 13 - .   .-<_>     .<> Foundation; either version 2 of the License,
14     ._= =}       : or (at your option) any later version. 14     ._= =}       : or (at your option) any later version.
15    .%`+i>       _;_. 15    .%`+i>       _;_.
16    .i_,=:_.      -<s. This program is distributed in the hope that 16    .i_,=:_.      -<s. This program is distributed in the hope that
17     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 17     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
18    : ..    .:,     . . . without even the implied warranty of 18    : ..    .:,     . . . without even the implied warranty of
19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
21..}^=.=       =       ; Library General Public License for more 21..}^=.=       =       ; Library General Public License for more
22++=   -.     .`     .: details. 22++=   -.     .`     .: details.
23 :     =  ...= . :.=- 23 :     =  ...= . :.=-
24 -.   .:....=;==+<; You should have received a copy of the GNU 24 -.   .:....=;==+<; You should have received a copy of the GNU
25  -_. . .   )=.  = Library General Public License along with 25  -_. . .   )=.  = Library General Public License along with
26    --        :-=` this library; see the file COPYING.LIB. 26    --        :-=` this library; see the file COPYING.LIB.
27 If not, write to the Free Software Foundation, 27 If not, write to the Free Software Foundation,
28 Inc., 59 Temple Place - Suite 330, 28 Inc., 59 Temple Place - Suite 330,
29 Boston, MA 02111-1307, USA. 29 Boston, MA 02111-1307, USA.
30 30
31*/ 31*/
32 32
33#include <qcolor.h> 33#include <qcolor.h>
34#include <qheader.h> 34#include <qheader.h>
35#include <qpainter.h> 35#include <qpainter.h>
36#include <qpixmap.h> 36#include <qpixmap.h>
37 37
38#include "olistview.h" 38#include "olistview.h"
39 39
40//****************************** OListView ************************************************************************** 40//****************************** OListView **************************************************************************
41 41
42OListView::OListView( QWidget *parent, const char *name ) 42OListView::OListView( QWidget *parent, const char *name )
43 :QListView( parent, name ) 43 :QListView( parent, name )
44{ 44{
45 //FIXME: get from global settings and calculate ==> see oglobalsettings.* 45 //FIXME: get from global settings and calculate ==> see oglobalsettings.*
46 46
47 m_alternateBackground = QColor( 238, 246, 255 ); 47 m_alternateBackground = QColor( 238, 246, 255 );
48 m_columnSeparator = QPen( QColor( 150, 160, 170 ), 0, DotLine ); 48 m_columnSeparator = QPen( QColor( 150, 160, 170 ), 0, DotLine );
49 m_fullWidth = true; 49 m_fullWidth = true;
50} 50}
51 51
52OListView::~OListView() 52OListView::~OListView()
53{ 53{
54} 54}
55 55
56void OListView::setFullWidth( bool fullWidth ) 56void OListView::setFullWidth( bool fullWidth )
57{ 57{
58 m_fullWidth = m_fullWidth; 58 m_fullWidth = m_fullWidth;
59 #if QT_VERSION > 290 59 #if QT_VERSION > 290
60 header()->setStretchEnabled( fullWidth, columns()-1 ); 60 header()->setStretchEnabled( fullWidth, columns()-1 );
61 #endif 61 #endif
62} 62}
63 63
64bool OListView::fullWidth() const 64bool OListView::fullWidth() const
65{ 65{
66 return m_fullWidth; 66 return m_fullWidth;
67} 67}
68 68
69int OListView::addColumn( const QString& label, int width ) 69int OListView::addColumn( const QString& label, int width )
70{ 70{
71 int result = QListView::addColumn( label, width ); 71 int result = QListView::addColumn( label, width );
72 #if QT_VERSION > 290 72 #if QT_VERSION > 290
73 if (m_fullWidth) { 73 if (m_fullWidth) {
74 header()->setStretchEnabled( false, columns()-2 ); 74 header()->setStretchEnabled( false, columns()-2 );
75 header()->setStretchEnabled( true, columns()-1 ); 75 header()->setStretchEnabled( true, columns()-1 );
76 } 76 }
77 #endif 77 #endif
78 return result; 78 return result;
79} 79}
80 80
81int OListView::addColumn( const QIconSet& iconset, const QString& label, int width ) 81int OListView::addColumn( const QIconSet& iconset, const QString& label, int width )
82{ 82{
83 int result = QListView::addColumn( iconset, label, width ); 83 int result = QListView::addColumn( iconset, label, width );
84 #if QT_VERSION > 290 84 #if QT_VERSION > 290
85 if (m_fullWidth) { 85 if (m_fullWidth) {
86 header()->setStretchEnabled( false, columns()-2 ); 86 header()->setStretchEnabled( false, columns()-2 );
87 header()->setStretchEnabled( true, columns()-1 ); 87 header()->setStretchEnabled( true, columns()-1 );
88 } 88 }
89 #endif 89 #endif
90 return result; 90 return result;
91} 91}
92 92
93void OListView::removeColumn( int index ) 93void OListView::removeColumn( int index )
94{ 94{
95 QListView::removeColumn(index); 95 QListView::removeColumn(index);
96 #if QT_VERSION > 290 96 #if QT_VERSION > 290
97 if ( m_fullWidth && index == columns() ) 97 if ( m_fullWidth && index == columns() )
98 { 98 {
99 header()->setStretchEnabled( true, columns()-1 ); 99 header()->setStretchEnabled( true, columns()-1 );
100 } 100 }
101 #endif 101 #endif
102} 102}
103 103
104const QColor& OListView::alternateBackground() const 104const QColor& OListView::alternateBackground() const
105{ 105{
106 return m_alternateBackground; 106 return m_alternateBackground;
107} 107}
108 108
109void OListView::setAlternateBackground( const QColor &c ) 109void OListView::setAlternateBackground( const QColor &c )
110{ 110{
111 m_alternateBackground = c; 111 m_alternateBackground = c;
112 repaint(); 112 repaint();
113} 113}
114 114
115const QPen& OListView::columnSeparator() const 115const QPen& OListView::columnSeparator() const
116{ 116{
117 return m_columnSeparator; 117 return m_columnSeparator;
118} 118}
119 119
120void OListView::setColumnSeparator( const QPen& p ) 120void OListView::setColumnSeparator( const QPen& p )
121{ 121{
122 m_columnSeparator = p; 122 m_columnSeparator = p;
123 repaint(); 123 repaint();
124} 124}
125 125
126OListViewItem* OListView::childFactory()
127{
128 return new OListViewItem( this );
129}
130
126#ifndef QT_NO_DATASTREAM 131#ifndef QT_NO_DATASTREAM
127void OListView::serializeTo( QDataStream& s ) const 132void OListView::serializeTo( QDataStream& s ) const
128{ 133{
129 #warning Caution... the binary format is still under construction... 134 #warning Caution... the binary format is still under construction...
130 qDebug( "storing OListView..." ); 135 qDebug( "storing OListView..." );
131 136
132 // store number of columns and the labels 137 // store number of columns and the labels
133 s << columns(); 138 s << columns();
134 for ( int i = 0; i < columns(); ++i ) 139 for ( int i = 0; i < columns(); ++i )
135 s << columnText( i ); 140 s << columnText( i );
136 141
137 // calculate the number of top-level items to serialize 142 // calculate the number of top-level items to serialize
138 int items = 0; 143 int items = 0;
139 QListViewItem* item = firstChild(); 144 QListViewItem* item = firstChild();
140 while ( item ) 145 while ( item )
141 { 146 {
142 item = item->nextSibling(); 147 item = item->nextSibling();
143 items++; 148 items++;
144 } 149 }
145 150
146 // store number of items and the items itself 151 // store number of items and the items itself
147 s << items; 152 s << items;
148 item = firstChild(); 153 item = firstChild();
149 for ( int i = 0; i < items; ++i ) 154 for ( int i = 0; i < items; ++i )
150 { 155 {
151 s << *static_cast<OListViewItem*>( item ); 156 s << *static_cast<OListViewItem*>( item );
152 item = item->nextSibling(); 157 item = item->nextSibling();
153 } 158 }
154 159
155 qDebug( "OListview stored." ); 160 qDebug( "OListview stored." );
156} 161}
157 162
158void OListView::serializeFrom( QDataStream& s ) 163void OListView::serializeFrom( QDataStream& s )
159{ 164{
160 #warning Caution... the binary format is still under construction... 165 #warning Caution... the binary format is still under construction...
161 qDebug( "loading OListView..." ); 166 qDebug( "loading OListView..." );
162 167
163 int cols; 168 int cols;
164 s >> cols; 169 s >> cols;
165 qDebug( "read number of columns = %d", cols ); 170 qDebug( "read number of columns = %d", cols );
166 171
167 while ( columns() < cols ) addColumn( QString::null ); 172 while ( columns() < cols ) addColumn( QString::null );
168 173
169 for ( int i = 0; i < cols; ++i ) 174 for ( int i = 0; i < cols; ++i )
170 { 175 {
171 QString coltext; 176 QString coltext;
172 s >> coltext; 177 s >> coltext;
173 qDebug( "read text '%s' for column %d", (const char*) coltext, i ); 178 qDebug( "read text '%s' for column %d", (const char*) coltext, i );
174 setColumnText( i, coltext ); 179 setColumnText( i, coltext );
175 } 180 }
176 181
177 int items; 182 int items;
178 s >> items; 183 s >> items;
179 qDebug( "read number of items = %d", items ); 184 qDebug( "read number of items = %d", items );
180 185
181 for ( int i = 0; i < items; ++i ) 186 for ( int i = 0; i < items; ++i )
182 { 187 {
183 OListViewItem* item = new OListViewItem( this ); 188 OListViewItem* item = childFactory();
184 s >> *item; 189 s >> *item;
185 } 190 }
186 191
187 qDebug( "OListView loaded." ); 192 qDebug( "OListView loaded." );
188 193
189} 194}
190 195
191QDataStream& operator<<( QDataStream& s, const OListView& lv ) 196QDataStream& operator<<( QDataStream& s, const OListView& lv )
192{ 197{
193 lv.serializeTo( s ); 198 lv.serializeTo( s );
194} 199}
195 200
196QDataStream& operator>>( QDataStream& s, OListView& lv ) 201QDataStream& operator>>( QDataStream& s, OListView& lv )
197{ 202{
198 lv.serializeFrom( s ); 203 lv.serializeFrom( s );
199} 204}
200#endif // QT_NO_DATASTREAM 205#endif // QT_NO_DATASTREAM
201 206
202//****************************** OListViewItem *********************************************************************** 207//****************************** OListViewItem ***********************************************************************
203 208
204OListViewItem::OListViewItem(QListView *parent) 209OListViewItem::OListViewItem(QListView *parent)
205 : QListViewItem(parent) 210 : QListViewItem(parent)
206{ 211{
207 init(); 212 init();
208} 213}
209 214
210OListViewItem::OListViewItem(QListViewItem *parent) 215OListViewItem::OListViewItem(QListViewItem *parent)
211 : QListViewItem(parent) 216 : QListViewItem(parent)
212{ 217{
213 init(); 218 init();
214} 219}
215 220
216OListViewItem::OListViewItem(QListView *parent, QListViewItem *after) 221OListViewItem::OListViewItem(QListView *parent, QListViewItem *after)
217 : QListViewItem(parent, after) 222 : QListViewItem(parent, after)
218{ 223{
219 init(); 224 init();
220} 225}
221 226
222OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after) 227OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after)
223 : QListViewItem(parent, after) 228 : QListViewItem(parent, after)
224{ 229{
225 init(); 230 init();
226} 231}
227 232
228OListViewItem::OListViewItem(QListView *parent, 233OListViewItem::OListViewItem(QListView *parent,
229 QString label1, QString label2, QString label3, QString label4, 234 QString label1, QString label2, QString label3, QString label4,
230 QString label5, QString label6, QString label7, QString label8) 235 QString label5, QString label6, QString label7, QString label8)
231 : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) 236 : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8)
232{ 237{
233 init(); 238 init();
234} 239}
235 240
236OListViewItem::OListViewItem(QListViewItem *parent, 241OListViewItem::OListViewItem(QListViewItem *parent,
237 QString label1, QString label2, QString label3, QString label4, 242 QString label1, QString label2, QString label3, QString label4,
238 QString label5, QString label6, QString label7, QString label8) 243 QString label5, QString label6, QString label7, QString label8)
239 : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) 244 : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8)
240{ 245{
241 init(); 246 init();
242} 247}
243 248
244OListViewItem::OListViewItem(QListView *parent, QListViewItem *after, 249OListViewItem::OListViewItem(QListView *parent, QListViewItem *after,
245 QString label1, QString label2, QString label3, QString label4, 250 QString label1, QString label2, QString label3, QString label4,
246 QString label5, QString label6, QString label7, QString label8) 251 QString label5, QString label6, QString label7, QString label8)
247 : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) 252 : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8)
248{ 253{
249 init(); 254 init();
250} 255}
251 256
252OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after, 257OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after,
253 QString label1, QString label2, QString label3, QString label4, 258 QString label1, QString label2, QString label3, QString label4,
254 QString label5, QString label6, QString label7, QString label8) 259 QString label5, QString label6, QString label7, QString label8)
255 : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) 260 : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8)
256{ 261{
257 init(); 262 init();
258} 263}
259 264
260OListViewItem::~OListViewItem() 265OListViewItem::~OListViewItem()
261{ 266{
262} 267}
263 268
264void OListViewItem::init() 269void OListViewItem::init()
265{ 270{
266 m_known = false; 271 m_known = false;
267} 272}
268 273
269const QColor &OListViewItem::backgroundColor() 274const QColor &OListViewItem::backgroundColor()
270{ 275{
271 return isAlternate() ? static_cast<OListView*>(listView())->alternateBackground() : 276 return isAlternate() ? static_cast<OListView*>(listView())->alternateBackground() :
272 listView()->viewport()->colorGroup().base(); 277 listView()->viewport()->colorGroup().base();
273} 278}
274 279
275bool OListViewItem::isAlternate() 280bool OListViewItem::isAlternate()
276{ 281{
277 OListView *lv = static_cast<OListView*>( listView() ); 282 OListView *lv = static_cast<OListView*>( listView() );
278 283
279 // check if the item above is an OListViewItem 284 // check if the item above is an OListViewItem
280 OListViewItem *above = static_cast<OListViewItem*>( itemAbove() ); 285 OListViewItem *above = static_cast<OListViewItem*>( itemAbove() );
281 /*if (! itemAbove()->inherits( "OListViewItem" )) return false;*/ 286 /*if (! itemAbove()->inherits( "OListViewItem" )) return false;*/
282 287
283 // check if we have a valid alternate background color 288 // check if we have a valid alternate background color
284 if (!(lv && lv->alternateBackground().isValid())) return false; 289 if (!(lv && lv->alternateBackground().isValid())) return false;
285 290
286 m_known = above ? above->m_known : true; 291 m_known = above ? above->m_known : true;
287 if (m_known) 292 if (m_known)
288 { 293 {
289 m_odd = above ? !above->m_odd : false; 294 m_odd = above ? !above->m_odd : false;
290 } 295 }
291 else 296 else
292 { 297 {
293 OListViewItem *item; 298 OListViewItem *item;
294 bool previous = true; 299 bool previous = true;
295 if (parent()) 300 if (parent())
296 { 301 {
297 item = static_cast<OListViewItem *>(parent()); 302 item = static_cast<OListViewItem *>(parent());
298 if ( item /*&& item->inherits( "OListViewItem" )*/ ) previous = item->m_odd; 303 if ( item /*&& item->inherits( "OListViewItem" )*/ ) previous = item->m_odd;
299 item = static_cast<OListViewItem *>(parent()->firstChild()); 304 item = static_cast<OListViewItem *>(parent()->firstChild());
300 /* if ( !item.inherits( "OListViewItem" ) item = 0; */ 305 /* if ( !item.inherits( "OListViewItem" ) item = 0; */
301 } 306 }
302 else 307 else
303 { 308 {
304 item = static_cast<OListViewItem *>(lv->firstChild()); 309 item = static_cast<OListViewItem *>(lv->firstChild());
305 } 310 }
306 311
307 while(item) 312 while(item)
308 { 313 {
309 item->m_odd = previous = !previous; 314 item->m_odd = previous = !previous;
310 item->m_known = true; 315 item->m_known = true;
311 item = static_cast<OListViewItem *>(item->nextSibling()); 316 item = static_cast<OListViewItem *>(item->nextSibling());
312 /* if (!item.inherits( "OListViewItem" ) ) break; */ 317 /* if (!item.inherits( "OListViewItem" ) ) break; */
313 } 318 }
314 } 319 }
315 return m_odd; 320 return m_odd;
316} 321}
317 322
318void OListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) 323void OListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment)
319{ 324{
320 QColorGroup _cg = cg; 325 QColorGroup _cg = cg;
321 const QPixmap *pm = listView()->viewport()->backgroundPixmap(); 326 const QPixmap *pm = listView()->viewport()->backgroundPixmap();
322 if (pm && !pm->isNull()) 327 if (pm && !pm->isNull())
323 { 328 {
324 _cg.setBrush( QColorGroup::Base, QBrush(backgroundColor(), *pm) ); 329 _cg.setBrush( QColorGroup::Base, QBrush(backgroundColor(), *pm) );
325 p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() ); 330 p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() );
326 } 331 }
327 else if ( isAlternate() ) 332 else if ( isAlternate() )
328 { 333 {
329 _cg.setColor( QColorGroup::Base, static_cast<OListView*>( listView() )->alternateBackground() ); 334 _cg.setColor( QColorGroup::Base, static_cast<OListView*>( listView() )->alternateBackground() );
330 } 335 }
331 QListViewItem::paintCell( p, _cg, column, width, alignment ); 336 QListViewItem::paintCell( p, _cg, column, width, alignment );
332 337
333 //FIXME: Use styling here! 338 //FIXME: Use styling here!
334 339
335 const QPen& pen = static_cast<OListView*>( listView() )->columnSeparator(); 340 const QPen& pen = static_cast<OListView*>( listView() )->columnSeparator();
336 p->setPen( pen ); 341 p->setPen( pen );
337 p->drawLine( width-1, 0, width-1, height() ); 342 p->drawLine( width-1, 0, width-1, height() );
338} 343}
339 344
345OListViewItem* OListViewItem::childFactory()
346{
347 return new OListViewItem( this );
348}
349
340#ifndef QT_NO_DATASTREAM 350#ifndef QT_NO_DATASTREAM
341void OListViewItem::serializeTo( QDataStream& s ) const 351void OListViewItem::serializeTo( QDataStream& s ) const
342{ 352{
343 #warning Caution... the binary format is still under construction... 353 #warning Caution... the binary format is still under construction...
344 qDebug( "storing OListViewItem..." ); 354 qDebug( "storing OListViewItem..." );
345 355
346 // store item text 356 // store item text
347 for ( int i = 0; i < listView()->columns(); ++i ) 357 for ( int i = 0; i < listView()->columns(); ++i )
348 { 358 {
349 s << text( i ); 359 s << text( i );
350 } 360 }
351 361
352 // calculate the number of children to serialize 362 // calculate the number of children to serialize
353 int items = 0; 363 int items = 0;
354 QListViewItem* item = firstChild(); 364 QListViewItem* item = firstChild();
355 while ( item ) 365 while ( item )
356 { 366 {
357 item = item->nextSibling(); 367 item = item->nextSibling();
358 items++; 368 items++;
359 } 369 }
360 370
361 // store number of items and the items itself 371 // store number of items and the items itself
362 s << items; 372 s << items;
363 item = firstChild(); 373 item = firstChild();
364 for ( int i = 0; i < items; ++i ) 374 for ( int i = 0; i < items; ++i )
365 { 375 {
366 s << *static_cast<OListViewItem*>( item ); 376 s << *static_cast<OListViewItem*>( item );
367 item = item->nextSibling(); 377 item = item->nextSibling();
368 } 378 }
369 379
370 qDebug( "OListviewItem stored." ); 380 qDebug( "OListviewItem stored." );
371} 381}
372void OListViewItem::serializeFrom( QDataStream& s ) 382void OListViewItem::serializeFrom( QDataStream& s )
373{ 383{
374 #warning Caution... the binary format is still under construction... 384 #warning Caution... the binary format is still under construction...
375 qDebug( "loading OListViewItem..." ); 385 qDebug( "loading OListViewItem..." );
376 386
377 for ( int i = 0; i < listView()->columns(); ++i ) 387 for ( int i = 0; i < listView()->columns(); ++i )
378 { 388 {
379 QString coltext; 389 QString coltext;
380 s >> coltext; 390 s >> coltext;
381 qDebug( "read text '%s' for column %d", (const char*) coltext, i ); 391 qDebug( "read text '%s' for column %d", (const char*) coltext, i );
382 setText( i, coltext ); 392 setText( i, coltext );
383 } 393 }
384 394
385 int items; 395 int items;
386 s >> items; 396 s >> items;
387 qDebug( "read number of items = %d", items ); 397 qDebug( "read number of items = %d", items );
388 398
389 for ( int i = 0; i < items; ++i ) 399 for ( int i = 0; i < items; ++i )
390 { 400 {
391 OListViewItem* item = new OListViewItem( this ); 401 OListViewItem* item = childFactory();
392 s >> (*item); 402 s >> (*item);
393 } 403 }
394 404
395 qDebug( "OListViewItem loaded." ); 405 qDebug( "OListViewItem loaded." );
396} 406}
397 407
398QDataStream& operator<<( QDataStream& s, const OListViewItem& lvi ) 408QDataStream& operator<<( QDataStream& s, const OListViewItem& lvi )
399{ 409{
400 lvi.serializeTo( s ); 410 lvi.serializeTo( s );
401} 411}
402 412
403QDataStream& operator>>( QDataStream& s, OListViewItem& lvi ) 413QDataStream& operator>>( QDataStream& s, OListViewItem& lvi )
404{ 414{
405 lvi.serializeFrom( s ); 415 lvi.serializeFrom( s );
406} 416}
407#endif // QT_NO_DATASTREAM 417#endif // QT_NO_DATASTREAM
diff --git a/noncore/net/wellenreiter/cornucopia/olistview.h b/noncore/net/wellenreiter/cornucopia/olistview.h
index 9df5500..8911e22 100644
--- a/noncore/net/wellenreiter/cornucopia/olistview.h
+++ b/noncore/net/wellenreiter/cornucopia/olistview.h
@@ -1,237 +1,237 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 3
4              Copyright (C) 2003 Michael 'Mickey' Lauer 4              Copyright (C) 2003 Michael 'Mickey' Lauer
5 <mickey@tm.informatik.uni-frankfurt.de> 5 <mickey@tm.informatik.uni-frankfurt.de>
6 =. 6 =.
7 .=l. 7 .=l.
8           .>+-= 8           .>+-=
9 _;:,     .>    :=|. This program is free software; you can 9 _;:,     .>    :=|. This program is free software; you can
10.> <`_,   >  .   <= redistribute it and/or modify it under 10.> <`_,   >  .   <= redistribute it and/or modify it under
11:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 11:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
12.="- .-=="i,     .._ License as published by the Free Software 12.="- .-=="i,     .._ License as published by the Free Software
13 - .   .-<_>     .<> Foundation; either version 2 of the License, 13 - .   .-<_>     .<> Foundation; either version 2 of the License,
14     ._= =}       : or (at your option) any later version. 14     ._= =}       : or (at your option) any later version.
15    .%`+i>       _;_. 15    .%`+i>       _;_.
16    .i_,=:_.      -<s. This program is distributed in the hope that 16    .i_,=:_.      -<s. This program is distributed in the hope that
17     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 17     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
18    : ..    .:,     . . . without even the implied warranty of 18    : ..    .:,     . . . without even the implied warranty of
19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
21..}^=.=       =       ; Library General Public License for more 21..}^=.=       =       ; Library General Public License for more
22++=   -.     .`     .: details. 22++=   -.     .`     .: details.
23 :     =  ...= . :.=- 23 :     =  ...= . :.=-
24 -.   .:....=;==+<; You should have received a copy of the GNU 24 -.   .:....=;==+<; You should have received a copy of the GNU
25  -_. . .   )=.  = Library General Public License along with 25  -_. . .   )=.  = Library General Public License along with
26    --        :-=` this library; see the file COPYING.LIB. 26    --        :-=` this library; see the file COPYING.LIB.
27 If not, write to the Free Software Foundation, 27 If not, write to the Free Software Foundation,
28 Inc., 59 Temple Place - Suite 330, 28 Inc., 59 Temple Place - Suite 330,
29 Boston, MA 02111-1307, USA. 29 Boston, MA 02111-1307, USA.
30 30
31*/ 31*/
32 32
33#ifndef OLISTVIEW_H 33#ifndef OLISTVIEW_H
34#define OLISTVIEW_H 34#define OLISTVIEW_H
35 35
36#include <qcolor.h> 36#include <qcolor.h>
37#include <qlistview.h> 37#include <qlistview.h>
38#include <qpen.h> 38#include <qpen.h>
39#include <qdatastream.h> 39#include <qdatastream.h>
40 40
41class OListViewFactory; 41class OListViewItem;
42 42
43/** 43/**
44 * A @ref QListView variant featuring visual and functional enhancements 44 * A @ref QListView variant featuring visual and functional enhancements
45 * like an alternate background for odd rows, an autostretch mode 45 * like an alternate background for odd rows, an autostretch mode
46 * for the width of the widget ( >= Qt 3 only ) and persistence capabilities. 46 * for the width of the widget ( >= Qt 3 only ) and persistence capabilities.
47 * 47 *
48 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 48 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
49 * @short OListView list/tree widget. 49 * @short OListView list/tree widget.
50 */ 50 */
51 class OListView: public QListView 51 class OListView: public QListView
52{ 52{
53 public: 53 public:
54 /** 54 /**
55 * Constructor. 55 * Constructor.
56 * 56 *
57 * The parameters @p parent and @p name are handled by 57 * The parameters @p parent and @p name are handled by
58 * @ref QListView, as usual. 58 * @ref QListView, as usual.
59 */ 59 */
60 OListView ( QWidget *parent = 0, const char *name = 0 ); 60 OListView ( QWidget *parent = 0, const char *name = 0 );
61 61
62 /** 62 /**
63 * Destructor. 63 * Destructor.
64 */ 64 */
65 virtual ~OListView(); 65 virtual ~OListView();
66 66
67 /** 67 /**
68 * Let the last column fit exactly all the available width. 68 * Let the last column fit exactly all the available width.
69 */ 69 */
70 void setFullWidth( bool fullWidth ); 70 void setFullWidth( bool fullWidth );
71 71
72 /** 72 /**
73 * Returns whether the last column is set to fit the available width. 73 * Returns whether the last column is set to fit the available width.
74 */ 74 */
75 bool fullWidth() const; 75 bool fullWidth() const;
76 76
77 /** 77 /**
78 * Reimplemented for full width support 78 * Reimplemented for full width support
79 */ 79 */
80 virtual int addColumn( const QString& label, int width = -1 ); 80 virtual int addColumn( const QString& label, int width = -1 );
81 81
82 /** 82 /**
83 * Reimplemented for full width support 83 * Reimplemented for full width support
84 */ 84 */
85 virtual int addColumn( const QIconSet& iconset, const QString& label, int width = -1 ); 85 virtual int addColumn( const QIconSet& iconset, const QString& label, int width = -1 );
86 86
87 /** 87 /**
88 * Reimplemented for full width support 88 * Reimplemented for full width support
89 */ 89 */
90 virtual void removeColumn(int index); 90 virtual void removeColumn(int index);
91 91
92 /** 92 /**
93 * sets the alternate background background color. 93 * sets the alternate background background color.
94 * This only has an effect if the items are OListViewItems 94 * This only has an effect if the items are OListViewItems
95 * 95 *
96 * @param c the color to use for every other item. Set to an invalid 96 * @param c the color to use for every other item. Set to an invalid
97 * color to disable alternate colors. 97 * color to disable alternate colors.
98 */ 98 */
99 void setAlternateBackground( const QColor &c ); 99 void setAlternateBackground( const QColor &c );
100 100
101 /** 101 /**
102 * sets the column separator pen. 102 * sets the column separator pen.
103 * 103 *
104 * @param p the pen used to draw the column separator. 104 * @param p the pen used to draw the column separator.
105 */ 105 */
106 void setColumnSeparator( const QPen &p ); 106 void setColumnSeparator( const QPen &p );
107 107
108 /** 108 /**
109 * @return the alternate background color 109 * @return the alternate background color
110 */ 110 */
111 const QColor& alternateBackground() const; 111 const QColor& alternateBackground() const;
112 112
113 /** 113 /**
114 * @return the column separator pen 114 * @return the column separator pen
115 */ 115 */
116 const QPen& columnSeparator() const; 116 const QPen& columnSeparator() const;
117 117
118 /**
119 * create a list view item as child of this object
120 * @return the new object
121 */
122 virtual OListViewItem* childFactory();
123
118 #ifndef QT_NO_DATASTREAM 124 #ifndef QT_NO_DATASTREAM
119 /** 125 /**
120 * serialize this object to a @ref QDataStream 126 * serialize this object to a @ref QDataStream
121 * @param s the stream used to serialize this object. 127 * @param s the stream used to serialize this object.
122 */ 128 */
123 virtual void serializeTo( QDataStream& s ) const; 129 virtual void serializeTo( QDataStream& s ) const;
124 130
125 /** 131 /**
126 * serialize this object from a @ref QDataStream 132 * serialize this object from a @ref QDataStream
127 * @param s the stream used to serialize this object. 133 * @param s the stream used to serialize this object.
128 */ 134 */
129 virtual void serializeFrom( QDataStream& s ); 135 virtual void serializeFrom( QDataStream& s );
130 #endif 136 #endif
131 137
132 /**
133 * returns a factory for OListView classes
134 * creates one on the fly if it doesn't exist
135 * @return the XML Factory
136 */
137 #ifndef QT_NO_XML
138 //OListViewFactory* Factory();
139 #endif
140
141 private: 138 private:
142 QColor m_alternateBackground; 139 QColor m_alternateBackground;
143 bool m_fullWidth; 140 bool m_fullWidth;
144 QPen m_columnSeparator; 141 QPen m_columnSeparator;
145 #ifndef QT_NO_XML
146 //OListViewFactory* m_Factory;
147 #endif
148}; 142};
149 143
150#ifndef QT_NO_DATASTREAM 144#ifndef QT_NO_DATASTREAM
151/** 145/**
152 * \relates QListView 146 * \relates QListView
153 * Writes a listview to the stream and returns a reference to the stream. 147 * Writes a listview to the stream and returns a reference to the stream.
154 */ 148 */
155QDataStream& operator<<( QDataStream& s, const OListView& lv ); 149QDataStream& operator<<( QDataStream& s, const OListView& lv );
156/** 150/**
157 * \relates QListView 151 * \relates QListView
158 * Reads a listview from the stream and returns a reference to the stream. 152 * Reads a listview from the stream and returns a reference to the stream.
159 */ 153 */
160QDataStream& operator>>( QDataStream& s, OListView& lv ); 154QDataStream& operator>>( QDataStream& s, OListView& lv );
161#endif // QT_NO_DATASTREAM 155#endif // QT_NO_DATASTREAM
162 156
163//****************************** OListViewItem ****************************************************************** 157//****************************** OListViewItem ******************************************************************
164 158
165class OListViewItem: public QListViewItem 159class OListViewItem: public QListViewItem
166{ 160{
167 public: 161 public:
168 OListViewItem( QListView * parent ); 162 OListViewItem( QListView * parent );
169 OListViewItem( QListViewItem * parent ); 163 OListViewItem( QListViewItem * parent );
170 OListViewItem( QListView * parent, QListViewItem * after ); 164 OListViewItem( QListView * parent, QListViewItem * after );
171 OListViewItem( QListViewItem * parent, QListViewItem * after ); 165 OListViewItem( QListViewItem * parent, QListViewItem * after );
172 166
173 OListViewItem( QListView * parent, 167 OListViewItem( QListView * parent,
174 QString, QString = QString::null, 168 QString, QString = QString::null,
175 QString = QString::null, QString = QString::null, 169 QString = QString::null, QString = QString::null,
176 QString = QString::null, QString = QString::null, 170 QString = QString::null, QString = QString::null,
177 QString = QString::null, QString = QString::null ); 171 QString = QString::null, QString = QString::null );
178 172
179 OListViewItem( QListViewItem * parent, 173 OListViewItem( QListViewItem * parent,
180 QString, QString = QString::null, 174 QString, QString = QString::null,
181 QString = QString::null, QString = QString::null, 175 QString = QString::null, QString = QString::null,
182 QString = QString::null, QString = QString::null, 176 QString = QString::null, QString = QString::null,
183 QString = QString::null, QString = QString::null ); 177 QString = QString::null, QString = QString::null );
184 178
185 OListViewItem( QListView * parent, QListViewItem * after, 179 OListViewItem( QListView * parent, QListViewItem * after,
186 QString, QString = QString::null, 180 QString, QString = QString::null,
187 QString = QString::null, QString = QString::null, 181 QString = QString::null, QString = QString::null,
188 QString = QString::null, QString = QString::null, 182 QString = QString::null, QString = QString::null,
189 QString = QString::null, QString = QString::null ); 183 QString = QString::null, QString = QString::null );
190 184
191 OListViewItem( QListViewItem * parent, QListViewItem * after, 185 OListViewItem( QListViewItem * parent, QListViewItem * after,
192 QString, QString = QString::null, 186 QString, QString = QString::null,
193 QString = QString::null, QString = QString::null, 187 QString = QString::null, QString = QString::null,
194 QString = QString::null, QString = QString::null, 188 QString = QString::null, QString = QString::null,
195 QString = QString::null, QString = QString::null ); 189 QString = QString::null, QString = QString::null );
196 190
197 virtual ~OListViewItem(); 191 virtual ~OListViewItem();
198 192
199 const QColor& backgroundColor(); 193 const QColor& backgroundColor();
200 bool isAlternate(); 194 bool isAlternate();
201 void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ); 195 void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment );
202 void init(); 196 void init();
203 197
198 /**
199 * create a list view item as child of this object
200 * @return the new object
201 */
202 virtual OListViewItem* childFactory();
203
204 #ifndef QT_NO_DATASTREAM 204 #ifndef QT_NO_DATASTREAM
205 /** 205 /**
206 * serialize this object to or from a @ref QDataStream 206 * serialize this object to or from a @ref QDataStream
207 * @param s the stream used to serialize this object. 207 * @param s the stream used to serialize this object.
208 */ 208 */
209 virtual void serializeTo( QDataStream& s ) const; 209 virtual void serializeTo( QDataStream& s ) const;
210 210
211 /** 211 /**
212 * serialize this object to or from a @ref QDataStream 212 * serialize this object to or from a @ref QDataStream
213 * @param s the stream used to serialize this object. 213 * @param s the stream used to serialize this object.
214 */ 214 */
215 virtual void serializeFrom( QDataStream& s ); 215 virtual void serializeFrom( QDataStream& s );
216 #endif 216 #endif
217 217
218 private: 218 private:
219 bool m_known; 219 bool m_known;
220 bool m_odd; 220 bool m_odd;
221}; 221};
222 222
223#ifndef QT_NO_DATASTREAM 223#ifndef QT_NO_DATASTREAM
224/** 224/**
225 * \relates QListViewItem 225 * \relates QListViewItem
226 * Writes a listview item and all subitems recursively to the stream 226 * Writes a listview item and all subitems recursively to the stream
227 * and returns a reference to the stream. 227 * and returns a reference to the stream.
228 */ 228 */
229QDataStream& operator<<( QDataStream &s, const OListViewItem& lvi ); 229QDataStream& operator<<( QDataStream &s, const OListViewItem& lvi );
230/** 230/**
231 * \relates QListViewItem 231 * \relates QListViewItem
232 * Reads a listview item from the stream and returns a reference to the stream. 232 * Reads a listview item from the stream and returns a reference to the stream.
233 */ 233 */
234QDataStream& operator>>( QDataStream &s, OListViewItem& lvi ); 234QDataStream& operator>>( QDataStream &s, OListViewItem& lvi );
235#endif // QT_NO_DATASTREAM 235#endif // QT_NO_DATASTREAM
236 236
237#endif // OLISTVIEW_H 237#endif // OLISTVIEW_H
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp
index 58a04fb..be1245e 100644
--- a/noncore/net/wellenreiter/gui/scanlist.cpp
+++ b/noncore/net/wellenreiter/gui/scanlist.cpp
@@ -1,263 +1,288 @@
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 "scanlist.h" 16#include "scanlist.h"
17 17
18#include <assert.h> 18#include <assert.h>
19#include "manufacturers.h" 19#include "manufacturers.h"
20#include <qdatetime.h> 20#include <qdatetime.h>
21#include <qtextstream.h> 21#include <qtextstream.h>
22 22
23MScanListView::MScanListView( QWidget* parent, const char* name ) 23MScanListView::MScanListView( QWidget* parent, const char* name )
24 :OListView( parent, name ), _manufacturerdb( 0 ) 24 :OListView( parent, name ), _manufacturerdb( 0 )
25{ 25{
26 26
27 setFrameShape( QListView::StyledPanel ); 27 setFrameShape( QListView::StyledPanel );
28 setFrameShadow( QListView::Sunken ); 28 setFrameShadow( QListView::Sunken );
29 29
30 addColumn( tr( "Net/Station" ) ); 30 addColumn( tr( "Net/Station" ) );
31 setColumnAlignment( 0, AlignLeft || AlignVCenter ); 31 setColumnAlignment( 0, AlignLeft || AlignVCenter );
32 addColumn( tr( "B" ) ); 32 addColumn( tr( "B" ) );
33 setColumnAlignment( 1, AlignCenter ); 33 setColumnAlignment( 1, AlignCenter );
34 addColumn( tr( "AP" ) ); 34 addColumn( tr( "AP" ) );
35 setColumnAlignment( 2, AlignCenter ); 35 setColumnAlignment( 2, AlignCenter );
36 addColumn( tr( "Chn" ) ); 36 addColumn( tr( "Chn" ) );
37 setColumnAlignment( 3, AlignCenter ); 37 setColumnAlignment( 3, AlignCenter );
38 addColumn( tr( "W" ) ); 38 addColumn( tr( "W" ) );
39 setColumnAlignment( 4, AlignCenter ); 39 setColumnAlignment( 4, AlignCenter );
40 addColumn( tr( "T" ) ); 40 addColumn( tr( "T" ) );
41 setColumnAlignment( 5, AlignCenter ); 41 setColumnAlignment( 5, AlignCenter );
42 addColumn( tr( "Manufacturer" ) ); 42 addColumn( tr( "Manufacturer" ) );
43 setColumnAlignment( 6, AlignCenter ); 43 setColumnAlignment( 6, AlignCenter );
44 addColumn( tr( "First Seen" ) ); 44 addColumn( tr( "First Seen" ) );
45 setColumnAlignment( 7, AlignCenter ); 45 setColumnAlignment( 7, AlignCenter );
46 addColumn( tr( "Last Seen" ) ); 46 addColumn( tr( "Last Seen" ) );
47 setColumnAlignment( 8, AlignCenter ); 47 setColumnAlignment( 8, AlignCenter );
48 setRootIsDecorated( true ); 48 setRootIsDecorated( true );
49 setAllColumnsShowFocus( true ); 49 setAllColumnsShowFocus( true );
50}; 50};
51 51
52MScanListView::~MScanListView() 52MScanListView::~MScanListView()
53{ 53{
54}; 54};
55 55
56OListViewItem* MScanListView::childFactory()
57{
58 return new MScanListItem( this );
59}
60
56void MScanListView::serializeTo( QDataStream& s) const 61void MScanListView::serializeTo( QDataStream& s) const
57{ 62{
58 qDebug( "serializing MScanListView" ); 63 qDebug( "serializing MScanListView" );
59 OListView::serializeTo( s ); 64 OListView::serializeTo( s );
60} 65}
61 66
62void MScanListView::serializeFrom( QDataStream& s) 67void MScanListView::serializeFrom( QDataStream& s)
63{ 68{
64 qDebug( "serializing MScanListView" ); 69 qDebug( "serializing MScanListView" );
65 OListView::serializeFrom( s ); 70 OListView::serializeFrom( s );
66} 71}
67 72
68void MScanListView::setManufacturerDB( ManufacturerDB* manufacturerdb ) 73void MScanListView::setManufacturerDB( ManufacturerDB* manufacturerdb )
69{ 74{
70 _manufacturerdb = manufacturerdb; 75 _manufacturerdb = manufacturerdb;
71} 76}
72 77
73void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) 78void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal )
74{ 79{
75 // FIXME: scanlistitem needs a proper encapsulation and not such a damn dealing with text(...) 80 // FIXME: scanlistitem needs a proper encapsulation and not such a damn dealing with text(...)
76 81
77 qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", 82 qDebug( "MScanList::addNewItem( %s / %s / %s [%d]",
78 (const char*) type, 83 (const char*) type,
79 (const char*) essid, 84 (const char*) essid,
80 (const char*) macaddr, 85 (const char*) macaddr,
81 channel ); 86 channel );
82 87
83 // search, if we already have seen this net 88 // search, if we already have seen this net
84 89
85 QString s; 90 QString s;
86 MScanListItem* network; 91 MScanListItem* network;
87 MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); 92 MScanListItem* item = static_cast<MScanListItem*> ( firstChild() );
88 93
89 while ( item && ( item->text( 0 ) != essid ) ) 94 while ( item && ( item->text( 0 ) != essid ) )
90 { 95 {
91 qDebug( "itemtext: %s", (const char*) item->text( 0 ) ); 96 qDebug( "itemtext: %s", (const char*) item->text( 0 ) );
92 item = static_cast<MScanListItem*> ( item->itemBelow() ); 97 item = static_cast<MScanListItem*> ( item->itemBelow() );
93 } 98 }
94 if ( item ) 99 if ( item )
95 { 100 {
96 // animate the item 101 // animate the item
97 102
98 /* 103 /*
99 104
100 const QPixmap* pixmap = item->pixmap( 0 ); 105 const QPixmap* pixmap = item->pixmap( 0 );
101 const QPixmap* nextpixmap = ani2; 106 const QPixmap* nextpixmap = ani2;
102 if ( pixmap == ani1 ) 107 if ( pixmap == ani1 )
103 nextpixmap = ani2; 108 nextpixmap = ani2;
104 else if ( pixmap == ani2 ) 109 else if ( pixmap == ani2 )
105 nextpixmap = ani3; 110 nextpixmap = ani3;
106 else if ( pixmap == ani3 ) 111 else if ( pixmap == ani3 )
107 nextpixmap = ani4; 112 nextpixmap = ani4;
108 else if ( pixmap == ani4 ) 113 else if ( pixmap == ani4 )
109 nextpixmap = ani1; 114 nextpixmap = ani1;
110 item->setPixmap( 0, *nextpixmap ); */ 115 item->setPixmap( 0, *nextpixmap ); */
111 116
112 //qDebug( "current pixmap %d, next %d", pixmap, nextpixmap ); 117 //qDebug( "current pixmap %d, next %d", pixmap, nextpixmap );
113 118
114 // we have already seen this net, check all childs if MAC exists 119 // we have already seen this net, check all childs if MAC exists
115 120
116 network = item; 121 network = item;
117 122
118 item = static_cast<MScanListItem*> ( item->firstChild() ); 123 item = static_cast<MScanListItem*> ( item->firstChild() );
119 assert( item ); // this shouldn't fail 124 assert( item ); // this shouldn't fail
120 125
121 while ( item && ( item->text( 2 ) != macaddr ) ) 126 while ( item && ( item->text( 2 ) != macaddr ) )
122 { 127 {
123 qDebug( "subitemtext: %s", (const char*) item->text( 2 ) ); 128 qDebug( "subitemtext: %s", (const char*) item->text( 2 ) );
124 item = static_cast<MScanListItem*> ( item->itemBelow() ); 129 item = static_cast<MScanListItem*> ( item->itemBelow() );
125 } 130 }
126 131
127 if ( item ) 132 if ( item )
128 { 133 {
129 // we have already seen this item, it's a dupe 134 // we have already seen this item, it's a dupe
130 #ifdef DEBUG 135 #ifdef DEBUG
131 qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); 136 qDebug( "%s is a dupe - ignoring...", (const char*) macaddr );
132 #endif 137 #endif
133 item->receivedBeacon(); 138 item->receivedBeacon();
134 return; 139 return;
135 } 140 }
136 } 141 }
137 else 142 else
138 { 143 {
139 s.sprintf( "(i) new network: '%s'", (const char*) essid ); 144 s.sprintf( "(i) new network: '%s'", (const char*) essid );
140 145
141 network = new MScanListItem( this, "networks", essid, QString::null, 0, 0, 0 ); 146 network = new MScanListItem( this, "networks", essid, QString::null, 0, 0, 0 );
142 } 147 }
143 148
144 149
145 // insert new station as child from network 150 // insert new station as child from network
146 151
147 // no essid to reduce clutter, maybe later we have a nick or stationname to display!? 152 // no essid to reduce clutter, maybe later we have a nick or stationname to display!?
148 153
149 qDebug( "inserting new station %s", (const char*) macaddr ); 154 qDebug( "inserting new station %s", (const char*) macaddr );
150 155
151 MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); 156 MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal );
152 if ( _manufacturerdb ) 157 if ( _manufacturerdb )
153 station->setManufacturer( _manufacturerdb->lookup( macaddr ) ); 158 station->setManufacturer( _manufacturerdb->lookup( macaddr ) );
154 159
155 if ( type == "managed" ) 160 if ( type == "managed" )
156 { 161 {
157 s.sprintf( "(i) new AP in '%s' [%d]", (const char*) essid, channel ); 162 s.sprintf( "(i) new AP in '%s' [%d]", (const char*) essid, channel );
158 } 163 }
159 else 164 else
160 { 165 {
161 s.sprintf( "(i) new adhoc station in '%s' [%d]", (const char*) essid, channel ); 166 s.sprintf( "(i) new adhoc station in '%s' [%d]", (const char*) essid, channel );
162 } 167 }
163 168
164} 169}
165 170
166#ifdef QWS 171#ifdef QWS
167#include <qpe/resource.h> 172#include <qpe/resource.h>
168#else 173#else
169#include "resource.h" 174#include "resource.h"
170#endif 175#endif
171 176
172const int col_type = 0; 177const int col_type = 0;
173const int col_essid = 0; 178const int col_essid = 0;
174const int col_sig = 1; 179const int col_sig = 1;
175const int col_ap = 2; 180const int col_ap = 2;
176const int col_channel = 3; 181const int col_channel = 3;
177const int col_wep = 4; 182const int col_wep = 4;
178const int col_traffic = 5; 183const int col_traffic = 5;
179const int col_manuf = 6; 184const int col_manuf = 6;
180const int col_firstseen = 7; 185const int col_firstseen = 7;
181const int col_lastseen = 8; 186const int col_lastseen = 8;
182 187
183MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr, 188MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr,
184 bool wep, int channel, int signal ) 189 bool wep, int channel, int signal )
185 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), 190 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ),
186 _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), 191 _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ),
187 _channel( channel ), _signal( signal ), _beacons( 0 ) 192 _channel( channel ), _signal( signal ), _beacons( 0 )
188{ 193{
189 qDebug( "creating scanlist item" ); 194 qDebug( "creating scanlist item" );
190 decorateItem( type, essid, macaddr, wep, channel, signal ); 195 decorateItem( type, essid, macaddr, wep, channel, signal );
191} 196}
192 197
193MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr, 198MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr,
194 bool wep, int channel, int signal ) 199 bool wep, int channel, int signal )
195 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) 200 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null )
196{ 201{
197 qDebug( "creating scanlist item" ); 202 qDebug( "creating scanlist item" );
198 decorateItem( type, essid, macaddr, wep, channel, signal ); 203 decorateItem( type, essid, macaddr, wep, channel, signal );
199} 204}
200 205
206OListViewItem* MScanListItem::childFactory()
207{
208 return new MScanListItem( this );
209}
210
201void MScanListItem::serializeTo( QDataStream& s ) const 211void MScanListItem::serializeTo( QDataStream& s ) const
202{ 212{
213 qDebug( "serializing MScanListItem" );
203 OListViewItem::serializeTo( s ); 214 OListViewItem::serializeTo( s );
215
216 s << _type;
217 s << (Q_UINT8) _wep;
204} 218}
205 219
206void MScanListItem::serializeFrom( QDataStream& s ) 220void MScanListItem::serializeFrom( QDataStream& s )
207{ 221{
222 qDebug( "serializing MScanListItem" );
208 OListViewItem::serializeFrom( s ); 223 OListViewItem::serializeFrom( s );
224
225 s >> _type;
226 s >> (Q_UINT8) _wep;
227
228 QString name;
229 name.sprintf( "wellenreiter/%s", (const char*) _type );
230 setPixmap( col_type, Resource::loadPixmap( name ) );
231 if ( _wep )
232 setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap!
233 listView()->triggerUpdate();
209} 234}
210 235
211void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) 236void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal )
212{ 237{
213 qDebug( "decorating scanlist item %s / %s / %s [%d]", 238 qDebug( "decorating scanlist item %s / %s / %s [%d]",
214 (const char*) type, 239 (const char*) type,
215 (const char*) essid, 240 (const char*) essid,
216 (const char*) macaddr, 241 (const char*) macaddr,
217 channel ); 242 channel );
218 243
219 // set icon for managed or adhoc mode 244 // set icon for managed or adhoc mode
220 QString name; 245 QString name;
221 name.sprintf( "wellenreiter/%s", (const char*) type ); 246 name.sprintf( "wellenreiter/%s", (const char*) type );
222 setPixmap( col_type, Resource::loadPixmap( name ) ); 247 setPixmap( col_type, Resource::loadPixmap( name ) );
223 248
224 // set icon for wep (wireless encryption protocol) 249 // set icon for wep (wireless encryption protocol)
225 if ( wep ) 250 if ( wep )
226 setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! 251 setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap!
227 252
228 // set channel and signal text 253 // set channel and signal text
229 254
230 if ( signal != -1 ) 255 if ( signal != -1 )
231 setText( col_sig, QString::number( signal ) ); 256 setText( col_sig, QString::number( signal ) );
232 if ( channel != -1 ) 257 if ( channel != -1 )
233 setText( col_channel, QString::number( channel ) ); 258 setText( col_channel, QString::number( channel ) );
234 259
235 setText( col_firstseen, QTime::currentTime().toString() ); 260 setText( col_firstseen, QTime::currentTime().toString() );
236 //setText( col_lastseen, QTime::currentTime().toString() ); 261 //setText( col_lastseen, QTime::currentTime().toString() );
237 262
238 listView()->triggerUpdate(); 263 listView()->triggerUpdate();
239 264
240 this->type = type; 265 this->type = type;
241 _type = type; 266 _type = type;
242 _essid = essid; 267 _essid = essid;
243 _macaddr = macaddr; 268 _macaddr = macaddr;
244 _channel = channel; 269 _channel = channel;
245 _beacons = 0; 270 _beacons = 0;
246 _signal = 0; 271 _signal = 0;
247} 272}
248 273
249void MScanListItem::setManufacturer( const QString& manufacturer ) 274void MScanListItem::setManufacturer( const QString& manufacturer )
250{ 275{
251 setText( col_manuf, manufacturer ); 276 setText( col_manuf, manufacturer );
252} 277}
253 278
254void MScanListItem::receivedBeacon() 279void MScanListItem::receivedBeacon()
255{ 280{
256 _beacons++; 281 _beacons++;
257 #ifdef DEBUG 282 #ifdef DEBUG
258 qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons ); 283 qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons );
259 #endif 284 #endif
260 setText( col_sig, QString::number( _beacons ) ); 285 setText( col_sig, QString::number( _beacons ) );
261 setText( col_lastseen, QTime::currentTime().toString() ); 286 setText( col_lastseen, QTime::currentTime().toString() );
262} 287}
263 288
diff --git a/noncore/net/wellenreiter/gui/scanlist.h b/noncore/net/wellenreiter/gui/scanlist.h
index 66c701b..222217c 100644
--- a/noncore/net/wellenreiter/gui/scanlist.h
+++ b/noncore/net/wellenreiter/gui/scanlist.h
@@ -1,119 +1,121 @@
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#ifndef SCANLIST_H 16#ifndef SCANLIST_H
17#define SCANLIST_H 17#define SCANLIST_H
18 18
19#include <cornucopia/olistview.h> 19#include <cornucopia/olistview.h>
20 20
21#include <qtextstream.h> 21#include <qtextstream.h>
22 22
23class QString; 23class QString;
24class ManufacturerDB; 24class ManufacturerDB;
25 25
26class MScanListView: public OListView 26class MScanListView: public OListView
27{ 27{
28 Q_OBJECT 28 Q_OBJECT
29 29
30 public: 30 public:
31 MScanListView( QWidget* parent = 0, const char* name = 0 ); 31 MScanListView( QWidget* parent = 0, const char* name = 0 );
32 virtual ~MScanListView(); 32 virtual ~MScanListView();
33 33
34 void setManufacturerDB( ManufacturerDB* manufacturerdb ); 34 void setManufacturerDB( ManufacturerDB* manufacturerdb );
35 35
36 virtual OListViewItem* childFactory();
36 virtual void serializeTo( QDataStream& s ) const; 37 virtual void serializeTo( QDataStream& s ) const;
37 virtual void serializeFrom( QDataStream& s ); 38 virtual void serializeFrom( QDataStream& s );
38 39
39 public slots: 40 public slots:
40 void addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ); 41 void addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal );
41 42
42 private: 43 private:
43 ManufacturerDB* _manufacturerdb; 44 ManufacturerDB* _manufacturerdb;
44 45
45}; 46};
46 47
47//****************************** MScanListItem **************************************************************** 48//****************************** MScanListItem ****************************************************************
48 49
49class MScanListItem: public OListViewItem 50class MScanListItem: public OListViewItem
50{ 51{
51 public: 52 public:
52 MScanListItem::MScanListItem( QListView* parent, 53 MScanListItem::MScanListItem( QListView* parent,
53 QString type, 54 QString type = "unknown",
54 QString essid, 55 QString essid = "unknown",
55 QString macaddr, 56 QString macaddr = "unknown",
56 bool wep, 57 bool wep = false,
57 int channel, 58 int channel = 0,
58 int signal ); 59 int signal = 0 );
59 60
60 MScanListItem::MScanListItem( QListViewItem* parent, 61 MScanListItem::MScanListItem( QListViewItem* parent,
61 QString type, 62 QString type = "unknown",
62 QString essid, 63 QString essid = "unknown",
63 QString macaddr, 64 QString macaddr = "unknown",
64 bool wep, 65 bool wep = false,
65 int channel, 66 int channel = 0,
66 int signal ); 67 int signal = 0 );
67 68
68 69
69 protected: 70 protected:
70 virtual void decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ); 71 virtual void decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal );
71 72
72 public: 73 public:
73 QString type; 74 QString type;
74 75
75 public: 76 public:
76 //const QString& type() { return _type; }; 77 //const QString& type() { return _type; };
77 const QString& essid() { return _essid; }; 78 const QString& essid() { return _essid; };
78 const QString& macaddr() { return _macaddr; }; 79 const QString& macaddr() { return _macaddr; };
79 bool wep() { return _wep; }; 80 bool wep() { return _wep; };
80 int channel() { return _channel; }; 81 int channel() { return _channel; };
81 int signal() { return _signal; }; 82 int signal() { return _signal; };
82 int beacons() { return _beacons; }; 83 int beacons() { return _beacons; };
83 84
84 void setSignal( int signal ) { /* TODO */ }; 85 void setSignal( int signal ) { /* TODO */ };
85 void receivedBeacon(); 86 void receivedBeacon();
86 87
87 void setManufacturer( const QString& manufacturer ); 88 void setManufacturer( const QString& manufacturer );
88 89
90 virtual OListViewItem* childFactory();
89 virtual void serializeTo( QDataStream& s ) const; 91 virtual void serializeTo( QDataStream& s ) const;
90 virtual void serializeFrom( QDataStream& s ); 92 virtual void serializeFrom( QDataStream& s );
91 93
92 private: 94 private:
93 QString _type; 95 QString _type;
94 QString _essid; 96 QString _essid;
95 QString _macaddr; 97 QString _macaddr;
96 bool _wep; 98 bool _wep;
97 int _channel; 99 int _channel;
98 int _signal; 100 int _signal;
99 int _beacons; 101 int _beacons;
100 102
101}; 103};
102 104
103//****************************** MScanListViewFactory **************************************************************** 105//****************************** MScanListViewFactory ****************************************************************
104 106
105/* 107/*
106 108
107class MScanListViewFactory : public OListViewFactory 109class MScanListViewFactory : public OListViewFactory
108{ 110{
109public: 111public:
110 virtual QListView* listViewFactory(); 112 virtual QListView* listViewFactory();
111 virtual QListViewItem* listViewItemFactory( QListView* lv ); 113 virtual QListViewItem* listViewItemFactory( QListView* lv );
112 virtual QListViewItem* listViewItemFactory( QListViewItem* lvi ); 114 virtual QListViewItem* listViewItemFactory( QListViewItem* lvi );
113 virtual void setColumnText( int depth, QListViewItem* lvi, int column, const QString& text ); 115 virtual void setColumnText( int depth, QListViewItem* lvi, int column, const QString& text );
114 virtual void setCustomData( int depth, QListViewItem* lvi, const QString& text ); 116 virtual void setCustomData( int depth, QListViewItem* lvi, const QString& text );
115} 117}
116*/ 118*/
117 119
118#endif 120#endif
119 121