1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: LocationPickerContent implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <QStandardItemModel> |
|
19 |
|
20 #include "locationpickercontent.h" |
|
21 #include "locationpickerproxymodel.h" |
|
22 #include "locationpickertypes.h" |
|
23 #include "locationpickerdatamanager.h" |
|
24 |
|
25 // ======== MEMBER FUNCTIONS ======== |
|
26 |
|
27 // ----------------------------------------------------------------------------- |
|
28 // LocationPickerContent::LocationPickerContent() |
|
29 // ----------------------------------------------------------------------------- |
|
30 LocationPickerContent::LocationPickerContent() |
|
31 :mDataManager(NULL), |
|
32 mStandardModel(NULL) |
|
33 { |
|
34 // create data manager to manage data in the model |
|
35 mDataManager = LocationPickerDataManager::getInstance(); |
|
36 |
|
37 } |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // LocationPickerContent::populateModel() |
|
41 // ----------------------------------------------------------------------------- |
|
42 bool LocationPickerContent::populateModel() |
|
43 { |
|
44 bool locationsFound; |
|
45 // Create a standard model for the list view |
|
46 mStandardModel = new QStandardItemModel( this ); |
|
47 if( mDataManager->populateModel( *mStandardModel, ELocationPickerContent ) ) |
|
48 { |
|
49 locationsFound = true; |
|
50 } |
|
51 else |
|
52 { |
|
53 createNoEntryDisplay(mStandardModel); |
|
54 locationsFound = false; |
|
55 } |
|
56 return locationsFound; |
|
57 } |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // LocationPickerContent::LocationPickerContent() |
|
61 // ----------------------------------------------------------------------------- |
|
62 LocationPickerContent::~LocationPickerContent() |
|
63 { |
|
64 delete mStandardModel; |
|
65 } |
|
66 |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // LocationPickerContent::getStandardModel() |
|
70 // ----------------------------------------------------------------------------- |
|
71 QStandardItemModel* LocationPickerContent::getStandardModel() |
|
72 { |
|
73 return mStandardModel; |
|
74 } |
|
75 |
|
76 // ---------------------------------------------------------------------------- |
|
77 // LocationPickerContent::createNoEntryDisplay() |
|
78 // ---------------------------------------------------------------------------- |
|
79 |
|
80 void LocationPickerContent::createNoEntryDisplay( QStandardItemModel *aModel ) |
|
81 { |
|
82 // no locations to display. |
|
83 QStandardItem *modelItem = new QStandardItem(); |
|
84 modelItem->setData(QVariant(hbTrId("txt_lint_list_no_location_entries_present")), Qt::DisplayRole); |
|
85 aModel->appendRow( modelItem ); |
|
86 } |
|