125 mDeviceStatus=0; |
95 mDeviceStatus=0; |
126 mDeviceStatus = qobject_cast<HbLabel *>( mLoader->findWidget( "deviceStatus" ) ); |
96 mDeviceStatus = qobject_cast<HbLabel *>( mLoader->findWidget( "deviceStatus" ) ); |
127 BTUI_ASSERT_X( mDeviceStatus != 0, "bt-device-view", "Device status not found" ); |
97 BTUI_ASSERT_X( mDeviceStatus != 0, "bt-device-view", "Device status not found" ); |
128 |
98 |
129 |
99 |
130 mConnectionCombobox = 0; |
100 mConnectionDataForm = 0; |
131 mConnectionCombobox = qobject_cast<HbDataForm *>( mLoader->findWidget( "connectionCombobox" ) ); |
101 mConnectionDataForm = qobject_cast<HbDataForm *>( mLoader->findWidget( "connectionCombobox" ) ); |
132 BTUI_ASSERT_X( mConnectionCombobox != 0, "bt-device-view", "connection combobox not found" ); |
102 BTUI_ASSERT_X( mConnectionDataForm != 0, "bt-device-view", "connection combobox not found" ); |
133 |
103 |
134 mConnectionComboboxModel = new HbDataFormModel(); |
104 mConnectionComboboxModel = new HbDataFormModel( this ); |
135 |
105 |
136 mPair_Unpair=0; |
106 mPair_Unpair=0; |
137 mPair_Unpair = qobject_cast<HbPushButton *>( mLoader->findWidget( "pushButton_0" ) ); |
107 mPair_Unpair = qobject_cast<HbPushButton *>( mLoader->findWidget( "devicePairUnpair" ) ); |
138 BTUI_ASSERT_X( mPair_Unpair != 0, "bt-device-view", "pair/unpair button not found" ); |
108 BTUI_ASSERT_X( mPair_Unpair != 0, "bt-device-view", "pair/unpair button not found" ); |
139 ret = connect(mPair_Unpair, SIGNAL(clicked()), this, SLOT(pairUnpair())); |
|
140 BTUI_ASSERT_X( ret, "BtCpUiDeviceView::BtCpUiDeviceView", "can't connect pair button" ); |
|
141 |
109 |
142 mConnect_Disconnect=0; |
110 mConnect_Disconnect=0; |
143 mConnect_Disconnect = qobject_cast<HbPushButton *>( mLoader->findWidget( "pushButton_1" ) ); |
111 mConnect_Disconnect = qobject_cast<HbPushButton *>( mLoader->findWidget( "deviceConnectDisconnect" ) ); |
144 BTUI_ASSERT_X( mConnect_Disconnect != 0, "bt-device-view", "connect/disconnect button not found" ); |
112 BTUI_ASSERT_X( mConnect_Disconnect != 0, "bt-device-view", "connect/disconnect button not found" ); |
145 ret = connect(mConnect_Disconnect, SIGNAL(clicked()), this, SLOT(connectDisconnect())); |
|
146 BTUI_ASSERT_X( ret, "BtCpUiDeviceView::BtCpUiDeviceView", "can't connect disconnect button" ); |
|
147 |
113 |
148 mDeviceSetting = 0; |
114 mDeviceSetting = 0; |
149 mDeviceSetting = qobject_cast<HbPushButton *>( mLoader->findWidget( "pushButton_2" ) ); |
115 mDeviceSetting = qobject_cast<HbPushButton *>( mLoader->findWidget( "deviceSettings" ) ); |
150 BTUI_ASSERT_X( mDeviceSetting != 0, "bt-device-view", "settings button not found" ); |
116 BTUI_ASSERT_X( mDeviceSetting != 0, "bt-device-view", "settings button not found" ); |
151 |
|
152 |
|
153 ret = connect(mDeviceSetting, SIGNAL(clicked()), this, |
117 ret = connect(mDeviceSetting, SIGNAL(clicked()), this, |
154 SLOT(handleDeviceSetting())); |
118 SLOT(handleDeviceSetting())); |
155 BTUI_ASSERT_X( ret, "Btui, BtCpUiDeviceView::BtCpUiDeviceView", "clicked() connect failed"); |
119 BTUI_ASSERT_X( ret, "Btui, BtcpuiDeviceView::BtcpuiDeviceView", "clicked() connect failed"); |
156 |
120 |
157 setConnectionCombobox(); |
121 setConnectionCombobox(); |
158 |
122 } |
159 } |
123 |
160 |
124 BtcpuiDeviceView::~BtcpuiDeviceView() |
161 BtCpUiDeviceView::~BtCpUiDeviceView() |
125 { |
162 { |
126 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
163 delete mLoader; // Also deletes all widgets that it constructed. |
127 delete mLoader; // Also deletes all widgets that it constructed. |
164 |
128 delete mAbstractDelegate; |
165 delete mConnectionComboboxModel; |
129 unloadDeviceDetails(); |
166 |
130 BOstraceFunctionExit0(DUMMY_DEVLIST); |
167 setNavigationAction(0); |
131 } |
168 delete mSoftKeyBackAction; |
132 |
169 if(mAbstractDelegate) |
133 void BtcpuiDeviceView::backToPreviousView() |
170 { |
134 { |
171 delete mAbstractDelegate; |
135 BtcpuiBaseView::backToPreviousView(); |
172 mAbstractDelegate = 0; |
136 unloadDeviceDetails(); |
173 } |
137 } |
174 |
138 |
175 } |
139 void BtcpuiDeviceView::loadDeviceDetails() |
176 |
140 { |
177 |
141 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
178 void BtCpUiDeviceView::setSoftkeyBack() |
142 bool ret(false); |
179 { |
143 unloadDeviceDetails(); // ToDo: is it necessary to delete the device view every time there is a change? |
180 if (navigationAction() != mSoftKeyBackAction) { |
144 mDeviceDetail = new BtCpUiDeviceDetail(); |
181 setNavigationAction(mSoftKeyBackAction); |
145 ret=connect(mDeviceDetail, SIGNAL(deviceSettingsChanged(bool)), |
182 connect( mSoftKeyBackAction, SIGNAL(triggered()), this, SLOT(switchToPreviousView()) ); |
146 this, SLOT(handleDeviceSettingsChange(bool))); |
183 } |
147 BTUI_ASSERT_X( ret, "Btui, BtcpuiDeviceView::loadDeviceDetails", "deviceSettingsChanged() connect failed"); |
184 } |
148 |
185 |
149 QString btAddr = mDeviceBdAddr.toString(); |
186 void BtCpUiDeviceView::switchToPreviousView() |
150 QString deviceName = mDeviceName->text(); |
187 { |
151 mDeviceDetail->loadDeviceDetailPlugins(btAddr, deviceName); |
188 BTUI_ASSERT_X(mMainView, "BtCpUiSearchView::switchToPreviousView", "invalid mMainView"); |
152 BOstraceFunctionExit0(DUMMY_DEVLIST); |
189 mMainView->switchToPreviousView(); |
153 } |
190 |
154 |
|
155 void BtcpuiDeviceView::unloadDeviceDetails() |
|
156 { |
|
157 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
191 if(mDeviceDetail) { |
158 if(mDeviceDetail) { |
192 mDeviceDetail->sendCloseEvent(); |
159 mDeviceDetail->sendCloseEvent(); |
193 } |
|
194 unloadDeviceDetails(); |
|
195 } |
|
196 |
|
197 void BtCpUiDeviceView::loadDeviceDetails() |
|
198 { |
|
199 bool ret(false); |
|
200 |
|
201 unloadDeviceDetails(); |
|
202 |
|
203 mDeviceDetail = new BtCpUiDeviceDetail(); |
|
204 |
|
205 ret=connect(mDeviceDetail, SIGNAL(deviceSettingsChanged(bool)), |
|
206 this, SLOT(handleDeviceSettingsChange(bool))); |
|
207 BTUI_ASSERT_X( ret, "Btui, BtCpUiDeviceView::loadDeviceDetails", "deviceSettingsChanged() connect failed"); |
|
208 |
|
209 mDeviceDetail->loadDeviceDetailPlugins(mDeviceBdAddr.toString(), mDeviceName->text()); |
|
210 } |
|
211 |
|
212 void BtCpUiDeviceView::unloadDeviceDetails() |
|
213 { |
|
214 if(mDeviceDetail) { |
|
215 disconnect(mDeviceDetail); |
|
216 delete mDeviceDetail; |
160 delete mDeviceDetail; |
217 mDeviceDetail = 0; |
161 mDeviceDetail = 0; |
218 } |
162 } |
219 } |
163 BOstraceFunctionExit0(DUMMY_DEVLIST); |
220 |
164 } |
221 void BtCpUiDeviceView::activateView( const QVariant& value, bool fromBackButton ) |
165 |
222 { |
166 void BtcpuiDeviceView::activateView( const QVariant& value, bool backNavi) |
223 |
167 { |
224 Q_UNUSED( fromBackButton ); |
168 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
225 |
169 Q_UNUSED( backNavi ); |
226 mConnectedStatus = false; |
170 // get bluetooth address of device in question |
227 setSoftkeyBack(); |
|
228 |
|
229 |
|
230 QModelIndex index = value.value<QModelIndex>(); |
171 QModelIndex index = value.value<QModelIndex>(); |
231 mDeviceBdAddr = (mDeviceModel->data(index, BtDeviceModel::ReadableBdaddrRole)); |
172 mDeviceBdAddr = (mDeviceModel->data(index, BtDeviceModel::ReadableBdaddrRole)); |
232 |
173 QModelIndex start = mDeviceModel->index(0,0); |
233 //activate view is called when device is selected |
174 QModelIndexList indexList = mDeviceModel->match(start,BtDeviceModel::ReadableBdaddrRole, mDeviceBdAddr); |
234 //clearViewData(); |
175 mDeviceIndex = indexList.at(0); |
|
176 |
|
177 bool ret = false; |
|
178 if (mMainWindow->orientation() == Qt::Horizontal) { |
|
179 //mLoader->load(BTUI_DEVICEVIEW_DOCML, "landscape", &ret); |
|
180 //BTUI_ASSERT_X( ret, "bt-device-view", "Invalid docml file: landscape section problem" ); |
|
181 int majorRole = (mDeviceModel->data(mDeviceIndex,BtDeviceModel::MajorPropertyRole)).toInt(); |
|
182 if (majorRole & BtuiDevProperty::Connectable ) { |
|
183 mLoader->load( BTUI_DEVICEVIEW_DOCML, "landscape", &ret ); |
|
184 BTUI_ASSERT_X( ret, "bt-device-view", "Invalid docml file: landscape section problem" ); |
|
185 } |
|
186 else{ |
|
187 mLoader->load( BTUI_DEVICEVIEW_DOCML, "landscape2", &ret ); |
|
188 BTUI_ASSERT_X( ret, "bt-device-view", "Invalid docml file: landscape2 section problem" ); |
|
189 } |
|
190 } |
|
191 else { |
|
192 mLoader->load(BTUI_DEVICEVIEW_DOCML, "portrait", &ret); |
|
193 BTUI_ASSERT_X( ret, "bt-device-view", "Invalid docml file: portrait section problem" ); |
|
194 |
|
195 |
|
196 } |
|
197 |
235 updateDeviceData(); |
198 updateDeviceData(); |
236 |
199 |
237 mDeviceSetting->setVisible(false); |
200 mDeviceSetting->setVisible(false); |
238 |
201 loadDeviceDetails(); |
239 bool ret(false); |
202 ret = false; |
240 ret=connect(mDeviceModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), |
203 ret=connect(mDeviceModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), |
241 this, SLOT(updateDeviceData())); |
204 this, SLOT(updateDeviceData())); |
242 BTUI_ASSERT_X( ret, "Btui, BtCpUiDeviceView::activateView", "dataChanged() connect failed"); |
205 BTUI_ASSERT_X( ret, "Btui, BtCpUiDeviceView::activateView", "dataChanged() connect failed"); |
243 |
206 BOstraceFunctionExit0(DUMMY_DEVLIST); |
244 } |
207 } |
245 |
208 |
246 void BtCpUiDeviceView::handleDeviceSettingsChange(bool status) |
209 void BtcpuiDeviceView::deactivateView() |
247 { |
210 { |
|
211 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
|
212 disconnect(mDeviceModel, 0, this, 0); |
|
213 unloadDeviceDetails(); |
|
214 BOstraceFunctionExit0(DUMMY_DEVLIST); |
|
215 } |
|
216 |
|
217 void BtcpuiDeviceView::handleDeviceSettingsChange(bool status) |
|
218 { |
|
219 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
248 mDeviceSetting->setVisible(status); |
220 mDeviceSetting->setVisible(status); |
249 } |
221 mDeviceSetting->setStretched(true); |
250 |
222 BOstraceFunctionExit0(DUMMY_DEVLIST); |
251 void BtCpUiDeviceView::handleDeviceSetting() |
223 } |
252 { |
224 |
|
225 void BtcpuiDeviceView::handleDeviceSetting() |
|
226 { |
|
227 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
253 if(mDeviceDetail) { |
228 if(mDeviceDetail) { |
254 mDeviceDetail->loadDeviceDetailsView(); |
229 mDeviceDetail->loadDeviceDetailsView(); |
255 } |
230 } |
256 } |
231 BOstraceFunctionExit0(DUMMY_DEVLIST); |
257 |
232 } |
258 void BtCpUiDeviceView::deactivateView() |
233 |
259 { |
|
260 } |
|
261 |
234 |
262 // called due to real orientation change event coming from main window |
235 // called due to real orientation change event coming from main window |
263 void BtCpUiDeviceView::changeOrientation( Qt::Orientation orientation ) |
236 void BtcpuiDeviceView::changeOrientation( Qt::Orientation orientation ) |
264 { |
237 { |
|
238 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
265 bool ok = false; |
239 bool ok = false; |
266 mOrientation = orientation; |
240 int majorRole = (mDeviceModel->data(mDeviceIndex,BtDeviceModel::MajorPropertyRole)).toInt(); |
267 if( orientation == Qt::Vertical ) { |
241 if( orientation == Qt::Vertical ) { |
268 // load "portrait" section |
242 // load "portrait" section |
269 mLoader->load( BTUI_DEVICEVIEW_DOCML, "portrait", &ok ); |
243 mLoader->load( BTUI_DEVICEVIEW_DOCML, "portrait", &ok ); |
270 BTUI_ASSERT_X( ok, "bt-device-view", "Invalid docml file: portrait section problem" ); |
244 BTUI_ASSERT_X( ok, "bt-device-view", "Invalid docml file: portrait section problem" ); |
271 } else { |
245 } else { |
272 // load "landscape" section |
246 // load "landscape" section |
273 mLoader->load( BTUI_DEVICEVIEW_DOCML, "landscape", &ok ); |
247 //mLoader->load( BTUI_DEVICEVIEW_DOCML, "landscape", &ok ); |
274 BTUI_ASSERT_X( ok, "bt-device-view", "Invalid docml file: landscape section problem" ); |
248 //BTUI_ASSERT_X( ok, "bt-device-view", "Invalid docml file: landscape section problem" ); |
275 } |
249 if (majorRole & BtuiDevProperty::Connectable ) { |
276 } |
250 mLoader->load( BTUI_DEVICEVIEW_DOCML, "landscape", &ok ); |
277 |
251 BTUI_ASSERT_X( ok, "bt-device-view", "Invalid docml file: landscape section problem" ); |
278 void BtCpUiDeviceView::clearViewData() |
252 } |
279 { |
253 else{ |
|
254 mLoader->load( BTUI_DEVICEVIEW_DOCML, "landscape2", &ok ); |
|
255 BTUI_ASSERT_X( ok, "bt-device-view", "Invalid docml file: landscape2 section problem" ); |
|
256 } |
|
257 } |
|
258 setTextAndVisibilityOfButtons(majorRole); |
|
259 BOstraceFunctionExit0(DUMMY_DEVLIST); |
|
260 } |
|
261 |
|
262 void BtcpuiDeviceView::clearViewData() |
|
263 { |
|
264 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
280 mDeviceIcon->clear(); |
265 mDeviceIcon->clear(); |
281 mDeviceCategory->clear(); |
266 mDeviceCategory->clear(); |
282 mDeviceStatus->clear(); |
267 mDeviceStatus->clear(); |
283 mConnectable = false; |
268 BOstraceFunctionExit0(DUMMY_DEVLIST); |
284 /* |
269 } |
285 mPairedStatus = false; |
270 |
286 mConnectedStatus = false; |
271 void BtcpuiDeviceView::updateDeviceData() |
287 mTrustedStatus = false; |
272 { |
288 mBlockedStatus = false; |
273 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
289 |
|
290 mConnectable = false; |
|
291 */ |
|
292 } |
|
293 |
|
294 void BtCpUiDeviceView::updateDeviceData() |
|
295 { |
|
296 clearViewData(); |
274 clearViewData(); |
297 //Get the QModelIndex of the device using the device BDAddres |
275 //Get the QModelIndex of the device using the device BDAddress |
298 QModelIndex start = mDeviceModel->index(0,0); |
276 QModelIndex start = mDeviceModel->index(0,0); |
299 QModelIndexList indexList = mDeviceModel->match(start,BtDeviceModel::ReadableBdaddrRole, mDeviceBdAddr); |
277 QModelIndexList indexList = mDeviceModel->match(start,BtDeviceModel::ReadableBdaddrRole, mDeviceBdAddr); |
300 mDeviceIndex = indexList.at(0); |
278 mDeviceIndex = indexList.at(0); |
301 |
279 |
302 //populate device view with device data fetched from UiModel |
280 //populate device view with device data fetched from UiModel |
308 |
286 |
309 int majorRole = (mDeviceModel->data(mDeviceIndex,BtDeviceModel::MajorPropertyRole)).toInt(); |
287 int majorRole = (mDeviceModel->data(mDeviceIndex,BtDeviceModel::MajorPropertyRole)).toInt(); |
310 |
288 |
311 setDeviceCategory(cod, majorRole); |
289 setDeviceCategory(cod, majorRole); |
312 setDeviceStatus(majorRole); |
290 setDeviceStatus(majorRole); |
313 setTextAndVisibilityOfButtons(); |
291 setTextAndVisibilityOfButtons(majorRole); |
314 } |
292 BOstraceFunctionExit0(DUMMY_DEVLIST); |
315 |
293 } |
316 void BtCpUiDeviceView::setDeviceCategory(int cod,int majorRole) |
294 |
317 { |
295 void BtcpuiDeviceView::setDeviceCategory(int cod,int majorRole) |
|
296 { |
|
297 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
318 mDeviceCategory->setPlainText( getDeviceTypeString( cod )); |
298 mDeviceCategory->setPlainText( getDeviceTypeString( cod )); |
319 HbIcon icon = |
299 HbIcon icon = |
320 getBadgedDeviceTypeIcon(cod, majorRole, |
300 getBadgedDeviceTypeIcon(cod, majorRole, |
321 BtuiBottomLeft | BtuiBottomRight | BtuiTopLeft | BtuiTopRight ); |
301 BtuiBottomLeft | BtuiBottomRight | BtuiTopLeft | BtuiTopRight ); |
322 mDeviceIcon->setIcon(icon); |
302 mDeviceIcon->setIcon(icon); |
323 |
303 BOstraceFunctionExit0(DUMMY_DEVLIST); |
324 if (majorRole & BtuiDevProperty::Connectable ) { |
304 } |
325 mConnectable = true; |
305 |
326 } |
306 void BtcpuiDeviceView::setDeviceStatus(int majorRole) |
327 } |
307 { |
328 |
308 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
329 void BtCpUiDeviceView::setDeviceStatus(int majorRole) |
|
330 { |
|
331 QString deviceStatus; |
309 QString deviceStatus; |
332 |
310 // Avoid unnecessary actions: |
333 updateStatusVariables(majorRole); // should we use bitmap instead?? |
311 // The device model has been modified and need to be reflected |
334 |
312 // in the UI however if we don't disable the signal before the UI update |
|
313 // the connectionPreferenceChanged function will be called and trigger |
|
314 // unnecessary update of the model by the device view. |
|
315 mConnectionDataForm->removeConnection(mCombobox, SIGNAL(currentIndexChanged (int)), |
|
316 this, SLOT(connectionPreferenceChanged(int))); |
335 if (majorRole & BtuiDevProperty::Bonded && |
317 if (majorRole & BtuiDevProperty::Bonded && |
336 majorRole & BtuiDevProperty::Trusted && |
318 majorRole & BtuiDevProperty::Trusted && |
337 majorRole & BtuiDevProperty::Connected ) { |
319 majorRole & BtuiDevProperty::Connected ) { |
338 mDeviceStatus->setPlainText(hbTrId("txt_bt_info_paired_trused_connected")); |
320 mDeviceStatus->setPlainText(hbTrId("txt_bt_info_paired_trused_connected")); |
|
321 mCombobox->setContentWidgetData("currentIndex", ConnectionAutomatic ); |
|
322 mComboboxIndex = ConnectionAutomatic; |
339 } |
323 } |
340 else if (majorRole & BtuiDevProperty::Bonded && |
324 else if (majorRole & BtuiDevProperty::Bonded && |
341 majorRole & BtuiDevProperty::Connected ) { |
325 majorRole & BtuiDevProperty::Connected ) { |
342 mDeviceStatus->setPlainText(hbTrId("txt_bt_info_paired_connected")); |
326 mDeviceStatus->setPlainText(hbTrId("txt_bt_info_paired_connected")); |
|
327 mCombobox->setContentWidgetData("currentIndex", ConnectionAlwaysAsk ); |
|
328 mComboboxIndex = ConnectionAlwaysAsk; |
343 } |
329 } |
344 else if (majorRole & BtuiDevProperty::Bonded && |
330 else if (majorRole & BtuiDevProperty::Bonded && |
345 majorRole & BtuiDevProperty::Trusted ) { |
331 majorRole & BtuiDevProperty::Trusted ) { |
346 mDeviceStatus->setPlainText(hbTrId("txt_bt_info_paired_trusted")); |
332 mDeviceStatus->setPlainText(hbTrId("txt_bt_info_paired_trusted")); |
|
333 mCombobox->setContentWidgetData("currentIndex", ConnectionAutomatic ); |
|
334 mComboboxIndex = ConnectionAutomatic; |
|
335 } |
|
336 else if (majorRole & BtuiDevProperty::Connected && |
|
337 majorRole & BtuiDevProperty::Trusted ) { |
|
338 mDeviceStatus->setPlainText(hbTrId("Trusted, Connected")); // ToDo: missing textId! |
|
339 mCombobox->setContentWidgetData("currentIndex", ConnectionAutomatic ); |
|
340 mComboboxIndex = ConnectionAutomatic; |
|
341 } |
|
342 else if (majorRole & BtuiDevProperty::Trusted ) { |
|
343 mDeviceStatus->setPlainText(hbTrId("Trusted")); // ToDo: missing textId! |
|
344 mCombobox->setContentWidgetData("currentIndex", ConnectionAutomatic ); |
|
345 mComboboxIndex = ConnectionAutomatic; |
347 } |
346 } |
348 else if (majorRole & BtuiDevProperty::Bonded) { |
347 else if (majorRole & BtuiDevProperty::Bonded) { |
349 mDeviceStatus->setPlainText(hbTrId("txt_bt_info_paired")); |
348 mDeviceStatus->setPlainText(hbTrId("txt_bt_info_paired")); |
|
349 mCombobox->setContentWidgetData("currentIndex", ConnectionAlwaysAsk ); |
|
350 mComboboxIndex = ConnectionAlwaysAsk; |
350 } |
351 } |
351 else if (majorRole & BtuiDevProperty::Connected) { |
352 else if (majorRole & BtuiDevProperty::Connected) { |
352 mDeviceStatus->setPlainText(hbTrId("txt_bt_info_connected")); |
353 mDeviceStatus->setPlainText(hbTrId("txt_bt_info_connected")); |
|
354 mCombobox->setContentWidgetData("currentIndex", ConnectionAlwaysAsk ); |
|
355 mComboboxIndex = ConnectionAlwaysAsk; |
353 } |
356 } |
354 else if (majorRole & BtuiDevProperty::Blocked) { |
357 else if (majorRole & BtuiDevProperty::Blocked) { |
355 mDeviceStatus->setPlainText(hbTrId("txt_bt_info_blocked")); |
358 mDeviceStatus->setPlainText(hbTrId("txt_bt_info_blocked")); |
|
359 mCombobox->setContentWidgetData("currentIndex", ConnectionBlocked ); |
|
360 mComboboxIndex = ConnectionBlocked; |
356 } |
361 } |
357 else { |
362 else { |
358 // device not paired, connected, trusted or blocked. is this ok? |
363 // device not paired, connected, trusted or blocked. |
359 } |
364 mDeviceStatus->setPlainText(" "); |
360 |
365 mCombobox->setContentWidgetData("currentIndex", ConnectionAlwaysAsk ); |
361 } |
366 mComboboxIndex = ConnectionAlwaysAsk; |
362 |
367 } |
363 void BtCpUiDeviceView::setConnectionCombobox(){ |
368 mConnectionDataForm->addConnection(mCombobox, SIGNAL(currentIndexChanged (int)), |
364 |
369 this, SLOT(connectionPreferenceChanged(int))); |
|
370 BOstraceFunctionExit0(DUMMY_DEVLIST); |
|
371 } |
|
372 |
|
373 void BtcpuiDeviceView::setConnectionCombobox() |
|
374 { |
|
375 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
365 //create a model class |
376 //create a model class |
366 |
377 mCombobox = mConnectionComboboxModel->appendDataFormItem( |
367 mConnectionComboboxModel->appendDataFormItem( |
378 HbDataFormModelItem::ComboBoxItem, hbTrId("txt_bt_setlabel_connection"), |
368 HbDataFormModelItem::ComboBoxItem, QString("Connection"), mConnectionComboboxModel->invisibleRootItem()); |
379 mConnectionComboboxModel->invisibleRootItem()); |
369 |
380 |
|
381 QStringList connList; |
|
382 connList.append( hbTrId("txt_bt_setlabel_bluetooth_val_automatic") ); |
|
383 connList.append( hbTrId("txt_bt_setlabel_bluetooth_val_always_ask") ); |
|
384 connList.append( hbTrId("txt_bt_setlabel_bluetooth_val_blocked") ); |
|
385 mCombobox->setContentWidgetData( "items", connList ); |
|
386 |
370 //set the model to the view, once model and data class are created |
387 //set the model to the view, once model and data class are created |
371 mConnectionCombobox->setModel(mConnectionComboboxModel); |
388 mConnectionDataForm->setModel(mConnectionComboboxModel); |
372 |
389 mConnectionDataForm->addConnection(mCombobox, SIGNAL(currentIndexChanged (int)), |
373 |
390 this, SLOT(connectionPreferenceChanged(int))); |
374 |
391 BOstraceFunctionExit0(DUMMY_DEVLIST); |
375 } |
392 } |
376 |
393 |
377 |
394 void BtcpuiDeviceView::setTextAndVisibilityOfButtons(int majorProperty) |
378 /*! |
395 { |
379 * instead of using separate boolean variables we could use bitmap in single variable |
396 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
380 */ |
397 disconnect(mPair_Unpair, 0, 0, 0); |
381 void BtCpUiDeviceView::updateStatusVariables(int majorRole) |
398 disconnect(mConnect_Disconnect, 0, 0, 0); |
382 { |
399 |
383 mPreviousConnectedStatus = mConnectedStatus; |
400 if (majorProperty & BtuiDevProperty::Blocked) { |
384 |
401 mPair_Unpair->setVisible(false); |
385 if (majorRole & BtuiDevProperty::Trusted ) { |
402 mConnect_Disconnect->setVisible(false); |
386 mTrustedStatus = true; |
403 mDeviceSetting->setVisible(false); |
387 } |
404 return; |
|
405 } |
|
406 bool ret; |
|
407 mPair_Unpair->setVisible(true); |
|
408 mPair_Unpair->setStretched(true); |
|
409 if (majorProperty & BtuiDevProperty::Bonded) { |
|
410 updateButton(mPair_Unpair, "qtg_mono_bt_unpair", hbTrId("txt_bt_button_unpair")); |
|
411 ret = connect(mPair_Unpair, SIGNAL(clicked()), this, SLOT(unpairDevice())); |
|
412 BTUI_ASSERT_X( ret, "BtcpuiDeviceView::BtcpuiDeviceView", "can't connect unpair button" ); |
|
413 } |
388 else { |
414 else { |
389 mTrustedStatus = false; |
415 updateButton(mPair_Unpair, "qtg_mono_bt_pair", hbTrId("txt_bt_button_pair")); |
390 } |
416 ret = connect(mPair_Unpair, SIGNAL(clicked()), this, SLOT(pairDevice())); |
391 if (majorRole & BtuiDevProperty::Bonded) { |
417 BTUI_ASSERT_X( ret, "BtcpuiDeviceView::BtcpuiDeviceView", "can't connect pair button" ); |
392 mPairedStatus = true; |
418 } |
393 } |
419 |
394 else { |
420 if (majorProperty & BtuiDevProperty::Connectable ) { |
395 mPairedStatus = false; |
|
396 } |
|
397 if (majorRole & BtuiDevProperty::Connected) { |
|
398 mConnectedStatus = true; |
|
399 if (!mPreviousConnectedStatus){ |
|
400 //Loading device detail plugins after successfull connection. |
|
401 loadDeviceDetails(); |
|
402 } |
|
403 } |
|
404 else { |
|
405 mConnectedStatus = false; |
|
406 } |
|
407 if (majorRole & BtuiDevProperty::Blocked) { |
|
408 mBlockedStatus = true; |
|
409 } |
|
410 else { |
|
411 mBlockedStatus = false; |
|
412 } |
|
413 } |
|
414 |
|
415 void BtCpUiDeviceView::setTextAndVisibilityOfButtons() |
|
416 { |
|
417 mPair_Unpair->setStretched(true); |
|
418 if (mPairedStatus) |
|
419 { |
|
420 HbIcon icon("qtg_mono_bt_unpair"); |
|
421 icon.setIconName("qtg_mono_bt_unpair"); |
|
422 mPair_Unpair->setIcon(icon); |
|
423 mPair_Unpair->setText(hbTrId("txt_bt_button_unpair")); |
|
424 |
|
425 } |
|
426 else |
|
427 { |
|
428 HbIcon icon("qtg_mono_bt_pair"); |
|
429 icon.setIconName("qtg_mono_bt_pair"); |
|
430 mPair_Unpair->setIcon(icon); |
|
431 mPair_Unpair->setText(hbTrId("txt_bt_button_pair")); |
|
432 } |
|
433 |
|
434 if (mConnectable) |
|
435 { |
|
436 mConnect_Disconnect->setVisible(true); |
421 mConnect_Disconnect->setVisible(true); |
437 mConnect_Disconnect->setStretched(true); |
422 mConnect_Disconnect->setStretched(true); |
438 if (mConnectedStatus) |
423 if (majorProperty & BtuiDevProperty::Connected) { |
439 { |
424 updateButton(mConnect_Disconnect, "qtg_mono_speaker_off", hbTrId("txt_bt_button_disconnect")); |
440 HbIcon icon("qtg_mono_speaker_off"); |
425 ret = connect(mConnect_Disconnect, SIGNAL(clicked()), this, SLOT(disconnectDevice())); |
441 icon.setIconName("qtg_mono_speaker_off"); |
426 BTUI_ASSERT_X( ret, "BtcpuiDeviceView::BtcpuiDeviceView", "can't connect disconnect button" ); |
442 mConnect_Disconnect->setIcon(icon); |
427 } |
443 mConnect_Disconnect->setText(hbTrId("txt_bt_button_disconnect")); |
428 else { |
444 } |
429 updateButton(mConnect_Disconnect, "qtg_mono_speaker", hbTrId("txt_bt_button_connect")); |
445 else |
430 ret = connect(mConnect_Disconnect, SIGNAL(clicked()), this, SLOT(connectDevice())); |
446 { |
431 BTUI_ASSERT_X( ret, "BtcpuiDeviceView::BtcpuiDeviceView", "can't connect connect button" ); |
447 HbIcon icon("qtg_mono_speaker"); |
432 } |
448 icon.setIconName("qtg_mono_speaker"); |
433 } |
449 mConnect_Disconnect->setIcon(icon); |
434 else { |
450 mConnect_Disconnect->setText(hbTrId("txt_bt_button_connect")); |
|
451 } |
|
452 |
|
453 } |
|
454 else |
|
455 { |
|
456 //it is not possible to connect, set the button invisible |
435 //it is not possible to connect, set the button invisible |
457 mConnect_Disconnect->setVisible(false); |
436 mConnect_Disconnect->setVisible(false); |
458 } |
437 } |
459 |
438 BOstraceFunctionExit0(DUMMY_DEVLIST); |
460 } |
439 } |
461 |
440 |
462 |
441 void BtcpuiDeviceView::connectionPreferenceChanged(int index) |
463 void BtCpUiDeviceView::pairUnpair() |
442 { |
464 { |
443 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
465 if (mPairedStatus) |
444 if ((index >= ConnectionAutomatic)&&(index != mComboboxIndex)) { |
466 { |
445 switch ( index ) |
467 //if the device is paired, call unpairDevice() when the button is tabbed |
446 { |
468 unpairDevice(); |
447 case ConnectionAutomatic: |
469 } |
448 setDeviceAuthorised(); |
470 else |
449 break; |
471 { |
450 case ConnectionAlwaysAsk: |
472 //if the device is unpaired, call pairDevice() when the button is tabbed |
451 setDeviceAlwaysAsk(); |
473 pairDevice(); |
452 break; |
474 |
453 case ConnectionBlocked: |
475 } |
454 setDeviceBlocked(); |
476 |
455 break; |
477 |
456 default: |
478 } |
457 BTUI_ASSERT_X( 0, "BtCpUiDeviceView::connectionPreferenceChanged()", "wrong index" ); |
479 |
458 } |
480 void BtCpUiDeviceView::connectDisconnect() |
459 } |
481 { |
460 BOstraceFunctionExit0(DUMMY_DEVLIST); |
482 if (mConnectedStatus) |
461 } |
483 { |
462 |
484 //if the device is connected, call disconnectDevice() when the button is tabbed |
463 void BtcpuiDeviceView::setDeviceAuthorised() |
485 disconnectDevice(); |
464 { |
486 } |
465 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
487 else |
466 if (!mAbstractDelegate){ |
488 { |
467 //if there is no other delegate running |
489 //if the device is disconnected, call connectDevice() when the button is tabbed |
468 QList<QVariant>list; |
490 connectDevice(); |
469 list.append(mDeviceBdAddr); |
491 |
470 |
492 } |
471 if (mComboboxIndex != ConnectionAutomatic) { // transition: (always ask|blocked) --> automatic |
493 } |
472 // unblock the device |
494 |
473 list.append(QVariant(BtAuthorize)); |
495 void BtCpUiDeviceView::pairDevice() |
474 } |
496 { |
475 else { |
|
476 // do nothing, state is already correct |
|
477 return; |
|
478 } |
|
479 mAbstractDelegate = BtDelegateFactory::newDelegate( |
|
480 BtDelegate::TrustDevice, mSettingModel, mDeviceModel); |
|
481 connect( mAbstractDelegate, SIGNAL(delegateCompleted(int,BtAbstractDelegate*)), |
|
482 this, SLOT(unpairDelegateCompleted(int)) ); |
|
483 mAbstractDelegate->exec(QVariant(list)); |
|
484 } |
|
485 BOstraceFunctionExit0(DUMMY_DEVLIST); |
|
486 } |
|
487 |
|
488 void BtcpuiDeviceView::setDeviceAlwaysAsk() |
|
489 { |
|
490 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
|
491 if (!mAbstractDelegate){ |
|
492 //if there is no other delegate running |
|
493 QList<QVariant>list; |
|
494 BtDelegate::EditorType type; |
|
495 list.append(mDeviceBdAddr); |
|
496 if (mComboboxIndex == ConnectionAutomatic) { // transition: automatic --> always ask |
|
497 // unauthorize the device |
|
498 list.append(QVariant(BtUnauthorize)); |
|
499 type = BtDelegate::UntrustDevice; |
|
500 } |
|
501 else if (mComboboxIndex == ConnectionBlocked) { // transition: blocked --> always ask |
|
502 // unblock the device |
|
503 list.append(QVariant(BtUnblock)); |
|
504 type = BtDelegate::UnblockDevice; |
|
505 } |
|
506 else { |
|
507 // do nothing, state is already correct |
|
508 return; |
|
509 } |
|
510 |
|
511 mAbstractDelegate = BtDelegateFactory::newDelegate( |
|
512 type, mSettingModel, mDeviceModel); |
|
513 connect( mAbstractDelegate, SIGNAL(delegateCompleted(int,BtAbstractDelegate*)), |
|
514 this, SLOT(unpairDelegateCompleted(int)) ); |
|
515 mAbstractDelegate->exec(QVariant(list)); |
|
516 } |
|
517 BOstraceFunctionExit0(DUMMY_DEVLIST); |
|
518 } |
|
519 |
|
520 void BtcpuiDeviceView::setDeviceBlocked() |
|
521 { |
|
522 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
|
523 //simple version of the delegate |
|
524 //TODO: disconnect after blocking |
|
525 if (!mAbstractDelegate){ |
|
526 //if there is no other delegate running |
|
527 QList<QVariant> list; |
|
528 list.append(mDeviceBdAddr); |
|
529 |
|
530 if ( mComboboxIndex == ConnectionAutomatic || |
|
531 mComboboxIndex == ConnectionAlwaysAsk ) { // transition: automatic|always ask --> blocked |
|
532 // to unauthorized the device |
|
533 list.append(QVariant(BtBlock)); |
|
534 } |
|
535 else{ |
|
536 // do nothing, state is already correct |
|
537 return; |
|
538 } |
|
539 mAbstractDelegate = BtDelegateFactory::newDelegate( |
|
540 BtDelegate::BlockDevice, mSettingModel, mDeviceModel); |
|
541 connect( mAbstractDelegate, SIGNAL(delegateCompleted(int,BtAbstractDelegate*)), |
|
542 this, SLOT(unpairDelegateCompleted(int)) ); |
|
543 mAbstractDelegate->exec(QVariant(list)); |
|
544 } |
|
545 BOstraceFunctionExit0(DUMMY_DEVLIST); |
|
546 } |
|
547 |
|
548 void BtcpuiDeviceView::pairDevice() |
|
549 { |
|
550 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
497 if (!mAbstractDelegate)//if there is no other delegate running |
551 if (!mAbstractDelegate)//if there is no other delegate running |
498 { |
552 { |
499 QVariant params; |
553 QVariant params; |
500 params.setValue(mDeviceIndex); |
554 params.setValue(mDeviceIndex); |
501 mAbstractDelegate = BtDelegateFactory::newDelegate( |
555 mAbstractDelegate = BtDelegateFactory::newDelegate( |
502 BtDelegate::Pair, mSettingModel, mDeviceModel); |
556 BtDelegate::PairDevice, mSettingModel, mDeviceModel); |
503 connect( mAbstractDelegate, SIGNAL(commandCompleted(int)), this, SLOT(pairDelegateCompleted(int)) ); |
557 connect( mAbstractDelegate, SIGNAL(delegateCompleted(int,BtAbstractDelegate*)), this, SLOT(pairDelegateCompleted(int)) ); |
504 mAbstractDelegate->exec(params); |
558 mAbstractDelegate->exec(params); |
505 } |
559 } |
506 |
560 BOstraceFunctionExit0(DUMMY_DEVLIST); |
507 } |
561 } |
508 |
562 |
509 void BtCpUiDeviceView::pairDelegateCompleted(int status) |
563 void BtcpuiDeviceView::pairDelegateCompleted(int status) |
510 { |
564 { |
|
565 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
511 Q_UNUSED(status); |
566 Q_UNUSED(status); |
512 //TODO: handle the error here |
567 //TODO: handle the error here |
513 if (mAbstractDelegate) |
568 if (mAbstractDelegate) |
514 { |
569 { |
515 disconnect(mAbstractDelegate); |
|
516 delete mAbstractDelegate; |
570 delete mAbstractDelegate; |
517 mAbstractDelegate = 0; |
571 mAbstractDelegate = 0; |
518 } |
572 } |
519 } |
573 BOstraceFunctionExit0(DUMMY_DEVLIST); |
520 |
574 } |
521 void BtCpUiDeviceView::unpairDevice() |
575 |
522 { |
576 void BtcpuiDeviceView::unpairDevice() |
|
577 { |
|
578 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
523 if (!mAbstractDelegate)//if there is no other delegate running |
579 if (!mAbstractDelegate)//if there is no other delegate running |
524 { |
580 { |
525 QVariant params; |
581 QList<QVariant>list; |
526 params.setValue(mDeviceIndex); |
582 list.append(mDeviceBdAddr); |
|
583 list.append(QVariant(BtUnpair)); |
|
584 |
527 mAbstractDelegate = BtDelegateFactory::newDelegate( |
585 mAbstractDelegate = BtDelegateFactory::newDelegate( |
528 BtDelegate::Unpair, mSettingModel, mDeviceModel); |
586 BtDelegate::UnpairDevice, mSettingModel, mDeviceModel); |
529 connect( mAbstractDelegate, SIGNAL(commandCompleted(int)), this, SLOT(unpairDelegateCompleted(int)) ); |
587 connect( mAbstractDelegate, SIGNAL(delegateCompleted(int,BtAbstractDelegate*)), this, |
530 mAbstractDelegate->exec(params); |
588 SLOT(unpairDelegateCompleted(int)) ); |
531 } |
589 mAbstractDelegate->exec(QVariant(list)); |
532 |
590 } |
533 |
591 BOstraceFunctionExit0(DUMMY_DEVLIST); |
534 } |
592 } |
535 |
593 |
536 void BtCpUiDeviceView::unpairDelegateCompleted(int status) |
594 void BtcpuiDeviceView::unpairDelegateCompleted(int status) |
537 { |
595 { |
|
596 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
538 Q_UNUSED(status); |
597 Q_UNUSED(status); |
539 //TODO: handle the error here |
598 //TODO: handle the error here |
540 if (mAbstractDelegate) |
599 if (mAbstractDelegate) |
541 { |
600 { |
542 disconnect(mAbstractDelegate); |
|
543 delete mAbstractDelegate; |
601 delete mAbstractDelegate; |
544 mAbstractDelegate = 0; |
602 mAbstractDelegate = 0; |
545 } |
603 } |
546 } |
604 BOstraceFunctionExit0(DUMMY_DEVLIST); |
547 |
605 } |
548 void BtCpUiDeviceView::connectDevice() |
606 |
549 { |
607 void BtcpuiDeviceView::connectDevice() |
550 |
608 { |
551 |
609 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
552 if (!mAbstractDelegate)//if there is no other delegate running |
610 |
553 { |
611 if (!mAbstractDelegate) { //if there is no other delegate running |
554 QVariant params; |
612 QVariant params; |
555 params.setValue(mDeviceIndex); |
613 params.setValue(mDeviceIndex); |
556 mAbstractDelegate = BtDelegateFactory::newDelegate( |
614 mAbstractDelegate = BtDelegateFactory::newDelegate( |
557 BtDelegate::Connect, mSettingModel, mDeviceModel); |
615 BtDelegate::ConnectService, mSettingModel, mDeviceModel); |
558 connect( mAbstractDelegate, SIGNAL(commandCompleted(int)), this, SLOT(connectDelegateCompleted(int)) ); |
616 connect( mAbstractDelegate, SIGNAL(delegateCompleted(int,BtAbstractDelegate*)), this, SLOT(connectDelegateCompleted(int)) ); |
559 mAbstractDelegate->exec(params); |
617 mAbstractDelegate->exec(params); |
560 } |
618 } |
561 |
619 BOstraceFunctionExit0(DUMMY_DEVLIST); |
562 |
620 } |
563 } |
621 |
564 |
622 void BtcpuiDeviceView::connectDelegateCompleted(int status) |
565 void BtCpUiDeviceView::connectDelegateCompleted(int status) |
623 { |
566 { |
624 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
|
625 Q_UNUSED(status); |
|
626 if (mAbstractDelegate) { |
|
627 delete mAbstractDelegate; |
|
628 mAbstractDelegate = 0; |
|
629 } |
|
630 BOstraceFunctionExit0(DUMMY_DEVLIST); |
|
631 } |
|
632 |
|
633 void BtcpuiDeviceView::disconnectDevice() |
|
634 { |
|
635 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
|
636 if (!mAbstractDelegate) { //if there is no other delegate running |
|
637 QList<QVariant>list; |
|
638 list.append(QVariant(ServiceLevel)); |
|
639 list.append(mDeviceBdAddr); |
|
640 |
|
641 mAbstractDelegate = BtDelegateFactory::newDelegate( |
|
642 BtDelegate::DisconnectService, mSettingModel, mDeviceModel); |
|
643 // todo: check return value of connect |
|
644 connect( mAbstractDelegate, SIGNAL(delegateCompleted(int,BtAbstractDelegate*)), this, SLOT(disconnectDelegateCompleted(int)) ); |
|
645 mAbstractDelegate->exec(QVariant(list)); |
|
646 } |
|
647 BOstraceFunctionExit0(DUMMY_DEVLIST); |
|
648 } |
|
649 |
|
650 void BtcpuiDeviceView::disconnectDelegateCompleted(int status) |
|
651 { |
|
652 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
567 Q_UNUSED(status); |
653 Q_UNUSED(status); |
568 if (mAbstractDelegate) |
654 if (mAbstractDelegate) |
569 { |
655 { |
570 disconnect(mAbstractDelegate); |
656 delete mAbstractDelegate; |
|
657 mAbstractDelegate = 0; |
|
658 } |
|
659 BOstraceFunctionExit0(DUMMY_DEVLIST); |
|
660 } |
|
661 |
|
662 void BtcpuiDeviceView::setPrevBtDeviceName() |
|
663 { |
|
664 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
|
665 QString deviceName = (mDeviceModel->data(mDeviceIndex, |
|
666 BtDeviceModel::NameAliasRole)).toString(); |
|
667 mDeviceName->setText(deviceName); |
|
668 BOstraceFunctionExit0(DUMMY_DEVLIST); |
|
669 } |
|
670 |
|
671 void BtcpuiDeviceView::changeBtDeviceName() |
|
672 { |
|
673 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
|
674 if (!mAbstractDelegate){ |
|
675 //if there is no other delegate running |
|
676 QList<QVariant>list; |
|
677 |
|
678 QVariant index; |
|
679 index.setValue(mDeviceIndex); |
|
680 |
|
681 QVariant name; |
|
682 name.setValue(mDeviceName->text()); |
|
683 |
|
684 list.append(index); |
|
685 list.append(name); |
|
686 |
|
687 QVariant params; |
|
688 params.setValue(list); |
|
689 |
|
690 mAbstractDelegate = BtDelegateFactory::newDelegate( |
|
691 BtDelegate::ChangeDeviceFriendlyName, mSettingModel, mDeviceModel); |
|
692 connect( mAbstractDelegate, SIGNAL(delegateCompleted(int,BtAbstractDelegate*)), |
|
693 this, SLOT(changeDevNameDelegateCompleted(int, QVariant)) ); |
|
694 mAbstractDelegate->exec(params); |
|
695 } |
|
696 else { |
|
697 setPrevBtDeviceName(); |
|
698 } |
|
699 BOstraceFunctionExit0(DUMMY_DEVLIST); |
|
700 } |
|
701 |
|
702 void BtcpuiDeviceView::changeDevNameDelegateCompleted(int status) |
|
703 { |
|
704 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
|
705 if(KErrNone != status) { |
|
706 setPrevBtDeviceName(); |
|
707 } |
|
708 |
|
709 if (mAbstractDelegate){ |
571 delete mAbstractDelegate; |
710 delete mAbstractDelegate; |
572 mAbstractDelegate = 0; |
711 mAbstractDelegate = 0; |
573 } |
712 } |
574 } |
713 BOstraceFunctionExit0(DUMMY_DEVLIST); |
575 |
714 } |
576 void BtCpUiDeviceView::disconnectDevice() |
715 |
577 { |
716 void BtcpuiDeviceView::updateButton(HbPushButton *button, const QString &iconName, const QString &text) |
578 if (!mAbstractDelegate)//if there is no other delegate running |
717 { |
579 { |
718 HbIcon icon(iconName); |
580 |
719 icon.setIconName(iconName); |
581 |
720 button->setIcon(icon); |
582 DisconnectOption discoOpt = ServiceLevel; |
721 button->setText(text); |
583 |
722 } |
584 QList<QVariant>list; |
|
585 QVariant paramFirst; |
|
586 paramFirst.setValue(mDeviceIndex); |
|
587 |
|
588 QVariant paramSecond; |
|
589 paramSecond.setValue((int)discoOpt); |
|
590 |
|
591 list.append(paramFirst); |
|
592 list.append(paramSecond); |
|
593 |
|
594 QVariant params; |
|
595 params.setValue(list); |
|
596 |
|
597 |
|
598 //params.setValue(mDeviceIndex); |
|
599 mAbstractDelegate = BtDelegateFactory::newDelegate( |
|
600 BtDelegate::Disconnect, mSettingModel, mDeviceModel); |
|
601 connect( mAbstractDelegate, SIGNAL(commandCompleted(int)), this, SLOT(disconnectDelegateCompleted(int)) ); |
|
602 mAbstractDelegate->exec(params); |
|
603 } |
|
604 |
|
605 } |
|
606 |
|
607 void BtCpUiDeviceView::disconnectDelegateCompleted(int status) |
|
608 { |
|
609 Q_UNUSED(status); |
|
610 if (mAbstractDelegate) |
|
611 { |
|
612 disconnect(mAbstractDelegate); |
|
613 delete mAbstractDelegate; |
|
614 mAbstractDelegate = 0; |
|
615 } |
|
616 } |
|
617 |
|
618 void BtCpUiDeviceView::setPrevBtDeviceName() |
|
619 { |
|
620 QString deviceName = (mDeviceModel->data(mDeviceIndex, |
|
621 BtDeviceModel::NameAliasRole)).toString(); |
|
622 mDeviceName->setText(deviceName); |
|
623 } |
|
624 |
|
625 void BtCpUiDeviceView::changeBtDeviceName(){ |
|
626 if (!mAbstractDelegate)//if there is no other delegate running |
|
627 { |
|
628 QList<QVariant>list; |
|
629 |
|
630 QVariant index; |
|
631 index.setValue(mDeviceIndex); |
|
632 |
|
633 QVariant name; |
|
634 name.setValue(mDeviceName->text()); |
|
635 |
|
636 list.append(index); |
|
637 list.append(name); |
|
638 |
|
639 QVariant params; |
|
640 params.setValue(list); |
|
641 |
|
642 mAbstractDelegate = BtDelegateFactory::newDelegate( |
|
643 BtDelegate::RemoteDevName, mSettingModel, mDeviceModel); |
|
644 connect( mAbstractDelegate, SIGNAL(commandCompleted(int, QVariant)), this, SLOT(changeDevNameDelegateCompleted(int, QVariant)) ); |
|
645 mAbstractDelegate->exec(params); |
|
646 } |
|
647 else { |
|
648 setPrevBtDeviceName(); |
|
649 } |
|
650 |
|
651 } |
|
652 |
|
653 void BtCpUiDeviceView::changeDevNameDelegateCompleted(int status, QVariant param) |
|
654 { |
|
655 |
|
656 |
|
657 if(KErrNone == status) { |
|
658 mDeviceName->setText(param.toString()); |
|
659 } |
|
660 else { |
|
661 setPrevBtDeviceName(); |
|
662 } |
|
663 //TODO:Error handling has to be done. |
|
664 if (mAbstractDelegate) |
|
665 { |
|
666 disconnect(mAbstractDelegate); |
|
667 delete mAbstractDelegate; |
|
668 mAbstractDelegate = 0; |
|
669 } |
|
670 |
|
671 |
|
672 } |
|