13 * |
13 * |
14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include <qinputcontext.h> |
18 #include <QInputContext> |
19 |
19 |
20 #include <hbinstance.h> |
20 #include <HbInstance> |
21 #include <hbmainwindow.h> |
21 #include <HbMainWindow> |
22 #include <hbaction.h> |
22 #include <HbAction> |
23 #include <hbdataform.h> |
23 #include <HbDataForm> |
24 #include <hbdataformmodel.h> |
24 #include <HbDataFormModel> |
25 #include <hbdocumentloader.h> |
25 #include <HbDocumentLoader> |
26 |
26 |
27 #include "nmmailboxsettingview.h" |
27 #include "nmmailboxsettingview.h" |
28 #include "nmmailboxsettingsmanager.h" |
28 #include "nmmailboxsettingsmanager.h" |
29 #include "nmsettingsformcustomitems.h" |
29 #include "nmsettingsformcustomitems.h" |
30 |
30 |
76 mForm = qobject_cast<HbDataForm*>( |
76 mForm = qobject_cast<HbDataForm*>( |
77 documentLoader.findWidget(NMSETTINGUI_SETTING_VIEW_FORM)); |
77 documentLoader.findWidget(NMSETTINGUI_SETTING_VIEW_FORM)); |
78 } |
78 } |
79 |
79 |
80 if (mForm) { |
80 if (mForm) { |
81 |
81 |
82 connect(mForm, SIGNAL(pressed(QModelIndex)), |
82 qRegisterMetaType<QModelIndex>("QModelIndex"); |
83 this, SLOT(itemPress(QModelIndex))); |
83 connect(mForm, SIGNAL(activated(QModelIndex)), |
84 |
84 this, SLOT(itemActivated(QModelIndex))); |
|
85 connect(mForm, SIGNAL(itemShown(QModelIndex)), |
|
86 this, SLOT(disablePredictiveText(QModelIndex))); |
|
87 |
85 // Fix for dataform item recycling. |
88 // Fix for dataform item recycling. |
86 mForm->setItemRecycling(false); |
89 mForm->setItemRecycling(false); |
87 |
90 |
88 // Set the form for the view. |
91 // Set the form for the view. |
89 setWidget(mForm); |
92 setWidget(mForm); |
160 } |
163 } |
161 } |
164 } |
162 } |
165 } |
163 |
166 |
164 /*! |
167 /*! |
165 Returns the mailbox id for this mailbox setting view. |
168 Returns the mailbox id for this mailbox setting view. |
166 */ |
169 */ |
167 NmId NmMailboxSettingView::mailboxId() |
170 NmId NmMailboxSettingView::mailboxId() |
168 { |
171 { |
169 return mMailboxId; |
172 return mMailboxId; |
170 } |
173 } |
171 |
174 |
172 /*! |
175 /*! |
173 Called when item is pressed on the view. |
176 Called when item is activated on the view. |
174 |
177 |
175 \param index Index to the pressed item. |
178 \param index Index to the pressed item. |
176 */ |
179 */ |
177 void NmMailboxSettingView::itemPress(const QModelIndex &index) |
180 void NmMailboxSettingView::itemActivated(const QModelIndex &index) |
178 { |
181 { |
179 NM_FUNCTION; |
182 NM_FUNCTION; |
180 |
183 |
181 int type(index.data(HbDataFormModelItem::ItemTypeRole).toInt()); |
184 int type(index.data(HbDataFormModelItem::ItemTypeRole).toInt()); |
182 |
185 |
183 if (type == HbDataFormModelItem::GroupItem) { |
186 if (type == HbDataFormModelItem::GroupItem) { |
184 // Scroll the groupitem to top if needed. |
187 |
185 HbDataFormViewItem *item = static_cast<HbDataFormViewItem *>(mForm->itemByIndex(index)); |
188 // Scroll the groupitem to top. |
186 |
189 if (!mForm->isExpanded(index)) { |
187 if (!item->isExpanded()) { |
190 QMetaObject::invokeMethod(this, "queuedScroll", |
188 mForm->scrollTo(index, HbAbstractItemView::PositionAtTop); |
191 Qt::QueuedConnection, Q_ARG(QModelIndex, index)); |
189 }else { |
192 }else { |
190 // Hide the virtual keyboard |
193 // Hide the virtual keyboard |
191 QInputContext *ic = qApp->inputContext(); |
194 QInputContext *ic = qApp->inputContext(); |
192 if (ic) { |
195 if (ic) { |
193 QEvent *closeEvent = new QEvent(QEvent::CloseSoftwareInputPanel); |
196 QEvent *closeEvent = new QEvent(QEvent::CloseSoftwareInputPanel); |
194 ic->filterEvent(closeEvent); |
197 ic->filterEvent(closeEvent); |
195 delete closeEvent; |
198 delete closeEvent; |
196 } |
199 } |
197 } |
200 } |
198 } |
201 } |
199 |
202 |
|
203 |
|
204 } |
|
205 |
|
206 /*! |
|
207 Called when item is shown on the view. |
|
208 |
|
209 \param index Index to the shown item. |
|
210 */ |
|
211 void NmMailboxSettingView::disablePredictiveText(const QModelIndex &index) |
|
212 { |
|
213 NM_FUNCTION; |
|
214 |
|
215 int type(index.data(HbDataFormModelItem::ItemTypeRole).toInt()); |
|
216 |
200 if (type == HbDataFormModelItem::TextItem) { |
217 if (type == HbDataFormModelItem::TextItem) { |
201 // Turn off predictive input for line-edit. |
218 // Turn off predictive input for line-edit. |
202 HbDataFormViewItem *item = static_cast<HbDataFormViewItem *>(mForm->itemByIndex(index)); |
219 HbDataFormViewItem *item = static_cast<HbDataFormViewItem *>(mForm->itemByIndex(index)); |
203 HbWidget *widget = item->dataItemContentWidget(); |
220 HbWidget *widget = item->dataItemContentWidget(); |
204 widget->setInputMethodHints(Qt::ImhNoPredictiveText); |
221 if (widget) { |
205 } |
222 widget->setInputMethodHints(Qt::ImhNoPredictiveText); |
|
223 } |
|
224 } |
|
225 } |
|
226 |
|
227 /*! |
|
228 Called when view needs to be scrolled. |
|
229 |
|
230 \param index Index to the item. |
|
231 */ |
|
232 void NmMailboxSettingView::queuedScroll(const QModelIndex &index) |
|
233 { |
|
234 NM_FUNCTION; |
|
235 |
|
236 mForm->scrollTo(index, HbAbstractItemView::PositionAtTop); |
206 } |
237 } |
207 // End of file. |
238 // End of file. |