author | zecke <zecke> | 2002-07-13 13:31:50 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-07-13 13:31:50 (UTC) |
commit | 21e275324433ac4902c89997b53cbb042bdca9ab (patch) (unidiff) | |
tree | 3c1aca780dcc3ed36cae580cd69eb25f0b6fc2f3 /noncore/net/opietooth | |
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 | |||
@@ -93,8 +93,10 @@ using namespace OpieTooth; | |||
93 | topLV2->setPixmap( 1, m_onPix ); | 93 | topLV2->setPixmap( 1, m_onPix ); |
94 | Services s1; | 94 | Services s1; |
95 | s1.setServiceName( "Serial" ); | 95 | s1.setServiceName( "Serial" ); |
96 | s1.insertClassId(1, "BlueNic"); | ||
96 | (void) new BTServiceItem( topLV2, s1 ); | 97 | (void) new BTServiceItem( topLV2, s1 ); |
97 | s1.setServiceName( "BlueNic" ); | 98 | s1.setServiceName( "BlueNic" ); |
99 | s1.insertClassId(2, "Obex"); | ||
98 | (void) new BTServiceItem( topLV2, s1 ); | 100 | (void) new BTServiceItem( topLV2, s1 ); |
99 | 101 | ||
100 | writeToHciConfig(); | 102 | writeToHciConfig(); |
@@ -299,7 +301,8 @@ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & poin | |||
299 | ret = menu->exec( point , 0); | 301 | ret = menu->exec( point , 0); |
300 | 302 | ||
301 | switch(ret) { | 303 | switch(ret) { |
302 | case 0: | 304 | case -1: |
305 | |||
303 | break; | 306 | break; |
304 | case 1: | 307 | case 1: |
305 | break; | 308 | break; |
@@ -313,23 +316,48 @@ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & poin | |||
313 | } | 316 | } |
314 | delete groups; | 317 | delete groups; |
315 | 318 | ||
316 | } else if ( ((BTListItem*)item)->type() == "service") { | 319 | } |
320 | /** | ||
321 | * We got service sensitive PopupMenus in our factory | ||
322 | * We will create one through the factory and will insert | ||
323 | * our Separator + ShowInfo into the menu or create a new | ||
324 | * one if the factory returns 0 | ||
325 | * PopupMenu deletion is kind of weird. | ||
326 | * If escaped( -1 ) or any of our items were chosen we'll | ||
327 | * delete the PopupMenu otherwise it's the responsibility of | ||
328 | * the PopupMenu to delete itself | ||
329 | * | ||
330 | */ | ||
331 | else if ( ((BTListItem*)item)->type() == "service") { | ||
332 | BTServiceItem* service = (BTServiceItem*)item; | ||
333 | QMap<int, QString> list = service->services().classIdList(); | ||
334 | QMap<int, QString>::Iterator it = list.begin(); | ||
335 | QPopupMenu *popup =0l; | ||
336 | if ( it != list.end() ) | ||
337 | popup = m_popHelper.find( it.key(), | ||
338 | service->services(), | ||
339 | service->parent() ); | ||
340 | |||
341 | if ( popup == 0l ) { | ||
342 | qWarning("factory returned 0l"); | ||
343 | popup = new QPopupMenu(); | ||
344 | } | ||
317 | 345 | ||
318 | menu->insertItem( tr("Test1:"), 0); | 346 | int test1 = popup->insertItem( tr("Test1:"), 0); |
319 | menu->insertItem( tr("connect"), 1); | 347 | int con = popup->insertItem( tr("connect"), 1); |
320 | menu->insertItem( tr("delete"), 2); | 348 | int del = popup->insertItem( tr("delete"), 2); |
321 | 349 | ||
322 | ret = menu->exec( point , 0); | 350 | ret = popup->exec( point ); |
323 | 351 | ||
324 | switch(ret) { | 352 | if ( ret == -1 ) |
325 | case 0: | 353 | delete popup; |
326 | break; | 354 | else if ( ret == test1 ) |
327 | case 1: | 355 | delete popup; |
328 | break; | 356 | else if ( ret == con ) |
329 | case 2: | 357 | delete popup; |
330 | // delete childs too | 358 | else if ( ret == del ) { |
359 | // take item first? -zecke | ||
331 | delete item; | 360 | delete item; |
332 | break; | ||
333 | } | 361 | } |
334 | } | 362 | } |
335 | delete menu; | 363 | delete menu; |
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 | |||
@@ -15,8 +15,10 @@ void PopupHelper::insert( int id, popupFactory fact ) { | |||
15 | m_map.insert(id, fact ); | 15 | m_map.insert(id, fact ); |
16 | } | 16 | } |
17 | QPopupMenu* PopupHelper::find( int id, const Services& ser, QListViewItem* item ) { | 17 | QPopupMenu* PopupHelper::find( int id, const Services& ser, QListViewItem* item ) { |
18 | qWarning("find"); | ||
18 | FactoryMap::Iterator it = m_map.find(id ); | 19 | FactoryMap::Iterator it = m_map.find(id ); |
19 | if ( it != m_map.end() ) { | 20 | if ( it != m_map.end() ) { |
21 | qWarning("found"); | ||
20 | popupFactory fact = it.data(); | 22 | popupFactory fact = it.data(); |
21 | return (*fact)(ser, item); | 23 | return (*fact)(ser, item); |
22 | } | 24 | } |