|
1 /* |
|
2 * Copyright (c) 2009 - 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 NMMESSAGELISTMODEL_H_ |
|
19 #define NMMESSAGELISTMODEL_H_ |
|
20 |
|
21 #include <QStandardItemModel> |
|
22 |
|
23 #include "nmcommon.h" |
|
24 #include "nmmessagelistmodelitem.h" |
|
25 #include "nmuienginedef.h" |
|
26 #include "nmuiviewids.h" |
|
27 |
|
28 class NmMessage; |
|
29 class NmDataManager; |
|
30 class QModelIndex; |
|
31 class NmMessageEnvelope; |
|
32 |
|
33 |
|
34 class NMUIENGINE_EXPORT NmMessageListModel : public QStandardItemModel |
|
35 { |
|
36 Q_OBJECT |
|
37 |
|
38 public: |
|
39 |
|
40 NmMessageListModel(NmDataManager &dataManager, |
|
41 QObject *parent = 0); |
|
42 |
|
43 virtual ~NmMessageListModel(); |
|
44 |
|
45 QVariant data(const QModelIndex &index, |
|
46 int role = Qt::DisplayRole) const; |
|
47 |
|
48 void refresh(const NmId mailboxId, |
|
49 const NmId folderId, |
|
50 const QList<NmMessageEnvelope*> &messageEnvelopeList); |
|
51 |
|
52 bool dividersActive(); |
|
53 |
|
54 // This function is temporary, to be removed when divider state can be |
|
55 // modified with settings. |
|
56 void setDividers(bool active); |
|
57 |
|
58 void setEnvelopeProperties(NmEnvelopeProperties property, |
|
59 const QList<NmId> &messageIds); |
|
60 |
|
61 NmId currentMailboxId(); |
|
62 |
|
63 void setIgnoreFolderIds(bool ignore); |
|
64 |
|
65 |
|
66 public slots: |
|
67 |
|
68 void handleMessageEvent(NmMessageEvent event, |
|
69 const NmId &folderId, |
|
70 const QList<NmId> &messageIds, |
|
71 const NmId &mailboxId); |
|
72 |
|
73 |
|
74 private: |
|
75 |
|
76 bool messagesBelongUnderSameDivider( |
|
77 const NmMessageEnvelope *message1, |
|
78 const NmMessageEnvelope *message2) const; |
|
79 |
|
80 void insertDividerIntoModel( |
|
81 NmMessageEnvelope *messageForDivider, |
|
82 int parentRow); |
|
83 |
|
84 void insertMessageIntoModel( |
|
85 NmMessageEnvelope *messageEnvelope, |
|
86 int childRow, |
|
87 bool emitSignal); |
|
88 |
|
89 void insertNewMessageIntoModel( |
|
90 const NmId &mailboxId, |
|
91 const NmId &folderId, |
|
92 const NmId &msgId); |
|
93 |
|
94 int getInsertionIndex(const NmMessageEnvelope &envelope) const; |
|
95 |
|
96 int dividerInsertionIndex(int messageIndex); |
|
97 |
|
98 NmMessageListModelItem *createTitleDividerItem(NmMessageEnvelope *messageForDivider); |
|
99 |
|
100 NmMessageListModelItem *createMessageItem(NmMessageEnvelope *message); |
|
101 |
|
102 void removeMessageFromModel(const NmId &msgId); |
|
103 |
|
104 void removeItem(int row, NmMessageListModelItem &item); |
|
105 |
|
106 NmMessageListModelItem *itemFromModel(const NmId &messageId); |
|
107 |
|
108 bool changed(const NmMessageEnvelope &first, |
|
109 const NmMessageEnvelope &second); |
|
110 |
|
111 void updateMessageEnvelope(const NmId &mailboxId, |
|
112 const NmId &folderId, |
|
113 const NmId &msgId); |
|
114 |
|
115 void updateEnvelope(NmEnvelopeProperties property, const NmId &msgId); |
|
116 |
|
117 |
|
118 signals: |
|
119 |
|
120 void setNewParam(NmUiStartParam *startParam); |
|
121 |
|
122 |
|
123 private: // Data |
|
124 |
|
125 NmDataManager &mDataManager; |
|
126 bool mDividersActive; |
|
127 NmMessageListModelItem *mParentPtr; // Not owned |
|
128 NmId mCurrentMailboxId; |
|
129 NmId mCurrentFolderId; |
|
130 NmFolderType mCurrentFolderType; |
|
131 bool mIgnoreFolderIds; |
|
132 }; |
|
133 |
|
134 #endif /* NMMESSAGELISTMODEL_H_*/ |