13 * |
13 * |
14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include <QDebug> |
|
19 #include <QtGui> |
18 #include <QtGui> |
20 #include <QGraphicsLinearLayout> |
19 #include <QGraphicsLinearLayout> |
21 #include <hbdocumentloader.h> |
20 #include <hbdocumentloader.h> |
22 #include <hblabel.h> |
21 #include <hblabel.h> |
23 #include <HbPushButton> |
22 #include <HbPushButton> |
|
23 #include <HbColorScheme> |
|
24 #include <HbEvent> |
24 #include "nmicons.h" |
25 #include "nmicons.h" |
25 #include "nmhswidgettitlerow.h" |
26 #include "nmhswidgettitlerow.h" |
26 #include "nmhswidgetconsts.h" |
27 #include "nmhswidgetconsts.h" |
|
28 #include "emailtrace.h" |
27 |
29 |
28 NmHsWidgetTitleRow::NmHsWidgetTitleRow(QGraphicsItem *parent, Qt::WindowFlags flags) : |
30 NmHsWidgetTitleRow::NmHsWidgetTitleRow(QGraphicsItem *parent, Qt::WindowFlags flags) : |
29 HbWidget(parent, flags), |
31 HbWidget(parent, flags), |
30 mMailboxIcon(0), |
32 mMailboxIcon(0), |
31 mMailboxInfo(0), |
33 mMailboxInfo(0), |
32 mUnreadCountLabel(0), |
34 mUnreadCountLabel(0), |
33 mCollapseExpIconLabel(0), |
35 mCollapseExpIconLabel(0), |
34 mAccountName(0), |
36 mAccountName(), |
35 mUnreadCount(0) |
37 mUnreadCount(0) |
36 { |
38 { |
37 qDebug() << "NmHsWidgetTitleRow::NmHsWidgetTitleRow IN -->>"; |
39 NM_FUNCTION; |
38 |
|
39 qDebug() << "NmHsWidgetTitleRow::NmHsWidgetTitleRow OUT <<--"; |
|
40 } |
40 } |
41 |
41 |
42 /*! |
42 /*! |
43 Destructor |
43 Destructor |
44 */ |
44 */ |
45 NmHsWidgetTitleRow::~NmHsWidgetTitleRow() |
45 NmHsWidgetTitleRow::~NmHsWidgetTitleRow() |
46 { |
46 { |
47 qDebug() << "NmHsWidgetTitleRow::~NmHsWidgetTitleRow IN -->>"; |
47 NM_FUNCTION; |
48 |
|
49 qDebug() << "NmHsWidgetTitleRow::~NmHsWidgetTitleRow OUT <<--"; |
|
50 } |
48 } |
51 |
49 |
52 /*! |
50 /*! |
53 Loads layout data and child items from docml file. Must be called after constructor. |
51 Loads layout data and child items from docml file. Must be called after constructor. |
54 /return true if loading succeeded, otherwise false. False indicates that object is unusable |
52 /return true if loading succeeded, otherwise false. False indicates that object is unusable |
55 */ |
53 */ |
56 bool NmHsWidgetTitleRow::loadDocML() |
54 bool NmHsWidgetTitleRow::loadDocML() |
57 { |
55 { |
|
56 NM_FUNCTION; |
58 QT_TRY{ |
57 QT_TRY{ |
59 qDebug() << "NmHsWidgetTitleRow::loadDocML IN -->>"; |
|
60 |
|
61 // Use document loader to load the contents |
58 // Use document loader to load the contents |
62 HbDocumentLoader loader; |
59 HbDocumentLoader loader; |
63 bool ok(false); |
60 bool ok(false); |
64 loader.load(KNmHsWidgetTitleRowDocML, &ok); |
61 loader.load(KNmHsWidgetTitleRowDocML, &ok); |
65 if (!ok) { |
62 if (!ok) { |
66 qDebug() << "NmHsWidgetTitleRow::loadDocML Fail @ loader -->>"; |
63 NM_ERROR(1,"NmHsWidgetTitleRow::loadDocML Fail @ loader"); |
67 return false; //failure |
64 return false; //failure |
68 } |
65 } |
69 |
66 |
70 //Create layout |
67 //Create layout |
71 QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical); |
68 QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical); |
76 setLayout(layout); //pass the ownership |
73 setLayout(layout); //pass the ownership |
77 |
74 |
78 // find container widget |
75 // find container widget |
79 QGraphicsWidget *container = loader.findWidget(KNmHsWidgetTitleRowContainer); |
76 QGraphicsWidget *container = loader.findWidget(KNmHsWidgetTitleRowContainer); |
80 if (!container) { |
77 if (!container) { |
81 qDebug() << "NmHsWidgetTitleRow::loadDocML Fail @ container -->>"; |
78 NM_ERROR(1,"NmHsWidgetTitleRow::loadDocML Fail @ container"); |
82 return false; |
79 return false; |
83 } |
80 } |
84 layout->addItem(container); |
81 layout->addItem(container); |
85 |
82 |
86 //child items possible to update |
83 //child items possible to update |
90 KNmHsWidgetTitleRowUnreadCountLabel)); |
87 KNmHsWidgetTitleRowUnreadCountLabel)); |
91 mCollapseExpIconLabel = static_cast<HbPushButton*> (loader.findWidget( |
88 mCollapseExpIconLabel = static_cast<HbPushButton*> (loader.findWidget( |
92 KNmHsWidgetTitleRowCollapseExpandIconLabel)); |
89 KNmHsWidgetTitleRowCollapseExpandIconLabel)); |
93 |
90 |
94 if (!mMailboxIcon || !mMailboxInfo || !mUnreadCountLabel || !mCollapseExpIconLabel) { |
91 if (!mMailboxIcon || !mMailboxInfo || !mUnreadCountLabel || !mCollapseExpIconLabel) { |
95 qDebug() << "NmHsWidgetTitleRow::loadDocML Fail @ icons & labels -->>"; |
92 NM_ERROR(1,"NmHsWidgetTitleRow::loadDocML Fail @ icons & labels"); |
96 return false; |
93 return false; |
97 } |
94 } |
98 |
95 |
99 //Expand collapse button |
96 //Expand collapse button |
100 connect(mCollapseExpIconLabel, SIGNAL(clicked()), this, SIGNAL(expandCollapseButtonPressed())); |
97 connect(mCollapseExpIconLabel, SIGNAL(clicked()), this, SIGNAL(expandCollapseButtonPressed())); |
101 |
98 |
102 qDebug() << "NmHsWidgetTitleRow::loadDocML OUT <<--"; |
99 //set fonts color |
|
100 setFontsColor(false); |
|
101 |
103 return true; |
102 return true; |
104 } |
103 } |
105 QT_CATCH(...){ |
104 QT_CATCH(...){ |
106 return false; |
105 return false; |
107 } |
106 } |
110 /*! |
109 /*! |
111 Slot for updating account name, calls updateData to update ui. |
110 Slot for updating account name, calls updateData to update ui. |
112 */ |
111 */ |
113 void NmHsWidgetTitleRow::updateAccountName(const QString& accountName) |
112 void NmHsWidgetTitleRow::updateAccountName(const QString& accountName) |
114 { |
113 { |
115 qDebug() << "NmHsWidgetTitleRow::updateAccountName IN -->>"; |
114 NM_FUNCTION; |
116 mAccountName = accountName; |
115 mAccountName = accountName; |
117 updateData(); |
116 updateData(); |
118 qDebug() << "NmHsWidgetTitleRow::updateAccountName OUT <<--"; |
|
119 } |
117 } |
120 |
118 |
121 /*! |
119 /*! |
122 Set account icon name |
120 Set account icon name |
123 */ |
121 */ |
124 void NmHsWidgetTitleRow::setAccountIcon(const QString& accountIconName) |
122 void NmHsWidgetTitleRow::setAccountIcon(const QString& accountIconName) |
125 { |
123 { |
126 qDebug() << "NmHsWidgetTitleRow::setAccountIcon -- accountIconName" << accountIconName; |
124 NM_FUNCTION; |
127 mMailboxIcon->setIcon(accountIconName); |
125 mMailboxIcon->setIcon(accountIconName); |
128 qDebug() << "NmHsWidgetTitleRow::setAccountIcon OUT <<--"; |
|
129 } |
126 } |
130 |
127 |
131 /*! |
128 /*! |
132 Slot for updating unread count, calls updateData to update ui. |
129 Slot for updating unread count, calls updateData to update ui. |
133 */ |
130 */ |
134 void NmHsWidgetTitleRow::updateUnreadCount(const int& unreadCount) |
131 void NmHsWidgetTitleRow::updateUnreadCount(const int& unreadCount) |
135 { |
132 { |
136 qDebug() << "NmHsWidgetTitleRow::updateUnreadCount IN -->>"; |
133 NM_FUNCTION; |
137 mUnreadCount = unreadCount; |
134 mUnreadCount = unreadCount; |
138 updateData(); |
135 updateData(); |
139 qDebug() << "NmHsWidgetTitleRow::updateUnreadCount OUT <<--"; |
136 } |
|
137 |
|
138 |
|
139 /*! |
|
140 Slot for updating expand collapse icon |
|
141 */ |
|
142 void NmHsWidgetTitleRow::setExpandCollapseIcon(const bool& expand) |
|
143 { |
|
144 NM_FUNCTION; |
|
145 if(expand){ |
|
146 HbIcon icon("qtg_mono_arrow_up"); |
|
147 mCollapseExpIconLabel->setIcon(icon); |
|
148 } |
|
149 else{ |
|
150 HbIcon icon("qtg_mono_arrow_down"); |
|
151 mCollapseExpIconLabel->setIcon(icon); |
|
152 } |
140 } |
153 } |
141 |
154 |
142 /*! |
155 /*! |
143 Update the data displayed in the UI |
156 Update the data displayed in the UI |
144 */ |
157 */ |
145 void NmHsWidgetTitleRow::updateData() |
158 void NmHsWidgetTitleRow::updateData() |
146 { |
159 { |
147 qDebug() << "NmHsWidgetTitleRow::updateData() IN -->>"; |
160 NM_FUNCTION; |
148 mMailboxInfo->setPlainText(mAccountName); |
161 mMailboxInfo->setPlainText(mAccountName); |
149 //If unread count is -1, hide the unread count label completely. |
162 //If unread count is -1, hide the unread count label completely. |
150 //This indicates that there are no mails at all (or the initial sync is not done) |
163 //This indicates that there are no mails at all (or the initial sync is not done) |
151 if (mUnreadCount != -1) { |
164 if (mUnreadCount != -1) { |
152 QString unreadCount(hbTrId("txt_mail_widget_list_l1").arg(mUnreadCount)); |
165 QString unreadCount(hbTrId("txt_mail_widget_list_l1").arg(mUnreadCount)); |
154 mUnreadCountLabel->setVisible(true); |
167 mUnreadCountLabel->setVisible(true); |
155 } |
168 } |
156 else { |
169 else { |
157 mUnreadCountLabel->setVisible(false); |
170 mUnreadCountLabel->setVisible(false); |
158 } |
171 } |
159 qDebug() << "NmHsWidgetTitleRow::updateData() OUT <<--"; |
172 } |
160 } |
173 |
|
174 /*! |
|
175 sets fonts color. |
|
176 param bool pressed indicates if row is pressed down or not |
|
177 */ |
|
178 void NmHsWidgetTitleRow::setFontsColor( bool pressed ) |
|
179 { |
|
180 NM_FUNCTION; |
|
181 QColor newFontColor; |
|
182 |
|
183 if(pressed){ |
|
184 newFontColor = HbColorScheme::color("qtc_hs_list_item_pressed"); |
|
185 } |
|
186 else{ |
|
187 newFontColor = HbColorScheme::color("qtc_hs_list_item_title_normal"); |
|
188 } |
|
189 |
|
190 mMailboxInfo->setTextColor(newFontColor); |
|
191 mUnreadCountLabel->setTextColor(newFontColor); |
|
192 } |
|
193 |
161 |
194 |
162 /*! |
195 /*! |
163 mousePressEvent(QGraphicsSceneMouseEvent *event) |
196 mousePressEvent(QGraphicsSceneMouseEvent *event) |
164 */ |
197 */ |
165 void NmHsWidgetTitleRow::mousePressEvent(QGraphicsSceneMouseEvent *event) |
198 void NmHsWidgetTitleRow::mousePressEvent(QGraphicsSceneMouseEvent *event) |
166 { |
199 { |
167 qDebug() << "NmHsWidgetTitleRow::mousePressEvent() IN -->>"; |
200 NM_FUNCTION; |
168 Q_UNUSED(event); |
201 Q_UNUSED(event); |
169 emit mailboxLaunchTriggered(); |
202 setFontsColor(true); |
170 qDebug() << "NmHsWidgetTitleRow::mousePressEvent() OUT <<--"; |
203 } |
171 } |
204 |
|
205 /*! |
|
206 mouseReleaseEvent(QGraphicsSceneMouseEvent *event) |
|
207 */ |
|
208 void NmHsWidgetTitleRow::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) |
|
209 { |
|
210 NM_FUNCTION; |
|
211 Q_UNUSED(event); |
|
212 setFontsColor(false); |
|
213 emit mailboxLaunchTriggered(); |
|
214 } |
|
215 |
|
216 /* |
|
217 * NmHsWidgetTitleRow::event() |
|
218 */ |
|
219 bool NmHsWidgetTitleRow::event( QEvent *event ) |
|
220 { |
|
221 NM_FUNCTION; |
|
222 QEvent::Type eventType = event->type(); |
|
223 if( eventType == HbEvent::ThemeChanged ){ |
|
224 setFontsColor(false); |
|
225 return true; |
|
226 } |
|
227 return HbWidget::event(event); |
|
228 } |