84 |
74 |
85 // assign automatically created widgets to local variables |
75 // assign automatically created widgets to local variables |
86 |
76 |
87 mDeviceIcon=0; |
77 mDeviceIcon=0; |
88 // can't use qobject_cast since HbIcon is not derived from QObject! |
78 // can't use qobject_cast since HbIcon is not derived from QObject! |
89 mDeviceIcon = qobject_cast<HbLabel *>( mLoader->findWidget( "icon" ) ); |
79 mDeviceIcon = qobject_cast<HbLabel *>( mLoader->findWidget( "searchIcon" ) ); |
90 BTUI_ASSERT_X( mDeviceIcon != 0, "BtCpUiSearchView::BtCpUiSearchView", "Device Icon not found" ); |
80 BTUI_ASSERT_X( mDeviceIcon != 0, "BtcpuiSearchView::BtcpuiSearchView", "Device Icon not found" ); |
91 |
81 |
92 mDataForm=0; |
82 mDataForm=0; |
93 mDataForm = qobject_cast<HbDataForm *>( mLoader->findWidget( "dataForm" ) ); |
83 mDataForm = qobject_cast<HbDataForm *>( mLoader->findWidget( "searchHeading" ) ); |
94 BTUI_ASSERT_X( mDataForm != 0, "BtCpUiSearchView::BtCpUiSearchView", "dataForm not found" ); |
84 BTUI_ASSERT_X( mDataForm != 0, "BtcpuiSearchView::BtcpuiSearchView", "dataForm not found" ); |
95 mDataForm->setHeading(hbTrId("txt_bt_subhead_bluetooth_found_devices")); |
85 mDataForm->setHeading(hbTrId("txt_bt_subhead_bluetooth_found_devices")); |
96 |
86 |
97 mLabelSearching=0; |
87 mLabelSearching=0; |
98 mLabelSearching = qobject_cast<HbLabel *>( mLoader->findWidget( "label_searching" ) ); |
88 mLabelSearching = qobject_cast<HbLabel *>( mLoader->findWidget( "searchStatus" ) ); |
99 BTUI_ASSERT_X( mLabelSearching != 0, "BtCpUiSearchView::BtCpUiSearchView", "Searching not found" ); |
89 BTUI_ASSERT_X( mLabelSearching != 0, "BtcpuiSearchView::BtcpuiSearchView", "Searching not found" ); |
100 mLabelSearching->setPlainText(hbTrId("txt_bt_subhead_searching")); |
90 mLabelSearching->setPlainText(hbTrId("txt_bt_subhead_searching")); |
101 |
91 |
102 mDeviceList=0; |
92 mDeviceList=0; |
103 mDeviceList = qobject_cast<HbListView *>( mLoader->findWidget( "deviceList" ) ); |
93 mDeviceList = qobject_cast<HbListView *>( mLoader->findWidget( "deviceList" ) ); |
104 BTUI_ASSERT_X( mDeviceList != 0, "BtCpUiSearchView::BtCpUiSearchView", "Device List not found" ); |
94 BTUI_ASSERT_X( mDeviceList != 0, "BtcpuiSearchView::BtcpuiSearchView", "Device List not found" ); |
105 |
95 |
106 |
96 ret = connect(mDeviceList, |
|
97 SIGNAL(longPressed(HbAbstractViewItem*, QPointF)), this, |
|
98 SLOT(showContextMenu(HbAbstractViewItem*, QPointF))); |
|
99 BTUI_ASSERT_X( ret, "bt-search-view", "deviceSelected can't connect" ); |
|
100 |
107 mDeviceList->setSelectionMode( HbAbstractItemView::SingleSelection ); |
101 mDeviceList->setSelectionMode( HbAbstractItemView::SingleSelection ); |
108 |
102 |
109 // read landscape orientation section from docml file if needed |
103 // read landscape orientation section from docml file if needed |
110 mOrientation = mMainWindow->orientation(); |
104 mOrientation = mMainWindow->orientation(); |
111 |
105 |
112 if (mOrientation == Qt::Horizontal) { |
106 if (mOrientation == Qt::Horizontal) { |
113 mLoader->load(BTUI_SEARCHVIEW_DOCML, "landscape_ui", &ok); |
107 mLoader->load(BTUI_SEARCHVIEW_DOCML, "landscape", &ok); |
114 BTUI_ASSERT_X( ok, "BtCpUiSearchView::BtCpUiSearchView", "Invalid docml file: landscape section problem" ); |
108 BTUI_ASSERT_X( ok, "BtcpuiSearchView::BtcpuiSearchView", "Invalid docml file: landscape section problem" ); |
115 } else { |
109 } else { |
116 mLoader->load(BTUI_SEARCHVIEW_DOCML, "portrait_ui", &ok); |
110 mLoader->load(BTUI_SEARCHVIEW_DOCML, "portrait", &ok); |
117 BTUI_ASSERT_X( ok, "BtCpUiSearchView::BtCpUiSearchView", "Invalid docml file: portrait section problem" ); |
111 BTUI_ASSERT_X( ok, "BtcpuiSearchView::BtcpuiSearchView", "Invalid docml file: portrait section problem" ); |
118 } |
112 } |
119 |
113 |
120 // listen for orientation changes |
114 // listen for orientation changes |
121 ret = connect(mMainWindow, SIGNAL(orientationChanged(Qt::Orientation)), |
115 ret = connect(mMainWindow, SIGNAL(orientationChanged(Qt::Orientation)), |
122 this, SLOT(changeOrientation(Qt::Orientation))); |
116 this, SLOT(changeOrientation(Qt::Orientation))); |
123 BTUI_ASSERT_X( ret, "BtCpUiSearchView::BtCpUiSearchView()", "connect orientationChanged() failed"); |
117 BTUI_ASSERT_X( ret, "BtcpuiSearchView::BtcpuiSearchView()", "connect orientationChanged() failed"); |
124 |
118 |
125 // load tool bar actions |
119 // load tool bar actions |
126 mViewBy = static_cast<HbAction*>( mLoader->findObject( "viewByAction" ) ); |
120 mViewBy = static_cast<HbAction*>( mLoader->findObject( "viewByAction" ) ); |
127 BTUI_ASSERT_X( mViewBy, "BtCpUiSearchView::BtCpUiSearchView", "view by action missing" ); |
121 BTUI_ASSERT_X( mViewBy, "BtcpuiSearchView::BtcpuiSearchView", "view by action missing" ); |
128 ret = connect(mViewBy, SIGNAL(triggered()), this, SLOT(viewByDeviceTypeDialog())); |
122 ret = connect(mViewBy, SIGNAL(triggered()), this, SLOT(viewByDeviceTypeDialog())); |
129 BTUI_ASSERT_X( ret, "BtCpUiSearchView::BtCpUiSearchView", "viewByAction can't connect" ); |
123 BTUI_ASSERT_X( ret, "BtcpuiSearchView::BtcpuiSearchView", "viewByAction can't connect" ); |
130 |
124 |
131 mStop = static_cast<HbAction*>( mLoader->findObject( "stopAction" ) ); |
125 mStop = static_cast<HbAction*>( mLoader->findObject( "stopAction" ) ); |
132 BTUI_ASSERT_X( mStop, "BtCpUiSearchView::BtCpUiSearchView", "stopAction missing" ); |
126 BTUI_ASSERT_X( mStop, "BtcpuiSearchView::BtcpuiSearchView", "stopAction missing" ); |
133 ret = connect(mStop, SIGNAL(triggered()), this, SLOT(stopSearching())); |
127 ret = connect(mStop, SIGNAL(triggered()), this, SLOT(stopSearching())); |
134 BTUI_ASSERT_X( ret, "BtCpUiSearchView::BtCpUiSearchView", "stopAction can't connect" ); |
128 BTUI_ASSERT_X( ret, "BtcpuiSearchView::BtcpuiSearchView", "stopAction can't connect" ); |
135 mStop->setEnabled(true); |
129 mStop->setEnabled(true); |
136 |
130 |
137 mRetry = static_cast<HbAction*>( mLoader->findObject( "retryAction" ) ); |
131 mRetry = static_cast<HbAction*>( mLoader->findObject( "retryAction" ) ); |
138 BTUI_ASSERT_X( mRetry, "BtCpUiSearchView::BtCpUiSearchView", "retryAction missing" ); |
132 BTUI_ASSERT_X( mRetry, "BtcpuiSearchView::BtcpuiSearchView", "retryAction missing" ); |
139 ret = connect(mRetry, SIGNAL(triggered()), this, SLOT(retrySearch())); |
133 ret = connect(mRetry, SIGNAL(triggered()), this, SLOT(retrySearch())); |
140 BTUI_ASSERT_X( ret, "BtCpUiSearchView::BtCpUiSearchView", "retryAction can't connect" ); |
134 BTUI_ASSERT_X( ret, "BtcpuiSearchView::BtcpuiSearchView", "retryAction can't connect" ); |
141 // Disable for initial search |
135 // Disable for initial search |
142 mRetry->setEnabled(false); |
136 mRetry->setEnabled(false); |
143 |
137 |
144 // load menu |
138 // load menu |
145 HbMenu *optionsMenu = qobject_cast<HbMenu *>(mLoader->findWidget("viewMenu")); |
139 HbMenu *optionsMenu = qobject_cast<HbMenu *>(mLoader->findWidget("viewMenu")); |
146 BTUI_ASSERT_X( optionsMenu != 0, "BtCpUiSearchView::BtCpUiSearchView", "Options menu not found" ); |
140 BTUI_ASSERT_X( optionsMenu != 0, "BtcpuiSearchView::BtcpuiSearchView", "Options menu not found" ); |
147 this->setMenu(optionsMenu); |
141 this->setMenu(optionsMenu); |
148 |
142 |
149 ret = connect(mDeviceList, SIGNAL(activated(QModelIndex)), this, SLOT(deviceSelected(QModelIndex))); |
143 ret = connect(mDeviceList, SIGNAL(activated(QModelIndex)), this, SLOT(deviceSelected(QModelIndex))); |
150 BTUI_ASSERT_X( ret, "BtCpUiSearchView::BtCpUiSearchView", "deviceSelected can't connect" ); |
144 BTUI_ASSERT_X( ret, "BtcpuiSearchView::BtcpuiSearchView", "deviceSelected can't connect" ); |
151 |
145 |
152 // initialize device type list for "view by" option |
146 bool regStatus(false); |
153 // Note: this list needs to be in the same order as enum devTypeSelectionList |
147 regStatus = HbStyleLoader::registerFilePath(":/docml/btcpuisearchlistviewitem.widgetml"); |
154 mDevTypeList << hbTrId("txt_bt_list_audio_devices") |
148 BTUI_ASSERT_X( regStatus, "BtcpuiSearchView::BtcpuiSearchView", "registerFilePath Widgetml Failed" ); |
155 << hbTrId("txt_bt_list_computers") |
149 regStatus = HbStyleLoader::registerFilePath(":/docml/btcpuisearchlistviewitem.css"); |
156 << hbTrId("txt_bt_list_input_devices") |
150 BTUI_ASSERT_X( regStatus, "BtcpuiSearchView::BtcpuiSearchView", "registerFilePath CSS Failed" ); |
157 << hbTrId("txt_bt_list_phones") |
151 |
158 << hbTrId("txt_bt_list_other_devices"); |
|
159 |
|
160 // initialize sort model & create |
152 // initialize sort model & create |
161 // inquiry delegate |
153 // inquiry delegate |
162 // Sort is set to dynamic sort filter = true in the class, will sort automatically |
154 // Sort is set to dynamic sort filter = true in the class, will sort automatically |
163 mBtuiModelSortFilter = new BtuiModelSortFilter(this); |
155 mBtuiModelSortFilter = new BtuiModelSortFilter(this); |
164 mBtuiModelSortFilter->setSourceModel(mDeviceModel); |
156 mBtuiModelSortFilter->setSourceModel(mDeviceModel); |
165 mBtuiModelSortFilter->addDeviceMajorFilter( |
157 mBtuiModelSortFilter->addDeviceMajorFilter( |
166 BtuiDevProperty::InRange, BtuiModelSortFilter::AtLeastMatch); |
158 BtuiDevProperty::InRange, BtuiModelSortFilter::AtLeastMatch); |
167 mDeviceList->setModel(mBtuiModelSortFilter); |
159 mDeviceList->setModel(mBtuiModelSortFilter); |
|
160 mDeviceList->setLayoutName("custom-list"); |
168 // add sort order to show devices in the order they are found |
161 // add sort order to show devices in the order they are found |
169 mBtuiModelSortFilter->setSortRole(BtDeviceModel::SeqNumRole); |
162 mBtuiModelSortFilter->setSortRole(BtDeviceModel::SeqNumRole); |
170 // Sort according to the first column (and the only column) in the listview - sorted according SeqNumRole |
163 // Sort according to the first column (and the only column) in the listview - sorted according SeqNumRole |
171 mBtuiModelSortFilter->sort(0, Qt::AscendingOrder); |
164 mBtuiModelSortFilter->sort(0, Qt::AscendingOrder); |
172 |
165 |
173 BtCpUiSearchListViewItem *prototype = new BtCpUiSearchListViewItem(mDeviceList); |
166 BtCpUiSearchListViewItem *prototype = new BtCpUiSearchListViewItem(mDeviceList); |
174 prototype->setModelSortFilter(mBtuiModelSortFilter); |
167 prototype->setModelSortFilter(mBtuiModelSortFilter); |
175 mDeviceList->setItemPrototype(prototype); |
168 mDeviceList->setItemPrototype(prototype); |
176 |
169 } |
177 // Create the inquiry delegate. |
170 |
178 mAbstractDelegate = BtDelegateFactory::newDelegate(BtDelegate::Inquiry, mSettingModel, mDeviceModel ); |
171 BtcpuiSearchView::~BtcpuiSearchView() |
179 |
|
180 |
|
181 } |
|
182 |
|
183 BtCpUiSearchView::~BtCpUiSearchView() |
|
184 { |
172 { |
185 delete mLoader; // Also deletes all widgets that it constructed. |
173 delete mLoader; // Also deletes all widgets that it constructed. |
186 |
174 delete mBtuiModelSortFilter; |
187 setNavigationAction(0); |
175 HbStyleLoader::unregisterFilePath(":/docml/btcpuisearchlistviewitem.widgetml"); |
188 disconnect( mSoftKeyBackAction ); |
176 HbStyleLoader::unregisterFilePath(":/docml/btcpuisearchlistviewitem.css"); |
189 delete mSoftKeyBackAction; |
177 } |
190 |
178 |
191 if(mAbstractDelegate) { |
179 void BtcpuiSearchView::changeOrientation( Qt::Orientation orientation ) |
192 disconnect(mAbstractDelegate); |
|
193 delete mAbstractDelegate; |
|
194 } |
|
195 if(mBtuiModelSortFilter) { |
|
196 delete mBtuiModelSortFilter; |
|
197 } |
|
198 if ( mQuery ) { |
|
199 delete mQuery; |
|
200 } |
|
201 } |
|
202 |
|
203 void BtCpUiSearchView::changeOrientation( Qt::Orientation orientation ) |
|
204 { |
180 { |
205 // ToDo: this does not handle redrawing list view items differently for portrait/landscape |
181 // ToDo: this does not handle redrawing list view items differently for portrait/landscape |
206 bool ok = false; |
182 bool ok = false; |
207 mOrientation = orientation; |
183 mOrientation = orientation; |
208 |
184 |
209 if( orientation == Qt::Vertical ) { |
185 if( orientation == Qt::Vertical ) { |
210 // load "portrait" section |
186 // load "portrait" section |
211 mLoader->load( BTUI_SEARCHVIEW_DOCML, "portrait_ui", &ok ); |
187 mLoader->load( BTUI_SEARCHVIEW_DOCML, "portrait", &ok ); |
212 BTUI_ASSERT_X( ok, "BtCpUiSearchView::changeOrientation", "Invalid docml file: portrait section problem" ); |
188 BTUI_ASSERT_X( ok, "BtcpuiSearchView::changeOrientation", "Invalid docml file: portrait section problem" ); |
213 } else { |
189 } else { |
214 // load "landscape" section |
190 // load "landscape" section |
215 mLoader->load( BTUI_SEARCHVIEW_DOCML, "landscape_ui", &ok ); |
191 mLoader->load( BTUI_SEARCHVIEW_DOCML, "landscape", &ok ); |
216 BTUI_ASSERT_X( ok, "BtCpUiSearchView::changeOrientation", "Invalid docml file: landscape section problem" ); |
192 BTUI_ASSERT_X( ok, "BtcpuiSearchView::changeOrientation", "Invalid docml file: landscape section problem" ); |
217 } |
193 } |
218 } |
194 } |
219 |
195 |
220 |
|
221 void BtCpUiSearchView::viewByDeviceTypeDialog() |
|
222 { |
|
223 if ( !mQuery ) { |
|
224 mQuery = new HbSelectionDialog; |
|
225 mQuery->setStringItems(mDevTypeList, 0); |
|
226 mQuery->setSelectionMode(HbAbstractItemView::MultiSelection); |
|
227 |
|
228 QList<QVariant> current; |
|
229 current.append(QVariant(0)); |
|
230 mQuery->setSelectedItems(current); |
|
231 |
|
232 // Set the heading for the dialog. |
|
233 HbLabel *headingLabel = new HbLabel(hbTrId("txt_bt_title_show"), mQuery); |
|
234 mQuery->setHeadingWidget(headingLabel); |
|
235 } |
|
236 mQuery->open(this,SLOT(viewByDialogClosed(HbAction*))); |
|
237 } |
|
238 /*! |
196 /*! |
239 Callback for HbSelectionDialog closing |
197 Callback for HbSelectionDialog closing |
|
198 ReImplemented Slot from Base class |
240 |
199 |
241 */ |
200 */ |
242 void BtCpUiSearchView::viewByDialogClosed(HbAction* action) |
201 void BtcpuiSearchView::viewByDialogClosed(HbAction* action) |
243 { |
202 { |
244 disconnect( mQuery ); // remove slot |
203 int devTypesWanted = 0; |
245 if (action == mQuery->actions().first()) { // user pressed "Ok" |
204 |
246 // Get selected items. |
205 devTypesWanted = selectedDeviceTypes(action); |
247 QList<QVariant> selections; |
206 |
248 selections = mQuery->selectedItems(); |
207 if (devTypesWanted) { |
249 |
208 mBtuiModelSortFilter->clearDeviceMajorFilters(); |
250 int devTypesWanted = 0; |
209 mBtuiModelSortFilter->addDeviceMajorFilter(BtuiDevProperty::InRange, |
251 |
210 BtuiModelSortFilter::AtLeastMatch); // device must be in range |
252 for (int i=0; i < selections.count(); i++) { |
211 mBtuiModelSortFilter->addDeviceMajorFilter(devTypesWanted, |
253 switch (selections.at(i).toInt()) { |
212 BtuiModelSortFilter::RoughMatch); // device can be any one of selected ones |
254 case BtUiDevAudioDevice: |
213 } |
255 devTypesWanted |= BtuiDevProperty::AVDev; |
214 } |
256 break; |
215 |
257 case BtUiDevComputer: |
216 void BtcpuiSearchView::stopSearching() |
258 devTypesWanted |= BtuiDevProperty::Computer; |
|
259 break; |
|
260 case BtUiDevInputDevice: |
|
261 devTypesWanted |= BtuiDevProperty::Peripheral; |
|
262 break; |
|
263 case BtUiDevPhone: |
|
264 devTypesWanted |= BtuiDevProperty::Phone; |
|
265 break; |
|
266 case BtUiDevOtherDevice: |
|
267 devTypesWanted |= (BtuiDevProperty::LANAccessDev | |
|
268 BtuiDevProperty::Toy | |
|
269 BtuiDevProperty::WearableDev | |
|
270 BtuiDevProperty::ImagingDev | |
|
271 BtuiDevProperty::HealthDev | |
|
272 BtuiDevProperty::UncategorizedDev); |
|
273 break; |
|
274 default: |
|
275 // should never get here |
|
276 BTUI_ASSERT_X(false, "BtCpUiSearchView::viewByDialogClosed()", |
|
277 "wrong device type in viewBy dialog!"); |
|
278 } |
|
279 } |
|
280 if (devTypesWanted) { |
|
281 mBtuiModelSortFilter->clearDeviceMajorFilters(); |
|
282 mBtuiModelSortFilter->addDeviceMajorFilter(BtuiDevProperty::InRange, |
|
283 BtuiModelSortFilter::AtLeastMatch); // device must be in range |
|
284 mBtuiModelSortFilter->addDeviceMajorFilter(devTypesWanted, |
|
285 BtuiModelSortFilter::RoughMatch); // device can be any one of selected ones |
|
286 } |
|
287 } |
|
288 } |
|
289 |
|
290 void BtCpUiSearchView::stopSearching() |
|
291 { |
217 { |
292 // Stop searching |
218 // Stop searching |
293 |
219 if (mDelegate) { |
294 // Stop search delegate |
220 mDelegate->cancel(); |
295 mAbstractDelegate->cancel(); |
221 // update the states of view items |
296 // reset view |
222 deviceSearchCompleted(KErrNone); |
297 deviceSearchCompleted(KErrNone); |
223 } |
298 } |
224 } |
299 |
225 |
300 void BtCpUiSearchView::startSearchDelegate () |
226 void BtcpuiSearchView::take(BtAbstractDelegate *delegate) |
301 { |
227 { |
302 bool ret = false; |
228 mDelegate = delegate; |
303 |
229 if (mDelegate) { |
304 // Connect to the signal from the BtDelegateInquiry for completion of the search request |
230 disconnect(mDelegate, 0, 0, 0); |
305 ret = connect(mAbstractDelegate, SIGNAL(commandCompleted(int)), this, SLOT(searchDelegateCompleted(int))); |
231 if (mDelegate->supportedEditorTypes() & BtDelegate::Inquiry) { |
306 BTUI_ASSERT_X( ret, "BtCpUiSearchView::BtCpUiSearchView", "searchDelegateCompleted can't connect" ); |
232 connect(mDelegate, SIGNAL(delegateCompleted(int,BtAbstractDelegate*)), |
307 |
233 this, SLOT(deviceSearchCompleted(int))); |
308 // Connect to the signal from the BtuiModel when the search has been completed. |
234 } else { |
309 ret = connect(mDeviceModel, SIGNAL(deviceSearchCompleted(int)), this, SLOT(deviceSearchCompleted(int))); |
235 connect(mDelegate, SIGNAL(delegateCompleted(int,BtAbstractDelegate*)), |
310 BTUI_ASSERT_X( ret, "BtCpUiSearchView::BtCpUiSearchView", "deviceSearchCompleted can't connect" ); |
236 this, SLOT(handleDelegateCompleted(int))); |
311 |
237 } |
312 mAbstractDelegate->exec(QVariant()); |
238 } |
313 } |
239 } |
314 |
240 |
315 void BtCpUiSearchView::retrySearch() |
241 void BtcpuiSearchView::startSearchDelegate() |
|
242 { |
|
243 (void) createExecuteDelegate(BtDelegate::Inquiry, |
|
244 this, SLOT(deviceSearchCompleted(int)), QVariant()); |
|
245 } |
|
246 |
|
247 void BtcpuiSearchView::retrySearch() |
316 { |
248 { |
317 // Retry search |
249 // Retry search |
318 |
|
319 // Change label and buttons to reflect status |
250 // Change label and buttons to reflect status |
320 mLabelSearching->setPlainText(hbTrId("txt_bt_subhead_searching")); |
251 mLabelSearching->setPlainText(hbTrId("txt_bt_subhead_searching")); |
321 mRetry->setEnabled(false); |
252 mRetry->setEnabled(false); |
322 mStop->setEnabled(true); |
253 mStop->setEnabled(true); |
323 |
254 |
324 // Make use of the delegate and start the search. |
255 // Make use of the delegate and start the search. |
325 startSearchDelegate (); |
256 startSearchDelegate(); |
326 } |
257 } |
327 |
258 |
328 void BtCpUiSearchView::setSoftkeyBack() |
259 void BtcpuiSearchView::activateView( const QVariant& value, bool backNavi) |
329 { |
|
330 if (navigationAction() != mSoftKeyBackAction) { |
|
331 setNavigationAction(mSoftKeyBackAction); |
|
332 connect( mSoftKeyBackAction, SIGNAL(triggered()), this, SLOT(switchToPreviousView()) ); |
|
333 } |
|
334 } |
|
335 |
|
336 void BtCpUiSearchView::switchToPreviousView() |
|
337 { |
|
338 BTUI_ASSERT_X(mMainView, "BtCpUiSearchView::switchToPreviousView", "invalid mMainView"); |
|
339 mMainView->switchToPreviousView(); |
|
340 } |
|
341 |
|
342 void BtCpUiSearchView::activateView( const QVariant& value, bool fromBackButton ) |
|
343 { |
260 { |
344 Q_UNUSED(value); |
261 Q_UNUSED(value); |
345 |
262 if (!backNavi) { |
|
263 retrySearch(); |
|
264 } |
|
265 |
346 // ToDo: consider whether orientation should be updated here rather than when orientation really changes; |
266 // ToDo: consider whether orientation should be updated here rather than when orientation really changes; |
347 // advantage: if orientation changes temporarily in another view, but returns to previous setting before |
267 // advantage: if orientation changes temporarily in another view, but returns to previous setting before |
348 // search is reactived, there is no processing overhead |
268 // search is reactived, there is no processing overhead |
349 |
269 } |
350 setSoftkeyBack(); |
270 |
351 |
271 void BtcpuiSearchView::deactivateView() |
352 if ( !fromBackButton ) { |
272 { |
353 // Sets the label and toolbar buttons |
273 stopSearching(); |
354 retrySearch(); |
274 } |
355 } |
275 void BtcpuiSearchView::deviceSearchCompleted(int error) |
356 } |
|
357 |
|
358 void BtCpUiSearchView::deactivateView() |
|
359 { |
|
360 mAbstractDelegate->cancel(); // Stop searching when leaving view |
|
361 deviceSearchCompleted(KErrNone); // reset view |
|
362 } |
|
363 |
|
364 void BtCpUiSearchView::searchDelegateCompleted(int error) |
|
365 { |
276 { |
366 Q_UNUSED(error); |
277 Q_UNUSED(error); |
367 |
|
368 } |
|
369 |
|
370 void BtCpUiSearchView::deviceSearchCompleted(int error) |
|
371 { |
|
372 //TODO - handle error. |
|
373 Q_UNUSED(error); |
|
374 |
|
375 mLabelSearching->setPlainText(hbTrId("txt_bt_subhead_search_done")); |
278 mLabelSearching->setPlainText(hbTrId("txt_bt_subhead_search_done")); |
376 mRetry->setEnabled(true); |
279 mRetry->setEnabled(true); |
377 mStop->setEnabled(false); |
280 mStop->setEnabled(false); |
378 |
281 handleDelegateCompleted(error, mDelegate); |
379 // disconnect signals |
282 } |
380 disconnect(mAbstractDelegate); |
283 |
381 disconnect(mDeviceModel); |
284 void BtcpuiSearchView::createContextMenuActions(int majorRole) |
382 } |
285 { |
383 |
286 if (majorRole & BtuiDevProperty::Connected) { |
384 void BtCpUiSearchView::deviceSelected(const QModelIndex& modelIndex) |
287 if(majorRole & BtuiDevProperty::AVDev) { |
385 { |
288 mContextMenu->addAction(hbTrId("txt_bt_menu_disconnect_audio")); |
386 QModelIndex index = mBtuiModelSortFilter->mapToSource(modelIndex); |
289 } |
387 static_cast<BtCpUiMainView*>(mMainView)->goToDeviceView(index); |
290 else { |
388 } |
291 mContextMenu->addAction(hbTrId("txt_bt_menu_disconnect")); |
|
292 } |
|
293 } |
|
294 else { |
|
295 if(majorRole & BtuiDevProperty::AVDev) { |
|
296 mContextMenu->addAction(hbTrId("txt_bt_menu_connect_audio")); |
|
297 } |
|
298 else { |
|
299 mContextMenu->addAction(hbTrId("txt_bt_menu_connect")); |
|
300 } |
|
301 } |
|
302 } |