Diffstat (limited to 'noncore/net/opietooth/manager/bluebase.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.cpp | 56 |
1 files changed, 42 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 @@ -94,6 +94,8 @@ using namespace OpieTooth; 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 ); @@ -300,5 +302,6 @@ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & poin switch(ret) { - case 0: + case -1: + break; case 1: @@ -314,21 +317,46 @@ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & poin 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; } } |