summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-06-23 16:18:52 (UTC)
committer harlekin <harlekin>2002-06-23 16:18:52 (UTC)
commit5cf97227889d00e366782d466eef5eafe1d73e5c (patch) (unidiff)
tree3a89e3db99b1ec45f69ec4bf6688fdb45eeab9a7
parent6382b7352205a71557bd87b4f43d7f19f7f3330e (diff)
downloadopie-5cf97227889d00e366782d466eef5eafe1d73e5c.zip
opie-5cf97227889d00e366782d466eef5eafe1d73e5c.tar.gz
opie-5cf97227889d00e366782d466eef5eafe1d73e5c.tar.bz2
little update
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/manager/bluebase.cpp69
-rw-r--r--noncore/net/opietooth/manager/bluebase.h2
-rw-r--r--noncore/net/opietooth/manager/scandialog.cpp3
3 files changed, 66 insertions, 8 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp
index cc51405..772dbd1 100644
--- a/noncore/net/opietooth/manager/bluebase.cpp
+++ b/noncore/net/opietooth/manager/bluebase.cpp
@@ -1,134 +1,138 @@
1/* 1/*
2 * bluebase.cpp * 2 * bluebase.cpp *
3 * --------------------- 3 * ---------------------
4 * 4 *
5 * copyright : (c) 2002 by Maximilian Reiß 5 * copyright : (c) 2002 by Maximilian Reiß
6 * email : max.reiss@gmx.de 6 * email : max.reiss@gmx.de
7 * 7 *
8 */ 8 */
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#include "bluebase.h" 18#include "bluebase.h"
19#include "scandialog.h" 19#include "scandialog.h"
20 20
21#include <qframe.h> 21#include <qframe.h>
22#include <qlabel.h> 22#include <qlabel.h>
23#include <qpushbutton.h> 23#include <qpushbutton.h>
24#include <qlayout.h> 24#include <qlayout.h>
25#include <qvariant.h> 25#include <qvariant.h>
26#include <qwhatsthis.h> 26#include <qwhatsthis.h>
27#include <qimage.h> 27#include <qimage.h>
28#include <qpixmap.h> 28#include <qpixmap.h>
29#include <qtabwidget.h> 29#include <qtabwidget.h>
30#include <qscrollview.h> 30#include <qscrollview.h>
31#include <qvbox.h> 31#include <qvbox.h>
32#include <qmessagebox.h> 32#include <qmessagebox.h>
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qcheckbox.h> 34#include <qcheckbox.h>
35#include <qlineedit.h> 35#include <qlineedit.h>
36#include <qlistview.h> 36#include <qlistview.h>
37#include <qdir.h> 37#include <qdir.h>
38#include <qpopupmenu.h>
38 39
39#include <qpe/resource.h> 40#include <qpe/resource.h>
40#include <qpe/config.h> 41#include <qpe/config.h>
41 42
42#include <remotedevice.h> 43#include <remotedevice.h>
43 44
44 45
45namespace OpieTooth { 46namespace OpieTooth {
46 47
47 48
48 BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) 49 BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl )
49 : BluetoothBase( parent, name, fl ) { 50 : BluetoothBase( parent, name, fl ) {
50 51
51 localDevice = new Manager( "hci0" ); 52 localDevice = new Manager( "hci0" );
52 53
53 connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) ); 54 connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) );
54 connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) ); 55 connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) );
55 connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ), 56 // not good since lib is async
56 this, SLOT( addServicesToDevice( QListViewItem * ) ) ); 57 // connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ),
58 // this, SLOT( addServicesToDevice( QListViewItem * ) ) );
57 connect( ListView2, SIGNAL( clicked( QListViewItem* )), 59 connect( ListView2, SIGNAL( clicked( QListViewItem* )),
58 this, SLOT( startServiceActionClicked( QListViewItem* ) ) ); 60 this, SLOT( startServiceActionClicked( QListViewItem* ) ) );
61 connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ),
62 this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) );
59 connect( localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ), 63 connect( localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ),
60 this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) ); 64 this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) );
61 65
62 66
63 //Load all icons needed 67 //Load all icons needed
64 68
65
66 offPix = Resource::loadPixmap( "editdelete" ); 69 offPix = Resource::loadPixmap( "editdelete" );
67 onPix = Resource::loadPixmap( "installed" ); 70 onPix = Resource::loadPixmap( "installed" );
68 71
69 QPalette pal = this->palette(); 72 QPalette pal = this->palette();
70 QColor col = pal.color( QPalette::Active, QColorGroup::Background ); 73 QColor col = pal.color( QPalette::Active, QColorGroup::Background );
71 pal.setColor( QPalette::Active, QColorGroup::Button, col ); 74 pal.setColor( QPalette::Active, QColorGroup::Button, col );
72 pal.setColor( QPalette::Inactive, QColorGroup::Button, col ); 75 pal.setColor( QPalette::Inactive, QColorGroup::Button, col );
73 pal.setColor( QPalette::Normal, QColorGroup::Button, col ); 76 pal.setColor( QPalette::Normal, QColorGroup::Button, col );
74 pal.setColor( QPalette::Disabled, QColorGroup::Button, col ); 77 pal.setColor( QPalette::Disabled, QColorGroup::Button, col );
75 this->setPalette( pal ); 78 this->setPalette( pal );
76 79
77 setCaption( tr( "Bluetooth Manager" ) ); 80 setCaption( tr( "Bluetooth Manager" ) );
78 81
79 readConfig(); 82 readConfig();
80 initGui(); 83 initGui();
81 84
82 //TESTING 85 //TESTING
83 ListView2->setRootIsDecorated(true); 86 ListView2->setRootIsDecorated(true);
84 87
85 QListViewItem *topLV2 = new QListViewItem( ListView2, "Siemens S45" , "no" ); 88 QListViewItem *topLV2 = new QListViewItem( ListView2, "Siemens S45" , "no" );
86 topLV2->setPixmap( 1, onPix ); 89 topLV2->setPixmap( 1, onPix );
90 topLV2->setText(4, "device" );
87 (void) new QListViewItem( topLV2, "Serial" ); 91 (void) new QListViewItem( topLV2, "Serial" );
88 (void) new QListViewItem( topLV2, "BlueNiC" ); 92 (void) new QListViewItem( topLV2, "BlueNiC" );
89 } 93 }
90 94
91 95
92 /** 96 /**
93 * Reads all options from the config file 97 * Reads all options from the config file
94 */ 98 */
95 void BlueBase::readConfig() { 99 void BlueBase::readConfig() {
96 100
97 Config cfg( "bluetoothmanager" ); 101 Config cfg( "bluetoothmanager" );
98 cfg.setGroup( "bluezsettings" ); 102 cfg.setGroup( "bluezsettings" );
99 103
100 104
101 deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with 105 deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with
102 defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak 106 defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak
103 useEncryption = cfg.readNumEntry( "useEncryption" , 1 ); 107 useEncryption = cfg.readNumEntry( "useEncryption" , 1 );
104 enableAuthentification = cfg.readNumEntry( "enableAuthentification" , 1 ); 108 enableAuthentification = cfg.readNumEntry( "enableAuthentification" , 1 );
105 enablePagescan = cfg.readNumEntry( "enablePagescan" , 1 ); 109 enablePagescan = cfg.readNumEntry( "enablePagescan" , 1 );
106 enableInquiryscan = cfg.readNumEntry( "enableInquiryscan" , 1 ); 110 enableInquiryscan = cfg.readNumEntry( "enableInquiryscan" , 1 );
107 111
108 } 112 }
109 113
110 /** 114 /**
111 * Writes all options to the config file 115 * Writes all options to the config file
112 */ 116 */
113 void BlueBase::writeConfig() { 117 void BlueBase::writeConfig() {
114 118
115 119
116 Config cfg( "bluetoothmanager" ); 120 Config cfg( "bluetoothmanager" );
117 cfg.setGroup( "bluezsettings" ); 121 cfg.setGroup( "bluezsettings" );
118 122
119 cfg.writeEntry( "name" , deviceName ); 123 cfg.writeEntry( "name" , deviceName );
120 cfg.writeEntryCrypt( "passkey" , defaultPasskey ); 124 cfg.writeEntryCrypt( "passkey" , defaultPasskey );
121 cfg.writeEntry( "useEncryption" , useEncryption ); 125 cfg.writeEntry( "useEncryption" , useEncryption );
122 cfg.writeEntry( "enableAuthentification" , enableAuthentification ); 126 cfg.writeEntry( "enableAuthentification" , enableAuthentification );
123 cfg.writeEntry( "enablePagescan" , enablePagescan ); 127 cfg.writeEntry( "enablePagescan" , enablePagescan );
124 cfg.writeEntry( "enableInquiryscan" , enableInquiryscan ); 128 cfg.writeEntry( "enableInquiryscan" , enableInquiryscan );
125} 129}
126 130
127 131
128 /** 132 /**
129 * Read the list of allready known devices 133 * Read the list of allready known devices
130 * 134 *
131 */ 135 */
132 void BlueBase::readSavedDevices() { 136 void BlueBase::readSavedDevices() {
133 137
134 QList<RemoteDevice> *loadedDevices = new QList<RemoteDevice>; 138 QList<RemoteDevice> *loadedDevices = new QList<RemoteDevice>;
@@ -206,163 +210,214 @@ namespace OpieTooth {
206 } 210 }
207 211
208 212
209 /** 213 /**
210 * Read the current values from the gui and invoke writeConfig() 214 * Read the current values from the gui and invoke writeConfig()
211 */ 215 */
212 void BlueBase::applyConfigChanges() { 216 void BlueBase::applyConfigChanges() {
213 217
214 deviceName = deviceNameLine->text(); 218 deviceName = deviceNameLine->text();
215 defaultPasskey = passkeyLine->text(); 219 defaultPasskey = passkeyLine->text();
216 useEncryption = cryptCheckBox->isChecked(); 220 useEncryption = cryptCheckBox->isChecked();
217 enableAuthentification = authCheckBox->isChecked(); 221 enableAuthentification = authCheckBox->isChecked();
218 enablePagescan = pagescanCheckBox->isChecked(); 222 enablePagescan = pagescanCheckBox->isChecked();
219 enableInquiryscan = inquiryscanCheckBox->isChecked(); 223 enableInquiryscan = inquiryscanCheckBox->isChecked();
220 224
221 writeConfig(); 225 writeConfig();
222 226
223 QMessageBox* box = new QMessageBox( this, "Test" ); 227 QMessageBox* box = new QMessageBox( this, "Test" );
224 box->setText( tr( "Changes applied" ) ); 228 box->setText( tr( "Changes applied" ) );
225 box->show(); 229 box->show();
226 // falls nötig hcid killhupen - die funktionalität adden 230 // falls nötig hcid killhupen - die funktionalität adden
227 } 231 }
228 232
229 233
230 /** 234 /**
231 * Add fresh found devices from scan dialog to the listing 235 * Add fresh found devices from scan dialog to the listing
232 * 236 *
233 */ 237 */
234 void BlueBase::addSearchedDevices( QList<RemoteDevice> &newDevices ) { 238 void BlueBase::addSearchedDevices( QList<RemoteDevice> &newDevices ) {
235 239
236 QListViewItem * deviceItem; 240 QListViewItem * deviceItem;
237 241
238 QListIterator<RemoteDevice> it( newDevices ); 242 QListIterator<RemoteDevice> it( newDevices );
239 243
240 for( ; it.current() ; ++it ) { 244 for( ; it.current() ; ++it ) {
241 245
242 246
243 RemoteDevice *dev = it.current(); 247 RemoteDevice *dev = it.current();
244 deviceItem = new QListViewItem( ListView2 , dev->name() ); 248 deviceItem = new QListViewItem( ListView2 , dev->name() );
245 deviceItem->setExpandable ( true ); 249 deviceItem->setExpandable ( true );
246 250
247 if ( deviceActive( dev ) ) { 251 if ( deviceActive( dev ) ) {
248 deviceItem->setPixmap( 1 , onPix ); 252 deviceItem->setPixmap( 1 , onPix );
249 } else { 253 } else {
250 deviceItem->setPixmap( 1, offPix ); 254 deviceItem->setPixmap( 1, offPix );
251 } 255 }
252 256
253 deviceItem->setText( 3, dev->mac() ); 257 deviceItem->setText( 3, dev->mac() );
258 // what kind of entry is it.
259 deviceItem->setText( 4, "device");
254 260
255 // ggf auch hier? 261 // ggf auch hier?
256 addServicesToDevice( deviceItem ); 262 addServicesToDevice( deviceItem );
257 } 263 }
258 } 264 }
259 265
260 266
261 /** 267 /**
262 * Action that is toggled on entrys on click 268 * Action that is toggled on entrys on click
263 */ 269 */
264 void BlueBase::startServiceActionClicked( QListViewItem *item ) { 270 void BlueBase::startServiceActionClicked( QListViewItem *item ) {
265 271
266 272
267 } 273 }
268 274
269 /** 275 /**
270 * Action that are toggled on hold (mostly QPopups i guess) 276 * Action that are toggled on hold (mostly QPopups i guess)
271 */ 277 */
272 void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int column ) { 278 void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int column ) {
273 279
280 QPopupMenu *menu = new QPopupMenu();
281 QPopupMenu *groups = new QPopupMenu();
282 int ret=0;
283
284 //QSize s = menu->sizeHint ( );
285
286 if ( item->text(4) == "device") {
287 menu->insertItem( tr("rescan sevices:"), 0);
288 menu->insertItem( tr("to group"), groups , 1);
289 menu->insertItem( tr("delete"), 2);
290 } else if ( item->text(4) == "service") {
291 menu->insertItem( tr("Test1:"), 0);
292 menu->insertItem( tr("connect"), 1);
293 menu->insertItem( tr("delete"), 2);
294 }
295
296 ret = menu->exec( point , 0);
297
298// noch differenzieren
299 switch(ret) {
300 case 0:
301 break;
302 case 1:
303 break;
304 case 2:
305 // delete childs too
306 delete item;
307 break;
308 }
309
310 delete menu;
311 delete groups;
274 } 312 }
275 313
276 /** 314 /**
277 * Search and display avail. services for a device (on expand from device listing) 315 * Search and display avail. services for a device (on expand from device listing)
278 * 316 *
279 */ 317 */
280 void BlueBase::addServicesToDevice( QListViewItem * item ) { 318 void BlueBase::addServicesToDevice( QListViewItem * item ) {
281 319
282 qDebug("addServicesToDevice"); 320 qDebug("addServicesToDevice");
283 // row of mac adress 321 // row of mac adress text(3)
284 RemoteDevice *device = new RemoteDevice( item->text(3), item->text(0) ); 322 RemoteDevice *device = new RemoteDevice( item->text(3), item->text(0) );
285 323
286 deviceList.insert( item->text(3) , item ); 324 deviceList.insert( item->text(3) , item );
287 325
288 // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back 326 // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back
289 localDevice->searchServices( *device ); 327 localDevice->searchServices( *device );
290 328
291 // delete 329 // delete
292 } 330 }
293 331
294 332
295 /** 333 /**
296 * Overloaded. This one it the one that is connected to the foundServices signal 334 * Overloaded. This one it the one that is connected to the foundServices signal
297 * @param device the mac address of the remote device 335 * @param device the mac address of the remote device
298 * @param servicesList the list with the service the device has. 336 * @param servicesList the list with the service the device has.
299 */ 337 */
300 void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) { 338 void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) {
301 339
302 qDebug("fill services list"); 340 qDebug("fill services list");
303 341
304
305 QMap<QString,QListViewItem*>::Iterator it; 342 QMap<QString,QListViewItem*>::Iterator it;
306 343
307 QListViewItem* deviceItem; 344 QListViewItem* deviceItem;
308 345
346 // get the right devices which requested the search
309 for( it = deviceList.begin(); it != deviceList.end(); ++it ) { 347 for( it = deviceList.begin(); it != deviceList.end(); ++it ) {
310 if ( it.key() == device ) { 348 if ( it.key() == device ) {
311 deviceItem = it.data(); 349 deviceItem = it.data();
312 } 350 }
313 } 351 }
314 352
353
354 // empty entries
355 // QListViewItem * myChild = deviceItem->firstChild();
356 //QList<QListViewItem*> tmpList;
357 //while( myChild ) {
358 // tmpList.append(myChild);
359 // myChild = myChild->nextSibling();
360 // }
361
362
315 QValueList<OpieTooth::Services>::Iterator it2; 363 QValueList<OpieTooth::Services>::Iterator it2;
316 364
317 QListViewItem * serviceItem; 365 QListViewItem * serviceItem;
318 366
319 for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) { 367 if (!servicesList.isEmpty() ) {
320 serviceItem = new QListViewItem( deviceItem , (*it2).serviceName() ); 368 // add services
369 for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) {
370 serviceItem = new QListViewItem( deviceItem , (*it2).serviceName() );
371 serviceItem->setText(4, "service");
372 }
373 } else {
374 serviceItem = new QListViewItem( deviceItem , tr("no services found") );
375 serviceItem->setText(4, "service");
321 } 376 }
322 } 377 }
323 378
324 379
325 /** 380 /**
326 * Add the existing connections (pairs) to the connections tab. 381 * Add the existing connections (pairs) to the connections tab.
327 * 382 *
328 */ 383 */
329 void BlueBase::addConnectedDevices() { 384 void BlueBase::addConnectedDevices() {
330 385
331 386
332 //mac address 387 //mac address
333 388
334 } 389 }
335 390
336 /** 391 /**
337 * Find out if a device can currently be reached 392 * Find out if a device can currently be reached
338 */ 393 */
339 bool BlueBase::deviceActive( RemoteDevice *device ) { 394 bool BlueBase::deviceActive( RemoteDevice *device ) {
340 395
341 // search by mac 396 // search by mac
342 localDevice->isAvailable( device->mac() ); 397 localDevice->isAvailable( device->mac() );
343 398
344 return true; 399 return true;
345 } 400 }
346 401
347 402
348 /** 403 /**
349 * Open the "scan for devices" dialog 404 * Open the "scan for devices" dialog
350 */ 405 */
351 void BlueBase::startScan() { 406 void BlueBase::startScan() {
352 407
353 ScanDialog *scan = new ScanDialog( this, "", true); 408 ScanDialog *scan = new ScanDialog( this, "", true);
354 QObject::connect( scan, SIGNAL( selectedDevices( QList<RemoteDevice>& ) ), 409 QObject::connect( scan, SIGNAL( selectedDevices( QList<RemoteDevice>& ) ),
355 this, SLOT( addSearchedDevices( QList<RemoteDevice>& ) ) ); 410 this, SLOT( addSearchedDevices( QList<RemoteDevice>& ) ) );
356 411
357 scan->showMaximized(); 412 scan->showMaximized();
358 } 413 }
359 414
360 415
361 /** 416 /**
362 * Set the informations about the local device in information Tab 417 * Set the informations about the local device in information Tab
363 */ 418 */
364 void BlueBase::setInfo() { 419 void BlueBase::setInfo() {
365 StatusLabel->setText( getStatus() ); 420 StatusLabel->setText( getStatus() );
366 } 421 }
367 422
368 /** 423 /**
diff --git a/noncore/net/opietooth/manager/bluebase.h b/noncore/net/opietooth/manager/bluebase.h
index 99d2fa6..bc48bb3 100644
--- a/noncore/net/opietooth/manager/bluebase.h
+++ b/noncore/net/opietooth/manager/bluebase.h
@@ -26,56 +26,56 @@ class QCheckBox;
26 26
27 27
28namespace OpieTooth { 28namespace OpieTooth {
29 29
30 30
31 31
32 class BlueBase : public BluetoothBase { 32 class BlueBase : public BluetoothBase {
33 Q_OBJECT 33 Q_OBJECT
34 34
35 public: 35 public:
36 BlueBase( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 36 BlueBase( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
37 ~BlueBase(); 37 ~BlueBase();
38 38
39 protected: 39 protected:
40 40
41 41
42 private slots: 42 private slots:
43 void startScan(); 43 void startScan();
44 44
45 private: 45 private:
46 void readConfig(); 46 void readConfig();
47 void writeConfig(); 47 void writeConfig();
48 void readSavedDevices(); 48 void readSavedDevices();
49 void writeSavedDevices(); 49 void writeSavedDevices();
50 QString getStatus(); 50 QString getStatus();
51 void initGui(); 51 void initGui();
52 void setInfo(); 52 void setInfo();
53 Manager *localDevice; 53 Manager *localDevice;
54 QMap<QString,QListViewItem*> deviceList; 54 QMap<QString,QListViewItem*> deviceList;
55 55
56 bool deviceActive( RemoteDevice *device ); 56 bool deviceActive( RemoteDevice *device );
57 57
58 QString deviceName; 58 QString deviceName;
59 QString defaultPasskey; 59 QString defaultPasskey;
60 int useEncryption; 60 int useEncryption;
61 int enableAuthentification; 61 int enableAuthentification;
62 int enablePagescan; 62 int enablePagescan;
63 int enableInquiryscan; 63 int enableInquiryscan;
64 64
65 QPixmap offPix; 65 QPixmap offPix;
66 QPixmap onPix; 66 QPixmap onPix;
67 67
68 private slots: 68 private slots:
69 void addSearchedDevices( QList<RemoteDevice> &newDevices ); 69 void addSearchedDevices( QList<RemoteDevice> &newDevices );
70 void addServicesToDevice( QListViewItem *item ); 70 void addServicesToDevice( QListViewItem *item );
71 void addServicesToDevice( const QString& device, Services::ValueList ); 71 void addServicesToDevice( const QString& device, Services::ValueList );
72 void addConnectedDevices(); 72 void addConnectedDevices();
73 void startServiceActionClicked( QListViewItem *item ); 73 void startServiceActionClicked( QListViewItem *item );
74 void startServiceActionHold( QListViewItem *item, const QPoint &point, int column); 74 void startServiceActionHold( QListViewItem *, const QPoint &, int );
75 void applyConfigChanges(); 75 void applyConfigChanges();
76 76
77 }; 77 };
78 78
79} 79}
80 80
81#endif 81#endif
diff --git a/noncore/net/opietooth/manager/scandialog.cpp b/noncore/net/opietooth/manager/scandialog.cpp
index 9520e73..0e6e93b 100644
--- a/noncore/net/opietooth/manager/scandialog.cpp
+++ b/noncore/net/opietooth/manager/scandialog.cpp
@@ -72,96 +72,99 @@ namespace OpieTooth {
72 StopButton->setText( tr( "Cancel scan" ) ); 72 StopButton->setText( tr( "Cancel scan" ) );
73 73
74 QHBoxLayout *buttonLayout = new QHBoxLayout(buttonFrame); 74 QHBoxLayout *buttonLayout = new QHBoxLayout(buttonFrame);
75 75
76 buttonLayout->addWidget(StartButton); 76 buttonLayout->addWidget(StartButton);
77 buttonLayout->addWidget(StopButton); 77 buttonLayout->addWidget(StopButton);
78 78
79 ListView1 = new QListView( privateLayoutWidget, "ListView1" ); 79 ListView1 = new QListView( privateLayoutWidget, "ListView1" );
80 80
81 //ListView1->addColumn( tr( "Add" ) ); 81 //ListView1->addColumn( tr( "Add" ) );
82 ListView1->addColumn( tr( "Add Device" ) ); 82 ListView1->addColumn( tr( "Add Device" ) );
83 //ListView1->addColumn( tr( "Type" ) ); 83 //ListView1->addColumn( tr( "Type" ) );
84 84
85 Layout11->addWidget( ListView1); 85 Layout11->addWidget( ListView1);
86 Layout11->addWidget(progress); 86 Layout11->addWidget(progress);
87 Layout11->addWidget( buttonFrame); 87 Layout11->addWidget( buttonFrame);
88 88
89 localDevice = new Manager( "hci0" ); 89 localDevice = new Manager( "hci0" );
90 90
91 connect( StartButton, SIGNAL( clicked() ), this, SLOT( startSearch() ) ); 91 connect( StartButton, SIGNAL( clicked() ), this, SLOT( startSearch() ) );
92 connect( StopButton, SIGNAL( clicked() ), this, SLOT( stopSearch() ) ); 92 connect( StopButton, SIGNAL( clicked() ), this, SLOT( stopSearch() ) );
93 connect( localDevice, SIGNAL( foundDevices( const QString& , RemoteDevice::ValueList ) ), 93 connect( localDevice, SIGNAL( foundDevices( const QString& , RemoteDevice::ValueList ) ),
94 this, SLOT(fillList(const QString& , RemoteDevice::ValueList ) ) ) ; 94 this, SLOT(fillList(const QString& , RemoteDevice::ValueList ) ) ) ;
95 // connect( this, SIGNAL( accept() ), this, SLOT( emitToManager() )); 95 // connect( this, SIGNAL( accept() ), this, SLOT( emitToManager() ));
96 progressStat = 0; 96 progressStat = 0;
97 } 97 }
98 98
99// hack, make cleaner later 99// hack, make cleaner later
100 void ScanDialog::progressTimer() { 100 void ScanDialog::progressTimer() {
101 101
102 progressStat++; 102 progressStat++;
103 if (progressStat++ < 20) { 103 if (progressStat++ < 20) {
104 QTimer::singleShot( 2000, this, SLOT(progressTimer() ) ); 104 QTimer::singleShot( 2000, this, SLOT(progressTimer() ) );
105 } 105 }
106 progress->setProgress(progressStat++); 106 progress->setProgress(progressStat++);
107 107
108 } 108 }
109 109
110 void ScanDialog::accept() { 110 void ScanDialog::accept() {
111 emitToManager(); 111 emitToManager();
112 QDialog::accept(); 112 QDialog::accept();
113 } 113 }
114 114
115 115
116 void ScanDialog::startSearch() { 116 void ScanDialog::startSearch() {
117 progress->setProgress(0); 117 progress->setProgress(0);
118 progressStat = 0; 118 progressStat = 0;
119 119
120 // empty list before a new scan
121 ListView1->clear();
122
120 QCheckListItem *deviceItem2 = new QCheckListItem( ListView1, "Test1", QCheckListItem::CheckBox ); 123 QCheckListItem *deviceItem2 = new QCheckListItem( ListView1, "Test1", QCheckListItem::CheckBox );
121 deviceItem2->setText(1, "BLAH" ); 124 deviceItem2->setText(1, "BLAH" );
122 125
123 progressTimer(); 126 progressTimer();
124 // when finished, it emmite foundDevices() 127 // when finished, it emmite foundDevices()
125 // checken ob initialisiert , qcop ans applet. 128 // checken ob initialisiert , qcop ans applet.
126 localDevice->searchDevices(); 129 localDevice->searchDevices();
127 130
128 } 131 }
129 132
130 void ScanDialog::stopSearch() { 133 void ScanDialog::stopSearch() {
131 134
132 } 135 }
133 136
134 void ScanDialog::fillList(const QString& device, RemoteDevice::ValueList deviceList) { 137 void ScanDialog::fillList(const QString& device, RemoteDevice::ValueList deviceList) {
135 138
136 qDebug("fill List"); 139 qDebug("fill List");
137 QCheckListItem * deviceItem; 140 QCheckListItem * deviceItem;
138 141
139 RemoteDevice::ValueList::Iterator it; 142 RemoteDevice::ValueList::Iterator it;
140 for( it = deviceList.begin(); it != deviceList.end(); ++it ) { 143 for( it = deviceList.begin(); it != deviceList.end(); ++it ) {
141 144
142 deviceItem = new QCheckListItem( ListView1, (*it).name(), QCheckListItem::CheckBox ); 145 deviceItem = new QCheckListItem( ListView1, (*it).name(), QCheckListItem::CheckBox );
143 deviceItem->setText(1, (*it).mac() ); 146 deviceItem->setText(1, (*it).mac() );
144 } 147 }
145 } 148 }
146 149
147/* 150/*
148 * Iterates trough the items, and collects the checked items. 151 * Iterates trough the items, and collects the checked items.
149 * Then it emits it, so the manager can connect to the signal to fill the listing. 152 * Then it emits it, so the manager can connect to the signal to fill the listing.
150 */ 153 */
151 void ScanDialog::emitToManager() { 154 void ScanDialog::emitToManager() {
152 qDebug("vor liste durchsuchen"); 155 qDebug("vor liste durchsuchen");
153 156
154 if (!ListView1) { 157 if (!ListView1) {
155 return; 158 return;
156 } 159 }
157 160
158 QList<RemoteDevice> *deviceList = new QList<RemoteDevice>; 161 QList<RemoteDevice> *deviceList = new QList<RemoteDevice>;
159 deviceList->setAutoDelete(true); 162 deviceList->setAutoDelete(true);
160 163
161 QListViewItemIterator it( ListView1 ); 164 QListViewItemIterator it( ListView1 );
162 for ( ; it.current(); ++it ) { 165 for ( ; it.current(); ++it ) {
163 if ( ((QCheckListItem*)it.current())->isOn() ) { 166 if ( ((QCheckListItem*)it.current())->isOn() ) {
164 RemoteDevice * device = new RemoteDevice( it.current()->text(1), it.current()->text(0)); 167 RemoteDevice * device = new RemoteDevice( it.current()->text(1), it.current()->text(0));
165 deviceList->append( device ); 168 deviceList->append( device );
166 } 169 }
167 } 170 }