25 // ======== MEMBER FUNCTIONS ======== |
25 // ======== MEMBER FUNCTIONS ======== |
26 |
26 |
27 // ----------------------------------------------------------------------------- |
27 // ----------------------------------------------------------------------------- |
28 // LocationPickerContent::LocationPickerContent() |
28 // LocationPickerContent::LocationPickerContent() |
29 // ----------------------------------------------------------------------------- |
29 // ----------------------------------------------------------------------------- |
30 LocationPickerContent::LocationPickerContent( Qt::Orientation aOrientation ) |
30 LocationPickerContent::LocationPickerContent() |
31 :mOrientation(aOrientation), |
31 :mDataManager(NULL), |
32 mListProxyModel(NULL), |
32 mListModel(NULL), |
33 mProxyGridModel(NULL), |
33 mGridModel(NULL) |
34 mDataManager(NULL), |
|
35 mModel(NULL), |
|
36 mLocationsFound(true) |
|
37 { |
34 { |
38 // Create a standard model for the list view |
|
39 mModel = new QStandardItemModel( this ); |
|
40 // create data manager to manage data in the model |
35 // create data manager to manage data in the model |
41 mDataManager = new LocationPickerDataManager( *mModel, ELocationPickerContent ); |
36 mDataManager = LocationPickerDataManager::getInstance(); |
42 if(mOrientation == Qt::Vertical) |
37 |
|
38 } |
|
39 |
|
40 // ----------------------------------------------------------------------------- |
|
41 // LocationPickerContent::populateModel() |
|
42 // ----------------------------------------------------------------------------- |
|
43 bool LocationPickerContent::populateModel( Qt::Orientation aOrientation ) |
|
44 { |
|
45 bool locationsFound; |
|
46 if(aOrientation == Qt::Vertical) |
43 { |
47 { |
44 if( mDataManager->populateModel(mOrientation) ) |
48 // Create a standard model for the list view |
|
49 mListModel = new QStandardItemModel( this ); |
|
50 if( mDataManager->populateModel( *mListModel, ELocationPickerContent, aOrientation) ) |
45 { |
51 { |
46 // Create the proxy model and set source model |
52 locationsFound = true; |
47 mListProxyModel = new LocationPickerProxyModel( mOrientation, this ); |
|
48 mListProxyModel->setSourceModel(mModel); |
|
49 // set sort properties |
|
50 mListProxyModel->setDynamicSortFilter(TRUE); |
|
51 mListProxyModel->setSortRole(Qt::DisplayRole); |
|
52 mListProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); |
|
53 |
|
54 // sort in ascending order |
|
55 mListProxyModel->sort(0, Qt::AscendingOrder); |
|
56 mLocationsFound = true; |
|
57 } |
53 } |
58 else |
54 else |
59 { |
55 { |
60 // no locations to display. |
56 createNoEntryDisplay(mListModel); |
61 QStandardItem *modelItem = new QStandardItem(); |
57 locationsFound = false; |
62 modelItem->setData(QVariant(hbTrId("txt_lint_list_no_location_entries_present")), Qt::DisplayRole); |
|
63 mModel->appendRow( modelItem ); |
|
64 mLocationsFound = false; |
|
65 } |
58 } |
66 } |
59 } |
67 //for landscape view |
60 //for landscape view |
68 else |
61 else |
69 { |
62 { |
70 if( mDataManager->populateModel(mOrientation) ) |
63 // Create a standard model for the grid view |
|
64 mGridModel = new QStandardItemModel( this ); |
|
65 if( mDataManager->populateModel(*mGridModel, ELocationPickerContent, aOrientation) ) |
71 { |
66 { |
72 // Create the proxy model and set source model |
67 locationsFound = true; |
73 mProxyGridModel = new LocationPickerProxyModel( mOrientation , this ); |
|
74 mProxyGridModel->setSourceModel(mModel); |
|
75 // set sort properties |
|
76 mProxyGridModel->setDynamicSortFilter(TRUE); |
|
77 mProxyGridModel->setSortRole(Qt::DisplayRole); |
|
78 mProxyGridModel->setSortCaseSensitivity(Qt::CaseInsensitive); |
|
79 |
|
80 // sort in ascending order |
|
81 mProxyGridModel->sort(0, Qt::AscendingOrder); |
|
82 mLocationsFound = true; |
|
83 } |
68 } |
84 else |
69 else |
85 { |
70 { |
86 // no locations to display. |
71 createNoEntryDisplay(mGridModel); |
87 QStandardItem *modelItem = new QStandardItem(); |
72 locationsFound = false; |
88 modelItem->setData(QVariant(hbTrId("txt_lint_list_no_location_entries_present")), Qt::DisplayRole); |
|
89 mModel->appendRow( modelItem ); |
|
90 mLocationsFound = false; |
|
91 } |
73 } |
92 } |
74 } |
|
75 return locationsFound; |
93 } |
76 } |
94 |
77 |
95 // ----------------------------------------------------------------------------- |
78 // ----------------------------------------------------------------------------- |
96 // LocationPickerContent::LocationPickerContent() |
79 // LocationPickerContent::LocationPickerContent() |
97 // ----------------------------------------------------------------------------- |
80 // ----------------------------------------------------------------------------- |
98 LocationPickerContent::~LocationPickerContent() |
81 LocationPickerContent::~LocationPickerContent() |
99 { |
82 { |
100 // delete data manager |
83 delete mListModel; |
101 if( mDataManager ) |
84 delete mGridModel; |
102 delete mDataManager; |
|
103 delete mProxyGridModel; |
|
104 delete mListProxyModel; |
|
105 delete mModel; |
|
106 } |
85 } |
107 |
86 |
108 // ----------------------------------------------------------------------------- |
87 // ----------------------------------------------------------------------------- |
109 // LocationPickerContent::locationsFound() |
88 // LocationPickerContent::getStandardListModel() |
110 // ----------------------------------------------------------------------------- |
89 // ----------------------------------------------------------------------------- |
111 bool LocationPickerContent::locationsFound() |
90 QStandardItemModel* LocationPickerContent::getStandardListModel() |
112 { |
91 { |
113 return mLocationsFound; |
92 return mListModel; |
114 } |
93 } |
115 |
94 |
116 // ----------------------------------------------------------------------------- |
95 // ----------------------------------------------------------------------------- |
117 // LocationPickerContent::getListProxyModel() |
96 // LocationPickerContent::getStandardGridModel() |
118 // ----------------------------------------------------------------------------- |
97 // ----------------------------------------------------------------------------- |
119 LocationPickerProxyModel* LocationPickerContent::getListProxyModel() |
98 QStandardItemModel* LocationPickerContent::getStandardGridModel() |
120 { |
99 { |
121 return mListProxyModel; |
100 return mGridModel; |
122 } |
101 } |
123 |
102 |
124 // ----------------------------------------------------------------------------- |
103 // ---------------------------------------------------------------------------- |
125 // LocationPickerContent::getStandardModel() |
104 // LocationPickerContent::createNoEntryDisplay() |
126 // ----------------------------------------------------------------------------- |
105 // ---------------------------------------------------------------------------- |
127 QStandardItemModel* LocationPickerContent::getStandardModel() |
106 |
|
107 void LocationPickerContent::createNoEntryDisplay( QStandardItemModel *aModel ) |
128 { |
108 { |
129 return mModel; |
109 // no locations to display. |
|
110 QStandardItem *modelItem = new QStandardItem(); |
|
111 modelItem->setData(QVariant(hbTrId("txt_lint_list_no_location_entries_present")), Qt::DisplayRole); |
|
112 aModel->appendRow( modelItem ); |
130 } |
113 } |
131 |
|
132 // ----------------------------------------------------------------------------- |
|
133 // LocationPickerContent::getDataManager() |
|
134 // ----------------------------------------------------------------------------- |
|
135 LocationPickerDataManager* LocationPickerContent::getDataManager() |
|
136 { |
|
137 return mDataManager; |
|
138 } |
|
139 |
|
140 // ----------------------------------------------------------------------------- |
|
141 // LocationPickerContent::getGridProxyModel() |
|
142 // ----------------------------------------------------------------------------- |
|
143 LocationPickerProxyModel* LocationPickerContent::getGridProxyModel() |
|
144 { |
|
145 return mProxyGridModel; |
|
146 } |
|