emailuis/nmailui/src/nmmailboxlistview.cpp
changeset 43 99bcbff212ad
parent 40 2c62ef3caffd
child 47 f83bd4ae1fe3
child 54 997a02608b3a
equal deleted inserted replaced
42:139d4b7b2938 43:99bcbff212ad
    44 mListModel(mailboxListModel),
    44 mListModel(mailboxListModel),
    45 mItemContextMenu(NULL),
    45 mItemContextMenu(NULL),
    46 mDocumentLoader(documentLoader),
    46 mDocumentLoader(documentLoader),
    47 mViewReady(false)
    47 mViewReady(false)
    48 {
    48 {
       
    49     NM_FUNCTION;
       
    50     
    49     // Load view layout
    51     // Load view layout
    50     loadViewLayout();
    52     loadViewLayout();
    51     
    53     
    52     // Set title
    54     // Set title
    53     setTitle(hbTrId("txt_mail_title_mail"));
    55     setTitle(hbTrId("txt_mail_title_mail"));
    56 /*!
    58 /*!
    57     Destructor
    59     Destructor
    58 */
    60 */
    59 NmMailboxListView::~NmMailboxListView()
    61 NmMailboxListView::~NmMailboxListView()
    60 {
    62 {
       
    63     NM_FUNCTION;
       
    64     
    61     delete mDocumentLoader;
    65     delete mDocumentLoader;
    62     mWidgetList.clear();
    66     mWidgetList.clear();
    63     if (mItemContextMenu){
    67     if (mItemContextMenu){
    64         mItemContextMenu->clearActions();
    68         mItemContextMenu->clearActions();
    65     }
    69     }
    69 /*!
    73 /*!
    70     View layout loading from XML
    74     View layout loading from XML
    71 */
    75 */
    72 void NmMailboxListView::loadViewLayout()
    76 void NmMailboxListView::loadViewLayout()
    73 {
    77 {
       
    78     NM_FUNCTION;
       
    79     
    74     // Use document loader to load the view
    80     // Use document loader to load the view
    75     bool ok = false;
    81     bool ok = false;
    76     setObjectName(QString(NMUI_MAILBOX_LIST_VIEW));
    82     setObjectName(QString(NMUI_MAILBOX_LIST_VIEW));
    77     QObjectList objectList;
    83     QObjectList objectList;
    78     objectList.append(this);
    84     objectList.append(this);
    88         mItemContextMenu = new HbMenu();
    94         mItemContextMenu = new HbMenu();
    89         // Get mailbox widget pointer and set parameters
    95         // Get mailbox widget pointer and set parameters
    90         mMailboxListWidget = qobject_cast<HbListView *>
    96         mMailboxListWidget = qobject_cast<HbListView *>
    91             (mDocumentLoader->findWidget(NMUI_MAILBOX_LIST_WIDGET));
    97             (mDocumentLoader->findWidget(NMUI_MAILBOX_LIST_WIDGET));
    92         if (mMailboxListWidget) {
    98         if (mMailboxListWidget) {
    93             NMLOG("nmailui: mailboxlistview: List object loaded");
    99             NM_COMMENT("nmailui: mailboxlistview: list object loaded");
    94             // Set item prototype.
   100             // Set item prototype.
    95             mMailboxListWidget->setItemPrototype(new NmMailboxListViewItem(this));
   101             mMailboxListWidget->setItemPrototype(new NmMailboxListViewItem(this));
    96             mMailboxListWidget->setItemRecycling(true);
   102             mMailboxListWidget->setItemRecycling(true);
    97             QObject::connect(mMailboxListWidget,
   103             QObject::connect(mMailboxListWidget,
    98                     SIGNAL(activated(const QModelIndex &)),
   104                     SIGNAL(activated(const QModelIndex &)),
    99                 this, SLOT(itemActivated(const QModelIndex &)));
   105                 this, SLOT(itemActivated(const QModelIndex &)));
   100             mMailboxListWidget->setClampingStyle(HbScrollArea::BounceBackClamping);
   106             mMailboxListWidget->setClampingStyle(HbScrollArea::BounceBackClamping);
   101             mMailboxListWidget->setFrictionEnabled(true);
   107             mMailboxListWidget->setFrictionEnabled(true);
   102         }
   108         }
   103         else {
   109         else {
   104             NMLOG("nmailui: mailboxlistview: List object loading failed");
   110             NM_ERROR(1,"nmailui: mailboxlistview: list object loading failed");
   105         }
   111         }
   106     }
   112     }
   107     else {
   113     else {
   108          NMLOG("nmailui: mailboxlistview: Reasource loading failed");
   114          NM_ERROR(1,"nmailui: mailboxlistview: resource loading failed");
   109     }
   115     }
   110 }
   116 }
   111 
   117 
   112 /*!
   118 /*!
   113     Lazy loading when view layout has been loaded
   119     Lazy loading when view layout has been loaded
   114 */
   120 */
   115 void NmMailboxListView::viewReady()
   121 void NmMailboxListView::viewReady()
   116 {
   122 {
       
   123     NM_FUNCTION;
       
   124     
   117     if (!mViewReady){
   125     if (!mViewReady){
   118         // Set title
   126         // Set title
   119         setTitle(hbTrId("txt_mail_title_mail"));
   127         setTitle(hbTrId("txt_mail_title_mail"));
   120         // Refresh list
   128         // Refresh list
   121         QMetaObject::invokeMethod(this, "refreshList", Qt::QueuedConnection); 
   129         QMetaObject::invokeMethod(this, "refreshList", Qt::QueuedConnection); 
   128     Typically when view is already open and external view activation occurs
   136     Typically when view is already open and external view activation occurs
   129     for this same view
   137     for this same view
   130 */
   138 */
   131 void NmMailboxListView::reloadViewContents(NmUiStartParam* startParam)
   139 void NmMailboxListView::reloadViewContents(NmUiStartParam* startParam)
   132 {
   140 {
       
   141     NM_FUNCTION;
       
   142     
   133     // Check start parameter validity.
   143     // Check start parameter validity.
   134     if (startParam&&startParam->viewId()==NmUiViewMailboxList) {
   144     if (startParam&&startParam->viewId()==NmUiViewMailboxList) {
   135         // Delete existing start parameter data
   145         // Delete existing start parameter data
   136         delete mStartParam;
   146         delete mStartParam;
   137         mStartParam=NULL;
   147         mStartParam=NULL;
   139         mStartParam=startParam;
   149         mStartParam=startParam;
   140         // Refresh model
   150         // Refresh model
   141         refreshList();
   151         refreshList();
   142     }
   152     }
   143     else {
   153     else {
   144         NMLOG("nmailui: mailboxlistview: Invalid start parameter");
   154         NM_ERROR(1,"nmailui: mailboxlistview: invalid start parameter");
   145         // Unused start parameter needs to be deleted
   155         // Unused start parameter needs to be deleted
   146         delete startParam;
   156         delete startParam;
   147         startParam = NULL;
   157         startParam = NULL;
   148     }
   158     }
   149 }
   159 }
   151 /*!
   161 /*!
   152     View id
   162     View id
   153 */
   163 */
   154 NmUiViewId NmMailboxListView::nmailViewId() const
   164 NmUiViewId NmMailboxListView::nmailViewId() const
   155 {
   165 {
       
   166     NM_FUNCTION;
       
   167     
   156     return NmUiViewMailboxList;
   168     return NmUiViewMailboxList;
   157 }
   169 }
   158 
   170 
   159 /*!
   171 /*!
   160     Refresh list
   172     Refresh list
   161 */
   173 */
   162 void NmMailboxListView::refreshList()
   174 void NmMailboxListView::refreshList()
   163 {
   175 {
       
   176     NM_FUNCTION;
       
   177     
   164 	if (mMailboxListWidget) {
   178 	if (mMailboxListWidget) {
   165         mMailboxListWidget->setModel(&mListModel);
   179         mMailboxListWidget->setModel(&mListModel);
   166 	}
   180 	}
   167 }
   181 }
   168 
   182 
   169 /*!
   183 /*!
   170     Item activated slot
   184     Item activated slot
   171 */
   185 */
   172 void NmMailboxListView::itemActivated(const QModelIndex &index)
   186 void NmMailboxListView::itemActivated(const QModelIndex &index)
   173 {
   187 {
       
   188     NM_FUNCTION;
       
   189     
   174     mActivatedIndex = index;
   190     mActivatedIndex = index;
   175     QMetaObject::invokeMethod(this, "openSelectedMailBox", Qt::QueuedConnection);
   191     QMetaObject::invokeMethod(this, "openSelectedMailBox", Qt::QueuedConnection);
   176 }
   192 }
   177 
   193 
   178 
   194 
   179 /*!
   195 /*!
   180     Open selected mailbox
   196     Open selected mailbox
   181 */
   197 */
   182 void NmMailboxListView::openSelectedMailBox()
   198 void NmMailboxListView::openSelectedMailBox()
   183 {
   199 {
       
   200     NM_FUNCTION;
       
   201     
   184     // Get mailbox meta data
   202     // Get mailbox meta data
   185     NmMailboxMetaData *mailbox =
   203     NmMailboxMetaData *mailbox =
   186         mListModel.data(mActivatedIndex, Qt::DisplayRole).value<NmMailboxMetaData*>();
   204         mListModel.data(mActivatedIndex, Qt::DisplayRole).value<NmMailboxMetaData*>();
   187     if (mailbox) {
   205     if (mailbox) {
   188         // Get standard folder inbox id
   206         // Get standard folder inbox id
   198     call to handle menu command in the UI.
   216     call to handle menu command in the UI.
   199 */
   217 */
   200 
   218 
   201 void NmMailboxListView::handleActionCommand(NmActionResponse &actionResponse)
   219 void NmMailboxListView::handleActionCommand(NmActionResponse &actionResponse)
   202 {
   220 {
       
   221     NM_FUNCTION;
       
   222     
   203     // Handle context menu commands here
   223     // Handle context menu commands here
   204     Q_UNUSED(actionResponse);
   224     Q_UNUSED(actionResponse);
   205 }
   225 }
   206 
   226 
   207 
   227