equal
deleted
inserted
replaced
40 mContentItemModel(NULL), |
40 mContentItemModel(NULL), |
41 mMailboxListModel(mailboxListModel), |
41 mMailboxListModel(mailboxListModel), |
42 mParent(parent), |
42 mParent(parent), |
43 mMailboxId(0) |
43 mMailboxId(0) |
44 { |
44 { |
|
45 NM_FUNCTION; |
|
46 |
45 // No implementation required. |
47 // No implementation required. |
46 } |
48 } |
47 |
49 |
48 |
50 |
49 /*! |
51 /*! |
50 Class destructor. |
52 Class destructor. |
51 */ |
53 */ |
52 NmMailboxSelectionDialog::~NmMailboxSelectionDialog() |
54 NmMailboxSelectionDialog::~NmMailboxSelectionDialog() |
53 { |
55 { |
|
56 NM_FUNCTION; |
|
57 |
54 delete mContentItemModel; |
58 delete mContentItemModel; |
55 delete mMailboxListView; |
59 delete mMailboxListView; |
56 delete mMailboxSelectionDialog; |
60 delete mMailboxSelectionDialog; |
57 } |
61 } |
58 |
62 |
61 Initializes and displays the dialog |
65 Initializes and displays the dialog |
62 Signal selectionDialogClosed will be emitted when the dialog is closed |
66 Signal selectionDialogClosed will be emitted when the dialog is closed |
63 */ |
67 */ |
64 void NmMailboxSelectionDialog::open() |
68 void NmMailboxSelectionDialog::open() |
65 { |
69 { |
66 NMLOG("NmMailboxSelectionDialog::open()"); |
70 NM_FUNCTION; |
|
71 |
67 mMailboxId = 0; |
72 mMailboxId = 0; |
68 |
73 |
69 // Initialize the UI and fetch the mailbox items into the list. |
74 // Initialize the UI and fetch the mailbox items into the list. |
70 if (initializeUi() && populateListItems()) { |
75 if (initializeUi() && populateListItems()) { |
71 mMailboxSelectionDialog->setModal(true); |
76 mMailboxSelectionDialog->setModal(true); |
77 /*! |
82 /*! |
78 Slot that is called when dialog is closed |
83 Slot that is called when dialog is closed |
79 */ |
84 */ |
80 void NmMailboxSelectionDialog::dialogClosed(HbAction *action) |
85 void NmMailboxSelectionDialog::dialogClosed(HbAction *action) |
81 { |
86 { |
|
87 NM_FUNCTION; |
|
88 |
82 Q_UNUSED(action); |
89 Q_UNUSED(action); |
83 |
90 |
84 // Store the ID of the selected mailbox into the given argument. |
91 // Store the ID of the selected mailbox into the given argument. |
85 NMLOG(QString("NmMailboxSelectionDialog::dialogClosed() return %1"). |
92 NM_COMMENT(QString("NmMailboxSelectionDialog::dialogClosed() return %1"). |
86 arg(mMailboxId.id())); |
93 arg(mMailboxId.id())); |
87 |
94 |
88 emit selectionDialogClosed(mMailboxId); |
95 emit selectionDialogClosed(mMailboxId); |
89 } |
96 } |
90 |
97 |
94 \return True if the widgets were loaded and set up successfully, false |
101 \return True if the widgets were loaded and set up successfully, false |
95 otherwise. |
102 otherwise. |
96 */ |
103 */ |
97 bool NmMailboxSelectionDialog::initializeUi() |
104 bool NmMailboxSelectionDialog::initializeUi() |
98 { |
105 { |
99 NMLOG("NmMailboxSelectionDialog::initializeUi()"); |
106 NM_FUNCTION; |
100 |
107 |
101 // Use the document loader to load the widgets. |
108 // Use the document loader to load the widgets. |
102 HbDocumentLoader documentLoader; |
109 HbDocumentLoader documentLoader; |
103 bool documentLoaded = false; |
110 bool documentLoaded = false; |
104 |
111 |
105 QObjectList objectList; |
112 QObjectList objectList; |
116 mMailboxListView = |
123 mMailboxListView = |
117 qobject_cast<HbListView*>(documentLoader.findWidget(NMUI_MAILBOX_LIST_VIEW)); |
124 qobject_cast<HbListView*>(documentLoader.findWidget(NMUI_MAILBOX_LIST_VIEW)); |
118 } |
125 } |
119 |
126 |
120 if (!mMailboxSelectionDialog || !mMailboxListView) { |
127 if (!mMailboxSelectionDialog || !mMailboxListView) { |
121 NMLOG("NmMailboxSelectionDialog::initializeUi(): Failed to load widgets!"); |
128 NM_ERROR(1,"NmMailboxSelectionDialog::initializeUi(): Failed to load widgets!"); |
122 return false; |
129 return false; |
123 } |
130 } |
124 |
131 |
125 // Set up the loaded widgets. |
132 // Set up the loaded widgets. |
126 mMailboxSelectionDialog->setParentItem(mParent); |
133 mMailboxSelectionDialog->setParentItem(mParent); |
151 |
158 |
152 \return True if success, false otherwise. |
159 \return True if success, false otherwise. |
153 */ |
160 */ |
154 bool NmMailboxSelectionDialog::populateListItems() |
161 bool NmMailboxSelectionDialog::populateListItems() |
155 { |
162 { |
156 NMLOG("NmMailboxSelectionDialog::populateListItems()"); |
163 NM_FUNCTION; |
|
164 |
157 const int count = mMailboxListModel.rowCount(); |
165 const int count = mMailboxListModel.rowCount(); |
158 |
166 |
159 if (!mContentItemModel || count == 0) { |
167 if (!mContentItemModel || count == 0) { |
160 // The UI skeleton was not set up successfully or no mailboxes exist! |
168 // The UI skeleton was not set up successfully or no mailboxes exist! |
161 return false; |
169 return false; |
189 \param index The index of the mailbox in the list model. |
197 \param index The index of the mailbox in the list model. |
190 \return A mailbox meta data instance. |
198 \return A mailbox meta data instance. |
191 */ |
199 */ |
192 NmMailboxMetaData *NmMailboxSelectionDialog::mailboxMetaData(int index) const |
200 NmMailboxMetaData *NmMailboxSelectionDialog::mailboxMetaData(int index) const |
193 { |
201 { |
|
202 NM_FUNCTION; |
|
203 |
194 QVariant mailbox = mMailboxListModel.data(mMailboxListModel.index(index, 0)); |
204 QVariant mailbox = mMailboxListModel.data(mMailboxListModel.index(index, 0)); |
195 NmMailboxMetaData *mailboxMetaData = mailbox.value<NmMailboxMetaData*>(); |
205 NmMailboxMetaData *mailboxMetaData = mailbox.value<NmMailboxMetaData*>(); |
196 return mailboxMetaData; |
206 return mailboxMetaData; |
197 } |
207 } |
198 |
208 |
202 |
212 |
203 \param index The index of the selected item. |
213 \param index The index of the selected item. |
204 */ |
214 */ |
205 void NmMailboxSelectionDialog::itemActivated(QModelIndex index) |
215 void NmMailboxSelectionDialog::itemActivated(QModelIndex index) |
206 { |
216 { |
|
217 NM_FUNCTION; |
|
218 |
207 const int rowIndex = index.row(); |
219 const int rowIndex = index.row(); |
208 NmMailboxMetaData *metaData = mailboxMetaData(rowIndex); |
220 NmMailboxMetaData *metaData = mailboxMetaData(rowIndex); |
209 |
221 |
210 if (metaData && mMailboxSelectionDialog) { |
222 if (metaData && mMailboxSelectionDialog) { |
211 mMailboxId = metaData->id(); |
223 mMailboxId = metaData->id(); |