32 // ======== MEMBER FUNCTIONS ======== |
32 // ======== MEMBER FUNCTIONS ======== |
33 |
33 |
34 // ---------------------------------------------------- |
34 // ---------------------------------------------------- |
35 // LocationPickerPotraitView::LocationPickerView() |
35 // LocationPickerPotraitView::LocationPickerView() |
36 // ---------------------------------------------------- |
36 // ---------------------------------------------------- |
37 LocationPickerPotraitView::LocationPickerPotraitView(HbDocumentLoader* aLoader) |
37 LocationPickerPotraitView::LocationPickerPotraitView( HbDocumentLoader* aLoader ) |
38 :mDocumentLoader(aLoader), |
38 :mDocumentLoader(aLoader), |
39 mLocationPickerContent(NULL), |
|
40 mLocationPickerCollectionListContent(NULL), |
39 mLocationPickerCollectionListContent(NULL), |
|
40 mProxyModel(NULL), |
41 mAllAction(NULL), |
41 mAllAction(NULL), |
42 mCollectionAction(NULL), |
42 mCollectionAction(NULL), |
43 mSearchAction(NULL), |
43 mSearchAction(NULL), |
44 mAscendingAction(NULL), |
44 mAscendingAction(NULL), |
45 mDescendingAction(NULL), |
45 mDescendingAction(NULL), |
46 mListView(NULL), |
46 mListView(NULL), |
47 mCollectionContent(NULL), |
47 mCollectionContent(NULL), |
48 mViewType(ELocationPickerContent) |
48 mViewType(ELocationPickerContent) |
49 { |
49 { |
50 // create back action |
50 // create back action |
51 mPotraitBackAction = new HbAction(Hb::BackAction); |
51 mPotraitBackAction = new HbAction(Hb::BackNaviAction); |
52 // add back key action |
52 // add back key action |
53 setNavigationAction(mPotraitBackAction); |
53 setNavigationAction(mPotraitBackAction); |
54 //connect to slots |
54 //connect to slots |
55 connect(mPotraitBackAction, SIGNAL(triggered()), this, |
55 connect(mPotraitBackAction, SIGNAL(triggered()), this, |
56 SLOT(backTriggered())); |
56 SLOT(backTriggered())); |
95 |
93 |
96 |
94 |
97 // ---------------------------------------------------- |
95 // ---------------------------------------------------- |
98 // LocationPickerPotraitView::init() |
96 // LocationPickerPotraitView::init() |
99 // ---------------------------------------------------- |
97 // ---------------------------------------------------- |
100 void LocationPickerPotraitView::init(Qt::Orientation aOrientation ) |
98 void LocationPickerPotraitView::init( bool aPopulated, Qt::Orientation aOrientation, QStandardItemModel *aModel ) |
101 { |
99 { |
|
100 mModel = aModel; |
|
101 if(aPopulated) |
|
102 { |
102 // Create Collection List Content |
103 // Create Collection List Content |
103 mLocationPickerCollectionListContent = new LocationPickerCollectionListContent(aOrientation); |
104 mLocationPickerCollectionListContent = new LocationPickerCollectionListContent(aOrientation); |
104 mLocationPickerContent = new LocationPickerContent(aOrientation); |
105 //create proxy model |
105 |
106 mProxyModel = new LocationPickerProxyModel( aOrientation , this ); |
|
107 mProxyModel->setSourceModel(aModel); |
|
108 // set sort properties |
|
109 mProxyModel->setDynamicSortFilter(TRUE); |
|
110 mProxyModel->setSortRole(Qt::DisplayRole); |
|
111 mProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); |
|
112 // sort in ascending order |
|
113 mProxyModel->sort(0, Qt::AscendingOrder); |
|
114 } |
106 //Get HbAction items |
115 //Get HbAction items |
107 mListView = qobject_cast<HbListView*> (mDocumentLoader->findObject(QString( |
116 mListView = qobject_cast<HbListView*> (mDocumentLoader->findObject(QString( |
108 "ListView"))); |
117 "ListView"))); |
109 |
|
110 //get the action items from docml |
118 //get the action items from docml |
111 mAllAction = qobject_cast<HbAction*> (mDocumentLoader->findObject(QString( |
119 mAllAction = qobject_cast<HbAction*> (mDocumentLoader->findObject(QString( |
112 "allAction"))); |
120 "allAction"))); |
113 mCollectionAction = qobject_cast<HbAction*> (mDocumentLoader->findObject( |
121 mCollectionAction = qobject_cast<HbAction*> (mDocumentLoader->findObject( |
114 QString("collectionAction"))); |
122 QString("collectionAction"))); |
116 "searchAction"))); |
124 "searchAction"))); |
117 mAscendingAction = qobject_cast<HbAction*> (mDocumentLoader->findObject( |
125 mAscendingAction = qobject_cast<HbAction*> (mDocumentLoader->findObject( |
118 QString("ascendingAction"))); |
126 QString("ascendingAction"))); |
119 mDescendingAction = qobject_cast<HbAction*> (mDocumentLoader->findObject( |
127 mDescendingAction = qobject_cast<HbAction*> (mDocumentLoader->findObject( |
120 QString("descendingAction"))); |
128 QString("descendingAction"))); |
121 if( !mAllAction || !mCollectionAction || !mSearchAction || !mListView || !mAscendingAction || !mDescendingAction) |
129 if( !mAllAction || !mCollectionAction || !mSearchAction || !mAscendingAction || !mDescendingAction || !mListView) |
122 { |
130 { |
123 qFatal("Error Reading Docml"); |
131 qFatal("Error Reading Docml"); |
124 } |
132 } |
125 |
133 |
126 //connect to slots |
134 //connect to slots |
127 connect(mAscendingAction, SIGNAL(triggered()), this, SLOT(sortAscending())); |
135 connect(mAscendingAction, SIGNAL(triggered()), this, SLOT(sortAscending())); |
128 connect(mDescendingAction, SIGNAL(triggered()), this, |
136 connect(mDescendingAction, SIGNAL(triggered()), this, |
129 SLOT(sortDescending())); |
137 SLOT(sortDescending())); |
130 //connect all action Items to respective slots |
138 //connect all action Items to respective slots |
135 // connect the signal of the list activated to a slot. |
143 // connect the signal of the list activated to a slot. |
136 connect(mListView, SIGNAL(activated(const QModelIndex &)), this, SLOT(handleActivated(const QModelIndex &))); |
144 connect(mListView, SIGNAL(activated(const QModelIndex &)), this, SLOT(handleActivated(const QModelIndex &))); |
137 } |
145 } |
138 |
146 |
139 void LocationPickerPotraitView::manageListView() |
147 void LocationPickerPotraitView::manageListView() |
140 { |
148 { |
141 if (!mLocationPickerContent->locationsFound()) |
149 //set the appropriate model |
142 { |
150 switch(mViewType) |
143 //if no location entries present |
151 { |
144 mListView->setModel(mLocationPickerContent->getStandardModel(),mListItem); |
152 case ELocationPickerContent: |
145 disableTabs(); |
153 { |
146 } |
154 mListItem->setGraphicsSize(HbListViewItem::Thumbnail); |
147 else |
155 mListView->setModel(mProxyModel,mListItem); |
148 { |
156 mAllAction->setChecked(true); |
149 //set the appropriate model |
157 mCollectionAction->setChecked(false); |
150 switch(mViewType) |
158 mViewType = ELocationPickerContent; |
151 { |
159 } |
152 case ELocationPickerContent: |
160 break; |
153 { |
161 case ELocationPickerCollectionListContent: |
154 mListItem->setGraphicsSize(HbListViewItem::Thumbnail); |
162 { |
155 mListView->setModel(mLocationPickerContent->getListProxyModel(),mListItem); |
163 mListItem->setGraphicsSize(HbListViewItem::MediumIcon); |
156 mAllAction->setChecked(true); |
164 mListView->setModel(mLocationPickerCollectionListContent->getStandardModel(),mListItem); |
157 mCollectionAction->setChecked(false); |
165 mCollectionAction->setChecked(true); |
158 mViewType = ELocationPickerContent; |
166 mAllAction->setChecked(false); |
159 } |
167 mViewType = ELocationPickerCollectionListContent; |
160 break; |
168 } |
161 case ELocationPickerCollectionListContent: |
169 break; |
162 { |
170 case ELocationPickerCollectionContent: |
163 mListItem->setGraphicsSize(HbListViewItem::MediumIcon); |
171 { |
164 mListView->setModel(mLocationPickerCollectionListContent->getStandardModel(),mListItem); |
172 setCollectionData(mCategoryId); |
165 mCollectionAction->setChecked(true); |
173 mCollectionAction->setChecked(true); |
166 mAllAction->setChecked(false); |
174 mAllAction->setChecked(false); |
167 mViewType = ELocationPickerCollectionListContent; |
175 mViewType = ELocationPickerCollectionContent; |
168 } |
176 } |
169 break; |
177 break; |
170 case ELocationPickerCollectionContent: |
178 default: |
171 { |
179 break; |
172 setCollectionData(mCategoryId); |
180 } |
173 mCollectionAction->setChecked(true); |
181 } |
174 mAllAction->setChecked(false); |
182 |
175 mViewType = ELocationPickerCollectionContent; |
183 |
176 } |
184 void LocationPickerPotraitView::disableTabs( QStandardItemModel *aModel ) |
177 break; |
185 { |
178 default: |
186 //if no location entries present |
179 break; |
187 mListView->setModel(aModel,mListItem); |
180 } |
|
181 |
|
182 } |
|
183 } |
|
184 |
|
185 |
|
186 void LocationPickerPotraitView::disableTabs() |
|
187 { |
|
188 mAllAction->setDisabled(true); |
188 mAllAction->setDisabled(true); |
189 mCollectionAction->setDisabled(true); |
189 mCollectionAction->setDisabled(true); |
190 mSearchAction->setDisabled(true); |
190 mSearchAction->setDisabled(true); |
191 mAscendingAction->setDisabled(true); |
191 mAscendingAction->setDisabled(true); |
192 mDescendingAction->setDisabled(true); |
192 mDescendingAction->setDisabled(true); |
193 } |
193 } |
194 |
194 |
195 // ----------------------------------------------------------------------------- |
195 // ----------------------------------------------------------------------------- |
196 // LocationPickerView::handleActivated() |
196 // LocationPickerView::handleActivated() |
197 // ----------------------------------------------------------------------------- |
197 // ----------------------------------------------------------------------------- |
198 void LocationPickerPotraitView::handleActivated(const QModelIndex &aIndex) |
198 void LocationPickerPotraitView::handleActivated( const QModelIndex &aIndex ) |
199 { |
199 { |
200 //handle the activated signal according to model set |
200 //handle the activated signal according to model set |
201 switch(mViewType) |
201 switch(mViewType) |
202 { |
202 { |
203 case ELocationPickerContent: |
203 case ELocationPickerContent: |
204 { |
204 { |
205 QModelIndex index = mLocationPickerContent->getListProxyModel()->mapToSource( |
205 if(!mProxyModel) |
|
206 { |
|
207 break; |
|
208 } |
|
209 QModelIndex index = mProxyModel->mapToSource( |
206 aIndex); |
210 aIndex); |
207 quint32 lm = 0; |
211 quint32 lm = 0; |
208 mLocationPickerContent->getDataManager()->getData(index.row(), lm); |
212 QStandardItem* item = mModel->item( index.row(), index.column() ); |
|
213 QVariant var = item->data( Qt::UserRole ); |
|
214 lm = var.toUInt(); |
209 //item selected, complete request |
215 //item selected, complete request |
210 emit selectItem( lm ); |
216 emit selectItem( lm ); |
211 } |
217 } |
212 break; |
218 break; |
213 case ELocationPickerCollectionListContent: |
219 case ELocationPickerCollectionListContent: |
214 { |
220 { |
215 mLocationPickerCollectionListContent->getDataManager()->getData( |
221 mLocationPickerCollectionListContent->getData( |
216 aIndex.row(), mCategoryId); |
222 aIndex, mCategoryId ); |
217 mViewType = ELocationPickerCollectionContent; |
223 mViewType = ELocationPickerCollectionContent; |
218 //send categoryID to set the collection content |
224 //send categoryID to set the collection content |
219 emit sendCategoryID(mCategoryId); |
225 emit sendCategoryID(mCategoryId); |
220 } |
226 } |
221 break; |
227 break; |
222 case ELocationPickerCollectionContent: |
228 case ELocationPickerCollectionContent: |
223 { |
229 { |
|
230 if(!mCollectionContent->getProxyModel()) |
|
231 { |
|
232 break; |
|
233 } |
224 QModelIndex index = mCollectionContent->getProxyModel()->mapToSource( |
234 QModelIndex index = mCollectionContent->getProxyModel()->mapToSource( |
225 aIndex); |
235 aIndex); |
226 quint32 lm = 0; |
236 quint32 lm = 0; |
227 mCollectionContent->getDataManager()->getData(index.row(), lm); |
237 mCollectionContent->getData(index, lm); |
228 //item selected, complete request |
238 //item selected, complete request |
229 emit selectItem(lm); |
239 emit selectItem(lm); |
230 } |
240 } |
231 break; |
241 break; |
232 default: |
242 default: |
336 // ----------------------------------------------------------------------------- |
346 // ----------------------------------------------------------------------------- |
337 // LocationPickerView::setCollectionData() |
347 // LocationPickerView::setCollectionData() |
338 // ----------------------------------------------------------------------------- |
348 // ----------------------------------------------------------------------------- |
339 void LocationPickerPotraitView::setCollectionData( quint32 acategoryId ) |
349 void LocationPickerPotraitView::setCollectionData( quint32 acategoryId ) |
340 { |
350 { |
341 mCollectionContent |
351 |
342 = new LocationPickerCollectionContent(this->mainWindow()->orientation() , acategoryId); |
352 if(!mCollectionContent) |
|
353 { |
|
354 mCollectionContent |
|
355 = new LocationPickerCollectionContent(Qt::Vertical , acategoryId); |
|
356 } |
343 mListItem->setGraphicsSize(HbListViewItem::Thumbnail); |
357 mListItem->setGraphicsSize(HbListViewItem::Thumbnail); |
344 mListView->setModel(mCollectionContent->getProxyModel(),mListItem); |
358 if(mCollectionContent->locationFound()) |
|
359 { |
|
360 mListView->setModel(mCollectionContent->getProxyModel(),mListItem); |
|
361 } |
|
362 else |
|
363 { |
|
364 mListView->setModel(mCollectionContent->getStandardModel(),mListItem); |
|
365 } |
345 mViewType = ELocationPickerCollectionContent; |
366 mViewType = ELocationPickerCollectionContent; |
346 //Enable the options |
367 //Enable the options |
347 mAscendingAction->setEnabled(true); |
368 mAscendingAction->setEnabled(true); |
348 mDescendingAction->setEnabled(true); |
369 mDescendingAction->setEnabled(true); |
349 mCollectionAction->setChecked(true); |
370 mCollectionAction->setChecked(true); |