author | zecke <zecke> | 2002-07-13 13:31:50 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-07-13 13:31:50 (UTC) |
commit | 21e275324433ac4902c89997b53cbb042bdca9ab (patch) (side-by-side diff) | |
tree | 3c1aca780dcc3ed36cae580cd69eb25f0b6fc2f3 | |
parent | d7f3722f9b7913731978437085b14cc2cccbfa24 (diff) | |
download | opie-21e275324433ac4902c89997b53cbb042bdca9ab.zip opie-21e275324433ac4902c89997b53cbb042bdca9ab.tar.gz opie-21e275324433ac4902c89997b53cbb042bdca9ab.tar.bz2 |
Factory code is in place... aye
Now we just need FactoryImpl of
OBEX,RfcCom,VoiceGateWay
There will be one small adjustment though
QListViewItem -> BTDeviceItem
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.cpp | 56 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/popuphelper.cpp | 2 |
2 files changed, 44 insertions, 14 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp index 189001d..3f2f138 100644 --- a/noncore/net/opietooth/manager/bluebase.cpp +++ b/noncore/net/opietooth/manager/bluebase.cpp @@ -84,26 +84,28 @@ using namespace OpieTooth; setCaption( tr( "Bluetooth Manager" ) ); readConfig(); initGui(); //TESTING ListView2->setRootIsDecorated(true); BTDeviceItem *topLV2 = new BTDeviceItem( ListView2, RemoteDevice("xx:", "Siemens S45" ) ); topLV2->setPixmap( 1, m_onPix ); Services s1; s1.setServiceName( "Serial" ); + s1.insertClassId(1, "BlueNic"); (void) new BTServiceItem( topLV2, s1 ); s1.setServiceName( "BlueNic" ); + s1.insertClassId(2, "Obex"); (void) new BTServiceItem( topLV2, s1 ); writeToHciConfig(); // search conncetions addConnectedDevices(); m_iconLoader = new BTIconLoader(); } /** * Reads all options from the config file */ void BlueBase::readConfig() { @@ -290,55 +292,81 @@ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & poin if ( ((BTListItem*)item)->type() == "device") { QPopupMenu *groups = new QPopupMenu(); menu->insertItem( tr("rescan sevices:"), 0); menu->insertItem( tr("to group"), groups , 1); menu->insertItem( tr("bound device"), 2); menu->insertItem( tr("delete"), 3); ret = menu->exec( point , 0); switch(ret) { - case 0: + case -1: + break; case 1: break; case 2: // make connection break; case 3: // delete childs too delete item; break; } delete groups; - } else if ( ((BTListItem*)item)->type() == "service") { + } + /** + * We got service sensitive PopupMenus in our factory + * We will create one through the factory and will insert + * our Separator + ShowInfo into the menu or create a new + * one if the factory returns 0 + * PopupMenu deletion is kind of weird. + * If escaped( -1 ) or any of our items were chosen we'll + * delete the PopupMenu otherwise it's the responsibility of + * the PopupMenu to delete itself + * + */ + else if ( ((BTListItem*)item)->type() == "service") { + BTServiceItem* service = (BTServiceItem*)item; + QMap<int, QString> list = service->services().classIdList(); + QMap<int, QString>::Iterator it = list.begin(); + QPopupMenu *popup =0l; + if ( it != list.end() ) + popup = m_popHelper.find( it.key(), + service->services(), + service->parent() ); + + if ( popup == 0l ) { + qWarning("factory returned 0l"); + popup = new QPopupMenu(); + } - menu->insertItem( tr("Test1:"), 0); - menu->insertItem( tr("connect"), 1); - menu->insertItem( tr("delete"), 2); + int test1 = popup->insertItem( tr("Test1:"), 0); + int con = popup->insertItem( tr("connect"), 1); + int del = popup->insertItem( tr("delete"), 2); - ret = menu->exec( point , 0); + ret = popup->exec( point ); - switch(ret) { - case 0: - break; - case 1: - break; - case 2: - // delete childs too + if ( ret == -1 ) + delete popup; + else if ( ret == test1 ) + delete popup; + else if ( ret == con ) + delete popup; + else if ( ret == del ) { + // take item first? -zecke delete item; - break; } } delete menu; } /** * Search and display avail. services for a device (on expand from device listing) * */ void BlueBase::addServicesToDevice( BTDeviceItem * item ) { qDebug("addServicesToDevice"); // row of mac adress text(3) diff --git a/noncore/net/opietooth/manager/popuphelper.cpp b/noncore/net/opietooth/manager/popuphelper.cpp index d8404d6..26c4b02 100644 --- a/noncore/net/opietooth/manager/popuphelper.cpp +++ b/noncore/net/opietooth/manager/popuphelper.cpp @@ -6,23 +6,25 @@ using namespace OpieTooth; PopupHelper::PopupHelper() { init(); } PopupHelper::~PopupHelper() { } void PopupHelper::insert( int id, popupFactory fact ) { m_map.insert(id, fact ); } QPopupMenu* PopupHelper::find( int id, const Services& ser, QListViewItem* item ) { + qWarning("find"); FactoryMap::Iterator it = m_map.find(id ); if ( it != m_map.end() ) { + qWarning("found"); popupFactory fact = it.data(); return (*fact)(ser, item); } return 0l; } void PopupHelper::init() { insert( 1, newRfcComPopup ); insert(2, newObexPushPopup ); } |