emailuis/nmsettingui/src/nmmailboxsettingview.cpp
changeset 68 83cc6bae1de8
parent 57 ae34e1715e21
child 74 6c59112cfd31
equal deleted inserted replaced
67:459da34cdb45 68:83cc6bae1de8
    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 
    57       mForm(NULL),
    57       mForm(NULL),
    58       mModel(NULL),
    58       mModel(NULL),
    59       mMailboxId(mailboxId.id())
    59       mMailboxId(mailboxId.id())
    60 {
    60 {
    61     NM_FUNCTION;
    61     NM_FUNCTION;
    62     
    62 
    63     setTitle(mailboxName);
    63     setTitle(mailboxName);
    64 
    64 
    65     HbDocumentLoader documentLoader;
    65     HbDocumentLoader documentLoader;
    66     bool documentLoaded = false;
    66     bool documentLoaded = false;
    67     QObjectList objectList;
    67     QObjectList objectList;
    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);
   106     Destructor of NmMailboxSettingView.
   109     Destructor of NmMailboxSettingView.
   107 */
   110 */
   108 NmMailboxSettingView::~NmMailboxSettingView()
   111 NmMailboxSettingView::~NmMailboxSettingView()
   109 {
   112 {
   110     NM_FUNCTION;
   113     NM_FUNCTION;
   111     
   114 
   112     delete mForm;
   115     delete mForm;
   113     delete mModel;
   116     delete mModel;
   114 }
   117 }
   115 
   118 
   116 
   119 
   122 */
   125 */
   123 void NmMailboxSettingView::mailboxListChanged(const NmId &mailboxId,
   126 void NmMailboxSettingView::mailboxListChanged(const NmId &mailboxId,
   124     NmSettings::MailboxEventType type)
   127     NmSettings::MailboxEventType type)
   125 {
   128 {
   126     NM_FUNCTION;
   129     NM_FUNCTION;
   127     
   130 
   128     Q_UNUSED(mailboxId);
   131     Q_UNUSED(mailboxId);
   129     Q_UNUSED(type);
   132     Q_UNUSED(type);
   130 
   133 
   131     HbAction *action = navigationAction();
   134     HbAction *action = navigationAction();
   132     if (action) {
   135     if (action) {
   145 void NmMailboxSettingView::mailboxPropertyChanged(const NmId &mailboxId,
   148 void NmMailboxSettingView::mailboxPropertyChanged(const NmId &mailboxId,
   146                                                   QVariant property,
   149                                                   QVariant property,
   147                                                   QVariant value)
   150                                                   QVariant value)
   148 {
   151 {
   149     NM_FUNCTION;
   152     NM_FUNCTION;
   150     
   153 
   151     Q_UNUSED(mailboxId);
   154     Q_UNUSED(mailboxId);
   152 
   155 
   153     switch (property.toInt()) {
   156     switch (property.toInt()) {
   154         case NmSettings::MailboxName: {
   157         case NmSettings::MailboxName: {
   155             setTitle(value.toString());
   158             setTitle(value.toString());
   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.