77 fetchDestinations(destinationList); |
77 fetchDestinations(destinationList); |
78 |
78 |
79 // Create Destination list |
79 // Create Destination list |
80 for (int i = 0; i < destinationList.count(); i++) { |
80 for (int i = 0; i < destinationList.count(); i++) { |
81 QString iapCount = |
81 QString iapCount = |
82 getDestinationAdditionalText(destinationList.at(i)->connectionMethodCount()); |
82 getDestinationAdditionalText(destinationList.at(i)); |
83 |
83 |
84 // Create new destination entry |
84 // Create new destination entry |
85 CpDestinationEntryItemData *destDataItem; |
85 CpDestinationEntryItemData *destDataItem; |
86 destDataItem = new CpDestinationEntryItemData(itemDataHelper); |
86 destDataItem = new CpDestinationEntryItemData(itemDataHelper); |
87 destDataItem->setContentWidgetData(QString("text"), destinationList.at(i)->name()); |
87 destDataItem->setContentWidgetData(QString("text"), destinationList.at(i)->name()); |
124 The new destination is shown in the UI immediately. |
124 The new destination is shown in the UI immediately. |
125 */ |
125 */ |
126 void CpDestinationGroup::addDestination(const QString &dest, int destId) |
126 void CpDestinationGroup::addDestination(const QString &dest, int destId) |
127 { |
127 { |
128 OstTraceFunctionEntry0(CPDESTINATIONGROUP_ADDDESTINATION_ENTRY); |
128 OstTraceFunctionEntry0(CPDESTINATIONGROUP_ADDDESTINATION_ENTRY); |
129 QString iapCount = getDestinationAdditionalText(0); |
|
130 |
129 |
131 // Create UI item for new destination |
130 // Create UI item for new destination |
132 CpDestinationEntryItemData *destDataItem; |
131 CpDestinationEntryItemData *destDataItem; |
133 destDataItem = new CpDestinationEntryItemData(*mItemDataHelper); |
132 destDataItem = new CpDestinationEntryItemData(*mItemDataHelper); |
134 destDataItem->setContentWidgetData(QString("text"), dest); |
133 destDataItem->setContentWidgetData(QString("text"), dest); |
135 destDataItem->setContentWidgetData(QString("additionalText"), iapCount); |
134 destDataItem->setContentWidgetData( |
|
135 QString("additionalText"), |
|
136 hbTrId("txt_occ_dblist_internet_val_no_access_points")); |
136 destDataItem->setDestinationId(destId); |
137 destDataItem->setDestinationId(destId); |
137 destDataItem->setDestinationName(dest); |
138 destDataItem->setDestinationName(dest); |
138 connect(destDataItem, SIGNAL(destChanged()), this, SLOT(updateDestinationInformation())); |
139 connect(destDataItem, SIGNAL(destChanged()), this, SLOT(updateDestinationInformation())); |
139 |
140 |
140 // Insert Child to correct position |
141 // Insert Child to correct position |
204 (Name and access point count) |
205 (Name and access point count) |
205 */ |
206 */ |
206 void CpDestinationGroup::updateDestinationInformation() |
207 void CpDestinationGroup::updateDestinationInformation() |
207 { |
208 { |
208 OstTraceFunctionEntry0(CPDESTINATIONGROUP_UPDATEDESTINATIONINFORMATION_ENTRY); |
209 OstTraceFunctionEntry0(CPDESTINATIONGROUP_UPDATEDESTINATIONINFORMATION_ENTRY); |
209 int apCount = 0; |
|
210 // "Add Destination" child is removed from count (childCount() -1) |
210 // "Add Destination" child is removed from count (childCount() -1) |
211 for (int i = 0; i < childCount() - 1; i++) { |
211 for (int i = 0; i < childCount() - 1; i++) { |
212 CpDestinationEntryItemData *destDataItem = |
212 CpDestinationEntryItemData *destDataItem = |
213 static_cast<CpDestinationEntryItemData*>(this->childAt(i)); |
213 static_cast<CpDestinationEntryItemData*>(this->childAt(i)); |
214 |
214 |
220 // delete empty uncategorised IAPs destination |
220 // delete empty uncategorised IAPs destination |
221 int index = this->indexOf(destDataItem); |
221 int index = this->indexOf(destDataItem); |
222 this->removeChild(index); |
222 this->removeChild(index); |
223 mUncategorisedShown = false; |
223 mUncategorisedShown = false; |
224 continue; |
224 continue; |
225 } |
225 } |
226 apCount = apList.count(); |
226 } |
227 } else { |
227 QString iapCount = getDestinationAdditionalText(destDataItem->destinationId()); |
228 CmDestinationShim *destination; |
|
229 destination = mCmManager->destination(destDataItem->destinationId()); |
|
230 apCount = destination->connectionMethodCount(); |
|
231 delete destination; |
|
232 } |
|
233 |
|
234 QString iapCount = getDestinationAdditionalText(apCount); |
|
235 destDataItem->setContentWidgetData(QString("additionalText"), iapCount); |
228 destDataItem->setContentWidgetData(QString("additionalText"), iapCount); |
236 destDataItem->setContentWidgetData(QString("text"), destDataItem->destinationName()); |
229 destDataItem->setContentWidgetData(QString("text"), destDataItem->destinationName()); |
237 } |
230 } |
238 OstTraceFunctionExit0(CPDESTINATIONGROUP_UPDATEDESTINATIONINFORMATION_EXIT); |
231 OstTraceFunctionExit0(CPDESTINATIONGROUP_UPDATEDESTINATIONINFORMATION_EXIT); |
239 } |
232 } |
250 if (apList.count() > 0) { |
243 if (apList.count() > 0) { |
251 // Create new destination entry |
244 // Create new destination entry |
252 CpDestinationEntryItemData *destDataItem; |
245 CpDestinationEntryItemData *destDataItem; |
253 destDataItem = new CpDestinationEntryItemData(*mItemDataHelper); |
246 destDataItem = new CpDestinationEntryItemData(*mItemDataHelper); |
254 destDataItem->setContentWidgetData(QString("text"), hbTrId("txt_occ_dblist_uncategorized")); |
247 destDataItem->setContentWidgetData(QString("text"), hbTrId("txt_occ_dblist_uncategorized")); |
255 QString iapCount = getDestinationAdditionalText(apList.count()); |
248 QString iapCount = getDestinationAdditionalText(0); |
256 destDataItem->setContentWidgetData(QString("additionalText"),iapCount); |
249 destDataItem->setContentWidgetData(QString("additionalText"),iapCount); |
257 destDataItem->setDestinationId(0); |
250 destDataItem->setDestinationId(0); |
258 destDataItem->setDestinationName(hbTrId("txt_occ_dblist_uncategorized")); |
251 destDataItem->setDestinationName(hbTrId("txt_occ_dblist_uncategorized")); |
259 HbIcon destIcon(mCmManager->getUncategorizedIcon()); |
252 HbIcon destIcon(mCmManager->getUncategorizedIcon()); |
260 destDataItem->setEntryItemIcon(destIcon); |
253 destDataItem->setEntryItemIcon(destIcon); |
288 for (int i = 0; i < destArray.count(); i++) { |
281 for (int i = 0; i < destArray.count(); i++) { |
289 CmDestinationShim *destination; |
282 CmDestinationShim *destination; |
290 destination = mCmManager->destination(destArray[i]); |
283 destination = mCmManager->destination(destArray[i]); |
291 if (!destination->isHidden()) { |
284 if (!destination->isHidden()) { |
292 destinationList.append(QSharedPointer<CmDestinationShim>(destination)); |
285 destinationList.append(QSharedPointer<CmDestinationShim>(destination)); |
|
286 } else { |
|
287 delete destination; |
293 } |
288 } |
294 } |
289 } |
295 } catch (const std::exception&) { |
290 } catch (const std::exception&) { |
296 OstTrace0(TRACE_NORMAL, CPDESTINATIONGROUP_FETCHDESTINATIONS, "CpDestinationGroup::fetchDestinations: exception caught, Reading destinations"); |
291 OstTrace0(TRACE_NORMAL, CPDESTINATIONGROUP_FETCHDESTINATIONS, "CpDestinationGroup::fetchDestinations: exception caught, Reading destinations"); |
297 } |
292 } |
319 } |
314 } |
320 OstTraceFunctionExit0(CPDESTINATIONGROUP_LOADBEARERPLUGINS_EXIT); |
315 OstTraceFunctionExit0(CPDESTINATIONGROUP_LOADBEARERPLUGINS_EXIT); |
321 } |
316 } |
322 |
317 |
323 /*! |
318 /*! |
324 Helper function to be used in localisation. |
319 Helper function to be used in localisation. (Overloaded) |
325 |
320 |
326 \return Returns correct localized QString according to access point count. |
321 \return Returns correct localized QString according to access point count. |
327 */ |
322 */ |
328 QString CpDestinationGroup::getDestinationAdditionalText(int iapCount) |
323 QString CpDestinationGroup::getDestinationAdditionalText(QSharedPointer<CmDestinationShim> destination) |
329 { |
324 { |
330 OstTraceFunctionEntry0(CPDESTINATIONGROUP_GETDESTINATIONADDITIONALTEXT_ENTRY); |
325 OstTraceFunctionEntry0(CPDESTINATIONGROUP_GETDESTINATIONADDITIONALTEXT_ENTRY); |
331 QString result = ""; |
326 QString result = ""; |
|
327 int iapCount = destination->connectionMethodCount(); |
|
328 int counter = 0; |
|
329 for (int i = 0; i < iapCount; i++) { |
|
330 CmConnectionMethodShim *cm = destination->connectionMethod(i); |
|
331 if (cm->getBoolAttribute(CMManagerShim::CmDestination) |
|
332 || cm->getBoolAttribute(CMManagerShim::CmHidden)) { |
|
333 counter++; |
|
334 } |
|
335 delete cm; |
|
336 } |
|
337 iapCount = iapCount - counter; |
332 if (iapCount > 0) { |
338 if (iapCount > 0) { |
333 result = hbTrId("txt_occ_dblist_internet_val_ln_access_points", iapCount); |
339 result = hbTrId("txt_occ_dblist_internet_val_ln_access_points", iapCount); |
334 } else { |
340 } else { |
335 result = hbTrId("txt_occ_dblist_internet_val_no_access_points"); |
341 result = hbTrId("txt_occ_dblist_internet_val_no_access_points"); |
336 } |
342 } |
337 OstTrace0(TRACE_FLOW, CPDESTINATIONGROUP_GETDESTINATIONADDITIONALTEXT_EXIT, "Exit"); |
343 OstTrace0(TRACE_FLOW, CPDESTINATIONGROUP_GETDESTINATIONADDITIONALTEXT_EXIT, "Exit"); |
|
344 return result; |
|
345 } |
|
346 |
|
347 /*! |
|
348 Helper function to be used in localisation. (Overloaded) |
|
349 |
|
350 \return Returns correct localized QString according to access point count. |
|
351 */ |
|
352 QString CpDestinationGroup::getDestinationAdditionalText(int destinationId) |
|
353 { |
|
354 OstTraceFunctionEntry0(CPDESTINATIONGROUP_GETDESTINATIONADDITIONALTEXT2_ENTRY); |
|
355 QString result = ""; |
|
356 int iapCount = 0; |
|
357 int counter = 0; |
|
358 if (destinationId == 0) { |
|
359 QList<uint> apList; |
|
360 mCmManager->connectionMethod(apList); |
|
361 iapCount = apList.count(); |
|
362 for (int i = 0; i < iapCount; i++) { |
|
363 CmConnectionMethodShim *cm = mCmManager->connectionMethod(apList[i]); |
|
364 if (cm->getBoolAttribute(CMManagerShim::CmDestination) |
|
365 || cm->getBoolAttribute(CMManagerShim::CmHidden)) { |
|
366 counter++; |
|
367 } |
|
368 delete cm; |
|
369 } |
|
370 } else { |
|
371 CmDestinationShim *destination = mCmManager->destination(destinationId); |
|
372 iapCount = destination->connectionMethodCount(); |
|
373 for (int i = 0; i < iapCount; i++) { |
|
374 CmConnectionMethodShim *cm = destination->connectionMethod(i); |
|
375 if (cm->getBoolAttribute(CMManagerShim::CmDestination) |
|
376 || cm->getBoolAttribute(CMManagerShim::CmHidden)) { |
|
377 counter++; |
|
378 } |
|
379 delete cm; |
|
380 } |
|
381 delete destination; |
|
382 } |
|
383 iapCount = iapCount - counter; |
|
384 if (iapCount > 0) { |
|
385 result = hbTrId("txt_occ_dblist_internet_val_ln_access_points", iapCount); |
|
386 } else { |
|
387 result = hbTrId("txt_occ_dblist_internet_val_no_access_points"); |
|
388 } |
|
389 OstTrace0(TRACE_FLOW, CPDESTINATIONGROUP_GETDESTINATIONADDITIONALTEXT2_EXIT, "Exit"); |
338 return result; |
390 return result; |
339 } |
391 } |
340 |
392 |
341 /*! |
393 /*! |
342 Helper function for showing icons. |
394 Helper function for showing icons. |