summaryrefslogtreecommitdiff
path: root/noncore/net/wellenreiter/gui/scanlist.cpp
Unidiff
Diffstat (limited to 'noncore/net/wellenreiter/gui/scanlist.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/scanlist.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp
index 809d0bd..085eec4 100644
--- a/noncore/net/wellenreiter/gui/scanlist.cpp
+++ b/noncore/net/wellenreiter/gui/scanlist.cpp
@@ -17,14 +17,16 @@
17#include "configwindow.h" 17#include "configwindow.h"
18#include "logwindow.h" 18#include "logwindow.h"
19 19
20#include <assert.h> 20#include <assert.h>
21#include <qdatetime.h> 21#include <qdatetime.h>
22#include <qtextstream.h> 22#include <qtextstream.h>
23#include <qpopupmenu.h>
23 24
24#ifdef QWS 25#ifdef QWS
26#include <qpe/qpeapplication.h>
25#include <opie/odevice.h> 27#include <opie/odevice.h>
26using namespace Opie; 28using namespace Opie;
27#endif 29#endif
28 30
29 31
30#ifdef QWS 32#ifdef QWS
@@ -71,12 +73,20 @@ MScanListView::MScanListView( QWidget* parent, const char* name )
71 addColumn( tr( "First Seen" ) ); 73 addColumn( tr( "First Seen" ) );
72 setColumnAlignment( col_firstseen, AlignCenter ); 74 setColumnAlignment( col_firstseen, AlignCenter );
73 addColumn( tr( "Last Seen" ) ); 75 addColumn( tr( "Last Seen" ) );
74 setColumnAlignment( col_lastseen, AlignCenter ); 76 setColumnAlignment( col_lastseen, AlignCenter );
75 setRootIsDecorated( true ); 77 setRootIsDecorated( true );
76 setAllColumnsShowFocus( true ); 78 setAllColumnsShowFocus( true );
79
80 connect( this, SIGNAL( rightButtonClicked(QListViewItem*,const QPoint&,int) ),
81 this, SLOT( contextMenuRequested(QListViewItem*,const QPoint&,int) ) );
82
83 #ifdef QWS
84 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
85 #endif
86
77}; 87};
78 88
79 89
80MScanListView::~MScanListView() 90MScanListView::~MScanListView()
81{ 91{
82}; 92};
@@ -314,12 +324,33 @@ void MScanListView::identify( const OMacAddress& macaddr, const QString& ip )
314 qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" ); 324 qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" );
315 MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled identification %s = %s!", 325 MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled identification %s = %s!",
316 (const char*) macaddr.toString(), (const char*) ip ) ); 326 (const char*) macaddr.toString(), (const char*) ip ) );
317} 327}
318 328
319 329
330void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, int col )
331{
332 if ( !item ) return;
333
334 MScanListItem* itm = static_cast<MScanListItem*>( item );
335
336 qDebug( "contextMenuRequested on item '%s' (%s) in column: '%d'",
337 (const char*) itm->text(0), (const char*) itm->type, col );
338
339 if ( itm->type == "adhoc" || itm->type == "managed" )
340 {
341 QString entry = QString().sprintf( "&Join %s Net '%s'...", (const char*) itm->type, (const char*) itm->essid() );
342
343 QPopupMenu m( this );
344 m.insertItem( entry, 37773, 0 );
345 int result = m.exec( QCursor::pos() );
346 if ( result == 37773 )
347 emit joinNetwork( itm->type, itm->essid(), itm->channel(), itm->macaddr() );
348 }
349}
350
320//============================================================ 351//============================================================
321// MScanListItem 352// MScanListItem
322//============================================================ 353//============================================================
323 354
324MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr, 355MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr,
325 bool wep, int channel, int signal ) 356 bool wep, int channel, int signal )
@@ -342,12 +373,20 @@ MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid
342 #ifdef DEBUG 373 #ifdef DEBUG
343 qDebug( "creating scanlist item" ); 374 qDebug( "creating scanlist item" );
344 #endif 375 #endif
345 decorateItem( type, essid, macaddr, wep, channel, signal ); 376 decorateItem( type, essid, macaddr, wep, channel, signal );
346} 377}
347 378
379const QString& MScanListItem::essid() const
380{
381 if ( type == "network" )
382 return _essid;
383 else
384 return ( (MScanListItem*) parent() )->essid();
385}
386
348OListViewItem* MScanListItem::childFactory() 387OListViewItem* MScanListItem::childFactory()
349{ 388{
350 return new MScanListItem( this ); 389 return new MScanListItem( this );
351} 390}
352 391
353void MScanListItem::serializeTo( QDataStream& s ) const 392void MScanListItem::serializeTo( QDataStream& s ) const