author | harlekin <harlekin> | 2002-06-23 20:55:21 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-06-23 20:55:21 (UTC) |
commit | 6fd150b4f49cab215eb65730242a7498ea990017 (patch) (side-by-side diff) | |
tree | 21bb54a14416773a4115e0302c8a6eea955e9cdc /noncore/net/opietooth/manager/bluebase.cpp | |
parent | a4a53967e152ba595d315b2491bb78070c446ee2 (diff) | |
download | opie-6fd150b4f49cab215eb65730242a7498ea990017.zip opie-6fd150b4f49cab215eb65730242a7498ea990017.tar.gz opie-6fd150b4f49cab215eb65730242a7498ea990017.tar.bz2 |
switched to BTListItem instead of setText atventures
Diffstat (limited to 'noncore/net/opietooth/manager/bluebase.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.cpp | 117 |
1 files changed, 78 insertions, 39 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp index 77eb62b..910bb8c 100644 --- a/noncore/net/opietooth/manager/bluebase.cpp +++ b/noncore/net/opietooth/manager/bluebase.cpp @@ -61,7 +61,7 @@ namespace OpieTooth { connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ), - this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) ); + this, SLOT(startServiceActionHold( BTListItem *, const QPoint &, int) ) ); connect( localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ), this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) ); - // connect( localDevice, SIGNAL( available( const QString& device, bool connected ) ), - // this, SLOT() ); + connect( localDevice, SIGNAL( available( const QString& device, bool connected ) ), + this, SLOT( deviceActive( const QString& mac, bool connected ) ) ); @@ -88,7 +88,6 @@ namespace OpieTooth { - QListViewItem *topLV2 = new QListViewItem( ListView2, "Siemens S45" , "no" ); + BTListItem *topLV2 = new BTListItem( ListView2, "Siemens S45", "", "device" ); topLV2->setPixmap( 1, onPix ); - topLV2->setText(4, "device" ); - (void) new QListViewItem( topLV2, "Serial" ); - (void) new QListViewItem( topLV2, "BlueNiC" ); + (void) new BTListItem( topLV2, "Serial" ,"", "service" ); + (void) new BTListItem( topLV2, "BlueNiC" , "", "service" ); } @@ -173,6 +172,7 @@ namespace OpieTooth { // seperate config file for each device, to store more information in future. +// TO FIX: BTLISTITEM!!! - Config conf( QDir::homeDirPath() + "/Settings/bluetooth/" + (it.current()->text(3)) + ".conf", Config::File ); - conf.setGroup( "Info" ); - conf.writeEntry( "name", it.current()->text(0) ); + // Config conf( QDir::homeDirPath() + "/Settings/bluetooth/" + (((BTListItem)it.current())->mac()) + ".conf", Config::File ); + // conf.setGroup( "Info" ); + // conf.writeEntry( "name", it.current()->name() ); } @@ -240,3 +240,3 @@ namespace OpieTooth { - QListViewItem * deviceItem; + BTListItem * deviceItem; @@ -248,14 +248,12 @@ namespace OpieTooth { RemoteDevice *dev = it.current(); - deviceItem = new QListViewItem( ListView2 , dev->name() ); + deviceItem = new BTListItem( ListView2 , dev->name(), dev->mac(), "device" ); deviceItem->setExpandable ( true ); - if ( deviceActive( dev ) ) { - deviceItem->setPixmap( 1 , onPix ); - } else { - deviceItem->setPixmap( 1, offPix ); - } + // look if device is avail. atm, async + deviceActive( dev ); - deviceItem->setText( 3, dev->mac() ); + // move into the c'tor + // deviceItem->setMac( dev->mac() ); // what kind of entry is it. - deviceItem->setText( 4, "device"); + //deviceItem->setType( "device"); @@ -278,6 +276,6 @@ namespace OpieTooth { */ - void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int column ) { + void BlueBase::startServiceActionHold( BTListItem * item, const QPoint & point, int column ) { QPopupMenu *menu = new QPopupMenu(); - QPopupMenu *groups = new QPopupMenu(); + int ret=0; @@ -286,3 +284,6 @@ namespace OpieTooth { - if ( item->text(4) == "device") { + if ( item->type() == "device") { + + QPopupMenu *groups = new QPopupMenu(); + menu->insertItem( tr("rescan sevices:"), 0); @@ -290,3 +291,19 @@ namespace OpieTooth { menu->insertItem( tr("delete"), 2); - } else if ( item->text(4) == "service") { + + + ret = menu->exec( point , 0); + + switch(ret) { + case 0: + break; + case 1: + break; + case 2: + // delete childs too + delete item; + break; + } + delete groups; + + } else if ( item->type() == "service") { menu->insertItem( tr("Test1:"), 0); @@ -294,3 +311,2 @@ namespace OpieTooth { menu->insertItem( tr("delete"), 2); - } @@ -298,3 +314,2 @@ namespace OpieTooth { -// noch differenzieren switch(ret) { @@ -309,5 +324,5 @@ namespace OpieTooth { } + } delete menu; - delete groups; } @@ -318,3 +333,3 @@ namespace OpieTooth { */ - void BlueBase::addServicesToDevice( QListViewItem * item ) { + void BlueBase::addServicesToDevice( BTListItem * item ) { @@ -322,5 +337,5 @@ namespace OpieTooth { // row of mac adress text(3) - RemoteDevice *device = new RemoteDevice( item->text(3), item->text(0) ); + RemoteDevice *device = new RemoteDevice( item->mac(), item->name() ); - deviceList.insert( item->text(3) , item ); + deviceList.insert( item->mac() , item ); @@ -342,5 +357,5 @@ namespace OpieTooth { - QMap<QString,QListViewItem*>::Iterator it; + QMap<QString,BTListItem*>::Iterator it; - QListViewItem* deviceItem; + BTListItem* deviceItem; @@ -365,3 +380,3 @@ namespace OpieTooth { - QListViewItem * serviceItem; + BTListItem * serviceItem; @@ -370,8 +385,8 @@ namespace OpieTooth { for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) { - serviceItem = new QListViewItem( deviceItem , (*it2).serviceName() ); - serviceItem->setText(4, "service"); + serviceItem = new BTListItem( deviceItem , (*it2).serviceName() , "" , "service" ); + //serviceItem->setText(4, "service"); } } else { - serviceItem = new QListViewItem( deviceItem , tr("no services found") ); - serviceItem->setText(4, "service"); + serviceItem = new BTListItem( deviceItem , tr("no services found"), "" , "service" ); + //serviceItem->setText(4, "service"); } @@ -394,11 +409,35 @@ namespace OpieTooth { */ - bool BlueBase::deviceActive( RemoteDevice *device ) { + void BlueBase::deviceActive( RemoteDevice *device ) { - // search by mac + // search by mac, async, gets a signal back localDevice->isAvailable( device->mac() ); + } + + /** + * The signal catcher. Set the avail. status on device. + * @param device - the mac address + * @param connected - if it is avail. or not + */ + void BlueBase::deviceActive( const QString& device, bool connected ) { + + qDebug("deviceActive slot"); + + QMap<QString,BTListItem*>::Iterator it; - return true; + BTListItem* deviceItem; + + // get the right devices which requested the search + for( it = deviceList.begin(); it != deviceList.end(); ++it ) { + if ( it.key() == device ) { + deviceItem = it.data(); + } } + if ( connected ) { + deviceItem->setPixmap( 1, onPix ); + } else { + deviceItem->setPixmap( 1, offPix ); + } + } |