30 // ======== MEMBER FUNCTIONS ======== |
30 // ======== MEMBER FUNCTIONS ======== |
31 |
31 |
32 // ---------------------------------------------------- |
32 // ---------------------------------------------------- |
33 // LocationPickerSearchView::LocationPickerSearchView() |
33 // LocationPickerSearchView::LocationPickerSearchView() |
34 // ---------------------------------------------------- |
34 // ---------------------------------------------------- |
35 LocationPickerSearchView::LocationPickerSearchView(HbDocumentLoader &aLoader) |
35 LocationPickerSearchView::LocationPickerSearchView( HbDocumentLoader &aLoader ) |
36 :mProxyModel(NULL), |
36 :mProxyModel(NULL), |
37 mModel(NULL), |
37 mModel(NULL), |
38 mListView(NULL), |
38 mListView(NULL), |
39 mSearchPanel(NULL), |
39 mSearchPanel(NULL), |
40 mDataManager(NULL), |
|
41 mEmptyLabel(NULL), |
40 mEmptyLabel(NULL), |
42 mVerticalLayout(NULL), |
41 mVerticalLayout(NULL), |
43 mDocumentLoader(aLoader) |
42 mDocumentLoader(aLoader) |
44 { |
43 { |
45 |
44 |
47 // ---------------------------------------------------- |
46 // ---------------------------------------------------- |
48 // LocationPickerSearchView::~LocationPickerSearchView() |
47 // LocationPickerSearchView::~LocationPickerSearchView() |
49 // ---------------------------------------------------- |
48 // ---------------------------------------------------- |
50 LocationPickerSearchView::~LocationPickerSearchView() |
49 LocationPickerSearchView::~LocationPickerSearchView() |
51 { |
50 { |
52 if( mDataManager ) |
|
53 delete mDataManager; |
|
54 delete mProxyModel; |
51 delete mProxyModel; |
55 delete mModel; |
|
56 delete mEmptyLabel; |
52 delete mEmptyLabel; |
57 } |
53 } |
58 |
54 |
59 // ---------------------------------------------------- |
55 // ---------------------------------------------------- |
60 // LocationPickerSearchView::init() |
56 // LocationPickerSearchView::init() |
61 // ---------------------------------------------------- |
57 // ---------------------------------------------------- |
62 void LocationPickerSearchView::init() |
58 void LocationPickerSearchView::init( QStandardItemModel *aModel ) |
63 { |
59 { |
|
60 mModel = aModel; |
64 //get listview from docml |
61 //get listview from docml |
65 mListView = qobject_cast<HbListView*>( |
62 mListView = qobject_cast<HbListView*>( |
66 mDocumentLoader.findObject(QString("SearchListView"))); |
63 mDocumentLoader.findObject(QString("SearchListView"))); |
67 if(mListView == NULL) |
64 if(mListView == NULL) |
68 { |
65 { |
84 //Set graphics size for the list items. |
81 //Set graphics size for the list items. |
85 HbListViewItem *hbListItem = new HbListViewItem(); |
82 HbListViewItem *hbListItem = new HbListViewItem(); |
86 hbListItem->setGraphicsSize(HbListViewItem::Thumbnail); |
83 hbListItem->setGraphicsSize(HbListViewItem::Thumbnail); |
87 mListView->setItemPrototype( hbListItem ); |
84 mListView->setItemPrototype( hbListItem ); |
88 |
85 |
89 // Create a standard model for the view list |
|
90 mModel = new QStandardItemModel(this); |
|
91 // create a data manager to populate the model |
|
92 mDataManager = new LocationPickerDataManager( *mModel, ELocationPickerSearchView ); |
|
93 |
|
94 // Create the proxy model. |
86 // Create the proxy model. |
95 mProxyModel = new LocationPickerProxyModel( Qt ::Vertical ); |
87 mProxyModel = new LocationPickerProxyModel( Qt ::Vertical ); |
96 mProxyModel->setSourceModel(mModel); |
88 mProxyModel->setSourceModel(mModel); |
97 mListView->setModel(mProxyModel); |
89 mListView->setModel(mProxyModel); |
98 |
90 |
99 // set filter properties |
91 // set filter properties |
100 mProxyModel->setDynamicSortFilter(TRUE); |
92 mProxyModel->setDynamicSortFilter(TRUE); |
101 mProxyModel->setSortRole(Qt::DisplayRole); |
93 mProxyModel->setSortRole(Qt::DisplayRole); |
102 mProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); |
94 mProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); |
103 |
|
104 // populate data |
|
105 bool populated = mDataManager->populateModel(Qt::Vertical); |
|
106 if(!populated) |
|
107 { |
|
108 // no entries to display. |
|
109 QStandardItem *modelItem = new QStandardItem(); |
|
110 modelItem->setData(QVariant(hbTrId("txt_lint_list_no_location_entries_present")), Qt::DisplayRole); |
|
111 mModel->appendRow( modelItem ); |
|
112 } |
|
113 |
|
114 // sort |
95 // sort |
115 mProxyModel->sort(0, Qt::AscendingOrder); |
96 mProxyModel->sort(0, Qt::AscendingOrder); |
116 } |
97 } |
117 |
98 |
118 // ---------------------------------------------------- |
99 // ---------------------------------------------------- |
125 } |
106 } |
126 |
107 |
127 // ---------------------------------------------------- |
108 // ---------------------------------------------------- |
128 // LocationPickerSearchView::doSearch() |
109 // LocationPickerSearchView::doSearch() |
129 // ---------------------------------------------------- |
110 // ---------------------------------------------------- |
130 void LocationPickerSearchView::doSearch(QString aCriteria) |
111 void LocationPickerSearchView::doSearch( QString aCriteria ) |
131 { |
112 { |
132 // use the string to search |
113 // use the string to search |
133 mProxyModel->filterParameterChanged(aCriteria); |
114 mProxyModel->filterParameterChanged(aCriteria); |
134 mProxyModel->setFilterFixedString(aCriteria); |
115 mProxyModel->setFilterFixedString(aCriteria); |
135 //if no entries presentdisplay empty text item |
116 //if no entries presentdisplay empty text item |
171 } |
152 } |
172 |
153 |
173 // ---------------------------------------------------- |
154 // ---------------------------------------------------- |
174 // LocationPickerSearchView::handleActivated() |
155 // LocationPickerSearchView::handleActivated() |
175 // ---------------------------------------------------- |
156 // ---------------------------------------------------- |
176 void LocationPickerSearchView::handleActivated(const QModelIndex &aIndex) |
157 void LocationPickerSearchView::handleActivated( const QModelIndex &aIndex ) |
177 { |
158 { |
178 QModelIndex index = mProxyModel->mapToSource(aIndex); |
159 QModelIndex index = mProxyModel->mapToSource(aIndex); |
179 quint32 lm = 0; |
160 quint32 lm = 0; |
180 mDataManager->getData( index.row(), lm ); |
161 getData( index, lm ); |
181 //emit item is selectedsignal |
162 //emit item is selectedsignal |
182 emit selectItem( lm ); |
163 emit selectItem( lm ); |
183 } |
164 } |
184 |
165 |
|
166 // ---------------------------------------------------------------------------- |
|
167 // LocationPickerSearchView::getData() |
|
168 // ---------------------------------------------------------------------------- |
|
169 |
|
170 void LocationPickerSearchView::getData( QModelIndex aIndex, quint32& aValue ) |
|
171 { |
|
172 QStandardItem* item = mModel->item( aIndex.row(), aIndex.column() ); |
|
173 QVariant var = item->data( Qt::UserRole ); |
|
174 aValue = var.toUInt(); |
|
175 } |