50 BtCpUiDeviceView::BtCpUiDeviceView( |
50 BtCpUiDeviceView::BtCpUiDeviceView( |
51 BtSettingModel &settingModel, |
51 BtSettingModel &settingModel, |
52 BtDeviceModel &deviceModel, |
52 BtDeviceModel &deviceModel, |
53 QGraphicsItem *parent) : |
53 QGraphicsItem *parent) : |
54 BtCpUiBaseView(settingModel,deviceModel,parent), |
54 BtCpUiBaseView(settingModel,deviceModel,parent), |
55 mPairedStatus(false), mConnectedStatus(false), mTrustedStatus(false), mBlockedStatus(false), |
55 mPairedStatus(false), mConnectedStatus(false),mPreviousConnectedStatus(false), mTrustedStatus(false), |
56 mConnectable(false), mAbstractDelegate(0), mDeviceDetail(0) |
56 mBlockedStatus(false), mConnectable(false), mAbstractDelegate(0), mDeviceDetail(0) |
57 { |
57 { |
58 mDeviceIndex = QModelIndex();//is it needed to initialize mIndex??? |
58 mDeviceIndex = QModelIndex();//is it needed to initialize mIndex??? |
59 |
59 |
60 mMainView = (BtCpUiMainView *) parent; |
60 mMainView = (BtCpUiMainView *) parent; |
61 |
61 |
185 |
185 |
186 void BtCpUiDeviceView::switchToPreviousView() |
186 void BtCpUiDeviceView::switchToPreviousView() |
187 { |
187 { |
188 BTUI_ASSERT_X(mMainView, "BtCpUiSearchView::switchToPreviousView", "invalid mMainView"); |
188 BTUI_ASSERT_X(mMainView, "BtCpUiSearchView::switchToPreviousView", "invalid mMainView"); |
189 mMainView->switchToPreviousView(); |
189 mMainView->switchToPreviousView(); |
190 delete mDeviceDetail; |
190 |
191 mDeviceDetail = 0; |
191 if(mDeviceDetail) { |
|
192 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; |
|
217 mDeviceDetail = 0; |
|
218 } |
192 } |
219 } |
193 |
220 |
194 void BtCpUiDeviceView::activateView( const QVariant& value, bool fromBackButton ) |
221 void BtCpUiDeviceView::activateView( const QVariant& value, bool fromBackButton ) |
195 { |
222 { |
|
223 |
196 Q_UNUSED( fromBackButton ); |
224 Q_UNUSED( fromBackButton ); |
197 |
225 |
|
226 mConnectedStatus = false; |
198 setSoftkeyBack(); |
227 setSoftkeyBack(); |
|
228 |
199 |
229 |
200 QModelIndex index = value.value<QModelIndex>(); |
230 QModelIndex index = value.value<QModelIndex>(); |
201 mDeviceBdAddr = (mDeviceModel->data(index, BtDeviceModel::ReadableBdaddrRole)); |
231 mDeviceBdAddr = (mDeviceModel->data(index, BtDeviceModel::ReadableBdaddrRole)); |
202 |
232 |
203 //activate view is called when device is selected |
233 //activate view is called when device is selected |
204 //clearViewData(); |
234 //clearViewData(); |
205 updateDeviceData(); |
235 updateDeviceData(); |
206 |
236 |
207 mDeviceSetting->setVisible(false); |
237 mDeviceSetting->setVisible(false); |
208 |
238 |
209 mDeviceDetail = new BtCpUiDeviceDetail(); |
|
210 |
|
211 bool ret(false); |
239 bool ret(false); |
212 ret=connect(mDeviceModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), |
240 ret=connect(mDeviceModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), |
213 this, SLOT(updateDeviceData())); |
241 this, SLOT(updateDeviceData())); |
214 BTUI_ASSERT_X( ret, "Btui, BtCpUiDeviceView::activateView", "dataChanged() connect failed"); |
242 BTUI_ASSERT_X( ret, "Btui, BtCpUiDeviceView::activateView", "dataChanged() connect failed"); |
215 |
243 |
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 } |
244 } |
224 |
245 |
225 void BtCpUiDeviceView::handleDeviceSettingsChange(bool status) |
246 void BtCpUiDeviceView::handleDeviceSettingsChange(bool status) |
226 { |
247 { |
227 mDeviceSetting->setVisible(status); |
248 mDeviceSetting->setVisible(status); |
228 } |
249 } |
229 |
250 |
230 void BtCpUiDeviceView::handleDeviceSetting() |
251 void BtCpUiDeviceView::handleDeviceSetting() |
231 { |
252 { |
232 mDeviceDetail->loadDeviceDetailsView(); |
253 if(mDeviceDetail) { |
|
254 mDeviceDetail->loadDeviceDetailsView(); |
|
255 } |
233 } |
256 } |
234 |
257 |
235 void BtCpUiDeviceView::deactivateView() |
258 void BtCpUiDeviceView::deactivateView() |
236 { |
259 { |
237 } |
260 } |
255 void BtCpUiDeviceView::clearViewData() |
278 void BtCpUiDeviceView::clearViewData() |
256 { |
279 { |
257 mDeviceIcon->clear(); |
280 mDeviceIcon->clear(); |
258 mDeviceCategory->clear(); |
281 mDeviceCategory->clear(); |
259 mDeviceStatus->clear(); |
282 mDeviceStatus->clear(); |
260 |
283 mConnectable = false; |
|
284 /* |
261 mPairedStatus = false; |
285 mPairedStatus = false; |
262 mConnectedStatus = false; |
286 mConnectedStatus = false; |
263 mTrustedStatus = false; |
287 mTrustedStatus = false; |
264 mBlockedStatus = false; |
288 mBlockedStatus = false; |
265 |
289 |
266 mConnectable = false; |
290 mConnectable = false; |
|
291 */ |
267 } |
292 } |
268 |
293 |
269 void BtCpUiDeviceView::updateDeviceData() |
294 void BtCpUiDeviceView::updateDeviceData() |
270 { |
295 { |
271 clearViewData(); |
296 clearViewData(); |
580 if (mAbstractDelegate) |
610 if (mAbstractDelegate) |
581 { |
611 { |
582 disconnect(mAbstractDelegate); |
612 disconnect(mAbstractDelegate); |
583 delete mAbstractDelegate; |
613 delete mAbstractDelegate; |
584 mAbstractDelegate = 0; |
614 mAbstractDelegate = 0; |
585 } |
615 } |
586 |
616 } |
587 |
617 |
|
618 void BtCpUiDeviceView::setPrevBtDeviceName() |
|
619 { |
|
620 QString deviceName = (mDeviceModel->data(mDeviceIndex, |
|
621 BtDeviceModel::NameAliasRole)).toString(); |
|
622 mDeviceName->setText(deviceName); |
588 } |
623 } |
589 |
624 |
590 void BtCpUiDeviceView::changeBtDeviceName(){ |
625 void BtCpUiDeviceView::changeBtDeviceName(){ |
591 if (!mAbstractDelegate)//if there is no other delegate running |
626 if (!mAbstractDelegate)//if there is no other delegate running |
592 { |
627 { |
607 mAbstractDelegate = BtDelegateFactory::newDelegate( |
642 mAbstractDelegate = BtDelegateFactory::newDelegate( |
608 BtDelegate::RemoteDevName, mSettingModel, mDeviceModel); |
643 BtDelegate::RemoteDevName, mSettingModel, mDeviceModel); |
609 connect( mAbstractDelegate, SIGNAL(commandCompleted(int, QVariant)), this, SLOT(changeDevNameDelegateCompleted(int, QVariant)) ); |
644 connect( mAbstractDelegate, SIGNAL(commandCompleted(int, QVariant)), this, SLOT(changeDevNameDelegateCompleted(int, QVariant)) ); |
610 mAbstractDelegate->exec(params); |
645 mAbstractDelegate->exec(params); |
611 } |
646 } |
|
647 else { |
|
648 setPrevBtDeviceName(); |
|
649 } |
612 |
650 |
613 } |
651 } |
614 |
652 |
615 void BtCpUiDeviceView::changeDevNameDelegateCompleted(int status, QVariant param) |
653 void BtCpUiDeviceView::changeDevNameDelegateCompleted(int status, QVariant param) |
616 { |
654 { |