88 // delete mBtLinkCountWatcher; |
88 // delete mBtLinkCountWatcher; |
89 //mBtLinkCountKey.Close(); |
89 //mBtLinkCountKey.Close(); |
90 } |
90 } |
91 |
91 |
92 |
92 |
93 bool BtLocalSetting::isValid( int column) const |
93 /*! |
94 { |
94 Tells whether the given column is in the range of the setting list. |
95 return column < mData.count(); |
95 |
96 } |
96 \param row the row number to be checked |
97 |
97 \param col the column number to be checked |
98 int BtLocalSetting::itemCount() const |
98 |
|
99 \return true if the given row and column are valid; false otherwise. |
|
100 */ |
|
101 bool BtLocalSetting::isValid( int row, int column) const |
|
102 { |
|
103 return row >= 0 && row < mData.count() && column == 0; |
|
104 } |
|
105 |
|
106 /*! |
|
107 \return the total amount of rows. |
|
108 |
|
109 */ |
|
110 int BtLocalSetting::rowCount() const |
99 { |
111 { |
100 return mData.count(); |
112 return mData.count(); |
101 } |
113 } |
102 |
114 |
103 void BtLocalSetting::data(QVariant& val, int col, int role ) const |
115 /*! |
104 { |
116 \return the total amount of columns. |
105 if ( isValid( col ) ) { |
117 |
106 val = mData.at( col ).value( role ); |
118 */ |
|
119 int BtLocalSetting::columnCount() const |
|
120 { |
|
121 return 1; |
|
122 } |
|
123 |
|
124 /*! |
|
125 Gets the value within a data item. |
|
126 \param val contains the value at return. |
|
127 \param row the row number which the value is from |
|
128 \param col the column number which the value is from |
|
129 \param role the role idenfier of the value. |
|
130 */ |
|
131 void BtLocalSetting::data(QVariant& val, int row, int col, int role ) const |
|
132 { |
|
133 if ( isValid( row, col ) ) { |
|
134 val = mData.at( row ).value( role ); |
107 } |
135 } |
108 else { |
136 else { |
109 val = QVariant( QVariant::Invalid ); |
137 val = QVariant( QVariant::Invalid ); |
110 } |
138 } |
111 } |
139 } |
112 |
140 |
113 BtuiModelDataItem BtLocalSetting::itemData( int col ) const |
141 /*! |
114 { |
142 Gets the whole item data at the specified column |
115 if ( isValid( col ) ) { |
143 \param row the row number of the item data to be returned |
116 return mData.at( col ); |
144 \param col the column number of the item data to be returned |
|
145 \return the item data |
|
146 */ |
|
147 BtuiModelDataItem BtLocalSetting::itemData( int row, int col ) const |
|
148 { |
|
149 if ( isValid( row, col ) ) { |
|
150 return mData.at( row ); |
117 } |
151 } |
118 return BtuiModelDataItem(); |
152 return BtuiModelDataItem(); |
119 } |
153 } |
120 |
|
121 |
154 |
122 /*! |
155 /*! |
123 Provides notification of changes in the power state |
156 Provides notification of changes in the power state |
124 of the Bluetooth hardware. |
157 of the Bluetooth hardware. |
125 |
158 |
126 @param state EBTPowerOff if the BT hardware has been turned off, |
159 \param state EBTPowerOff if the BT hardware has been turned off, |
127 EBTPowerOn if it has been turned on. |
160 EBTPowerOn if it has been turned on. |
128 */ |
161 */ |
129 void BtLocalSetting::PowerStateChanged( TBTPowerStateValue state ) |
162 void BtLocalSetting::PowerStateChanged( TBTPowerStateValue state ) |
130 { |
163 { |
131 setPowerSetting( state ); |
164 setPowerSetting( state ); |
132 emit settingDataChanged( BtuiModel::LocalSettingRow, BtuiModel::PowerStateCol, this ); |
165 mModel.emitDataChanged( BtSettingModel::PowerStateRow, 0, this ); |
133 } |
166 } |
134 |
167 |
135 /*! |
168 /*! |
136 Provides notification of changes in the discoverability |
169 Provides notification of changes in the discoverability |
137 mode of the Bluetooth hardware. |
170 mode of the Bluetooth hardware. |
138 @param state EBTDiscModeHidden if the BT hardware is in hidden mode, |
171 \param state EBTDiscModeHidden if the BT hardware is in hidden mode, |
139 EBTDiscModeGeneral if it is in visible mode. |
172 EBTDiscModeGeneral if it is in visible mode. |
140 */ |
173 */ |
141 void BtLocalSetting::VisibilityModeChanged( TBTVisibilityMode state ) |
174 void BtLocalSetting::VisibilityModeChanged( TBTVisibilityMode state ) |
142 { |
175 { |
143 setVisibilityMode( state ); |
176 setVisibilityMode( state ); |
144 emit settingDataChanged( BtuiModel::LocalSettingRow, BtuiModel::VisibilityCol, this ); |
177 mModel.emitDataChanged( BtSettingModel::VisibilityRow, 0, this ); |
145 } |
178 } |
146 |
179 |
147 void BtLocalSetting::RequestCompletedL( CBtSimpleActive* active, TInt status ) { |
180 void BtLocalSetting::RequestCompletedL( CBtSimpleActive* active, TInt status ) { |
148 Q_UNUSED( active ); |
181 Q_UNUSED( active ); |
149 Q_UNUSED( status ); |
182 Q_UNUSED( status ); |
174 */ |
207 */ |
175 void BtLocalSetting::updateDeviceName( const QString &name ) |
208 void BtLocalSetting::updateDeviceName( const QString &name ) |
176 { |
209 { |
177 // To-do: the data structure initialization is not impled yet in the model |
210 // To-do: the data structure initialization is not impled yet in the model |
178 BtuiModelDataItem& item = |
211 BtuiModelDataItem& item = |
179 mData[ BtuiModel::BluetoothNameCol ]; |
212 mData[ BtSettingModel::LocalBtNameRow ]; |
180 |
213 |
181 if ( item.isEmpty() ) { |
214 if ( item.isEmpty() ) { |
182 // Initialize with additional information on the setting |
215 // Initialize with additional information on the setting |
183 item[ BtuiModel::SettingIdentity ] = QVariant( tr( "Local Bluetooth name" ) ); |
216 item[ BtSettingModel::SettingNameRole ] = QVariant( tr( "Local Bluetooth name" ) ); |
184 } |
217 } |
185 |
218 |
186 bool setByUser = !name.isEmpty(); |
219 bool setByUser = !name.isEmpty(); |
187 |
220 |
188 // The additional parameter is the flag indicating whether the |
221 // The additional parameter is the flag indicating whether the |
189 // Bluetooth name has been set by the user. |
222 // Bluetooth name has been set by the user. |
190 // The flag is set to true if the name has been set. |
223 // The flag is set to true if the name has been set. |
191 // requirement does not |
224 // requirement does not |
192 //nitem[ BtuiModel::SettingValueParam ] = QVariant( setByUser ); |
225 //nitem[ BtSettingModel::SettingValueParamRole ] = QVariant( setByUser ); |
193 |
226 |
194 QString resolvedName( name ); |
227 QString resolvedName( name ); |
195 if ( resolvedName.isEmpty() ) { |
228 if ( resolvedName.isEmpty() ) { |
196 // We get the default name as suggestion for the user to set. |
229 // We get the default name as suggestion for the user to set. |
197 getNameFromRegistry( resolvedName ); |
230 getNameFromRegistry( resolvedName ); |
198 } |
231 } |
199 item[ BtuiModel::settingDisplay ] = QVariant( resolvedName ); |
232 item[ BtSettingModel::settingDisplayRole ] = QVariant( resolvedName ); |
200 item[ BtuiModel::SettingValue ] = QVariant( resolvedName ); |
233 item[ BtSettingModel::SettingValueRole ] = QVariant( resolvedName ); |
201 } |
234 } |
202 |
235 |
203 /*! |
236 /*! |
204 Updates all values related to the power setting. |
237 Updates all values related to the power setting. |
205 */ |
238 */ |
206 void BtLocalSetting::setPowerSetting( TBTPowerStateValue state ) |
239 void BtLocalSetting::setPowerSetting( TBTPowerStateValue state ) |
207 { |
240 { |
208 BtuiModelDataItem& item = |
241 BtuiModelDataItem& item = |
209 mData[ BtuiModel::PowerStateCol ]; |
242 mData[ BtSettingModel::PowerStateRow ]; |
210 if ( item.isEmpty() ) { |
243 if ( item.isEmpty() ) { |
211 // Initialize with additional information on the setting |
244 // Initialize with additional information on the setting |
212 item[ BtuiModel::SettingIdentity ] = QVariant( tr( "Bluetooth power" ) ); |
245 item[ BtSettingModel::SettingNameRole ] = QVariant( tr( "Bluetooth power" ) ); |
213 } |
246 } |
214 |
247 |
215 bool powerOn = ( state == EBTPowerOn ); |
248 bool powerOn = ( state == EBTPowerOn ); |
216 |
249 |
217 item[ BtuiModel::settingDisplay ] = |
250 item[ BtSettingModel::settingDisplayRole ] = |
218 powerOn ? QVariant( tr( "On" ) ) : QVariant( tr( "Off" ) ); |
251 powerOn ? QVariant( tr( "On" ) ) : QVariant( tr( "Off" ) ); |
219 item[ BtuiModel::SettingValue ] = QVariant( powerOn ); |
252 item[ BtSettingModel::SettingValueRole ] = QVariant( powerOn ); |
220 } |
253 } |
221 |
254 |
222 void BtLocalSetting::setVisibilityMode( TBTVisibilityMode state ) |
255 void BtLocalSetting::setVisibilityMode( TBTVisibilityMode state ) |
223 { |
256 { |
224 BtuiModelDataItem& item = mData[ BtuiModel::VisibilityCol ]; |
257 BtuiModelDataItem& item = mData[ BtSettingModel::VisibilityRow ]; |
225 |
258 |
226 if ( item.isEmpty() ) { |
259 if ( item.isEmpty() ) { |
227 item[ BtuiModel::SettingIdentity ] = QVariant( tr( "Phone visibility" ) ); |
260 item[ BtSettingModel::SettingNameRole ] = QVariant( tr( "Phone visibility" ) ); |
228 } |
261 } |
229 |
262 |
230 if ( state == EBTVisibilityModeHidden ) |
263 if ( state == EBTVisibilityModeHidden ) |
231 { |
264 { |
232 item [ BtuiModel::settingDisplay ] = QVariant( tr( "Hidden" ) ); |
265 item [ BtSettingModel::settingDisplayRole ] = QVariant( tr( "Hidden" ) ); |
233 } |
266 } |
234 else if ( state == EBTVisibilityModeGeneral ) |
267 else if ( state == EBTVisibilityModeGeneral ) |
235 { |
268 { |
236 item [ BtuiModel::settingDisplay ] = QVariant( tr( "Visible" ) ); |
269 item [ BtSettingModel::settingDisplayRole ] = QVariant( tr( "Visible" ) ); |
237 } |
270 } |
238 else |
271 else |
239 { |
272 { |
240 item [ BtuiModel::settingDisplay ] = QVariant( tr( "Temporarily visible" ) ); |
273 item [ BtSettingModel::settingDisplayRole ] = QVariant( tr( "Temporarily visible" ) ); |
241 } |
274 } |
242 item [ BtuiModel::SettingValue ] = QVariant( QtVisibilityMode(state) ); |
275 item [ BtSettingModel::SettingValueRole ] = QVariant( QtVisibilityMode(state) ); |
243 } |
276 } |
244 |
277 |
245 /*! |
278 /*! |
246 Get local Bluetooth device name from BTRegistry. |
279 Get local Bluetooth device name from BTRegistry. |
247 */ |
280 */ |