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")); |
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; |
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 |