diff -r 64e38f08e49c -r 47d84de1c893 emailuis/nmsettingui/src/nmmailboxsettingview.cpp --- a/emailuis/nmsettingui/src/nmmailboxsettingview.cpp Fri Sep 17 08:27:21 2010 +0300 +++ b/emailuis/nmsettingui/src/nmmailboxsettingview.cpp Mon Oct 04 00:05:37 2010 +0300 @@ -15,14 +15,14 @@ * */ -#include +#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include "nmmailboxsettingview.h" #include "nmmailboxsettingsmanager.h" @@ -59,7 +59,7 @@ mMailboxId(mailboxId.id()) { NM_FUNCTION; - + setTitle(mailboxName); HbDocumentLoader documentLoader; @@ -78,10 +78,13 @@ } if (mForm) { - - connect(mForm, SIGNAL(pressed(QModelIndex)), - this, SLOT(itemPress(QModelIndex))); - + + qRegisterMetaType("QModelIndex"); + connect(mForm, SIGNAL(activated(QModelIndex)), + this, SLOT(itemActivated(QModelIndex))); + connect(mForm, SIGNAL(itemShown(QModelIndex)), + this, SLOT(disablePredictiveText(QModelIndex))); + // Fix for dataform item recycling. mForm->setItemRecycling(false); @@ -108,7 +111,7 @@ NmMailboxSettingView::~NmMailboxSettingView() { NM_FUNCTION; - + delete mForm; delete mModel; } @@ -124,7 +127,7 @@ NmSettings::MailboxEventType type) { NM_FUNCTION; - + Q_UNUSED(mailboxId); Q_UNUSED(type); @@ -147,7 +150,7 @@ QVariant value) { NM_FUNCTION; - + Q_UNUSED(mailboxId); switch (property.toInt()) { @@ -162,7 +165,7 @@ } /*! - Returns the mailbox id for this mailbox setting view. + Returns the mailbox id for this mailbox setting view. */ NmId NmMailboxSettingView::mailboxId() { @@ -170,22 +173,22 @@ } /*! - Called when item is pressed on the view. + Called when item is activated on the view. \param index Index to the pressed item. */ -void NmMailboxSettingView::itemPress(const QModelIndex &index) +void NmMailboxSettingView::itemActivated(const QModelIndex &index) { NM_FUNCTION; - + int type(index.data(HbDataFormModelItem::ItemTypeRole).toInt()); - + if (type == HbDataFormModelItem::GroupItem) { - // Scroll the groupitem to top if needed. - HbDataFormViewItem *item = static_cast(mForm->itemByIndex(index)); - - if (!item->isExpanded()) { - mForm->scrollTo(index, HbAbstractItemView::PositionAtTop); + + // Scroll the groupitem to top. + if (!mForm->isExpanded(index)) { + QMetaObject::invokeMethod(this, "queuedScroll", + Qt::QueuedConnection, Q_ARG(QModelIndex, index)); }else { // Hide the virtual keyboard QInputContext *ic = qApp->inputContext(); @@ -196,12 +199,40 @@ } } } - + + +} + +/*! + Called when item is shown on the view. + + \param index Index to the shown item. +*/ +void NmMailboxSettingView::disablePredictiveText(const QModelIndex &index) +{ + NM_FUNCTION; + + int type(index.data(HbDataFormModelItem::ItemTypeRole).toInt()); + if (type == HbDataFormModelItem::TextItem) { // Turn off predictive input for line-edit. HbDataFormViewItem *item = static_cast(mForm->itemByIndex(index)); HbWidget *widget = item->dataItemContentWidget(); - widget->setInputMethodHints(Qt::ImhNoPredictiveText); + if (widget) { + widget->setInputMethodHints(Qt::ImhNoPredictiveText); + } } } + +/*! + Called when view needs to be scrolled. + + \param index Index to the item. +*/ +void NmMailboxSettingView::queuedScroll(const QModelIndex &index) +{ + NM_FUNCTION; + + mForm->scrollTo(index, HbAbstractItemView::PositionAtTop); +} // End of file.