19 #include "btuiviewutil.h" |
19 #include "btuiviewutil.h" |
20 #include <QtGui/QGraphicsLinearLayout> |
20 #include <QtGui/QGraphicsLinearLayout> |
21 #include <HbInstance> |
21 #include <HbInstance> |
22 #include <hbdocumentloader.h> |
22 #include <hbdocumentloader.h> |
23 #include <hbdataform.h> |
23 #include <hbdataform.h> |
|
24 #include <hbdataformmodel.h> |
|
25 #include <hbdataformmodelitem.h> |
24 #include <hbgroupbox.h> |
26 #include <hbgroupbox.h> |
25 #include <hbpushbutton.h> |
27 #include <hbpushbutton.h> |
26 #include <hblabel.h> |
28 #include <hblabel.h> |
27 #include <hbtextedit.h> |
29 #include <hbicon.h> |
|
30 #include <hblineedit.h> |
28 #include <hblistview.h> |
31 #include <hblistview.h> |
29 #include <hbmenu.h> |
32 #include <hbmenu.h> |
30 #include <qstring> |
33 #include <qstring> |
31 #include <qstringlist> |
34 #include <qstringlist> |
32 #include <qdebug> |
35 #include <qdebug> |
33 #include <bluetoothuitrace.h> |
36 #include <bluetoothuitrace.h> |
34 #include "btcpuimainview.h" |
37 #include "btcpuimainview.h" |
35 #include <btabstractdelegate.h> |
38 #include <btabstractdelegate.h> |
36 #include <btdelegatefactory.h> |
39 #include <btdelegatefactory.h> |
37 #include <QModelIndex> |
40 #include <QModelIndex> |
|
41 #include "btuiiconutil.h" |
|
42 #include "btuidevtypemap.h" |
38 |
43 |
39 // docml to load |
44 // docml to load |
40 const char* BTUI_DEVICEVIEW_DOCML = ":/docml/bt-device-view.docml"; |
45 const char* BTUI_DEVICEVIEW_DOCML = ":/docml/bt-device-view.docml"; |
41 |
46 |
42 |
47 |
43 BtCpUiDeviceView::BtCpUiDeviceView( |
48 BtCpUiDeviceView::BtCpUiDeviceView( |
44 BtSettingModel &settingModel, |
49 BtSettingModel &settingModel, |
45 BtDeviceModel &deviceModel, |
50 BtDeviceModel &deviceModel, |
46 QGraphicsItem *parent) : |
51 QGraphicsItem *parent) : |
47 BtCpUiBaseView(settingModel,deviceModel,parent), |
52 BtCpUiBaseView(settingModel,deviceModel,parent), |
48 mPairStatus(false), mConnectStatus(false), mConnectable(false), mAbstractDelegate(0) |
53 mPairedStatus(false), mConnectedStatus(false), mTrustedStatus(false), mBlockedStatus(false), |
|
54 mConnectable(false), mAbstractDelegate(0) |
49 { |
55 { |
50 mDeviceIndex = QModelIndex();//is it needed to initialize mIndex??? |
56 mDeviceIndex = QModelIndex();//is it needed to initialize mIndex??? |
51 |
57 |
52 mMainView = (BtCpUiMainView *) parent; |
58 mMainView = (BtCpUiMainView *) parent; |
53 |
59 |
61 // Create view for the application. |
67 // Create view for the application. |
62 // Set the name for the view. The name should be same as the view's |
68 // Set the name for the view. The name should be same as the view's |
63 // name in docml. |
69 // name in docml. |
64 setObjectName("bt_device_view"); |
70 setObjectName("bt_device_view"); |
65 |
71 |
|
72 mLoader = new HbDocumentLoader(); |
|
73 // Pass the view to documentloader. Document loader uses this view |
|
74 // when docml is parsed, instead of creating new view. |
66 QObjectList objectList; |
75 QObjectList objectList; |
67 objectList.append(this); |
76 objectList.append(this); |
68 // Pass the view to documentloader. Document loader uses this view |
|
69 // when docml is parsed, instead of creating new view. |
|
70 mLoader = new HbDocumentLoader(); |
|
71 mLoader->setObjectTree(objectList); |
77 mLoader->setObjectTree(objectList); |
72 |
78 |
73 bool ret = false; |
79 bool ret = false; |
74 |
80 |
75 bool ok = false; |
81 bool ok = false; |
76 mLoader->load( BTUI_DEVICEVIEW_DOCML, &ok ); |
82 mLoader->load( BTUI_DEVICEVIEW_DOCML, &ok ); |
77 // Exit if the file format is invalid |
83 // Exit if the file format is invalid |
78 BTUI_ASSERT_X( ok, "bt-device-view", "Invalid docml file" ); |
84 BTUI_ASSERT_X( ok, "bt-device-view", "Invalid docml file" ); |
79 |
85 |
80 // Set title for the control panel |
86 mOrientation = mMainWindow->orientation(); |
81 // ToDo: check if deprecated API |
87 |
82 setTitle("Control Panel"); |
88 if (mOrientation == Qt::Horizontal) { |
83 |
89 mLoader->load(BTUI_DEVICEVIEW_DOCML, "landscape", &ok); |
|
90 BTUI_ASSERT_X( ok, "bt-device-view", "Invalid docml file: landscape section problem" ); |
|
91 } |
|
92 else { |
|
93 mLoader->load(BTUI_DEVICEVIEW_DOCML, "portrait", &ok); |
|
94 BTUI_ASSERT_X( ok, "bt-device-view", "Invalid docml file: landscape section problem" ); |
|
95 } |
|
96 |
|
97 // listen for orientation changes |
|
98 ret = connect(mMainWindow, SIGNAL(orientationChanged(Qt::Orientation)), |
|
99 this, SLOT(changeOrientation(Qt::Orientation))); |
|
100 BTUI_ASSERT_X( ret, "BtCpUiDeviceView::BtCpUiDeviceView()", "connect orientationChanged() failed"); |
|
101 |
|
102 |
84 // assign automatically created widgets to local variables |
103 // assign automatically created widgets to local variables |
85 |
104 /* |
86 mGroupBox = 0; |
105 mGroupBox = 0; |
87 mGroupBox = qobject_cast<HbGroupBox *>( mLoader->findWidget( "groupBox_deviceView" ) ); |
106 mGroupBox = qobject_cast<HbGroupBox *>( mLoader->findWidget( "groupBox_deviceView" ) ); |
88 BTUI_ASSERT_X( mGroupBox != 0, "bt-device-view", "Device groupbox not found" ); |
107 BTUI_ASSERT_X( mGroupBox != 0, "bt-device-view", "Device groupbox not found" ); |
89 |
108 */ |
90 mDeviceIcon=0; |
109 mDeviceIcon=0; |
91 //can't use qobject_cast since HbIcon is not derived from QObject! |
110 //can't use qobject_cast since HbIcon is not derived from QObject! |
92 mDeviceIcon = qobject_cast<HbLabel *>( mLoader->findWidget( "deviceIcon" ) ); |
111 mDeviceIcon = qobject_cast<HbLabel *>( mLoader->findWidget( "deviceIcon" ) ); |
93 BTUI_ASSERT_X( mDeviceIcon != 0, "bt-device-view", "Device Icon not found" ); |
112 BTUI_ASSERT_X( mDeviceIcon != 0, "bt-device-view", "Device Icon not found" ); |
94 |
113 |
95 mDeviceName=0; |
114 mDeviceName=0; |
96 mDeviceName = qobject_cast<HbTextEdit *>( mLoader->findWidget( "deviceName" ) ); |
115 mDeviceName = qobject_cast<HbLineEdit *>( mLoader->findWidget( "deviceName" ) ); |
97 BTUI_ASSERT_X( mDeviceName != 0, "bt-device-view", "Device Name not found" ); |
116 BTUI_ASSERT_X( mDeviceName != 0, "bt-device-view", "Device Name not found" ); |
98 ret = connect(mDeviceName, SIGNAL(editingFinished ()), this, SLOT(changeBtDeviceName())); |
117 ret = connect(mDeviceName, SIGNAL(editingFinished ()), this, SLOT(changeBtDeviceName())); |
99 |
118 |
100 mDeviceCategory=0; |
119 mDeviceCategory=0; |
101 mDeviceCategory = qobject_cast<HbLabel *>( mLoader->findWidget( "deviceCategory" ) ); |
120 mDeviceCategory = qobject_cast<HbLabel *>( mLoader->findWidget( "deviceCategory" ) ); |
102 BTUI_ASSERT_X( mDeviceCategory != 0, "bt-device-view", "Device Category not found" ); |
121 BTUI_ASSERT_X( mDeviceCategory != 0, "bt-device-view", "Device Category not found" ); |
103 |
122 |
104 mDeviceStatus=0; |
123 mDeviceStatus=0; |
105 mDeviceStatus = qobject_cast<HbLabel *>( mLoader->findWidget( "deviceStatus" ) ); |
124 mDeviceStatus = qobject_cast<HbLabel *>( mLoader->findWidget( "deviceStatus" ) ); |
106 BTUI_ASSERT_X( mDeviceStatus != 0, "bt-device-view", "Device status not found" ); |
125 BTUI_ASSERT_X( mDeviceStatus != 0, "bt-device-view", "Device status not found" ); |
|
126 |
|
127 |
|
128 mConnectionCombobox = 0; |
|
129 mConnectionCombobox = qobject_cast<HbDataForm *>( mLoader->findWidget( "connectionCombobox" ) ); |
|
130 BTUI_ASSERT_X( mConnectionCombobox != 0, "bt-device-view", "connection combobox not found" ); |
|
131 |
|
132 mConnectionComboboxModel = new HbDataFormModel(); |
107 |
133 |
108 mPair_Unpair=0; |
134 mPair_Unpair=0; |
109 mPair_Unpair = qobject_cast<HbPushButton *>( mLoader->findWidget( "pushButton_0" ) ); |
135 mPair_Unpair = qobject_cast<HbPushButton *>( mLoader->findWidget( "pushButton_0" ) ); |
110 BTUI_ASSERT_X( mPair_Unpair != 0, "bt-device-view", "pair/unpair button not found" ); |
136 BTUI_ASSERT_X( mPair_Unpair != 0, "bt-device-view", "pair/unpair button not found" ); |
111 ret = connect(mPair_Unpair, SIGNAL(clicked()), this, SLOT(pairUnpair())); |
137 ret = connect(mPair_Unpair, SIGNAL(clicked()), this, SLOT(pairUnpair())); |
119 |
145 |
120 mDeviceSetting = 0; |
146 mDeviceSetting = 0; |
121 mDeviceSetting = qobject_cast<HbPushButton *>( mLoader->findWidget( "pushButton_2" ) ); |
147 mDeviceSetting = qobject_cast<HbPushButton *>( mLoader->findWidget( "pushButton_2" ) ); |
122 BTUI_ASSERT_X( mDeviceSetting != 0, "bt-device-view", "settings button not found" ); |
148 BTUI_ASSERT_X( mDeviceSetting != 0, "bt-device-view", "settings button not found" ); |
123 |
149 |
124 // read landscape orientation section from docml file if needed |
150 setConnectionCombobox(); |
125 // mOrientation = ((BTUIViewManager*)parent)->orientation(); |
151 |
126 mOrientation = Qt::Vertical; |
|
127 if (mOrientation == Qt::Horizontal) { |
|
128 mLoader->load(BTUI_DEVICEVIEW_DOCML, "landscape", &ok); |
|
129 BTUI_ASSERT_X( ok, "bt-device-view", "Invalid docml file: landscape section problem" ); |
|
130 } |
|
131 |
152 |
132 } |
153 } |
133 |
154 |
134 BtCpUiDeviceView::~BtCpUiDeviceView() |
155 BtCpUiDeviceView::~BtCpUiDeviceView() |
135 { |
156 { |
|
157 delete mLoader; // Also deletes all widgets that it constructed. |
|
158 |
|
159 delete mConnectionComboboxModel; |
|
160 |
136 setNavigationAction(0); |
161 setNavigationAction(0); |
137 delete mSoftKeyBackAction; |
162 delete mSoftKeyBackAction; |
138 if(mAbstractDelegate) |
163 if(mAbstractDelegate) |
139 { |
164 { |
140 delete mAbstractDelegate; |
165 delete mAbstractDelegate; |
178 |
203 |
179 void BtCpUiDeviceView::deactivateView() |
204 void BtCpUiDeviceView::deactivateView() |
180 { |
205 { |
181 } |
206 } |
182 |
207 |
|
208 // called due to real orientation change event coming from main window |
|
209 void BtCpUiDeviceView::changeOrientation( Qt::Orientation orientation ) |
|
210 { |
|
211 bool ok = false; |
|
212 mOrientation = orientation; |
|
213 if( orientation == Qt::Vertical ) { |
|
214 // load "portrait" section |
|
215 mLoader->load( BTUI_DEVICEVIEW_DOCML, "portrait", &ok ); |
|
216 BTUI_ASSERT_X( ok, "bt-device-view", "Invalid docml file: portrait section problem" ); |
|
217 } else { |
|
218 // load "landscape" section |
|
219 mLoader->load( BTUI_DEVICEVIEW_DOCML, "landscape", &ok ); |
|
220 BTUI_ASSERT_X( ok, "bt-device-view", "Invalid docml file: landscape section problem" ); |
|
221 } |
|
222 } |
|
223 |
183 void BtCpUiDeviceView::clearViewData() |
224 void BtCpUiDeviceView::clearViewData() |
184 { |
225 { |
185 mDeviceIcon->clear(); |
226 mDeviceIcon->clear(); |
186 mDeviceCategory->clear(); |
227 mDeviceCategory->clear(); |
187 mDeviceStatus->clear(); |
228 mDeviceStatus->clear(); |
188 |
229 |
189 mPairStatus = false; |
230 mPairedStatus = false; |
190 mConnectStatus = false; |
231 mConnectedStatus = false; |
|
232 mTrustedStatus = false; |
|
233 mBlockedStatus = false; |
|
234 |
191 mConnectable = false; |
235 mConnectable = false; |
192 } |
236 } |
193 |
237 |
194 void BtCpUiDeviceView::updateDeviceData() |
238 void BtCpUiDeviceView::updateDeviceData() |
195 { |
239 { |
196 QModelIndex localIndex = mSettingModel->index( BtSettingModel::LocalBtNameRow, 0); |
240 clearViewData(); |
|
241 // ToDo: the groupbox header should only say "Bluetooth", ie. without device name; |
|
242 // check new TextMap file for the right TextId |
|
243 /*QModelIndex localIndex = mSettingModel->index( BtSettingModel::LocalBtNameRow, 0); |
197 QString localName = (mSettingModel->data(localIndex,BtSettingModel::settingDisplayRole)).toString(); |
244 QString localName = (mSettingModel->data(localIndex,BtSettingModel::settingDisplayRole)).toString(); |
198 QString groupBoxTitle (tr("Bluetooth-")); |
245 QString groupBoxTitle (hbTrId("txt_bt_subhead_bluetooth_1").arg(localName)); |
199 mGroupBox->setHeading(groupBoxTitle.append(localName)); |
246 mGroupBox->setHeading(groupBoxTitle); |
|
247 */ |
200 //Get the QModelIndex of the device using the device BDAddres |
248 //Get the QModelIndex of the device using the device BDAddres |
201 QModelIndex start = mDeviceModel->index(0,0); |
249 QModelIndex start = mDeviceModel->index(0,0); |
202 QModelIndexList indexList = mDeviceModel->match(start,BtDeviceModel::ReadableBdaddrRole, mDeviceBdAddr); |
250 QModelIndexList indexList = mDeviceModel->match(start,BtDeviceModel::ReadableBdaddrRole, mDeviceBdAddr); |
203 mDeviceIndex = indexList.at(0); |
251 mDeviceIndex = indexList.at(0); |
204 |
252 |
205 //populate device view with device data fetched from UiModel |
253 //populate device view with device data fetched from UiModel |
206 QString deviceName = (mDeviceModel->data(mDeviceIndex, |
254 QString deviceName = (mDeviceModel->data(mDeviceIndex, |
207 BtDeviceModel::NameAliasRole)).toString(); |
255 BtDeviceModel::NameAliasRole)).toString(); |
208 mDeviceName->setPlainText(deviceName); |
256 mDeviceName->setText(deviceName); |
209 |
257 |
210 int cod = (mDeviceModel->data(mDeviceIndex,BtDeviceModel::CoDRole)).toInt(); |
258 int cod = (mDeviceModel->data(mDeviceIndex,BtDeviceModel::CoDRole)).toInt(); |
211 |
259 |
212 int majorRole = (mDeviceModel->data(mDeviceIndex,BtDeviceModel::MajorPropertyRole)).toInt(); |
260 int majorRole = (mDeviceModel->data(mDeviceIndex,BtDeviceModel::MajorPropertyRole)).toInt(); |
213 int minorRole = (mDeviceModel->data(mDeviceIndex,BtDeviceModel::MinorPropertyRole)).toInt(); |
261 int minorRole = (mDeviceModel->data(mDeviceIndex,BtDeviceModel::MinorPropertyRole)).toInt(); |
217 setTextAndVisibilityOfButtons(); |
265 setTextAndVisibilityOfButtons(); |
218 } |
266 } |
219 |
267 |
220 void BtCpUiDeviceView::setDeviceCategory(int cod,int majorRole, int minorRole) |
268 void BtCpUiDeviceView::setDeviceCategory(int cod,int majorRole, int minorRole) |
221 { |
269 { |
222 //TODO: change the hardcoded numeric value to enumerations |
270 mDeviceCategory->setPlainText( getDeviceTypeString( cod )); |
223 if (cod) |
271 HbIcon icon = |
224 { |
272 getBadgedDeviceTypeIcon(cod, majorRole, |
225 if (majorRole & 0x00020000) |
273 BtuiBottomLeft | BtuiBottomRight | BtuiTopLeft | BtuiTopRight ); |
|
274 mDeviceIcon->setIcon(icon); |
|
275 |
|
276 if (majorRole & BtuiDevProperty::AVDev) { |
|
277 if ( minorRole & BtuiDevProperty::Headset){ |
|
278 // this is a Headset, it is possible to connect |
|
279 mConnectable = true; |
|
280 } |
|
281 } |
|
282 } |
|
283 |
|
284 void BtCpUiDeviceView::setDeviceStatus(int majorRole) |
|
285 { |
|
286 QString deviceStatus; |
|
287 |
|
288 updateStatusVariables(majorRole); // should we use bitmap instead?? |
|
289 |
|
290 if (majorRole & BtuiDevProperty::Bonded && |
|
291 majorRole & BtuiDevProperty::Trusted && |
|
292 majorRole & BtuiDevProperty::Connected ) { |
|
293 mDeviceStatus->setPlainText(hbTrId("txt_bt_info_paired_trused_connected")); |
|
294 } |
|
295 else if (majorRole & BtuiDevProperty::Bonded && |
|
296 majorRole & BtuiDevProperty::Connected ) { |
|
297 mDeviceStatus->setPlainText(hbTrId("txt_bt_info_paired_connected")); |
|
298 } |
|
299 else if (majorRole & BtuiDevProperty::Bonded && |
|
300 majorRole & BtuiDevProperty::Trusted ) { |
|
301 mDeviceStatus->setPlainText(hbTrId("txt_bt_info_paired_trusted")); |
|
302 } |
|
303 else if (majorRole & BtuiDevProperty::Bonded) { |
|
304 mDeviceStatus->setPlainText(hbTrId("txt_bt_info_paired")); |
|
305 } |
|
306 else if (majorRole & BtuiDevProperty::Connected) { |
|
307 mDeviceStatus->setPlainText(hbTrId("txt_bt_info_connected")); |
|
308 } |
|
309 else if (majorRole & BtuiDevProperty::Blocked) { |
|
310 mDeviceStatus->setPlainText(hbTrId("txt_bt_info_blocked")); |
|
311 } |
|
312 else { |
|
313 // device not paired, connected, trusted or blocked. is this ok? |
|
314 } |
|
315 |
|
316 } |
|
317 |
|
318 void BtCpUiDeviceView::setConnectionCombobox(){ |
|
319 |
|
320 //create a model class |
|
321 |
|
322 mConnectionComboboxModel->appendDataFormItem( |
|
323 HbDataFormModelItem::ComboBoxItem, QString("Connection"), mConnectionComboboxModel->invisibleRootItem()); |
|
324 |
|
325 //set the model to the view, once model and data class are created |
|
326 mConnectionCombobox->setModel(mConnectionComboboxModel); |
|
327 |
|
328 |
|
329 |
|
330 } |
|
331 |
|
332 |
|
333 /*! |
|
334 * instead of using separate boolean variables we could use bitmap in single variable |
|
335 */ |
|
336 void BtCpUiDeviceView::updateStatusVariables(int majorRole) |
|
337 { |
|
338 if (majorRole & BtuiDevProperty::Trusted ) { |
|
339 mTrustedStatus = true; |
|
340 } |
|
341 else { |
|
342 mTrustedStatus = false; |
|
343 } |
|
344 if (majorRole & BtuiDevProperty::Bonded) { |
|
345 mPairedStatus = true; |
|
346 } |
|
347 else { |
|
348 mPairedStatus = false; |
|
349 } |
|
350 if (majorRole & BtuiDevProperty::Connected) { |
|
351 mConnectedStatus = true; |
|
352 } |
|
353 else { |
|
354 mConnectedStatus = false; |
|
355 } |
|
356 if (majorRole & BtuiDevProperty::Blocked) { |
|
357 mBlockedStatus = true; |
|
358 } |
|
359 else { |
|
360 mBlockedStatus = false; |
|
361 } |
|
362 } |
|
363 |
|
364 void BtCpUiDeviceView::setTextAndVisibilityOfButtons() |
|
365 { |
|
366 mPair_Unpair->setStretched(true); |
|
367 if (mPairedStatus) |
|
368 { |
|
369 HbIcon icon("qtg_mono_bt_unpair"); |
|
370 icon.setIconName("qtg_mono_bt_unpair"); |
|
371 mPair_Unpair->setIcon(icon); |
|
372 mPair_Unpair->setText(hbTrId("txt_bt_button_unpair")); |
|
373 |
|
374 } |
|
375 else |
|
376 { |
|
377 HbIcon icon("qtg_mono_bt_pair"); |
|
378 icon.setIconName("qtg_mono_bt_pair"); |
|
379 mPair_Unpair->setIcon(icon); |
|
380 mPair_Unpair->setText(hbTrId("txt_bt_button_pair")); |
|
381 } |
|
382 |
|
383 if (mConnectable) |
|
384 { |
|
385 mConnect_Disconnect->setStretched(true); |
|
386 if (mConnectedStatus) |
226 { |
387 { |
227 //this is a phone |
388 HbIcon icon("qtg_mono_speaker_off"); |
228 mDeviceCategory->setPlainText(tr("Phone")); |
389 icon.setIconName("qtg_mono_speaker_off"); |
229 } |
390 mConnect_Disconnect->setIcon(icon); |
230 else if (majorRole & 0x00010000) |
391 mConnect_Disconnect->setText(hbTrId("txt_bt_button_disconnect")); |
231 { |
|
232 //this is a computer |
|
233 mDeviceCategory->setPlainText(tr("Computer")); |
|
234 |
|
235 } |
|
236 else if (majorRole & 0x00080000) |
|
237 { |
|
238 //this is a A/V device |
|
239 //int minorRole = (mDeviceModel->data(mIndex,BtDeviceModel::MinorPropertyRole)).toInt(); |
|
240 if ( minorRole & 0x00000002) |
|
241 { |
|
242 //this is a Headset, it is possible to connect |
|
243 mConnectable = true; |
|
244 mDeviceCategory->setPlainText(tr("Headset")); |
|
245 } |
|
246 } |
|
247 else |
|
248 { |
|
249 mDeviceCategory->setPlainText(tr("Uncategorized Dev")); |
|
250 } |
|
251 |
|
252 } |
|
253 |
|
254 |
|
255 } |
|
256 void BtCpUiDeviceView::setDeviceStatus(int majorRole) |
|
257 { |
|
258 //TODO: change the hardcoded numeric value to enumerations |
|
259 QString deviceStatus; |
|
260 if (majorRole & 0x00000001) |
|
261 { |
|
262 deviceStatus = deviceStatus.append(tr("Paired")); |
|
263 mPairStatus = true; |
|
264 } |
|
265 else |
|
266 { |
|
267 mPairStatus = false; |
|
268 } |
|
269 |
|
270 if ((majorRole & 0x00000020)&& (mConnectable)) |
|
271 { |
|
272 //if the device is connected and it is a headset NOTE! two phone can be paired but not be connected |
|
273 deviceStatus = deviceStatus.append(tr(", connected")); |
|
274 mConnectStatus = true; |
|
275 } |
|
276 else |
|
277 { |
|
278 mConnectStatus = false; |
|
279 } |
|
280 mDeviceStatus->setPlainText(deviceStatus); |
|
281 |
|
282 |
|
283 |
|
284 } |
|
285 |
|
286 void BtCpUiDeviceView::setTextAndVisibilityOfButtons() |
|
287 { |
|
288 if (mPairStatus) |
|
289 { |
|
290 mPair_Unpair->setText(tr("Unpair")); |
|
291 } |
|
292 else |
|
293 { |
|
294 mPair_Unpair->setText(tr("Pair")); |
|
295 } |
|
296 |
|
297 if (mConnectable) |
|
298 { |
|
299 if (mConnectStatus) |
|
300 { |
|
301 mConnect_Disconnect->setText(tr("Disconnect")); |
|
302 } |
392 } |
303 else |
393 else |
304 { |
394 { |
305 mConnect_Disconnect->setText(tr("Connect")); |
395 HbIcon icon("qtg_mono_speaker"); |
|
396 icon.setIconName("qtg_mono_speaker"); |
|
397 mConnect_Disconnect->setIcon(icon); |
|
398 mConnect_Disconnect->setText(hbTrId("txt_bt_button_connect")); |
306 } |
399 } |
307 |
400 |
308 } |
401 } |
309 else |
402 else |
310 { |
403 { |
446 |
527 |
447 void BtCpUiDeviceView::disconnectDevice() |
528 void BtCpUiDeviceView::disconnectDevice() |
448 { |
529 { |
449 if (!mAbstractDelegate)//if there is no other delegate running |
530 if (!mAbstractDelegate)//if there is no other delegate running |
450 { |
531 { |
|
532 |
|
533 |
|
534 DisconnectOption discoOpt = ServiceLevel; |
|
535 |
|
536 QList<QVariant>list; |
|
537 QVariant paramFirst; |
|
538 paramFirst.setValue(mDeviceIndex); |
|
539 |
|
540 QVariant paramSecond; |
|
541 paramSecond.setValue((int)discoOpt); |
|
542 |
|
543 list.append(paramFirst); |
|
544 list.append(paramSecond); |
|
545 |
451 QVariant params; |
546 QVariant params; |
452 params.setValue(mDeviceIndex); |
547 params.setValue(list); |
|
548 |
|
549 |
|
550 //params.setValue(mDeviceIndex); |
453 mAbstractDelegate = BtDelegateFactory::newDelegate( |
551 mAbstractDelegate = BtDelegateFactory::newDelegate( |
454 BtDelegate::Disconnect, mSettingModel, mDeviceModel); |
552 BtDelegate::Disconnect, mSettingModel, mDeviceModel); |
455 connect( mAbstractDelegate, SIGNAL(commandCompleted(int)), this, SLOT(disconnectDelegateCompleted(int)) ); |
553 connect( mAbstractDelegate, SIGNAL(commandCompleted(int)), this, SLOT(disconnectDelegateCompleted(int)) ); |
456 mAbstractDelegate->exec(params); |
554 mAbstractDelegate->exec(params); |
457 } |
555 } |