|
1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef NMHSWIDGET_H |
|
19 #define NMHSWIDGET_H |
|
20 |
|
21 #include <hbwidget.h> |
|
22 #include "nmcommon.h" |
|
23 |
|
24 class NmHsWidgetEmailEngine; |
|
25 class NmHsWidgetTitleRow; |
|
26 class NmHsWidgetEmailRow; |
|
27 class QGraphicsLinearLayout; |
|
28 class QTranslator; |
|
29 class HbFrameDrawer; |
|
30 class NmHsWidgetDateTimeObserver; |
|
31 class HbLabel; |
|
32 class HbDocumentLoader; |
|
33 |
|
34 class NmHsWidget : public HbWidget |
|
35 { |
|
36 Q_OBJECT |
|
37 |
|
38 Q_PROPERTY(QString accountId READ accountId WRITE setAccountId) |
|
39 Q_PROPERTY(QString accountIconName READ accountIconName WRITE setAccountIconName) |
|
40 Q_PROPERTY(QString widgetState READ widgetStateProperty WRITE setWidgetStateProperty) |
|
41 |
|
42 public: |
|
43 NmHsWidget(QGraphicsItem *parent = 0, Qt::WindowFlags flags = 0); |
|
44 ~NmHsWidget(); |
|
45 |
|
46 QPainterPath shape() const; |
|
47 |
|
48 public slots: |
|
49 //from home screen fw |
|
50 void onInitialize(); |
|
51 void onShow(); |
|
52 void onHide(); |
|
53 //engine |
|
54 void updateMailData(); |
|
55 void onEngineException(const int& exc); |
|
56 //properties |
|
57 void setAccountId(const QString &text); |
|
58 QString accountId() const; |
|
59 void setAccountIconName(const QString &text); |
|
60 QString accountIconName() const; |
|
61 void setWidgetStateProperty(QString value); |
|
62 QString widgetStateProperty(); |
|
63 //user actions |
|
64 void handleExpandCollapseEvent(); |
|
65 |
|
66 signals: |
|
67 void finished(); |
|
68 void setPreferences(const QStringList &names); |
|
69 void error(); |
|
70 private: |
|
71 void setupLocalization(); |
|
72 void setupUi(); |
|
73 bool loadDocML(HbDocumentLoader &loader); |
|
74 void updateMailRowsVisibility(const int visibleCount); |
|
75 void addNoMailsLabelToLayout(); |
|
76 void removeNoMailsLabelFromLayout(); |
|
77 void addEmailRowsToLayout(); |
|
78 void removeEmailRowsFromLayout(); |
|
79 void updateLayout(const int visibleCount); |
|
80 void toggleExpansionState(); |
|
81 |
|
82 protected: |
|
83 void createMailRowsList(); |
|
84 |
|
85 private: |
|
86 //UI components |
|
87 HbWidget* mMainContainer; //container including all UI components |
|
88 HbWidget* mEmptySpaceContainer; //container for empty space above mWidgetContainer |
|
89 HbWidget* mWidgetContainer; //container including title row and mContentContainer |
|
90 NmHsWidgetTitleRow* mTitleRow; //mailbox icon, name, unread count and expand button |
|
91 HbWidget* mContentContainer; //container for mail rows or mNoMailsLabel |
|
92 QList<NmHsWidgetEmailRow*> mMailRows; //list including mail row instances |
|
93 HbLabel* mNoMailsLabel; //label shown in mContentContainer when no mails in inbox |
|
94 QGraphicsLinearLayout* mContentLayout; //layout used in mContentContainer |
|
95 HbFrameDrawer* mBackgroundFrameDrawer; //drawer for widget background shown in mWidgetContainer |
|
96 QTranslator* mTranslator; |
|
97 |
|
98 NmHsWidgetEmailEngine* mEngine; |
|
99 NmId mAccountId; //mail account id widget is monitoring |
|
100 QString mAccountIconName; //name of mailbox icon shown in titlerow |
|
101 NmHsWidgetDateTimeObserver* mDateObserver; //observer for time/locale changes |
|
102 bool mIsExpanded; //true when widget expanded, false when collapsed |
|
103 |
|
104 public: |
|
105 friend class TestNmHsWidget; |
|
106 }; |
|
107 |
|
108 #endif // NMHSWIDGET_H |