summaryrefslogtreecommitdiff
authorzecke <zecke>2002-07-13 13:31:50 (UTC)
committer zecke <zecke>2002-07-13 13:31:50 (UTC)
commit21e275324433ac4902c89997b53cbb042bdca9ab (patch) (side-by-side diff)
tree3c1aca780dcc3ed36cae580cd69eb25f0b6fc2f3
parentd7f3722f9b7913731978437085b14cc2cccbfa24 (diff)
downloadopie-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
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/opietooth/manager/bluebase.cpp62
-rw-r--r--noncore/net/opietooth/manager/popuphelper.cpp2
2 files changed, 47 insertions, 17 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
@@ -92,10 +92,12 @@ using namespace OpieTooth;
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
@@ -298,9 +300,10 @@ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & poin
ret = menu->exec( point , 0);
switch(ret) {
- case 0:
+ case -1:
+
break;
case 1:
break;
case 2:
@@ -312,25 +315,50 @@ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & poin
break;
}
delete groups;
- } else if ( ((BTListItem*)item)->type() == "service") {
-
- menu->insertItem( tr("Test1:"), 0);
- menu->insertItem( tr("connect"), 1);
- menu->insertItem( tr("delete"), 2);
-
- ret = menu->exec( point , 0);
-
- switch(ret) {
- case 0:
- break;
- case 1:
- break;
- case 2:
- // delete childs too
+ }
+ /**
+ * 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();
+ }
+
+ int test1 = popup->insertItem( tr("Test1:"), 0);
+ int con = popup->insertItem( tr("connect"), 1);
+ int del = popup->insertItem( tr("delete"), 2);
+
+ ret = popup->exec( point );
+
+ 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;
}
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
@@ -14,10 +14,12 @@ 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;