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 +1,11 @@
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
@@ -24,3 +34,2 @@ RfcommAssignDialog::RfcommAssignDialog( QWidget* parent, const char* name, bool
24{ 34{
25
26 m_range = 5; 35 m_range = 5;
@@ -50,3 +59,3 @@ RfcommAssignDialog::~RfcommAssignDialog()
50 59
51void RfcommAssignDialog::newDevice( const QString & mac ) 60void RfcommAssignDialog::newDevice(const QString & mac, int channel)
52{ 61{
@@ -55,5 +64,4 @@ void RfcommAssignDialog::newDevice( const QString & mac )
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
@@ -64,6 +72,11 @@ void RfcommAssignDialog::newDevice( const QString & mac )
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
@@ -71,10 +84,13 @@ void RfcommAssignDialog::newDevice( const QString & mac )
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 }
@@ -83,10 +99,9 @@ void RfcommAssignDialog::newDevice( const QString & mac )
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 );
@@ -95,6 +110,5 @@ void RfcommAssignDialog::loadConfig()
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() );
@@ -102,8 +116,4 @@ void RfcommAssignDialog::loadConfig()
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 }
@@ -112,9 +122,8 @@ void RfcommAssignDialog::loadConfig()
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;
@@ -123,17 +132,23 @@ void RfcommAssignDialog::saveConfig()
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