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" |
|
43 |
|
44 #include "btcpuidevicedetail.h" |
38 |
45 |
39 // docml to load |
46 // docml to load |
40 const char* BTUI_DEVICEVIEW_DOCML = ":/docml/bt-device-view.docml"; |
47 const char* BTUI_DEVICEVIEW_DOCML = ":/docml/bt-device-view.docml"; |
41 |
48 |
42 |
49 |
43 BtCpUiDeviceView::BtCpUiDeviceView( |
50 BtCpUiDeviceView::BtCpUiDeviceView( |
44 BtSettingModel &settingModel, |
51 BtSettingModel &settingModel, |
45 BtDeviceModel &deviceModel, |
52 BtDeviceModel &deviceModel, |
46 QGraphicsItem *parent) : |
53 QGraphicsItem *parent) : |
47 BtCpUiBaseView(settingModel,deviceModel,parent), |
54 BtCpUiBaseView(settingModel,deviceModel,parent), |
48 mPairStatus(false), mConnectStatus(false), mConnectable(false), mAbstractDelegate(0) |
55 mPairedStatus(false), mConnectedStatus(false), mTrustedStatus(false), mBlockedStatus(false), |
|
56 mConnectable(false), mAbstractDelegate(0), mDeviceDetail(0) |
49 { |
57 { |
50 mDeviceIndex = QModelIndex();//is it needed to initialize mIndex??? |
58 mDeviceIndex = QModelIndex();//is it needed to initialize mIndex??? |
51 |
59 |
52 mMainView = (BtCpUiMainView *) parent; |
60 mMainView = (BtCpUiMainView *) parent; |
53 |
61 |
61 // Create view for the application. |
69 // Create view for the application. |
62 // Set the name for the view. The name should be same as the view's |
70 // Set the name for the view. The name should be same as the view's |
63 // name in docml. |
71 // name in docml. |
64 setObjectName("bt_device_view"); |
72 setObjectName("bt_device_view"); |
65 |
73 |
|
74 mLoader = new HbDocumentLoader(); |
|
75 // Pass the view to documentloader. Document loader uses this view |
|
76 // when docml is parsed, instead of creating new view. |
66 QObjectList objectList; |
77 QObjectList objectList; |
67 objectList.append(this); |
78 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); |
79 mLoader->setObjectTree(objectList); |
72 |
80 |
73 bool ret = false; |
81 bool ret = false; |
74 |
82 |
75 bool ok = false; |
83 bool ok = false; |
76 mLoader->load( BTUI_DEVICEVIEW_DOCML, &ok ); |
84 mLoader->load( BTUI_DEVICEVIEW_DOCML, &ok ); |
77 // Exit if the file format is invalid |
85 // Exit if the file format is invalid |
78 BTUI_ASSERT_X( ok, "bt-device-view", "Invalid docml file" ); |
86 BTUI_ASSERT_X( ok, "bt-device-view", "Invalid docml file" ); |
79 |
87 |
80 // Set title for the control panel |
88 mOrientation = mMainWindow->orientation(); |
81 // ToDo: check if deprecated API |
89 |
82 setTitle("Control Panel"); |
90 if (mOrientation == Qt::Horizontal) { |
83 |
91 mLoader->load(BTUI_DEVICEVIEW_DOCML, "landscape", &ok); |
|
92 BTUI_ASSERT_X( ok, "bt-device-view", "Invalid docml file: landscape section problem" ); |
|
93 } |
|
94 else { |
|
95 mLoader->load(BTUI_DEVICEVIEW_DOCML, "portrait", &ok); |
|
96 BTUI_ASSERT_X( ok, "bt-device-view", "Invalid docml file: landscape section problem" ); |
|
97 } |
|
98 |
|
99 // listen for orientation changes |
|
100 ret = connect(mMainWindow, SIGNAL(orientationChanged(Qt::Orientation)), |
|
101 this, SLOT(changeOrientation(Qt::Orientation))); |
|
102 BTUI_ASSERT_X( ret, "BtCpUiDeviceView::BtCpUiDeviceView()", "connect orientationChanged() failed"); |
|
103 |
|
104 |
84 // assign automatically created widgets to local variables |
105 // assign automatically created widgets to local variables |
85 |
106 /* |
86 mGroupBox = 0; |
107 mGroupBox = 0; |
87 mGroupBox = qobject_cast<HbGroupBox *>( mLoader->findWidget( "groupBox_deviceView" ) ); |
108 mGroupBox = qobject_cast<HbGroupBox *>( mLoader->findWidget( "groupBox_deviceView" ) ); |
88 BTUI_ASSERT_X( mGroupBox != 0, "bt-device-view", "Device groupbox not found" ); |
109 BTUI_ASSERT_X( mGroupBox != 0, "bt-device-view", "Device groupbox not found" ); |
89 |
110 */ |
90 mDeviceIcon=0; |
111 mDeviceIcon=0; |
91 //can't use qobject_cast since HbIcon is not derived from QObject! |
112 //can't use qobject_cast since HbIcon is not derived from QObject! |
92 mDeviceIcon = qobject_cast<HbLabel *>( mLoader->findWidget( "deviceIcon" ) ); |
113 mDeviceIcon = qobject_cast<HbLabel *>( mLoader->findWidget( "deviceIcon" ) ); |
93 BTUI_ASSERT_X( mDeviceIcon != 0, "bt-device-view", "Device Icon not found" ); |
114 BTUI_ASSERT_X( mDeviceIcon != 0, "bt-device-view", "Device Icon not found" ); |
94 |
115 |
95 mDeviceName=0; |
116 mDeviceName=0; |
96 mDeviceName = qobject_cast<HbTextEdit *>( mLoader->findWidget( "deviceName" ) ); |
117 mDeviceName = qobject_cast<HbLineEdit *>( mLoader->findWidget( "deviceName" ) ); |
97 BTUI_ASSERT_X( mDeviceName != 0, "bt-device-view", "Device Name not found" ); |
118 BTUI_ASSERT_X( mDeviceName != 0, "bt-device-view", "Device Name not found" ); |
98 ret = connect(mDeviceName, SIGNAL(editingFinished ()), this, SLOT(changeBtDeviceName())); |
119 ret = connect(mDeviceName, SIGNAL(editingFinished ()), this, SLOT(changeBtDeviceName())); |
99 |
120 |
100 mDeviceCategory=0; |
121 mDeviceCategory=0; |
101 mDeviceCategory = qobject_cast<HbLabel *>( mLoader->findWidget( "deviceCategory" ) ); |
122 mDeviceCategory = qobject_cast<HbLabel *>( mLoader->findWidget( "deviceCategory" ) ); |
102 BTUI_ASSERT_X( mDeviceCategory != 0, "bt-device-view", "Device Category not found" ); |
123 BTUI_ASSERT_X( mDeviceCategory != 0, "bt-device-view", "Device Category not found" ); |
103 |
124 |
104 mDeviceStatus=0; |
125 mDeviceStatus=0; |
105 mDeviceStatus = qobject_cast<HbLabel *>( mLoader->findWidget( "deviceStatus" ) ); |
126 mDeviceStatus = qobject_cast<HbLabel *>( mLoader->findWidget( "deviceStatus" ) ); |
106 BTUI_ASSERT_X( mDeviceStatus != 0, "bt-device-view", "Device status not found" ); |
127 BTUI_ASSERT_X( mDeviceStatus != 0, "bt-device-view", "Device status not found" ); |
|
128 |
|
129 |
|
130 mConnectionCombobox = 0; |
|
131 mConnectionCombobox = qobject_cast<HbDataForm *>( mLoader->findWidget( "connectionCombobox" ) ); |
|
132 BTUI_ASSERT_X( mConnectionCombobox != 0, "bt-device-view", "connection combobox not found" ); |
|
133 |
|
134 mConnectionComboboxModel = new HbDataFormModel(); |
107 |
135 |
108 mPair_Unpair=0; |
136 mPair_Unpair=0; |
109 mPair_Unpair = qobject_cast<HbPushButton *>( mLoader->findWidget( "pushButton_0" ) ); |
137 mPair_Unpair = qobject_cast<HbPushButton *>( mLoader->findWidget( "pushButton_0" ) ); |
110 BTUI_ASSERT_X( mPair_Unpair != 0, "bt-device-view", "pair/unpair button not found" ); |
138 BTUI_ASSERT_X( mPair_Unpair != 0, "bt-device-view", "pair/unpair button not found" ); |
111 ret = connect(mPair_Unpair, SIGNAL(clicked()), this, SLOT(pairUnpair())); |
139 ret = connect(mPair_Unpair, SIGNAL(clicked()), this, SLOT(pairUnpair())); |
153 |
185 |
154 void BtCpUiDeviceView::switchToPreviousView() |
186 void BtCpUiDeviceView::switchToPreviousView() |
155 { |
187 { |
156 BTUI_ASSERT_X(mMainView, "BtCpUiSearchView::switchToPreviousView", "invalid mMainView"); |
188 BTUI_ASSERT_X(mMainView, "BtCpUiSearchView::switchToPreviousView", "invalid mMainView"); |
157 mMainView->switchToPreviousView(); |
189 mMainView->switchToPreviousView(); |
158 } |
190 delete mDeviceDetail; |
159 |
191 mDeviceDetail = 0; |
160 void BtCpUiDeviceView::activateView( const QVariant& value, int cmdId ) |
192 } |
161 { |
193 |
162 Q_UNUSED(cmdId); |
194 void BtCpUiDeviceView::activateView( const QVariant& value, bool fromBackButton ) |
|
195 { |
|
196 Q_UNUSED( fromBackButton ); |
163 |
197 |
164 setSoftkeyBack(); |
198 setSoftkeyBack(); |
165 |
199 |
166 QModelIndex index = value.value<QModelIndex>(); |
200 QModelIndex index = value.value<QModelIndex>(); |
167 mDeviceBdAddr = (mDeviceModel->data(index, BtDeviceModel::ReadableBdaddrRole)); |
201 mDeviceBdAddr = (mDeviceModel->data(index, BtDeviceModel::ReadableBdaddrRole)); |
168 |
202 |
169 //activate view is called when device is selected |
203 //activate view is called when device is selected |
170 clearViewData(); |
204 //clearViewData(); |
171 updateDeviceData(); |
205 updateDeviceData(); |
|
206 |
|
207 mDeviceSetting->setVisible(false); |
|
208 |
|
209 mDeviceDetail = new BtCpUiDeviceDetail(); |
172 |
210 |
173 bool ret(false); |
211 bool ret(false); |
174 ret=connect(mDeviceModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), |
212 ret=connect(mDeviceModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), |
175 this, SLOT(updateDeviceData())); |
213 this, SLOT(updateDeviceData())); |
176 BTUI_ASSERT_X( ret, "Btui, BtCpUiDeviceView::activateView", "dataChanged() connect failed"); |
214 BTUI_ASSERT_X( ret, "Btui, BtCpUiDeviceView::activateView", "dataChanged() connect failed"); |
|
215 |
|
216 ret=connect(mDeviceDetail, SIGNAL(deviceSettingsChanged(bool)), |
|
217 this, SLOT(handleDeviceSettingsChange(bool))); |
|
218 BTUI_ASSERT_X( ret, "Btui, BtCpUiDeviceView::activateView", "deviceSettingsChanged() connect failed"); |
|
219 |
|
220 |
|
221 mDeviceDetail->loadDeviceDetailPlugins(mDeviceBdAddr.toString(), mDeviceName->text()); |
|
222 |
|
223 } |
|
224 |
|
225 void BtCpUiDeviceView::handleDeviceSettingsChange(bool status) |
|
226 { |
|
227 mDeviceSetting->setVisible(status); |
|
228 } |
|
229 |
|
230 void BtCpUiDeviceView::handleDeviceSetting() |
|
231 { |
|
232 mDeviceDetail->loadDeviceDetailsView(); |
177 } |
233 } |
178 |
234 |
179 void BtCpUiDeviceView::deactivateView() |
235 void BtCpUiDeviceView::deactivateView() |
180 { |
236 { |
|
237 } |
|
238 |
|
239 // called due to real orientation change event coming from main window |
|
240 void BtCpUiDeviceView::changeOrientation( Qt::Orientation orientation ) |
|
241 { |
|
242 bool ok = false; |
|
243 mOrientation = orientation; |
|
244 if( orientation == Qt::Vertical ) { |
|
245 // load "portrait" section |
|
246 mLoader->load( BTUI_DEVICEVIEW_DOCML, "portrait", &ok ); |
|
247 BTUI_ASSERT_X( ok, "bt-device-view", "Invalid docml file: portrait section problem" ); |
|
248 } else { |
|
249 // load "landscape" section |
|
250 mLoader->load( BTUI_DEVICEVIEW_DOCML, "landscape", &ok ); |
|
251 BTUI_ASSERT_X( ok, "bt-device-view", "Invalid docml file: landscape section problem" ); |
|
252 } |
181 } |
253 } |
182 |
254 |
183 void BtCpUiDeviceView::clearViewData() |
255 void BtCpUiDeviceView::clearViewData() |
184 { |
256 { |
185 mDeviceIcon->clear(); |
257 mDeviceIcon->clear(); |
186 mDeviceCategory->clear(); |
258 mDeviceCategory->clear(); |
187 mDeviceStatus->clear(); |
259 mDeviceStatus->clear(); |
188 |
260 |
189 mPairStatus = false; |
261 mPairedStatus = false; |
190 mConnectStatus = false; |
262 mConnectedStatus = false; |
|
263 mTrustedStatus = false; |
|
264 mBlockedStatus = false; |
|
265 |
191 mConnectable = false; |
266 mConnectable = false; |
192 } |
267 } |
193 |
268 |
194 void BtCpUiDeviceView::updateDeviceData() |
269 void BtCpUiDeviceView::updateDeviceData() |
195 { |
270 { |
196 QModelIndex localIndex = mSettingModel->index( BtSettingModel::LocalBtNameRow, 0); |
271 clearViewData(); |
197 QString localName = (mSettingModel->data(localIndex,BtSettingModel::settingDisplayRole)).toString(); |
|
198 QString groupBoxTitle (tr("Bluetooth-")); |
|
199 mGroupBox->setHeading(groupBoxTitle.append(localName)); |
|
200 //Get the QModelIndex of the device using the device BDAddres |
272 //Get the QModelIndex of the device using the device BDAddres |
201 QModelIndex start = mDeviceModel->index(0,0); |
273 QModelIndex start = mDeviceModel->index(0,0); |
202 QModelIndexList indexList = mDeviceModel->match(start,BtDeviceModel::ReadableBdaddrRole, mDeviceBdAddr); |
274 QModelIndexList indexList = mDeviceModel->match(start,BtDeviceModel::ReadableBdaddrRole, mDeviceBdAddr); |
203 mDeviceIndex = indexList.at(0); |
275 mDeviceIndex = indexList.at(0); |
204 |
276 |
205 //populate device view with device data fetched from UiModel |
277 //populate device view with device data fetched from UiModel |
206 QString deviceName = (mDeviceModel->data(mDeviceIndex, |
278 QString deviceName = (mDeviceModel->data(mDeviceIndex, |
207 BtDeviceModel::NameAliasRole)).toString(); |
279 BtDeviceModel::NameAliasRole)).toString(); |
208 mDeviceName->setPlainText(deviceName); |
280 mDeviceName->setText(deviceName); |
209 |
281 |
210 int cod = (mDeviceModel->data(mDeviceIndex,BtDeviceModel::CoDRole)).toInt(); |
282 int cod = (mDeviceModel->data(mDeviceIndex,BtDeviceModel::CoDRole)).toInt(); |
211 |
283 |
212 int majorRole = (mDeviceModel->data(mDeviceIndex,BtDeviceModel::MajorPropertyRole)).toInt(); |
284 int majorRole = (mDeviceModel->data(mDeviceIndex,BtDeviceModel::MajorPropertyRole)).toInt(); |
213 int minorRole = (mDeviceModel->data(mDeviceIndex,BtDeviceModel::MinorPropertyRole)).toInt(); |
285 |
214 |
286 setDeviceCategory(cod, majorRole); |
215 setDeviceCategory(cod, majorRole, minorRole); |
|
216 setDeviceStatus(majorRole); |
287 setDeviceStatus(majorRole); |
217 setTextAndVisibilityOfButtons(); |
288 setTextAndVisibilityOfButtons(); |
218 } |
289 } |
219 |
290 |
220 void BtCpUiDeviceView::setDeviceCategory(int cod,int majorRole, int minorRole) |
291 void BtCpUiDeviceView::setDeviceCategory(int cod,int majorRole) |
221 { |
292 { |
222 //TODO: change the hardcoded numeric value to enumerations |
293 mDeviceCategory->setPlainText( getDeviceTypeString( cod )); |
223 if (cod) |
294 HbIcon icon = |
224 { |
295 getBadgedDeviceTypeIcon(cod, majorRole, |
225 if (majorRole & 0x00020000) |
296 BtuiBottomLeft | BtuiBottomRight | BtuiTopLeft | BtuiTopRight ); |
|
297 mDeviceIcon->setIcon(icon); |
|
298 |
|
299 if (majorRole & BtuiDevProperty::Connectable ) { |
|
300 mConnectable = true; |
|
301 } |
|
302 } |
|
303 |
|
304 void BtCpUiDeviceView::setDeviceStatus(int majorRole) |
|
305 { |
|
306 QString deviceStatus; |
|
307 |
|
308 updateStatusVariables(majorRole); // should we use bitmap instead?? |
|
309 |
|
310 if (majorRole & BtuiDevProperty::Bonded && |
|
311 majorRole & BtuiDevProperty::Trusted && |
|
312 majorRole & BtuiDevProperty::Connected ) { |
|
313 mDeviceStatus->setPlainText(hbTrId("txt_bt_info_paired_trused_connected")); |
|
314 } |
|
315 else if (majorRole & BtuiDevProperty::Bonded && |
|
316 majorRole & BtuiDevProperty::Connected ) { |
|
317 mDeviceStatus->setPlainText(hbTrId("txt_bt_info_paired_connected")); |
|
318 } |
|
319 else if (majorRole & BtuiDevProperty::Bonded && |
|
320 majorRole & BtuiDevProperty::Trusted ) { |
|
321 mDeviceStatus->setPlainText(hbTrId("txt_bt_info_paired_trusted")); |
|
322 } |
|
323 else if (majorRole & BtuiDevProperty::Bonded) { |
|
324 mDeviceStatus->setPlainText(hbTrId("txt_bt_info_paired")); |
|
325 } |
|
326 else if (majorRole & BtuiDevProperty::Connected) { |
|
327 mDeviceStatus->setPlainText(hbTrId("txt_bt_info_connected")); |
|
328 } |
|
329 else if (majorRole & BtuiDevProperty::Blocked) { |
|
330 mDeviceStatus->setPlainText(hbTrId("txt_bt_info_blocked")); |
|
331 } |
|
332 else { |
|
333 // device not paired, connected, trusted or blocked. is this ok? |
|
334 } |
|
335 |
|
336 } |
|
337 |
|
338 void BtCpUiDeviceView::setConnectionCombobox(){ |
|
339 |
|
340 //create a model class |
|
341 |
|
342 mConnectionComboboxModel->appendDataFormItem( |
|
343 HbDataFormModelItem::ComboBoxItem, QString("Connection"), mConnectionComboboxModel->invisibleRootItem()); |
|
344 |
|
345 //set the model to the view, once model and data class are created |
|
346 mConnectionCombobox->setModel(mConnectionComboboxModel); |
|
347 |
|
348 |
|
349 |
|
350 } |
|
351 |
|
352 |
|
353 /*! |
|
354 * instead of using separate boolean variables we could use bitmap in single variable |
|
355 */ |
|
356 void BtCpUiDeviceView::updateStatusVariables(int majorRole) |
|
357 { |
|
358 if (majorRole & BtuiDevProperty::Trusted ) { |
|
359 mTrustedStatus = true; |
|
360 } |
|
361 else { |
|
362 mTrustedStatus = false; |
|
363 } |
|
364 if (majorRole & BtuiDevProperty::Bonded) { |
|
365 mPairedStatus = true; |
|
366 } |
|
367 else { |
|
368 mPairedStatus = false; |
|
369 } |
|
370 if (majorRole & BtuiDevProperty::Connected) { |
|
371 mConnectedStatus = true; |
|
372 } |
|
373 else { |
|
374 mConnectedStatus = false; |
|
375 } |
|
376 if (majorRole & BtuiDevProperty::Blocked) { |
|
377 mBlockedStatus = true; |
|
378 } |
|
379 else { |
|
380 mBlockedStatus = false; |
|
381 } |
|
382 } |
|
383 |
|
384 void BtCpUiDeviceView::setTextAndVisibilityOfButtons() |
|
385 { |
|
386 mPair_Unpair->setStretched(true); |
|
387 if (mPairedStatus) |
|
388 { |
|
389 HbIcon icon("qtg_mono_bt_unpair"); |
|
390 icon.setIconName("qtg_mono_bt_unpair"); |
|
391 mPair_Unpair->setIcon(icon); |
|
392 mPair_Unpair->setText(hbTrId("txt_bt_button_unpair")); |
|
393 |
|
394 } |
|
395 else |
|
396 { |
|
397 HbIcon icon("qtg_mono_bt_pair"); |
|
398 icon.setIconName("qtg_mono_bt_pair"); |
|
399 mPair_Unpair->setIcon(icon); |
|
400 mPair_Unpair->setText(hbTrId("txt_bt_button_pair")); |
|
401 } |
|
402 |
|
403 if (mConnectable) |
|
404 { |
|
405 mConnect_Disconnect->setStretched(true); |
|
406 if (mConnectedStatus) |
226 { |
407 { |
227 //this is a phone |
408 HbIcon icon("qtg_mono_speaker_off"); |
228 mDeviceCategory->setPlainText(tr("Phone")); |
409 icon.setIconName("qtg_mono_speaker_off"); |
229 } |
410 mConnect_Disconnect->setIcon(icon); |
230 else if (majorRole & 0x00010000) |
411 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 } |
412 } |
303 else |
413 else |
304 { |
414 { |
305 mConnect_Disconnect->setText(tr("Connect")); |
415 HbIcon icon("qtg_mono_speaker"); |
|
416 icon.setIconName("qtg_mono_speaker"); |
|
417 mConnect_Disconnect->setIcon(icon); |
|
418 mConnect_Disconnect->setText(hbTrId("txt_bt_button_connect")); |
306 } |
419 } |
307 |
420 |
308 } |
421 } |
309 else |
422 else |
310 { |
423 { |
311 //it is not possible to connect, set the button invisible |
424 //it is not possible to connect, set the button invisible |
312 mConnect_Disconnect->setVisible(false); |
425 mConnect_Disconnect->setVisible(false); |
313 } |
426 } |
314 |
427 |
315 mDeviceSetting->setVisible(false); |
428 } |
316 |
429 |
317 } |
|
318 |
|
319 void BtCpUiDeviceView::changeBtDeviceName() |
|
320 { |
|
321 /* |
|
322 if (!mAbstractDelegate) |
|
323 { |
|
324 mAbstractDelegate = BtDelegateFactory::newDelegate(BtDelegate::DeviceName, mModel); |
|
325 connect( mAbstractDelegate, SIGNAL(commandCompleted(int,QVariant)), this, SLOT(btNameDelegateCompleted(int,QVariant)) ); |
|
326 mAbstractDelegate->exec(mDeviceNameEdit->text ()); |
|
327 } |
|
328 */ |
|
329 |
|
330 } |
|
331 |
430 |
332 void BtCpUiDeviceView::pairUnpair() |
431 void BtCpUiDeviceView::pairUnpair() |
333 { |
432 { |
334 if (mPairStatus) |
433 if (mPairedStatus) |
335 { |
434 { |
336 //if the device is paired, call unpairDevice() when the button is tabbed |
435 //if the device is paired, call unpairDevice() when the button is tabbed |
337 unpairDevice(); |
436 unpairDevice(); |
338 } |
437 } |
339 else |
438 else |