Diffstat (limited to 'noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp | 115 |
1 files changed, 65 insertions, 50 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,6 +34,5 @@ RfcommAssignDialog::RfcommAssignDialog( QWidget* parent, const char* name, bool | |||
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); |
29 | m_scrollView->setResizePolicy( QScrollView::AutoOneFit ); | 38 | m_scrollView->setResizePolicy( QScrollView::AutoOneFit ); |
@@ -31,6 +40,6 @@ RfcommAssignDialog::RfcommAssignDialog( QWidget* parent, const char* name, bool | |||
31 | 40 | ||
32 | RfcommAssignDialogBaseLayout->addWidget( m_scrollView ); | 41 | RfcommAssignDialogBaseLayout->addWidget(m_scrollView); |
33 | 42 | ||
34 | m_box = new QVBox( m_scrollView->viewport() ); | 43 | m_box = new QVBox(m_scrollView->viewport()); |
35 | m_scrollView->addChild( m_box ); | 44 | m_scrollView->addChild(m_box); |
36 | 45 | ||
@@ -50,3 +59,3 @@ RfcommAssignDialog::~RfcommAssignDialog() | |||
50 | 59 | ||
51 | void RfcommAssignDialog::newDevice( const QString & mac ) | 60 | void RfcommAssignDialog::newDevice(const QString & mac, int channel) |
52 | { | 61 | { |
@@ -55,7 +64,6 @@ 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 |
60 | if ( it == confHandler->foundEntries().end() ) | 68 | if ( it == confHandler->foundEntries().end() ) |
61 | { | 69 | { |
@@ -64,6 +72,11 @@ void RfcommAssignDialog::newDevice( const QString & mac ) | |||
64 | (QSizePolicy::SizeType)7, sizePolicy().hasHeightForWidth())); | 72 | (QSizePolicy::SizeType)7, sizePolicy().hasHeightForWidth())); |
65 | 73 | QVBoxLayout layout(&dialog); | |
66 | RfcommDialogItem *newDev = new RfcommDialogItem( &dialog ); | 74 | layout.setSpacing( 0 ); |
67 | newDev->setIdent( i ); | 75 | layout.setMargin( 0 ); |
68 | newDev->setMac( mac ); | 76 | |
77 | RfcommDialogItem newDev(&dialog); | ||
78 | newDev.setIdent( i ); | ||
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,27 +99,21 @@ void RfcommAssignDialog::newDevice( const QString & mac ) | |||
83 | 99 | ||
100 | /* | ||
101 | * Load rfcomm bind configuration | ||
102 | */ | ||
84 | void RfcommAssignDialog::loadConfig() | 103 | void 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; | 114 | rfcomm->setMac(it.data()->mac()); |
100 | rfcomm->setMac( it.data()->mac() ); | 115 | rfcomm->setChannel(it.data()->channel()); |
101 | rfcomm->setChannel( it.data()->channel() ); | 116 | rfcomm->setComment(it.data()->comment()); |
102 | 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 | */ | ||
113 | void RfcommAssignDialog::saveConfig() | 126 | void 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 | } |
141 | confHandler->save(outMap); | ||
142 | } | ||
136 | 143 | ||
137 | confHandler->save( outMap ); | 144 | /* |
138 | 145 | * Reaction on the OK button | |
146 | */ | ||
147 | void RfcommAssignDialog::accept() | ||
148 | { | ||
149 | odebug << "save configuration" << oendl; | ||
150 | saveConfig(); | ||
151 | RfcommAssignDialogBase::accept(); | ||
139 | } | 152 | } |
153 | |||
154 | //eof | ||