154 (void)iapId; |
155 (void)iapId; |
155 mStatusLabel->setPlainText(hbTrId("txt_occ_grid_not_connected")); |
156 mStatusLabel->setPlainText(hbTrId("txt_occ_grid_not_connected")); |
156 mConnectingIapId = 0; |
157 mConnectingIapId = 0; |
157 |
158 |
158 OstTraceFunctionExit0( WLANSNIFFERLISTVIEW_UPDATECONNECTIONCLOSED_EXIT ); |
159 OstTraceFunctionExit0( WLANSNIFFERLISTVIEW_UPDATECONNECTIONCLOSED_EXIT ); |
|
160 } |
|
161 |
|
162 void WlanSnifferListView::handleContextMenuClosed() |
|
163 { |
|
164 OstTraceFunctionEntry0( WLANSNIFFERLISTVIEW_HANDLECONTEXTMENUCLOSED_ENTRY ); |
|
165 |
|
166 // Menu deletes itself, but we need to cleanup the member variable |
|
167 // in order to enable list updating again |
|
168 mContextMenu = NULL; |
|
169 |
|
170 OstTraceFunctionExit0( WLANSNIFFERLISTVIEW_HANDLECONTEXTMENUCLOSED_EXIT ); |
159 } |
171 } |
160 |
172 |
161 void WlanSnifferListView::handleListItemActivated(HbListWidgetItem *item) |
173 void WlanSnifferListView::handleListItemActivated(HbListWidgetItem *item) |
162 { |
174 { |
163 OstTraceFunctionEntry0( WLANSNIFFERLISTVIEW_HANDLELISTITEMACTIVATED_ENTRY ); |
175 OstTraceFunctionEntry0( WLANSNIFFERLISTVIEW_HANDLELISTITEMACTIVATED_ENTRY ); |
191 |
203 |
192 void WlanSnifferListView::handleListItemLongPressed(HbListWidgetItem *item, const QPointF &coords) |
204 void WlanSnifferListView::handleListItemLongPressed(HbListWidgetItem *item, const QPointF &coords) |
193 { |
205 { |
194 OstTraceFunctionEntry0( WLANSNIFFERLISTVIEW_HANDLELISTITEMLONGPRESSED_ENTRY ); |
206 OstTraceFunctionEntry0( WLANSNIFFERLISTVIEW_HANDLELISTITEMLONGPRESSED_ENTRY ); |
195 |
207 |
196 // Disable list refreshing while context menu is shown |
208 Q_ASSERT(mContextMenu == NULL); |
197 // Todo: Propably a more elegant way to do this is needed.. |
209 |
198 mIapItemMenuOpen = true; |
210 if (item->data().canConvert<int>() && item->data().toInt() == |
199 |
211 mAppRef->wlanQtUtils()->connectedWlanId()) { |
200 (void)item; |
212 // Connected IAP, add "Disconnect" action |
201 HbMenu *contextMenu = new HbMenu(); |
213 mContextMenu = new HbMenu(); |
202 HbAction *actionDetails = contextMenu->addAction(hbTrId("txt_occ_menu_details")); |
214 // Remember the item that was long pressed |
203 HbAction *actionSettings = contextMenu->addAction(hbTrId("txt_occ_menu_network_settings")); |
215 mContextMenuData = item->data(); |
204 HbAction *actionDisable = contextMenu->addAction(hbTrId("txt_occ_menu_disable_network")); |
216 mContextMenu->addAction( |
205 |
217 hbTrId("txt_common_menu_disconnect"), |
206 // Add disconnect option if the IAP is connected |
218 this, |
207 HbAction *actionDisconnect = 0; |
219 SLOT(handleListItemDisconnect())); |
208 WlanQtUtilsIap *iap = 0; |
220 // Show the menu and connect closure signal (to re-enable list refreshing) |
209 QVariant data = item->data(); |
221 bool connectStatus = connect( |
210 if (data.canConvert<int>()) { |
222 mContextMenu, |
211 // Item was an IAP. |
223 SIGNAL(aboutToClose()), |
212 iap = mAppRef->wlanQtUtils()->iap(data.toInt()); |
224 this, |
213 if (iap->connectionStatus() == WlanQtUtilsConnectionStatusConnected) { |
225 SLOT(handleContextMenuClosed())); |
214 actionDisconnect = contextMenu->addAction(hbTrId("txt_common_menu_disconnect")); |
226 Q_ASSERT(connectStatus); |
215 } |
227 mContextMenu->setAttribute(Qt::WA_DeleteOnClose); |
216 } |
228 mContextMenu->setTimeout(HbPopup::ContextMenuTimeout); |
217 |
229 mContextMenu->setPreferredPos(coords); |
218 // Show the menu |
230 mContextMenu->show(); |
219 HbAction *selectedAction = contextMenu->exec(coords); |
231 } |
220 // Re-enable list refreshing |
|
221 mIapItemMenuOpen = false; |
|
222 |
|
223 if (selectedAction) { |
|
224 // Handle the "Disconnect" menu selection |
|
225 if (selectedAction == actionDisconnect) { |
|
226 mStatusLabel->setPlainText(hbTrId("txt_occ_grid_not_connected")); |
|
227 mAppRef->wlanQtUtils()->disconnectIap(iap->id()); |
|
228 // Redraw the list so that disconnected network is not shown anymore |
|
229 update(); |
|
230 } |
|
231 } |
|
232 |
232 |
233 OstTraceFunctionExit0( WLANSNIFFERLISTVIEW_HANDLELISTITEMLONGPRESSED_EXIT ); |
233 OstTraceFunctionExit0( WLANSNIFFERLISTVIEW_HANDLELISTITEMLONGPRESSED_EXIT ); |
|
234 } |
|
235 |
|
236 /*! |
|
237 Handles a "Disconnect" action selected from the context menu for a list item. |
|
238 */ |
|
239 void WlanSnifferListView::handleListItemDisconnect() |
|
240 { |
|
241 OstTraceFunctionEntry0( WLANSNIFFERLISTVIEW_HANDLELISTITEMDISCONNECT_ENTRY ); |
|
242 |
|
243 // "Disconnect" was only added, if the item was an IAP and data was |
|
244 // the IAP ID |
|
245 Q_ASSERT(mContextMenuData.canConvert<int>()); |
|
246 mAppRef->wlanQtUtils()->disconnectIap(mContextMenuData.toInt()); |
|
247 |
|
248 OstTraceFunctionExit0( WLANSNIFFERLISTVIEW_HANDLELISTITEMDISCONNECT_EXIT ); |
234 } |
249 } |
235 |
250 |
236 // Todo: This is a temporary solution - real WLAN status indication & listening |
251 // Todo: This is a temporary solution - real WLAN status indication & listening |
237 // is implemented later on. |
252 // is implemented later on. |
238 void WlanSnifferListView::handleDisconnect() |
253 void WlanSnifferListView::handleDisconnect() |