author | harlekin <harlekin> | 2003-03-07 23:58:45 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2003-03-07 23:58:45 (UTC) |
commit | 3e92beca986b9fecd8193f55513ea1ecd2cd0866 (patch) (unidiff) | |
tree | 651a9a6fe0f35c18baea5d793425e03d12e70104 | |
parent | e2f480bc22863bf803259e98b1c62933af20b48f (diff) | |
download | opie-3e92beca986b9fecd8193f55513ea1ecd2cd0866.zip opie-3e92beca986b9fecd8193f55513ea1ecd2cd0866.tar.gz opie-3e92beca986b9fecd8193f55513ea1ecd2cd0866.tar.bz2 |
nicer refresh handling for connections
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.cpp | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp index 9663b52..b5a09e5 100644 --- a/noncore/net/opietooth/manager/bluebase.cpp +++ b/noncore/net/opietooth/manager/bluebase.cpp | |||
@@ -214,371 +214,397 @@ void BlueBase::initGui() { | |||
214 | setInfo(); | 214 | setInfo(); |
215 | } | 215 | } |
216 | 216 | ||
217 | 217 | ||
218 | /** | 218 | /** |
219 | * Get the status informations and returns it | 219 | * Get the status informations and returns it |
220 | * @return QString the status informations gathered | 220 | * @return QString the status informations gathered |
221 | */ | 221 | */ |
222 | QString BlueBase::status()const{ | 222 | QString BlueBase::status()const{ |
223 | QString infoString = tr( "<b>Device name : </b> Ipaq" ); | 223 | QString infoString = tr( "<b>Device name : </b> Ipaq" ); |
224 | infoString += QString( "<br><b>" + tr( "MAC adress: " ) +"</b> No idea" ); | 224 | infoString += QString( "<br><b>" + tr( "MAC adress: " ) +"</b> No idea" ); |
225 | infoString += QString( "<br><b>" + tr( "Class" ) + "</b> PDA" ); | 225 | infoString += QString( "<br><b>" + tr( "Class" ) + "</b> PDA" ); |
226 | 226 | ||
227 | return (infoString); | 227 | return (infoString); |
228 | } | 228 | } |
229 | 229 | ||
230 | 230 | ||
231 | /** | 231 | /** |
232 | * Read the current values from the gui and invoke writeConfig() | 232 | * Read the current values from the gui and invoke writeConfig() |
233 | */ | 233 | */ |
234 | void BlueBase::applyConfigChanges() { | 234 | void BlueBase::applyConfigChanges() { |
235 | m_deviceName = deviceNameLine->text(); | 235 | m_deviceName = deviceNameLine->text(); |
236 | m_defaultPasskey = passkeyLine->text(); | 236 | m_defaultPasskey = passkeyLine->text(); |
237 | m_useEncryption = cryptCheckBox->isChecked(); | 237 | m_useEncryption = cryptCheckBox->isChecked(); |
238 | m_enableAuthentification = authCheckBox->isChecked(); | 238 | m_enableAuthentification = authCheckBox->isChecked(); |
239 | m_enablePagescan = pagescanCheckBox->isChecked(); | 239 | m_enablePagescan = pagescanCheckBox->isChecked(); |
240 | m_enableInquiryscan = inquiryscanCheckBox->isChecked(); | 240 | m_enableInquiryscan = inquiryscanCheckBox->isChecked(); |
241 | 241 | ||
242 | writeConfig(); | 242 | writeConfig(); |
243 | 243 | ||
244 | QMessageBox::information( this, tr("Test") , tr("Changes were applied.") ); | 244 | QMessageBox::information( this, tr("Test") , tr("Changes were applied.") ); |
245 | } | 245 | } |
246 | 246 | ||
247 | /** | 247 | /** |
248 | * Add fresh found devices from scan dialog to the listing | 248 | * Add fresh found devices from scan dialog to the listing |
249 | * | 249 | * |
250 | */ | 250 | */ |
251 | void BlueBase::addSearchedDevices( const QValueList<RemoteDevice> &newDevices ) { | 251 | void BlueBase::addSearchedDevices( const QValueList<RemoteDevice> &newDevices ) { |
252 | BTDeviceItem * deviceItem; | 252 | BTDeviceItem * deviceItem; |
253 | QValueList<RemoteDevice>::ConstIterator it; | 253 | QValueList<RemoteDevice>::ConstIterator it; |
254 | 254 | ||
255 | for( it = newDevices.begin(); it != newDevices.end() ; ++it ) { | 255 | for( it = newDevices.begin(); it != newDevices.end() ; ++it ) { |
256 | 256 | ||
257 | if (find( (*it) )) // is already inserted | 257 | if (find( (*it) )) // is already inserted |
258 | continue; | 258 | continue; |
259 | 259 | ||
260 | deviceItem = new BTDeviceItem( ListView2 , (*it) ); | 260 | deviceItem = new BTDeviceItem( ListView2 , (*it) ); |
261 | deviceItem->setPixmap( 1, m_findPix ); | 261 | deviceItem->setPixmap( 1, m_findPix ); |
262 | deviceItem->setExpandable ( true ); | 262 | deviceItem->setExpandable ( true ); |
263 | 263 | ||
264 | // look if device is avail. atm, async | 264 | // look if device is avail. atm, async |
265 | deviceActive( (*it) ); | 265 | deviceActive( (*it) ); |
266 | 266 | ||
267 | // ggf auch hier? | 267 | // ggf auch hier? |
268 | addServicesToDevice( deviceItem ); | 268 | addServicesToDevice( deviceItem ); |
269 | } | 269 | } |
270 | } | 270 | } |
271 | 271 | ||
272 | 272 | ||
273 | /** | 273 | /** |
274 | * Action that is toggled on entrys on click | 274 | * Action that is toggled on entrys on click |
275 | */ | 275 | */ |
276 | void BlueBase::startServiceActionClicked( QListViewItem */*item*/ ) { | 276 | void BlueBase::startServiceActionClicked( QListViewItem */*item*/ ) { |
277 | } | 277 | } |
278 | 278 | ||
279 | 279 | ||
280 | /** | 280 | /** |
281 | * Action that are toggled on hold (mostly QPopups i guess) | 281 | * Action that are toggled on hold (mostly QPopups i guess) |
282 | */ | 282 | */ |
283 | void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int /*column*/ ) { | 283 | void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int /*column*/ ) { |
284 | if (!item ) | 284 | if (!item ) |
285 | return; | 285 | return; |
286 | 286 | ||
287 | QPopupMenu *menu = new QPopupMenu(); | 287 | QPopupMenu *menu = new QPopupMenu(); |
288 | int ret=0; | 288 | int ret=0; |
289 | 289 | ||
290 | if ( ((BTListItem*)item)->type() == "device") { | 290 | if ( ((BTListItem*)item)->type() == "device") { |
291 | 291 | ||
292 | QPopupMenu *groups = new QPopupMenu(); | 292 | QPopupMenu *groups = new QPopupMenu(); |
293 | 293 | ||
294 | menu->insertItem( ((BTDeviceItem*)item)->name(),0 ); | 294 | menu->insertItem( ((BTDeviceItem*)item)->name(),0 ); |
295 | menu->insertSeparator(1); | 295 | menu->insertSeparator(1); |
296 | menu->insertItem( tr("rescan sevices"), 2); | 296 | menu->insertItem( tr("rescan sevices"), 2); |
297 | menu->insertItem( tr("to group"), groups , 3); | 297 | menu->insertItem( tr("to group"), groups , 3); |
298 | menu->insertItem( tr("delete"), 4); | 298 | menu->insertItem( tr("delete"), 4); |
299 | 299 | ||
300 | ret = menu->exec( point , 0); | 300 | ret = menu->exec( point , 0); |
301 | 301 | ||
302 | switch(ret) { | 302 | switch(ret) { |
303 | case -1: | 303 | case -1: |
304 | break; | 304 | break; |
305 | case 2: | 305 | case 2: |
306 | addServicesToDevice( (BTDeviceItem*)item ); | 306 | addServicesToDevice( (BTDeviceItem*)item ); |
307 | break; | 307 | break; |
308 | 308 | ||
309 | case 4: | 309 | case 4: |
310 | // deletes childs too | 310 | // deletes childs too |
311 | delete item; | 311 | delete item; |
312 | break; | 312 | break; |
313 | } | 313 | } |
314 | delete groups; | 314 | delete groups; |
315 | 315 | ||
316 | } | 316 | } |
317 | 317 | ||
318 | /* | 318 | /* |
319 | * We got service sensitive PopupMenus in our factory | 319 | * We got service sensitive PopupMenus in our factory |
320 | * We will create one through the factory and will insert | 320 | * We will create one through the factory and will insert |
321 | * our Separator + ShowInfo into the menu or create a new | 321 | * our Separator + ShowInfo into the menu or create a new |
322 | * one if the factory returns 0 | 322 | * one if the factory returns 0 |
323 | * PopupMenu deletion is kind of weird. | 323 | * PopupMenu deletion is kind of weird. |
324 | * If escaped( -1 ) or any of our items were chosen we'll | 324 | * If escaped( -1 ) or any of our items were chosen we'll |
325 | * delete the PopupMenu otherwise it's the responsibility of | 325 | * delete the PopupMenu otherwise it's the responsibility of |
326 | * the PopupMenu to delete itself | 326 | * the PopupMenu to delete itself |
327 | * | 327 | * |
328 | */ | 328 | */ |
329 | else if ( ((BTListItem*)item)->type() == "service") { | 329 | else if ( ((BTListItem*)item)->type() == "service") { |
330 | BTServiceItem* service = (BTServiceItem*)item; | 330 | BTServiceItem* service = (BTServiceItem*)item; |
331 | QMap<int, QString> list = service->services().classIdList(); | 331 | QMap<int, QString> list = service->services().classIdList(); |
332 | QMap<int, QString>::Iterator it = list.begin(); | 332 | QMap<int, QString>::Iterator it = list.begin(); |
333 | QPopupMenu *popup =0l; | 333 | QPopupMenu *popup =0l; |
334 | if ( it != list.end() ) { | 334 | if ( it != list.end() ) { |
335 | qWarning("Searching id %d %s", it.key(), it.data().latin1() ); | 335 | qWarning("Searching id %d %s", it.key(), it.data().latin1() ); |
336 | popup = m_popHelper.find( it.key() /*1*/, | 336 | popup = m_popHelper.find( it.key() /*1*/, |
337 | service->services(), | 337 | service->services(), |
338 | (BTDeviceItem*)service->parent() ); | 338 | (BTDeviceItem*)service->parent() ); |
339 | }else { | 339 | }else { |
340 | qWarning("Empty"); | 340 | qWarning("Empty"); |
341 | } | 341 | } |
342 | 342 | ||
343 | if ( popup == 0l ) { | 343 | if ( popup == 0l ) { |
344 | qWarning("factory returned 0l"); | 344 | qWarning("factory returned 0l"); |
345 | popup = new QPopupMenu(); | 345 | popup = new QPopupMenu(); |
346 | } | 346 | } |
347 | int test1 = popup->insertItem( tr("Test1:"), 2); | 347 | int test1 = popup->insertItem( tr("Test1:"), 2); |
348 | 348 | ||
349 | ret = popup->exec( point ); | 349 | ret = popup->exec( point ); |
350 | qWarning("returned from exec() "); | 350 | qWarning("returned from exec() "); |
351 | if ( ret == -1 ) { | 351 | if ( ret == -1 ) { |
352 | ; | 352 | ; |
353 | } else if ( ret == test1 ) { | 353 | } else if ( ret == test1 ) { |
354 | ; | 354 | ; |
355 | } | 355 | } |
356 | delete popup; | 356 | delete popup; |
357 | } | 357 | } |
358 | delete menu; | 358 | delete menu; |
359 | } | 359 | } |
360 | 360 | ||
361 | 361 | ||
362 | /** | 362 | /** |
363 | * Search and display avail. services for a device (on expand from device listing) | 363 | * Search and display avail. services for a device (on expand from device listing) |
364 | * @param item the service item returned | 364 | * @param item the service item returned |
365 | */ | 365 | */ |
366 | void BlueBase::addServicesToDevice( BTDeviceItem * item ) { | 366 | void BlueBase::addServicesToDevice( BTDeviceItem * item ) { |
367 | qDebug("addServicesToDevice"); | 367 | qDebug("addServicesToDevice"); |
368 | // row of mac adress text(3) | 368 | // row of mac adress text(3) |
369 | RemoteDevice device = item->remoteDevice(); | 369 | RemoteDevice device = item->remoteDevice(); |
370 | m_deviceList.insert( item->mac() , item ); | 370 | m_deviceList.insert( item->mac() , item ); |
371 | // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back | 371 | // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back |
372 | m_localDevice->searchServices( device ); | 372 | m_localDevice->searchServices( device ); |
373 | } | 373 | } |
374 | 374 | ||
375 | 375 | ||
376 | /** | 376 | /** |
377 | * Overloaded. This one it the one that is | 377 | * Overloaded. This one it the one that is |
378 | ted to the foundServices signal | 378 | ted to the foundServices signal |
379 | * @param device the mac address of the remote device | 379 | * @param device the mac address of the remote device |
380 | * @param servicesList the list with the service the device has. | 380 | * @param servicesList the list with the service the device has. |
381 | */ | 381 | */ |
382 | void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) { | 382 | void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) { |
383 | qDebug("fill services list"); | 383 | qDebug("fill services list"); |
384 | 384 | ||
385 | QMap<QString,BTDeviceItem*>::Iterator it; | 385 | QMap<QString,BTDeviceItem*>::Iterator it; |
386 | BTDeviceItem* deviceItem = 0; | 386 | BTDeviceItem* deviceItem = 0; |
387 | 387 | ||
388 | // get the right devices which requested the search | 388 | // get the right devices which requested the search |
389 | it = m_deviceList.find( device ); | 389 | it = m_deviceList.find( device ); |
390 | if( it == m_deviceList.end() ) | 390 | if( it == m_deviceList.end() ) |
391 | return; | 391 | return; |
392 | deviceItem = it.data(); | 392 | deviceItem = it.data(); |
393 | 393 | ||
394 | // remove previous entries | 394 | // remove previous entries |
395 | QList<QListViewItem> tempList; | 395 | QList<QListViewItem> tempList; |
396 | tempList.setAutoDelete( true ); | 396 | tempList.setAutoDelete( true ); |
397 | QListViewItem * child = deviceItem->firstChild(); | 397 | QListViewItem * child = deviceItem->firstChild(); |
398 | while( child ) { | 398 | while( child ) { |
399 | tempList.append( child ); | 399 | tempList.append( child ); |
400 | child = child->nextSibling(); | 400 | child = child->nextSibling(); |
401 | } | 401 | } |
402 | tempList.clear(); | 402 | tempList.clear(); |
403 | 403 | ||
404 | QValueList<OpieTooth::Services>::Iterator it2; | 404 | QValueList<OpieTooth::Services>::Iterator it2; |
405 | BTServiceItem* serviceItem; | 405 | BTServiceItem* serviceItem; |
406 | 406 | ||
407 | 407 | ||
408 | if (!servicesList.isEmpty() ) { | 408 | if (!servicesList.isEmpty() ) { |
409 | // add services | 409 | // add services |
410 | QMap<int, QString> list; | 410 | QMap<int, QString> list; |
411 | QMap<int, QString>::Iterator classIt; | 411 | QMap<int, QString>::Iterator classIt; |
412 | for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) { | 412 | for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) { |
413 | serviceItem = new BTServiceItem( deviceItem, (*it2) ); | 413 | serviceItem = new BTServiceItem( deviceItem, (*it2) ); |
414 | list = (*it2).classIdList(); | 414 | list = (*it2).classIdList(); |
415 | classIt = list.begin(); | 415 | classIt = list.begin(); |
416 | int classId=0; | 416 | int classId=0; |
417 | if ( classIt != list.end() ) { | 417 | if ( classIt != list.end() ) { |
418 | classId = classIt.key(); | 418 | classId = classIt.key(); |
419 | } | 419 | } |
420 | 420 | ||
421 | serviceItem->setPixmap( 0, m_iconLoader->serviceIcon( classId ) ); | 421 | serviceItem->setPixmap( 0, m_iconLoader->serviceIcon( classId ) ); |
422 | } | 422 | } |
423 | } else { | 423 | } else { |
424 | Services s1; | 424 | Services s1; |
425 | s1.setServiceName( tr("no services found") ); | 425 | s1.setServiceName( tr("no services found") ); |
426 | serviceItem = new BTServiceItem( deviceItem, s1 ); | 426 | serviceItem = new BTServiceItem( deviceItem, s1 ); |
427 | } | 427 | } |
428 | // now remove them from the list | 428 | // now remove them from the list |
429 | m_deviceList.remove( it ); | 429 | m_deviceList.remove( it ); |
430 | } | 430 | } |
431 | 431 | ||
432 | 432 | ||
433 | 433 | ||
434 | 434 | ||
435 | 435 | ||
436 | void BlueBase::addSignalStrength() { | 436 | void BlueBase::addSignalStrength() { |
437 | 437 | ||
438 | QListViewItemIterator it( ListView4 ); | 438 | QListViewItemIterator it( ListView4 ); |
439 | for ( ; it.current(); ++it ) { | 439 | for ( ; it.current(); ++it ) { |
440 | m_localDevice->signalStrength( ((BTConnectionItem*)it.current() )->connection().mac() ); | 440 | m_localDevice->signalStrength( ((BTConnectionItem*)it.current() )->connection().mac() ); |
441 | } | 441 | } |
442 | 442 | ||
443 | QTimer::singleShot( 5000, this, SLOT( addSignalStrength() ) ); | 443 | QTimer::singleShot( 5000, this, SLOT( addSignalStrength() ) ); |
444 | } | 444 | } |
445 | 445 | ||
446 | void BlueBase::addSignalStrength( const QString& mac, const QString& strength ) { | 446 | void BlueBase::addSignalStrength( const QString& mac, const QString& strength ) { |
447 | 447 | ||
448 | QListViewItemIterator it( ListView4 ); | 448 | QListViewItemIterator it( ListView4 ); |
449 | for ( ; it.current(); ++it ) { | 449 | for ( ; it.current(); ++it ) { |
450 | if( ((BTConnectionItem*)it.current())->connection().mac() == mac ) { | 450 | if( ((BTConnectionItem*)it.current())->connection().mac() == mac ) { |
451 | ((BTConnectionItem*)it.current() )->setSignalStrength( strength ); | 451 | ((BTConnectionItem*)it.current() )->setSignalStrength( strength ); |
452 | } | 452 | } |
453 | } | 453 | } |
454 | } | 454 | } |
455 | 455 | ||
456 | /** | 456 | /** |
457 | * Add the existing connections (pairs) to the connections tab. | 457 | * Add the existing connections (pairs) to the connections tab. |
458 | * This one triggers the search | 458 | * This one triggers the search |
459 | */ | 459 | */ |
460 | void BlueBase::addConnectedDevices() { | 460 | void BlueBase::addConnectedDevices() { |
461 | m_localDevice->searchConnections(); | 461 | m_localDevice->searchConnections(); |
462 | } | 462 | } |
463 | 463 | ||
464 | /** | 464 | /** |
465 | * This adds the found connections to the connection tab. | 465 | * This adds the found connections to the connection tab. |
466 | * @param connectionList the ValueList with all current connections | 466 | * @param connectionList the ValueList with all current connections |
467 | */ | 467 | */ |
468 | void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList ) { | 468 | void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList ) { |
469 | 469 | ||
470 | // clear the ListView first | ||
471 | ListView4->clear(); | ||
472 | |||
473 | QValueList<OpieTooth::ConnectionState>::Iterator it; | 470 | QValueList<OpieTooth::ConnectionState>::Iterator it; |
474 | BTConnectionItem * connectionItem; | 471 | BTConnectionItem * connectionItem; |
475 | 472 | ||
476 | if ( !connectionList.isEmpty() ) { | 473 | if ( !connectionList.isEmpty() ) { |
477 | 474 | ||
478 | for (it = connectionList.begin(); it != connectionList.end(); ++it) { | 475 | for (it = connectionList.begin(); it != connectionList.end(); ++it) { |
479 | connectionItem = new BTConnectionItem( ListView4, (*it) ); | ||
480 | 476 | ||
481 | if( m_deviceList.find((*it).mac()).data() ) { | 477 | QListViewItemIterator it2( ListView4 ); |
478 | bool found = false; | ||
479 | for ( ; it2.current(); ++it2 ) { | ||
480 | if( ( (BTConnectionItem*)it2.current())->connection().mac() == (*it).mac() ) { | ||
481 | found = true; | ||
482 | } | ||
483 | } | ||
484 | |||
485 | if ( found == false ) { | ||
486 | connectionItem = new BTConnectionItem( ListView4, (*it) ); | ||
487 | |||
488 | if( m_deviceList.find((*it).mac()).data() ) { | ||
489 | connectionItem->setName( m_deviceList.find( (*it).mac()).data()->name() ); | ||
490 | } | ||
491 | } | ||
482 | 492 | ||
483 | connectionItem->setName( m_deviceList.find( (*it).mac()).data()->name() ); | ||
484 | } | ||
485 | } | 493 | } |
494 | |||
495 | QListViewItemIterator it2( ListView4 ); | ||
496 | for ( ; it2.current(); ++it2 ) { | ||
497 | bool found = false; | ||
498 | for (it = connectionList.begin(); it != connectionList.end(); ++it) { | ||
499 | if( ( ((BTConnectionItem*)it2.current())->connection().mac() ) == (*it).mac() ) { | ||
500 | found = true; | ||
501 | } | ||
502 | } | ||
503 | |||
504 | if ( !found ) { | ||
505 | delete it2.current(); | ||
506 | } | ||
507 | |||
508 | } | ||
509 | |||
510 | |||
486 | } else { | 511 | } else { |
512 | ListView4->clear(); | ||
487 | ConnectionState con; | 513 | ConnectionState con; |
488 | con.setMac( tr("No connections found") ); | 514 | con.setMac( tr("No connections found") ); |
489 | connectionItem = new BTConnectionItem( ListView4 , con ); | 515 | connectionItem = new BTConnectionItem( ListView4 , con ); |
490 | } | 516 | } |
491 | 517 | ||
492 | // recall connection search after some time | 518 | // recall connection search after some time |
493 | QTimer::singleShot( 15000, this, SLOT( addConnectedDevices() ) ); | 519 | QTimer::singleShot( 15000, this, SLOT( addConnectedDevices() ) ); |
494 | } | 520 | } |
495 | 521 | ||
496 | 522 | ||
497 | /** | 523 | /** |
498 | * Find out if a device can currently be reached | 524 | * Find out if a device can currently be reached |
499 | * @param device | 525 | * @param device |
500 | */ | 526 | */ |
501 | void BlueBase::deviceActive( const RemoteDevice &device ) { | 527 | void BlueBase::deviceActive( const RemoteDevice &device ) { |
502 | // search by mac, async, gets a signal back | 528 | // search by mac, async, gets a signal back |
503 | // We should have a BTDeviceItem there or where does it get added to the map -zecke | 529 | // We should have a BTDeviceItem there or where does it get added to the map -zecke |
504 | m_localDevice->isAvailable( device.mac() ); | 530 | m_localDevice->isAvailable( device.mac() ); |
505 | } | 531 | } |
506 | 532 | ||
507 | 533 | ||
508 | /** | 534 | /** |
509 | * The signal catcher. Set the avail. status on device. | 535 | * The signal catcher. Set the avail. status on device. |
510 | * @param device - the mac address | 536 | * @param device - the mac address |
511 | * @param connected - if it is avail. or not | 537 | * @param connected - if it is avail. or not |
512 | */ | 538 | */ |
513 | void BlueBase::deviceActive( const QString& device, bool connected ) { | 539 | void BlueBase::deviceActive( const QString& device, bool connected ) { |
514 | qDebug("deviceActive slot"); | 540 | qDebug("deviceActive slot"); |
515 | 541 | ||
516 | QMap<QString,BTDeviceItem*>::Iterator it; | 542 | QMap<QString,BTDeviceItem*>::Iterator it; |
517 | 543 | ||
518 | it = m_deviceList.find( device ); | 544 | it = m_deviceList.find( device ); |
519 | if( it == m_deviceList.end() ) | 545 | if( it == m_deviceList.end() ) |
520 | return; | 546 | return; |
521 | 547 | ||
522 | BTDeviceItem* deviceItem = it.data(); | 548 | BTDeviceItem* deviceItem = it.data(); |
523 | 549 | ||
524 | 550 | ||
525 | if ( connected ) { | 551 | if ( connected ) { |
526 | deviceItem->setPixmap( 1, m_onPix ); | 552 | deviceItem->setPixmap( 1, m_onPix ); |
527 | } else { | 553 | } else { |
528 | deviceItem->setPixmap( 1, m_offPix ); | 554 | deviceItem->setPixmap( 1, m_offPix ); |
529 | } | 555 | } |
530 | m_deviceList.remove( it ); | 556 | m_deviceList.remove( it ); |
531 | } | 557 | } |
532 | 558 | ||
533 | 559 | ||
534 | /** | 560 | /** |
535 | * Open the "scan for devices" dialog | 561 | * Open the "scan for devices" dialog |
536 | */ | 562 | */ |
537 | void BlueBase::startScan() { | 563 | void BlueBase::startScan() { |
538 | ScanDialog *scan = new ScanDialog( this, "ScanDialog", | 564 | ScanDialog *scan = new ScanDialog( this, "ScanDialog", |
539 | true, WDestructiveClose ); | 565 | true, WDestructiveClose ); |
540 | QObject::connect( scan, SIGNAL( selectedDevices( const QValueList<RemoteDevice>& ) ), | 566 | QObject::connect( scan, SIGNAL( selectedDevices( const QValueList<RemoteDevice>& ) ), |
541 | this, SLOT( addSearchedDevices( const QValueList<RemoteDevice>& ) ) ); | 567 | this, SLOT( addSearchedDevices( const QValueList<RemoteDevice>& ) ) ); |
542 | 568 | ||
543 | scan->showMaximized(); | 569 | scan->showMaximized(); |
544 | } | 570 | } |
545 | 571 | ||
546 | 572 | ||
547 | /** | 573 | /** |
548 | * Set the informations about the local device in information Tab | 574 | * Set the informations about the local device in information Tab |
549 | */ | 575 | */ |
550 | void BlueBase::setInfo() { | 576 | void BlueBase::setInfo() { |
551 | StatusLabel->setText( status() ); | 577 | StatusLabel->setText( status() ); |
552 | } | 578 | } |
553 | 579 | ||
554 | 580 | ||
555 | /** | 581 | /** |
556 | * Decontructor | 582 | * Decontructor |
557 | */ | 583 | */ |
558 | BlueBase::~BlueBase() { | 584 | BlueBase::~BlueBase() { |
559 | writeSavedDevices(); | 585 | writeSavedDevices(); |
560 | delete m_iconLoader; | 586 | delete m_iconLoader; |
561 | } | 587 | } |
562 | 588 | ||
563 | 589 | ||
564 | /** | 590 | /** |
565 | * find searches the ListView for a BTDeviceItem containig | 591 | * find searches the ListView for a BTDeviceItem containig |
566 | * the same Device if found return true else false | 592 | * the same Device if found return true else false |
567 | * @param dev RemoteDevice to find | 593 | * @param dev RemoteDevice to find |
568 | * @return returns true if found | 594 | * @return returns true if found |
569 | */ | 595 | */ |
570 | bool BlueBase::find( const RemoteDevice& rem ) { | 596 | bool BlueBase::find( const RemoteDevice& rem ) { |
571 | QListViewItemIterator it( ListView2 ); | 597 | QListViewItemIterator it( ListView2 ); |
572 | BTListItem* item; | 598 | BTListItem* item; |
573 | BTDeviceItem* device; | 599 | BTDeviceItem* device; |
574 | for (; it.current(); ++it ) { | 600 | for (; it.current(); ++it ) { |
575 | item = (BTListItem*) it.current(); | 601 | item = (BTListItem*) it.current(); |
576 | if ( item->typeId() != BTListItem::Device ) | 602 | if ( item->typeId() != BTListItem::Device ) |
577 | continue; | 603 | continue; |
578 | 604 | ||
579 | device = (BTDeviceItem*)item; | 605 | device = (BTDeviceItem*)item; |
580 | if ( rem.equals( device->remoteDevice() ) ) | 606 | if ( rem.equals( device->remoteDevice() ) ) |
581 | return true; | 607 | return true; |
582 | } | 608 | } |
583 | return false; // not found | 609 | return false; // not found |
584 | } | 610 | } |