summaryrefslogtreecommitdiff
path: root/noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp
Unidiff
Diffstat (limited to 'noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp89
1 files changed, 52 insertions, 37 deletions
diff --git a/noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp b/noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp
index be720b8..7943deb 100644
--- a/noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp
+++ b/noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp
@@ -1,3 +1,13 @@
1/* $Id$ */
2/* RFCOMM binding table edit dialog */
3/***************************************************************************
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 ***************************************************************************/
1 11
2#include "rfcommassigndialogimpl.h" 12#include "rfcommassigndialogimpl.h"
3#include "rfcommassigndialogitem.h" 13#include "rfcommassigndialogitem.h"
@@ -22,7 +32,6 @@ using namespace OpieTooth;
22RfcommAssignDialog::RfcommAssignDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) 32RfcommAssignDialog::RfcommAssignDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
23 : RfcommAssignDialogBase( parent, name, modal, fl ) 33 : RfcommAssignDialogBase( parent, name, modal, fl )
24{ 34{
25
26 m_range = 5; 35 m_range = 5;
27 36
28 m_scrollView = new QScrollView( this ); 37 m_scrollView = new QScrollView( this );
@@ -48,92 +57,98 @@ RfcommAssignDialog::~RfcommAssignDialog()
48} 57}
49 58
50 59
51void RfcommAssignDialog::newDevice( const QString & mac ) 60void RfcommAssignDialog::newDevice(const QString & mac, int channel)
52{ 61{
53 62
54 for ( int i = 0 ; i < m_range; i++ ) 63 for ( int i = 0 ; i < m_range; i++ )
55 { 64 {
56
57 QMap<QString, RfCommConfObject*>::Iterator it; 65 QMap<QString, RfCommConfObject*>::Iterator it;
58 it = confHandler->foundEntries().find( QString("%1").arg( i ) ); 66 it = confHandler->foundEntries().find(QString::number(i));
59 // make sure that rfcommX is not assigned yet 67 // make sure that rfcommX is not assigned yet
60 if ( it == confHandler->foundEntries().end() ) 68 if ( it == confHandler->foundEntries().end() )
61 { 69 {
62 QDialog dialog( this, "newdevice", true, WStyle_ContextHelp ); 70 QDialog dialog( this, "newdevice", true, WStyle_ContextHelp );
63 dialog.setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, 71 dialog.setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7,
64 (QSizePolicy::SizeType)7, sizePolicy().hasHeightForWidth())); 72 (QSizePolicy::SizeType)7, sizePolicy().hasHeightForWidth()));
73 QVBoxLayout layout(&dialog);
74 layout.setSpacing( 0 );
75 layout.setMargin( 0 );
65 76
66 RfcommDialogItem *newDev = new RfcommDialogItem( &dialog ); 77 RfcommDialogItem newDev(&dialog);
67 newDev->setIdent( i ); 78 newDev.setIdent( i );
68 newDev->setMac( mac ); 79 newDev.setMac( mac );
80 newDev.setChannel( channel );
81 layout.addWidget(&newDev);
69 82
70 if ( QPEApplication::execDialog( &dialog ) == QDialog::Accepted ) 83 if ( QPEApplication::execDialog( &dialog ) == QDialog::Accepted )
71 { 84 {
72 RfcommDialogItem *rfcomm = new RfcommDialogItem( m_box ); 85 QMap<int, RfcommDialogItem*>::Iterator it;
73 m_itemList.insert( i , rfcomm ); 86 it = m_itemList.find( i );
87 RfcommDialogItem *rfcomm = it.data();
74 rfcomm->setIdent( i ); 88 rfcomm->setIdent( i );
75 rfcomm->setMac( mac ); 89 rfcomm->setMac( mac );
76 rfcomm->setChannel( newDev->channel() ); 90 rfcomm->setChannel( newDev.channel() );
77 rfcomm->setComment( newDev->comment() ); 91 rfcomm->setComment( newDev.comment() );
92 rfcomm->setBind( newDev.isBind() );
78 odebug << "New device set up" << oendl; 93 odebug << "New device set up" << oendl;
79 } 94 }
95 break;
80 } 96 }
81 } 97 }
82} 98}
83 99
100/*
101 * Load rfcomm bind configuration
102 */
84void RfcommAssignDialog::loadConfig() 103void RfcommAssignDialog::loadConfig()
85{ 104{
86
87 //Config cfg( "bluetoothmanager-rfcommbind" );
88
89 for ( int i = 0 ; i < m_range; i++ ) 105 for ( int i = 0 ; i < m_range; i++ )
90 { 106 {
91 // cfg.setGroup( QString("%1").arg( i ) );
92 RfcommDialogItem *rfcomm = new RfcommDialogItem( m_box ); 107 RfcommDialogItem *rfcomm = new RfcommDialogItem( m_box );
93 m_itemList.insert( i , rfcomm ); 108 m_itemList.insert( i , rfcomm );
94 rfcomm->setIdent( i ); 109 rfcomm->setIdent( i );
95 QMap<QString, RfCommConfObject*>::Iterator it; 110 QMap<QString, RfCommConfObject*>::Iterator it;
96 it = confHandler->foundEntries().find( QString("%1").arg( i ) ); 111 it = confHandler->foundEntries().find(QString::number(i));
97 if ( it != confHandler->foundEntries().end() ) 112 if ( it != confHandler->foundEntries().end() )
98 { 113 {
99 odebug << "Found key in foundEntries() " << oendl;
100 rfcomm->setMac( it.data()->mac() ); 114 rfcomm->setMac( it.data()->mac() );
101 rfcomm->setChannel( it.data()->channel() ); 115 rfcomm->setChannel( it.data()->channel() );
102 rfcomm->setComment( it.data()->comment() ); 116 rfcomm->setComment( it.data()->comment() );
117 rfcomm->setBind(it.data()->isBind());
103 } 118 }
104 /* Use rfcomm.conf directly for now
105 * rfcomm->setMac( cfg.readEntry( "mac", "" ) );
106 * rfcomm->setChannel( cfg.readNumEntry( "channel", 1 ) );
107 * rfcomm->setComment( cfg.readEntry( "comment", "" ) );
108 */
109 } 119 }
110} 120}
111 121
112 122
123/*
124 * Save rfcomm bind configuration
125 */
113void RfcommAssignDialog::saveConfig() 126void RfcommAssignDialog::saveConfig()
114{ 127{
115
116 //Config cfg( "bluetoothmanager-rfcommbind" );
117
118 QMap< int, RfcommDialogItem*>::Iterator it; 128 QMap< int, RfcommDialogItem*>::Iterator it;
119
120 QMap< QString, RfCommConfObject*> outMap; 129 QMap< QString, RfCommConfObject*> outMap;
121 130
122 for( it = m_itemList.begin(); it != m_itemList.end(); ++it ) 131 for( it = m_itemList.begin(); it != m_itemList.end(); ++it )
123 { 132 {
124
125 //cfg.setGroup( QString("%1").arg( it.key() ) );
126 RfcommDialogItem *rfcomm = it.data(); 133 RfcommDialogItem *rfcomm = it.data();
127 134 if (rfcomm->mac().isEmpty())
128 135 continue;
129 outMap.insert( QString( "%1").arg( it.key() ), new RfCommConfObject( it.key(), rfcomm->mac(), rfcomm->channel(), rfcomm->comment() ) ); 136 outMap.insert(QString::number(it.key()),
130 137 new RfCommConfObject(it.key(),
131 138 rfcomm->mac(), rfcomm->channel(), rfcomm->comment(),
132 //cfg.writeEntry( "mac", rfcomm->mac() ); 139 rfcomm->isBind()));
133 //cfg.writeEntry( "channel", rfcomm->channel() );
134 //cfg.writeEntry( "comment", rfcomm->comment() );
135 } 140 }
136
137 confHandler->save( outMap ); 141 confHandler->save( outMap );
142}
138 143
144/*
145 * Reaction on the OK button
146 */
147void RfcommAssignDialog::accept()
148{
149 odebug << "save configuration" << oendl;
150 saveConfig();
151 RfcommAssignDialogBase::accept();
139} 152}
153
154//eof