33 #include <hbmenu.h> |
33 #include <hbmenu.h> |
34 #include <hbaction.h> |
34 #include <hbaction.h> |
35 #include <hbcombobox.h> |
35 #include <hbcombobox.h> |
36 #include <hbgroupbox.h> |
36 #include <hbgroupbox.h> |
37 #include <hbdataform.h> |
37 #include <hbdataform.h> |
|
38 #include <HbStyleLoader> |
|
39 #include <bluetoothuitrace.h> |
|
40 #include <HbMessageBox> |
|
41 #include <btabstractdelegate.h> |
|
42 #include "btqtconstants.h" |
|
43 #include "btcpuimaingridviewitem.h" |
|
44 #include "btuidevtypemap.h" |
|
45 #include "btcpuiviewmgr.h" |
38 #include "btcpuisearchview.h" |
46 #include "btcpuisearchview.h" |
39 #include "btcpuideviceview.h" |
47 #include "btcpuideviceview.h" |
40 #include <bluetoothuitrace.h> |
|
41 #include <btdelegatefactory.h> |
|
42 #include <btabstractdelegate.h> |
|
43 #include "btqtconstants.h" |
|
44 #include "btcpuimainlistviewitem.h" |
|
45 #include "btuidevtypemap.h" |
|
46 |
48 |
47 // docml to load |
49 // docml to load |
48 const char* BTUI_MAINVIEW_DOCML = ":/docml/bt-main-view.docml"; |
50 const char* BTUI_MAINVIEW_DOCML = ":/docml/bt-main-view.docml"; |
49 |
51 |
50 /*! |
52 /*! |
51 Constructs a new BtUiMainView using HBDocumentLoader. Docml (basically xml) file |
53 Constructs a new BtUiMainView using HBDocumentLoader. Docml (basically xml) file |
52 has been generated using Application Designer. |
54 has been generated using Application Designer. |
53 |
55 */ |
54 */ |
56 BtcpuiMainView::BtcpuiMainView(QGraphicsItem *parent ) |
55 BtCpUiMainView::BtCpUiMainView( |
57 : BtcpuiBaseView(parent), mSearchView(0), mDeviceView(0) |
56 BtSettingModel &settingModel, |
58 { |
|
59 loadDocument(); |
|
60 setViewMgr(this); |
|
61 } |
|
62 |
|
63 /*! |
|
64 Constructs a new BtUiMainView using HBDocumentLoader. Docml (basically xml) file |
|
65 has been generated using Application Designer. |
|
66 */ |
|
67 BtcpuiMainView::BtcpuiMainView(BtSettingModel &settingModel, |
57 BtDeviceModel &deviceModel, |
68 BtDeviceModel &deviceModel, |
58 QGraphicsItem *parent ) |
69 QGraphicsItem *parent ) |
59 : BtCpUiBaseView( settingModel, deviceModel, parent ), |
70 : BtcpuiBaseView(settingModel, deviceModel, parent ), mSearchView(0), mDeviceView(0) |
60 mAbstractDelegate(0), mMainFilterModel(0) |
71 { |
61 { |
72 loadDocument(); |
62 bool ret(false); |
73 setViewMgr(this); |
63 |
74 } |
64 mMainWindow = hbInstance->allMainWindows().first(); |
75 |
65 mMainView = this; |
76 /*! |
66 |
77 Destructs the BtcpuiMainView. |
67 // Create view for the application. |
78 */ |
68 // Set the name for the view. The name should be same as the view's |
79 BtcpuiMainView::~BtcpuiMainView() |
69 // name in docml. |
80 { |
70 setObjectName("view"); |
81 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
71 |
82 delete mSearchView; |
72 mLoader = new HbDocumentLoader(); |
83 delete mDeviceView; |
73 // Pass the view to documentloader. Document loader uses this view |
84 delete mLoader; // Also deletes all widgets that it constructed. |
74 // when docml is parsed, instead of creating new view. |
85 HbStyleLoader::unregisterFilePath(":/docml/btcpuimaingridviewitem.widgetml"); |
75 QObjectList objectList; |
86 HbStyleLoader::unregisterFilePath(":/docml/btcpuimaingridviewitem.css"); |
76 objectList.append(this); |
87 BOstraceFunctionExit0(DUMMY_DEVLIST); |
77 mLoader->setObjectTree(objectList); |
88 } |
78 |
89 |
79 bool ok = false; |
90 /*! |
80 mLoader->load( BTUI_MAINVIEW_DOCML, &ok ); |
91 from base class, initialize the view |
81 // Exit if the file format is invalid |
92 */ |
82 BTUI_ASSERT_X( ok, "bt-main-view", "Invalid docml file" ); |
93 void BtcpuiMainView::activateView(const QVariant& value, bool backNavi) |
83 |
94 { |
84 mOrientation = mMainWindow->orientation(); |
95 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
85 |
96 Q_UNUSED(value); |
86 if (mOrientation == Qt::Horizontal) { |
97 Q_UNUSED(backNavi); |
87 mLoader->load(BTUI_MAINVIEW_DOCML, "landscape", &ok); |
|
88 BTUI_ASSERT_X( ok, "bt-main-view", "Invalid docml file: landscape section problem" ); |
|
89 } |
|
90 else { |
|
91 mLoader->load(BTUI_MAINVIEW_DOCML, "portrait", &ok); |
|
92 BTUI_ASSERT_X( ok, "bt-main-view", "Invalid docml file: landscape section problem" ); |
|
93 } |
|
94 |
|
95 mDeviceNameEdit=0; |
|
96 mDeviceNameEdit = qobject_cast<HbLineEdit *>( mLoader->findWidget( "lineEdit" ) ); |
|
97 BTUI_ASSERT_X( mDeviceNameEdit != 0, "bt-main-view", "Device Name not found" ); |
|
98 ret = connect(mDeviceNameEdit, SIGNAL(editingFinished ()), this, SLOT(changeBtLocalName())); |
|
99 |
|
100 mPowerButton=0; |
|
101 mPowerButton = qobject_cast<HbPushButton *>( mLoader->findWidget( "pushButton" ) ); |
|
102 BTUI_ASSERT_X( mPowerButton != 0, "bt-main-view", "power button not found" ); |
|
103 ret = connect(mPowerButton, SIGNAL(clicked()), this, SLOT(changePowerState())); |
|
104 BTUI_ASSERT_X( ret, "BtCpUiMainView::BtCpUiMainView", "can't connect power button" ); |
|
105 |
|
106 mVisibilityMode=0; |
|
107 mVisibilityMode = qobject_cast<HbComboBox *>( mLoader->findWidget( "combobox" ) ); |
|
108 BTUI_ASSERT_X( mVisibilityMode != 0, "bt-main-view", "visibility combobox not found" ); |
|
109 // add new item for temporary visibility |
|
110 // NOTE: translation (at least default english) gives string "(p)Visible for 5 min", |
|
111 // if setting 1 min --> "(s)Visible for 1 min", ie p=plural, s=singular, but these should |
|
112 // not be shown to the user! |
|
113 // ToDo: change this to use translation once it starts working |
|
114 QString tempVis(hbTrId("txt_bt_setlabel_visibility_val_visible_for_l1_min", 5)); |
|
115 //QString tempVis(hbTrId("Visible for 5 min")); |
|
116 mVisibilityMode->addItem(tempVis, Qt::DisplayRole); |
|
117 |
|
118 mDeviceList=0; |
|
119 mDeviceList = qobject_cast<HbListView *>( mLoader->findWidget( "listView" ) ); |
|
120 BTUI_ASSERT_X( mDeviceList != 0, "bt-main-view", "Device List (grid view) not found" ); |
|
121 |
|
122 ret = connect(mDeviceList, SIGNAL(activated(QModelIndex)), this, SLOT(deviceSelected(QModelIndex))); |
|
123 BTUI_ASSERT_X( ret, "bt-search-view", "deviceSelected can't connect" ); |
|
124 |
|
125 // listen for orientation changes |
|
126 ret = connect(mMainWindow, SIGNAL(orientationChanged(Qt::Orientation)), |
|
127 this, SLOT(changeOrientation(Qt::Orientation))); |
|
128 BTUI_ASSERT_X( ret, "BtCpUiMainView::BtCpUiMainView()", "connect orientationChanged() failed"); |
|
129 |
|
130 // load tool bar actions |
|
131 HbAction *discoverAction = static_cast<HbAction*>( mLoader->findObject( "discoverAction" ) ); |
|
132 BTUI_ASSERT_X( discoverAction, "bt-main-view", "discover action missing" ); |
|
133 ret = connect(discoverAction, SIGNAL(triggered()), this, SLOT(goToDiscoveryView())); |
|
134 BTUI_ASSERT_X( ret, "bt-main-view", "discover action can't connect" ); |
|
135 |
|
136 // load tool bar actions |
|
137 mAllAction = static_cast<HbAction*>( mLoader->findObject( "allAction" ) ); |
|
138 BTUI_ASSERT_X( mAllAction, "bt-main-view", "All action missing" ); |
|
139 ret = connect(mAllAction, SIGNAL(triggered()), this, SLOT(allActionTriggered())); |
|
140 BTUI_ASSERT_X( ret, "bt-main-view", "all action can't connect" ); |
|
141 |
|
142 // load tool bar actions |
|
143 mPairAction = static_cast<HbAction*>( mLoader->findObject( "pairedAction" ) ); |
|
144 BTUI_ASSERT_X( mPairAction, "bt-main-view", "Pair action missing" ); |
|
145 ret = connect(mPairAction, SIGNAL(triggered()), this, SLOT(pairActionTriggered())); |
|
146 BTUI_ASSERT_X( ret, "bt-main-view", "pair action can't connect" ); |
|
147 |
|
148 mDataForm = qobject_cast<HbDataForm *>( mLoader->findWidget( "dataForm" ) ); |
|
149 BTUI_ASSERT_X( mDataForm != 0, "bt-main-view", "dataForm not found" ); |
|
150 |
|
151 |
|
152 // load menu |
|
153 HbMenu *optionsMenu = qobject_cast<HbMenu *>(mLoader->findWidget("viewMenu")); |
|
154 BTUI_ASSERT_X( optionsMenu != 0, "bt-main-view", "Options menu not found" ); |
|
155 this->setMenu(optionsMenu); |
|
156 |
|
157 HbMenu *menu = this->menu(); |
|
158 mRemovePairedDevices = menu->addAction(hbTrId("txt_bt_opt_remove_paired_devices")); |
|
159 |
|
160 mSubMenu = new HbMenu(hbTrId("txt_bt_opt_remove")); |
|
161 mSubMenu->addAction(hbTrId("txt_bt_opt_remove_sub_all_devices")); |
|
162 mSubMenu->addAction(hbTrId("txt_bt_opt_remove_sub_paired_devices")); |
|
163 mSubMenu->addAction(hbTrId("txt_bt_opt_remove_sub_blocked_devices")); |
|
164 |
|
165 // update display when setting data changed |
|
166 ret = connect(mSettingModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), |
|
167 this, SLOT(updateSettingItems(QModelIndex,QModelIndex))); |
|
168 BTUI_ASSERT_X( ret, "BtCpUiMainView::BtCpUiMainView", "can't connect dataChanged" ); |
|
169 |
|
170 QModelIndex top = mSettingModel->index( BtSettingModel::LocalBtNameRow, 0 ); |
98 QModelIndex top = mSettingModel->index( BtSettingModel::LocalBtNameRow, 0 ); |
171 QModelIndex bottom = mSettingModel->index( BtSettingModel::AllowedInOfflineRow, 0 ); |
99 QModelIndex bottom = mSettingModel->index( BtSettingModel::AllowedInOfflineRow, 0 ); |
172 // update name, power and visibility rows |
100 // update name, power and visibility rows |
173 updateSettingItems( top, bottom ); |
101 updateSettingItems( top, bottom ); |
174 |
102 BOstraceFunctionExit0(DUMMY_DEVLIST); |
175 //Handle Visibility Change User Interaction |
103 } |
176 ret = connect(mVisibilityMode, SIGNAL(currentIndexChanged (int)), |
104 |
177 this, SLOT(visibilityChanged (int))); |
105 /*! |
178 // create other views |
|
179 createViews(); |
|
180 mCurrentView = this; |
|
181 mCurrentViewId = MainView; |
|
182 |
|
183 mMainFilterModel = new BtuiModelSortFilter(this); |
|
184 |
|
185 mMainFilterModel->setSourceModel( mDeviceModel ); |
|
186 mDeviceList->setModel(mMainFilterModel); |
|
187 updateDeviceListFilter(BtuiPaired); |
|
188 // List view item |
|
189 BtCpUiMainListViewItem *prototype = new BtCpUiMainListViewItem(mDeviceList); |
|
190 prototype->setModelSortFilter(mMainFilterModel); |
|
191 mDeviceList->setItemPrototype(prototype); |
|
192 |
|
193 } |
|
194 |
|
195 /*! |
|
196 Destructs the BtCpUiMainView. |
|
197 */ |
|
198 BtCpUiMainView::~BtCpUiMainView() |
|
199 { |
|
200 delete mLoader; // Also deletes all widgets that it constructed. |
|
201 mMainWindow->removeView(mSearchView); |
|
202 mMainWindow->removeView(mDeviceView); |
|
203 if (mAbstractDelegate) { |
|
204 delete mAbstractDelegate; |
|
205 } |
|
206 |
|
207 } |
|
208 |
|
209 /*! |
|
210 from base class, initialize the view |
|
211 */ |
|
212 void BtCpUiMainView::activateView(const QVariant& value, bool fromBackButton ) |
|
213 { |
|
214 Q_UNUSED(value); |
|
215 Q_UNUSED(fromBackButton); |
|
216 |
|
217 //Reset the device list when returning to the view, as it may have been invalidated by the device view |
|
218 mMainFilterModel->setSourceModel( mDeviceModel ); |
|
219 mDeviceList->setModel(mMainFilterModel); |
|
220 } |
|
221 |
|
222 /*! |
|
223 From base class. Handle resource before the current view is deactivated. |
106 From base class. Handle resource before the current view is deactivated. |
224 */ |
107 */ |
225 void BtCpUiMainView::deactivateView() |
108 void BtcpuiMainView::deactivateView() |
226 { |
109 { |
227 |
110 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
228 } |
111 BOstraceFunctionExit0(DUMMY_DEVLIST); |
229 |
112 } |
230 void BtCpUiMainView::goToDiscoveryView() |
113 |
231 { |
114 void BtcpuiMainView::launchDeviceDiscovery() |
232 changeView( SearchView, false ); |
115 { |
233 } |
116 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
234 |
117 // Construct the search view if it does not exist yet. |
235 void BtCpUiMainView::goToDeviceView(const QModelIndex& modelIndex) |
118 (void) searchView(); |
236 { |
119 bool ok = createDelegate(BtDelegate::Inquiry, |
237 //the QModelIndex of the selected device should be given as parameter here |
120 this, SLOT(handleDelegateCompleted(int,BtAbstractDelegate*))); |
238 QVariant params; |
121 if (ok) { |
239 params.setValue(modelIndex); |
122 // Connect to the signal from BtDelegateInquiry for switching to |
240 changeView( DeviceView, false, params ); |
123 // search view when BT inquiry operation is really started. |
241 } |
124 ok = connect(mDelegate, SIGNAL(beginUiEditMode()), this, SLOT(goToSearchView())); |
242 |
125 BTUI_ASSERT_X( ok, "BtcpuiMainView", "launchDeviceDiscovery() can't connect" ); |
243 Qt::Orientation BtCpUiMainView::orientation() |
126 } |
244 { |
127 if (ok) { |
245 return mOrientation; |
128 mDelegate->exec(QVariant()); |
246 } |
129 } |
247 |
130 BOstraceFunctionExit0(DUMMY_DEVLIST); |
248 void BtCpUiMainView::changeBtLocalName() |
131 } |
249 { |
132 |
250 //Error handling has to be done. |
133 void BtcpuiMainView::goToSearchView() |
251 if (!mAbstractDelegate) { |
134 { |
252 mAbstractDelegate = BtDelegateFactory::newDelegate(BtDelegate::DeviceName, |
135 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
253 mSettingModel, mDeviceModel); |
136 BtcpuiBaseView *search = searchView(); |
254 connect( mAbstractDelegate, SIGNAL(commandCompleted(int,QVariant)), this, SLOT(btNameDelegateCompleted(int,QVariant)) ); |
137 // For navigating back to this view |
255 mAbstractDelegate->exec(mDeviceNameEdit->text ()); |
138 search->setPreviousView( this ); |
256 } |
139 search->take(mDelegate); |
257 else { |
140 mDelegate = 0; |
|
141 switchView(this, search, QVariant(), false); |
|
142 BOstraceFunctionExit0(DUMMY_DEVLIST); |
|
143 } |
|
144 |
|
145 void BtcpuiMainView::changeBtLocalName() |
|
146 { |
|
147 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
|
148 bool ok = createExecuteDelegate(BtDelegate::ChangeLocalName, |
|
149 this, SLOT(btNameDelegateCompleted(int)), mDeviceNameEdit->text()); |
|
150 if (!ok) { |
258 setPrevBtLocalName(); |
151 setPrevBtLocalName(); |
259 } |
152 } |
260 } |
153 BOstraceFunctionExit0(DUMMY_DEVLIST); |
261 |
154 } |
262 void BtCpUiMainView::setPrevBtLocalName() |
155 |
263 { |
156 void BtcpuiMainView::setPrevBtLocalName() |
264 //ToDo: Should we notify user this as Error...? |
157 { |
265 //HbNotificationDialog::launchDialog(hbTrId("Error")); |
158 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
266 QModelIndex index = mSettingModel->index( BtSettingModel::LocalBtNameRow,0 ); |
159 QModelIndex index = mSettingModel->index( BtSettingModel::LocalBtNameRow,0 ); |
267 |
160 |
268 mDeviceNameEdit->setText( mSettingModel->data( |
161 mDeviceNameEdit->setText( mSettingModel->data( |
269 index,BtSettingModel::settingDisplayRole).toString() ); |
162 index,BtSettingModel::settingDisplayRole).toString() ); |
270 } |
163 BOstraceFunctionExit0(DUMMY_DEVLIST); |
271 |
164 } |
272 |
165 |
273 void BtCpUiMainView::btNameDelegateCompleted(int status, QVariant param) |
166 void BtcpuiMainView::btNameDelegateCompleted(int status) |
274 { |
167 { |
275 if(KErrNone == status) { |
168 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
276 mDeviceNameEdit->setText(param.toString()); |
169 if(KErrNone != status) { |
|
170 setPrevBtLocalName(); |
|
171 } |
|
172 handleDelegateCompleted(status, mDelegate); |
|
173 BOstraceFunctionExit0(DUMMY_DEVLIST); |
|
174 } |
|
175 |
|
176 void BtcpuiMainView::removeRegistryDevices(BtDelegate::EditorType type) |
|
177 { |
|
178 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
|
179 |
|
180 if (type != BtDelegate::RemoveBlockedDevices) { |
|
181 //Before removing devices from the list call disconnect delegate |
|
182 //to disconnect all active connections, this is done if all/paired |
|
183 //devices are removed. |
|
184 QList<QVariant> list; |
|
185 list.append(QVariant( AllOngoingConnections )); |
|
186 |
|
187 (void) createExecuteDelegate(BtDelegate::DisconnectAllConnections, |
|
188 this, SLOT(disconnectAllDelegateCompleted(int)), list); |
277 } |
189 } |
278 else { |
190 else { |
279 setPrevBtLocalName(); |
191 //In case of Blocked devices, just remove devices from list. |
280 } |
192 (void) createExecuteDelegate(type, |
281 //Error handling has to be done. |
193 this, SLOT(handleDelegateCompleted(int,BtAbstractDelegate*)), type); |
282 if (mAbstractDelegate) |
194 } |
283 { |
195 |
284 disconnect(mAbstractDelegate); |
196 BOstraceFunctionExit0(DUMMY_DEVLIST); |
285 delete mAbstractDelegate; |
197 } |
286 mAbstractDelegate = 0; |
198 |
287 } |
199 void BtcpuiMainView::disconnectAllDelegateCompleted(int status) |
288 |
200 { |
289 } |
201 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
290 |
202 handleDelegateCompleted(status, mDelegate); |
291 void BtCpUiMainView::visibilityChanged (int index) |
203 |
292 { |
204 //Remove Device list from registry after disconnect is done. |
|
205 (void) createExecuteDelegate(mRemoveDevDelegateType, |
|
206 this, SLOT(handleDelegateCompleted(int,BtAbstractDelegate*)), mRemoveDevDelegateType); |
|
207 |
|
208 BOstraceFunctionExit0(DUMMY_DEVLIST); |
|
209 } |
|
210 |
|
211 void BtcpuiMainView::changeVisibility(int index) |
|
212 { |
|
213 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
293 QList<QVariant> list; |
214 QList<QVariant> list; |
294 |
215 |
295 VisibilityMode mode = indexToVisibilityMode(index); |
216 VisibilityMode mode = indexToVisibilityMode(index); |
296 list.append(QVariant((int)mode)); |
217 list.append(QVariant((int)mode)); |
297 if( BtTemporary == VisibilityMode(mode) ) { |
218 if( BtTemporary == VisibilityMode(mode) ) { |
298 //Right now hardcoded to 5 Mins. |
219 //Right now hardcoded to 5 Mins. |
299 list.append(QVariant(5)); |
220 list.append(QVariant(5)); |
300 } |
221 } |
|
222 bool ok = createExecuteDelegate(BtDelegate::ChangeVisibility, |
|
223 this, SLOT(visibilityDelegateCompleted(int)), list); |
301 //Error handling has to be done. |
224 //Error handling has to be done. |
302 if ( !mAbstractDelegate ) { |
225 if ( !ok ) { |
303 mAbstractDelegate = BtDelegateFactory::newDelegate(BtDelegate::Visibility, |
|
304 mSettingModel, mDeviceModel); |
|
305 connect( mAbstractDelegate, SIGNAL(commandCompleted(int)), this, SLOT(visibilityDelegateCompleted(int)) ); |
|
306 mAbstractDelegate->exec(list); |
|
307 } |
|
308 else { |
|
309 setPrevVisibilityMode(); |
226 setPrevVisibilityMode(); |
310 } |
227 } |
311 |
228 BOstraceFunctionExit0(DUMMY_DEVLIST); |
312 } |
229 } |
313 |
230 |
314 void BtCpUiMainView::setPrevVisibilityMode() |
231 void BtcpuiMainView::setPrevVisibilityMode() |
315 { |
232 { |
316 |
233 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
317 QModelIndex index = mSettingModel->index( BtSettingModel::VisibilityRow, 0 ); |
234 QModelIndex index = mSettingModel->index( BtSettingModel::VisibilityRow, 0 ); |
318 |
235 |
319 mVisibilityMode->setCurrentIndex ( visibilityModeToIndex((VisibilityMode) |
236 mVisibilityMode->setCurrentIndex ( visibilityModeToIndex((VisibilityMode) |
320 mSettingModel->data(index,BtSettingModel::SettingValueRole).toInt()) ); |
237 mSettingModel->data(index,BtSettingModel::SettingValueRole).toInt()) ); |
321 |
238 BOstraceFunctionExit0(DUMMY_DEVLIST); |
322 } |
239 } |
323 |
240 |
324 |
241 |
325 void BtCpUiMainView::allActionTriggered() |
242 void BtcpuiMainView::allActionTriggered() |
326 { |
243 { |
327 HbMenu *menu = this->menu(); |
244 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
328 menu->removeAction(mRemovePairedDevices); |
245 |
329 mRemoveDevices = menu->addMenu( mSubMenu ); |
|
330 |
|
331 updateDeviceListFilter(BtuiAll); |
246 updateDeviceListFilter(BtuiAll); |
332 } |
247 BOstraceFunctionExit0(DUMMY_DEVLIST); |
333 |
248 } |
334 void BtCpUiMainView::pairActionTriggered() |
249 |
335 { |
250 void BtcpuiMainView::pairActionTriggered() |
336 HbMenu *menu = this->menu(); |
251 { |
337 menu->removeAction(mRemoveDevices); |
252 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
338 mRemovePairedDevices = menu->addAction(hbTrId("txt_bt_opt_remove_paired_devices")); |
253 |
339 updateDeviceListFilter(BtuiPaired); |
254 updateDeviceListFilter(BtuiPaired); |
340 } |
255 BOstraceFunctionExit0(DUMMY_DEVLIST); |
341 |
256 } |
342 void BtCpUiMainView::updateDeviceListFilter(BtCpUiMainView::filterType filter) |
257 |
343 { |
258 void BtcpuiMainView::aboutToShowOptionsMenu() |
344 mMainFilterModel->clearDeviceMajorFilters(); |
259 { |
|
260 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
|
261 |
|
262 updateOptionsMenu(); |
|
263 BOstraceFunctionExit0(DUMMY_DEVLIST); |
|
264 } |
|
265 |
|
266 void BtcpuiMainView::updateOptionsMenu() |
|
267 { |
|
268 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
|
269 |
|
270 if(mPairAction->isEnabled()) { |
|
271 //All Toolbar Action is active |
|
272 mRemovePairedDevices->setVisible(false); |
|
273 |
|
274 int devCount = mDeviceModel->deviceCount(BtuiDevProperty::InRegistry); |
|
275 bool visibility = false; |
|
276 |
|
277 HbAction *subMenuAction = static_cast<HbAction*> (mLoader->findObject( |
|
278 "showAction")); |
|
279 |
|
280 if(!devCount) { |
|
281 //No Registry devices then return. |
|
282 mSubMenu->menuAction()->setVisible(false); |
|
283 subMenuAction->setVisible(false); |
|
284 return; |
|
285 } |
|
286 |
|
287 visibility = true; |
|
288 mSubMenu->menuAction()->setVisible(visibility); |
|
289 subMenuAction->setVisible(visibility); |
|
290 |
|
291 subMenuAction = static_cast<HbAction*> (mLoader->findObject( |
|
292 "removeAllAction")); |
|
293 subMenuAction->setVisible(visibility); |
|
294 |
|
295 devCount = mDeviceModel->deviceCount(BtuiDevProperty::Bonded); |
|
296 |
|
297 visibility = false; |
|
298 if(devCount) { |
|
299 visibility = true; |
|
300 } |
|
301 subMenuAction = static_cast<HbAction*> (mLoader->findObject( |
|
302 "removePairedAction")); |
|
303 subMenuAction->setVisible(visibility); |
|
304 |
|
305 devCount = mDeviceModel->deviceCount(BtuiDevProperty::Blocked); |
|
306 |
|
307 visibility = false; |
|
308 if(devCount) { |
|
309 visibility = true; |
|
310 } |
|
311 subMenuAction = static_cast<HbAction*> (mLoader->findObject( |
|
312 "removeBlockedAction")); |
|
313 subMenuAction->setVisible(visibility); |
|
314 |
|
315 } |
|
316 else { |
|
317 //Pair Toolbar Action is active |
|
318 mSubMenu->menuAction()->setVisible(false); |
|
319 |
|
320 int devCount = mDeviceModel->deviceCount(BtuiDevProperty::Bonded); |
|
321 bool visibility = false; |
|
322 |
|
323 HbAction *subMenuAction = static_cast<HbAction*> (mLoader->findObject( |
|
324 "showAction")); |
|
325 |
|
326 if(devCount) { |
|
327 visibility = true; |
|
328 } |
|
329 mRemovePairedDevices->setVisible(visibility); |
|
330 subMenuAction->setVisible(visibility); |
|
331 } |
|
332 BOstraceFunctionExit0(DUMMY_DEVLIST); |
|
333 } |
|
334 |
|
335 void BtcpuiMainView::menuActionTriggered(HbAction *action) |
|
336 { |
|
337 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
|
338 |
|
339 if(!(action->text().compare(hbTrId("txt_bt_opt_advanced_settings")))) { |
|
340 //Advance Settings is not implemented yet. |
|
341 return; |
|
342 } |
|
343 |
|
344 if(!(action->text().compare(hbTrId("txt_bt_opt_show")))) { |
|
345 viewByDeviceTypeDialog(); |
|
346 } |
|
347 else { |
|
348 QString dialogtext; |
|
349 |
|
350 if(!(action->text().compare(hbTrId("txt_bt_opt_remove_sub_all_devices")))) { |
|
351 mRemoveDevDelegateType = BtDelegate::RemoveAllRegistryDevices; |
|
352 dialogtext = hbTrId("txt_bt_info_delete_all_devices_some_devices_may_b"); |
|
353 } |
|
354 else if(!(action->text().compare(hbTrId("txt_bt_opt_remove_sub_blocked_devices")))) { |
|
355 mRemoveDevDelegateType = BtDelegate::RemoveBlockedDevices; |
|
356 dialogtext = hbTrId("txt_bt_info_delete_all_blocked_devices"); |
|
357 } |
|
358 else { |
|
359 mRemoveDevDelegateType = BtDelegate::RemovePairedDevices; |
|
360 dialogtext = hbTrId("txt_bt_info_delete_all_paired_devices_some_device"); |
|
361 } |
|
362 |
|
363 HbMessageBox* dialog = new HbMessageBox(HbMessageBox::MessageTypeQuestion); |
|
364 dialog->setText(dialogtext); |
|
365 dialog->setStandardButtons(HbMessageBox::Yes | HbMessageBox::No); |
|
366 dialog->setAttribute(Qt::WA_DeleteOnClose); |
|
367 |
|
368 dialog->open(this,SLOT(onRemoveQuestionDialogClosed(int))); |
|
369 |
|
370 } |
|
371 BOstraceFunctionExit0(DUMMY_DEVLIST); |
|
372 } |
|
373 |
|
374 void BtcpuiMainView::onRemoveQuestionDialogClosed(int action) |
|
375 { |
|
376 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
|
377 |
|
378 if (action == HbMessageBox::Yes) { |
|
379 removeRegistryDevices(mRemoveDevDelegateType); |
|
380 } |
|
381 BOstraceFunctionExit0(DUMMY_DEVLIST); |
|
382 } |
|
383 |
|
384 /*! |
|
385 Callback for HbSelectionDialog closing |
|
386 ReImplemented Slot from Base class |
|
387 |
|
388 */ |
|
389 void BtcpuiMainView::viewByDialogClosed(HbAction* action) |
|
390 { |
|
391 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
|
392 |
|
393 int devTypesWanted = 0; |
|
394 |
|
395 devTypesWanted = selectedDeviceTypes(action); |
|
396 |
|
397 if (devTypesWanted) { |
|
398 mBtuiModelSortFilter->clearDeviceMajorFilters(); |
|
399 if(mAllAction->isEnabled()) { |
|
400 mBtuiModelSortFilter->addDeviceMajorFilter( |
|
401 BtuiDevProperty::InRegistry | BtuiDevProperty::Bonded, |
|
402 BtuiModelSortFilter::AtLeastMatch); |
|
403 } |
|
404 else { |
|
405 mBtuiModelSortFilter->addDeviceMajorFilter( |
|
406 BtuiDevProperty::InRegistry, |
|
407 BtuiModelSortFilter::AtLeastMatch); |
|
408 } |
|
409 mBtuiModelSortFilter->addDeviceMajorFilter(devTypesWanted, |
|
410 BtuiModelSortFilter::RoughMatch); // device can be any one of selected ones |
|
411 } |
|
412 BOstraceFunctionExit0(DUMMY_DEVLIST); |
|
413 } |
|
414 |
|
415 BtcpuiBaseView *BtcpuiMainView::searchView() |
|
416 { |
|
417 if (!mSearchView) { |
|
418 mSearchView = new BtcpuiSearchView(*mSettingModel, *mDeviceModel); |
|
419 mSearchView->setViewMgr(this); |
|
420 mMainWindow->addView(mSearchView); |
|
421 } |
|
422 return mSearchView; |
|
423 } |
|
424 |
|
425 BtcpuiBaseView *BtcpuiMainView::deviceView() |
|
426 { |
|
427 if (!mDeviceView) { |
|
428 mDeviceView = new BtcpuiDeviceView(*mSettingModel, *mDeviceModel); |
|
429 mDeviceView->setViewMgr(this); |
|
430 mMainWindow->addView(mDeviceView); |
|
431 } |
|
432 return mDeviceView; |
|
433 } |
|
434 |
|
435 void BtcpuiMainView::switchView( |
|
436 BtcpuiBaseView *from, BtcpuiBaseView *destination, |
|
437 const QVariant &init, bool backNavi) |
|
438 { |
|
439 BTUI_ASSERT_X( from && destination, "BtcpuiSettingItem::switchView", "null view" ); |
|
440 from->deactivateView(); |
|
441 mMainWindow->setCurrentView( destination ); |
|
442 destination->activateView( init, backNavi); |
|
443 } |
|
444 |
|
445 void BtcpuiMainView::updateDeviceListFilter(BtcpuiMainView::filterType filter) |
|
446 { |
|
447 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
|
448 mBtuiModelSortFilter->clearDeviceMajorFilters(); |
345 |
449 |
346 switch (filter) { |
450 switch (filter) { |
347 case BtuiAll: |
451 case BtuiAll: |
348 mDataForm->setHeading(hbTrId("txt_bt_subhead_bluetooth_all_devices")); |
452 mDataForm->setHeading(hbTrId("txt_bt_subhead_bluetooth_all_devices")); |
349 mPairAction->setEnabled(true); |
453 mPairAction->setEnabled(true); |
350 mAllAction->setEnabled(false); |
454 mAllAction->setEnabled(false); |
351 mMainFilterModel->addDeviceMajorFilter( |
455 mBtuiModelSortFilter->addDeviceMajorFilter( |
352 BtuiDevProperty::InRegistry, |
456 BtuiDevProperty::InRegistry, |
353 BtuiModelSortFilter::AtLeastMatch); |
457 BtuiModelSortFilter::AtLeastMatch); |
354 |
458 |
355 break; |
459 break; |
356 case BtuiPaired: |
460 case BtuiPaired: |
357 mDataForm->setHeading(hbTrId("txt_bt_subhead_bluetooth_paired_devices")); |
461 mDataForm->setHeading(hbTrId("txt_bt_subhead_bluetooth_paired_devices")); |
358 mPairAction->setEnabled(false); |
462 mPairAction->setEnabled(false); |
359 mAllAction->setEnabled(true); |
463 mAllAction->setEnabled(true); |
360 mMainFilterModel->addDeviceMajorFilter( |
464 mBtuiModelSortFilter->addDeviceMajorFilter( |
361 BtuiDevProperty::InRegistry | BtuiDevProperty::Bonded, |
465 BtuiDevProperty::InRegistry | BtuiDevProperty::Bonded, |
362 BtuiModelSortFilter::AtLeastMatch); |
466 BtuiModelSortFilter::AtLeastMatch); |
363 |
467 |
364 break; |
468 break; |
365 } |
469 } |
366 } |
470 BOstraceFunctionExit0(DUMMY_DEVLIST); |
367 |
471 } |
368 |
472 |
369 void BtCpUiMainView::visibilityDelegateCompleted(int status) |
473 void BtcpuiMainView::visibilityDelegateCompleted(int status) |
370 { |
474 { |
371 |
475 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
372 //This should be mapped to Qt error |
476 //This should be mapped to Qt error |
373 if(KErrNone != status) { |
477 if(KErrNone != status) { |
374 setPrevVisibilityMode(); |
478 setPrevVisibilityMode(); |
375 } |
479 } |
376 |
480 handleDelegateCompleted(status, mDelegate); |
377 //Error handling has to be done. |
481 BOstraceFunctionExit0(DUMMY_DEVLIST); |
378 if (mAbstractDelegate) |
|
379 { |
|
380 disconnect(mAbstractDelegate); |
|
381 delete mAbstractDelegate; |
|
382 mAbstractDelegate = 0; |
|
383 } |
|
384 |
|
385 } |
482 } |
386 |
483 |
387 |
484 |
388 // called due to real orientation change event coming from main window |
485 // called due to real orientation change event coming from main window |
389 void BtCpUiMainView::changeOrientation( Qt::Orientation orientation ) |
486 void BtcpuiMainView::changeOrientation( Qt::Orientation orientation ) |
390 { |
487 { |
|
488 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
391 bool ok = false; |
489 bool ok = false; |
392 mOrientation = orientation; |
490 mOrientation = orientation; |
393 if( orientation == Qt::Vertical ) { |
491 if( orientation == Qt::Vertical ) { |
394 // load "portrait" section |
492 // load "portrait" section |
395 mLoader->load( BTUI_MAINVIEW_DOCML, "portrait", &ok ); |
493 mLoader->load( BTUI_MAINVIEW_DOCML, "portrait", &ok ); |
396 BTUI_ASSERT_X( ok, "bt-main-view", "Invalid docml file: portrait section problem" ); |
494 BTUI_ASSERT_X( ok, "bt-main-view", "Invalid docml file: portrait section problem" ); |
|
495 |
|
496 mDeviceList->setColumnCount(1); |
|
497 mDeviceList->setRowCount(4); |
|
498 mDeviceList->setScrollDirections(Qt::Vertical); |
|
499 mDeviceList->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAsNeeded ); |
397 } else { |
500 } else { |
398 // load "landscape" section |
501 // load "landscape" section |
399 mLoader->load( BTUI_MAINVIEW_DOCML, "landscape", &ok ); |
502 mLoader->load( BTUI_MAINVIEW_DOCML, "landscape", &ok ); |
400 BTUI_ASSERT_X( ok, "bt-main-view", "Invalid docml file: landscape section problem" ); |
503 BTUI_ASSERT_X( ok, "bt-main-view", "Invalid docml file: landscape section problem" ); |
401 } |
504 |
|
505 mDeviceList->setRowCount(1); |
|
506 mDeviceList->setColumnCount(6); |
|
507 mDeviceList->setScrollDirections(Qt::Horizontal); |
|
508 mDeviceList->setHorizontalScrollBarPolicy(HbScrollArea::ScrollBarAsNeeded ); |
|
509 } |
|
510 BOstraceFunctionExit0(DUMMY_DEVLIST); |
402 } |
511 } |
403 |
512 |
404 /*! |
513 /*! |
405 Slot for receiving notification of local setting changes from the model. |
514 Slot for receiving notification of local setting changes from the model. |
406 Identify the setting changed and update the corresponding UI item. |
515 Identify the setting changed and update the corresponding UI item. |
407 */ |
516 */ |
408 void BtCpUiMainView::updateSettingItems(const QModelIndex &topLeft, const QModelIndex &bottomRight) |
517 void BtcpuiMainView::updateSettingItems(const QModelIndex &topLeft, const QModelIndex &bottomRight) |
409 { |
518 { |
|
519 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
410 bool val(false); |
520 bool val(false); |
411 |
521 |
412 // update only the part of the view specified by the model's row(s) |
522 // update only the part of the view specified by the model's row(s) |
413 for (int i=topLeft.row(); i <= bottomRight.row(); i++) { |
523 for (int i=topLeft.row(); i <= bottomRight.row(); i++) { |
414 QModelIndex index = mSettingModel->index( i, 0); |
524 QModelIndex index = mSettingModel->index( i, 0); |
434 case BtSettingModel::VisibilityRow: |
544 case BtSettingModel::VisibilityRow: |
435 mVisibilityMode->setCurrentIndex ( visibilityModeToIndex((VisibilityMode) |
545 mVisibilityMode->setCurrentIndex ( visibilityModeToIndex((VisibilityMode) |
436 mSettingModel->data(index,BtSettingModel::SettingValueRole).toInt()) ); |
546 mSettingModel->data(index,BtSettingModel::SettingValueRole).toInt()) ); |
437 break; |
547 break; |
438 } |
548 } |
439 } |
549 } |
|
550 BOstraceFunctionExit0(DUMMY_DEVLIST); |
440 } |
551 } |
441 |
552 |
442 /*! |
553 /*! |
443 Slot for receiving notification for user interaction on power state. |
554 Slot for receiving notification for user interaction on power state. |
444 Manually update model data since HbPushButton is not linked to model directly. |
555 Manually update model data since HbPushButton is not linked to model directly. |
445 */ |
556 */ |
446 void BtCpUiMainView::changePowerState() |
557 void BtcpuiMainView::changePowerState() |
447 { |
558 { |
|
559 BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); |
448 QModelIndex index = mSettingModel->index(BtSettingModel::PowerStateRow, 0); |
560 QModelIndex index = mSettingModel->index(BtSettingModel::PowerStateRow, 0); |
449 PowerStateQtValue powerState = (PowerStateQtValue)mSettingModel->data(index, Qt::EditRole).toInt(); |
561 PowerStateQtValue powerState = (PowerStateQtValue)mSettingModel->data(index, Qt::EditRole).toInt(); |
450 BTUI_ASSERT_X(((powerState == BtPowerOn) || (powerState == BtPowerOff)), |
562 BTUI_ASSERT_X(((powerState == BtPowerOn) || (powerState == BtPowerOff)), |
451 "BtCpUiMainView::changePowerState()", "incorrect qt power state"); |
563 "BtcpuiMainView::changePowerState()", "incorrect qt power state"); |
452 |
564 |
453 if (powerState == BtPowerOff) { |
565 if (powerState == BtPowerOff) { |
454 powerState = BtPowerOn; |
566 powerState = BtPowerOn; |
455 } |
567 } |
456 else { |
568 else { |
457 powerState = BtPowerOff; |
569 powerState = BtPowerOff; |
458 } |
570 } |
459 |
571 (void) createExecuteDelegate(BtDelegate::ManagePower, |
460 if (!mAbstractDelegate)//if there is no other delegate running |
572 this, SLOT(handleDelegateCompleted(int,BtAbstractDelegate*)), |
461 { |
573 QVariant((int)powerState)); |
462 mAbstractDelegate = BtDelegateFactory::newDelegate(BtDelegate::ManagePower, |
574 BOstraceFunctionExit0(DUMMY_DEVLIST); |
463 mSettingModel, mDeviceModel ); |
575 } |
464 connect( mAbstractDelegate, SIGNAL(commandCompleted(int)), this, SLOT(powerDelegateCompleted(int)) ); |
576 |
465 mAbstractDelegate->exec(QVariant((int)powerState)); |
577 void BtcpuiMainView::loadDocument() |
466 } |
578 { |
467 |
579 bool ret(false); |
468 } |
580 // Create view for the application. |
469 |
581 // Set the name for the view. The name should be same as the view's |
470 void BtCpUiMainView::powerDelegateCompleted(int status) |
582 // name in docml. |
471 { |
583 setObjectName("bt_main_view"); |
472 Q_UNUSED(status); |
584 |
473 //ToDo: Error handling here |
585 mLoader = new HbDocumentLoader(); |
474 if (mAbstractDelegate) |
586 // Pass the view to documentloader. Document loader uses this view |
475 { |
587 // when docml is parsed, instead of creating new view. |
476 disconnect(mAbstractDelegate); |
588 QObjectList objectList; |
477 delete mAbstractDelegate; |
589 objectList.append(this); |
478 mAbstractDelegate = 0; |
590 mLoader->setObjectTree(objectList); |
479 } |
591 |
480 //BTUI_ASSERT_X( status, "bt-main-view", "error in delegate complete" ); |
592 bool ok = false; |
|
593 mLoader->load( BTUI_MAINVIEW_DOCML, &ok ); |
|
594 // Exit if the file format is invalid |
|
595 BTUI_ASSERT_X( ok, "bt-main-view", "Invalid docml file" ); |
|
596 |
|
597 mDeviceList=0; |
|
598 mDeviceList = qobject_cast<HbGridView *>( mLoader->findWidget( "deviceList" ) ); |
|
599 BTUI_ASSERT_X( mDeviceList != 0, "bt-main-view", "Device List (grid view) not found" ); |
|
600 |
|
601 ret = connect(mDeviceList, SIGNAL(activated(QModelIndex)), this, SLOT(deviceSelected(QModelIndex))); |
|
602 BTUI_ASSERT_X( ret, "bt-main-view", "deviceSelected can't connect" ); |
|
603 |
|
604 ret = connect(mDeviceList, |
|
605 SIGNAL(longPressed(HbAbstractViewItem*, QPointF)), this, |
|
606 SLOT(showContextMenu(HbAbstractViewItem*, QPointF))); |
|
607 BTUI_ASSERT_X( ret, "bt-main-view", "deviceSelected can't connect" ); |
|
608 |
|
609 mOrientation = mMainWindow->orientation(); |
|
610 |
|
611 mDeviceList->setSwapDimensionsOnOrientationChange(false); |
|
612 |
|
613 if (mOrientation == Qt::Horizontal) { |
|
614 mLoader->load(BTUI_MAINVIEW_DOCML, "landscape", &ok); |
|
615 BTUI_ASSERT_X( ok, "bt-main-view", "Invalid docml file: landscape section problem" ); |
|
616 mDeviceList->setRowCount(1); |
|
617 mDeviceList->setColumnCount(6); |
|
618 mDeviceList->setScrollDirections(Qt::Horizontal); |
|
619 mDeviceList->setHorizontalScrollBarPolicy(HbScrollArea::ScrollBarAsNeeded ); |
|
620 } |
|
621 else { |
|
622 mLoader->load(BTUI_MAINVIEW_DOCML, "portrait", &ok); |
|
623 BTUI_ASSERT_X( ok, "bt-main-view", "Invalid docml file: landscape section problem" ); |
|
624 mDeviceList->setColumnCount(1); |
|
625 mDeviceList->setRowCount(4); |
|
626 mDeviceList->setScrollDirections(Qt::Vertical); |
|
627 mDeviceList->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAsNeeded ); |
|
628 } |
|
629 |
|
630 mDeviceNameEdit=0; |
|
631 mDeviceNameEdit = qobject_cast<HbLineEdit *>( mLoader->findWidget( "deviceNameEdit" ) ); |
|
632 BTUI_ASSERT_X( mDeviceNameEdit != 0, "bt-main-view", "Device Name not found" ); |
|
633 ret = connect(mDeviceNameEdit, SIGNAL(editingFinished ()), this, SLOT(changeBtLocalName())); |
|
634 |
|
635 mPowerButton=0; |
|
636 mPowerButton = qobject_cast<HbPushButton *>( mLoader->findWidget( "toggleBluetoothPower" ) ); |
|
637 BTUI_ASSERT_X( mPowerButton != 0, "bt-main-view", "power button not found" ); |
|
638 ret = connect(mPowerButton, SIGNAL(clicked()), this, SLOT(changePowerState())); |
|
639 BTUI_ASSERT_X( ret, "BtcpuiMainView::BtcpuiMainView", "can't connect power button" ); |
|
640 |
|
641 mVisibilityMode=0; |
|
642 mVisibilityMode = qobject_cast<HbComboBox *>( mLoader->findWidget( "visibilityMode" ) ); |
|
643 BTUI_ASSERT_X( mVisibilityMode != 0, "bt-main-view", "visibility combobox not found" ); |
|
644 // add new item for temporary visibility |
|
645 // NOTE: translation (at least default english) gives string "(p)Visible for 5 min", |
|
646 // if setting 1 min --> "(s)Visible for 1 min", ie p=plural, s=singular, but these should |
|
647 // not be shown to the user! |
|
648 // ToDo: change this to use translation once it starts working |
|
649 QString tempVis(hbTrId("txt_bt_setlabel_visibility_val_visible_for_l1_min", 5)); |
|
650 //QString tempVis(hbTrId("Visible for 5 min")); |
|
651 mVisibilityMode->addItem(tempVis, Qt::DisplayRole); |
|
652 |
|
653 // listen for orientation changes |
|
654 ret = connect(mMainWindow, SIGNAL(orientationChanged(Qt::Orientation)), |
|
655 this, SLOT(changeOrientation(Qt::Orientation))); |
|
656 BTUI_ASSERT_X( ret, "BtcpuiMainView::BtcpuiMainView()", "connect orientationChanged() failed"); |
|
657 |
|
658 // load tool bar actions |
|
659 HbAction *discoverAction = static_cast<HbAction*>( mLoader->findObject( "discoverAction" ) ); |
|
660 BTUI_ASSERT_X( discoverAction, "bt-main-view", "discover action missing" ); |
|
661 ret = connect(discoverAction, SIGNAL(triggered()), this, SLOT(launchDeviceDiscovery())); |
|
662 BTUI_ASSERT_X( ret, "bt-main-view", "discover action can't connect" ); |
|
663 |
|
664 // load tool bar actions |
|
665 mAllAction = static_cast<HbAction*>( mLoader->findObject( "allAction" ) ); |
|
666 BTUI_ASSERT_X( mAllAction, "bt-main-view", "All action missing" ); |
|
667 ret = connect(mAllAction, SIGNAL(triggered()), this, SLOT(allActionTriggered())); |
|
668 BTUI_ASSERT_X( ret, "bt-main-view", "all action can't connect" ); |
|
669 |
|
670 // load tool bar actions |
|
671 mPairAction = static_cast<HbAction*>( mLoader->findObject( "pairedAction" ) ); |
|
672 BTUI_ASSERT_X( mPairAction, "bt-main-view", "Pair action missing" ); |
|
673 ret = connect(mPairAction, SIGNAL(triggered()), this, SLOT(pairActionTriggered())); |
|
674 BTUI_ASSERT_X( ret, "bt-main-view", "pair action can't connect" ); |
|
675 |
|
676 mDataForm = qobject_cast<HbDataForm *>( mLoader->findWidget( "bluetoothHeading" ) ); |
|
677 BTUI_ASSERT_X( mDataForm != 0, "bt-main-view", "dataForm not found" ); |
|
678 |
|
679 |
|
680 // load menu |
|
681 HbMenu *optionsMenu = qobject_cast<HbMenu *>(mLoader->findWidget("viewMenu")); |
|
682 BTUI_ASSERT_X( optionsMenu != 0, "bt-main-view", "Options menu not found" ); |
|
683 ret = connect(optionsMenu, SIGNAL(triggered(HbAction *)), this, SLOT(menuActionTriggered(HbAction *))); |
|
684 BTUI_ASSERT_X( ret, "bt-main-view", "Menu can't connect" ); |
|
685 |
|
686 ret = connect(optionsMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowOptionsMenu())); |
|
687 BTUI_ASSERT_X( ret, "bt-main-view", "Menu aboutToShow() can't connect" ); |
|
688 |
|
689 mSubMenu = qobject_cast<HbMenu *>(mLoader->findWidget("removeSubMenu")); |
|
690 BTUI_ASSERT_X( optionsMenu != 0, "bt-main-view", "Options Sub menu not found" ); |
|
691 |
|
692 mRemovePairedDevices = static_cast<HbAction*>( mLoader->findObject( "viewRemovePairedAction" ) ); |
|
693 |
|
694 // update display when setting data changed |
|
695 ret = connect(mSettingModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), |
|
696 this, SLOT(updateSettingItems(QModelIndex,QModelIndex))); |
|
697 BTUI_ASSERT_X( ret, "BtcpuiMainView::BtcpuiMainView", "can't connect dataChanged" ); |
|
698 |
|
699 QModelIndex top = mSettingModel->index( BtSettingModel::LocalBtNameRow, 0 ); |
|
700 QModelIndex bottom = mSettingModel->index( BtSettingModel::AllowedInOfflineRow, 0 ); |
|
701 // update name, power and visibility rows |
|
702 updateSettingItems( top, bottom ); |
|
703 |
|
704 //Handle Visibility Change User Interaction |
|
705 ret = connect(mVisibilityMode, SIGNAL(currentIndexChanged (int)), |
|
706 this, SLOT(changeVisibility(int))); |
|
707 |
|
708 bool regStatus(false); |
|
709 regStatus = HbStyleLoader::registerFilePath(":/docml/btcpuimaingridviewitem.widgetml"); |
|
710 BTUI_ASSERT_X( regStatus, "BtcpuiMainView::BtcpuiMainView", "registerFilePath Widgetml Failed" ); |
|
711 regStatus = HbStyleLoader::registerFilePath(":/docml/btcpuimaingridviewitem.css"); |
|
712 BTUI_ASSERT_X( regStatus, "BtcpuiMainView::BtcpuiMainView", "registerFilePath CSS Failed" ); |
|
713 |
|
714 mBtuiModelSortFilter = new BtuiModelSortFilter(this); |
|
715 |
|
716 mBtuiModelSortFilter->setSourceModel( mDeviceModel ); |
|
717 mDeviceList->setModel(mBtuiModelSortFilter); |
|
718 mDeviceList->setLayoutName("portrait"); |
|
719 updateDeviceListFilter(BtuiPaired); |
|
720 |
|
721 mSubMenu->menuAction()->setVisible(false); |
|
722 // Grid view item |
|
723 BtCpUiMainGridViewItem *prototype = new BtCpUiMainGridViewItem(mDeviceList); |
|
724 prototype->setModelSortFilter(mBtuiModelSortFilter); |
|
725 mDeviceList->setItemPrototype(prototype); |
481 } |
726 } |
482 |
727 |
483 /*! |
728 /*! |
484 * Mapping from visibility mode UI row to VisibilityMode |
729 * Mapping from visibility mode UI row to VisibilityMode |
485 */ |
730 */ |
486 VisibilityMode BtCpUiMainView::indexToVisibilityMode(int index) |
731 VisibilityMode BtcpuiMainView::indexToVisibilityMode(int index) |
487 { |
732 { |
488 VisibilityMode mode = BtVisibilityUnknown; |
733 VisibilityMode mode = BtVisibilityUnknown; |
489 switch(index) { |
734 switch(index) { |
490 case UiRowBtHidden: |
735 case UiRowBtHidden: |
491 mode = BtHidden; |
736 mode = BtHidden; |