|
1 /* |
|
2 * Copyright (c) 2009 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: model for drafts view. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef DRAFTS_MODEL_H |
|
19 #define DRAFTS_MODEL_H |
|
20 |
|
21 // INCLUDES |
|
22 #include <QObject> |
|
23 #include <QStandardItemModel> |
|
24 #include <ccsdefs.h> |
|
25 #include "convergedmessage.h" |
|
26 |
|
27 // FORWARD DECLARATIONS |
|
28 class TMsvEntry; |
|
29 |
|
30 /** |
|
31 * This class implements the model of the model/view framework. |
|
32 * The model holds data for the drafts view fetched from the |
|
33 * server. |
|
34 * |
|
35 * Data from server is mapped to UI via Model |
|
36 * |
|
37 */ |
|
38 |
|
39 class DraftsModel : public QStandardItemModel |
|
40 { |
|
41 Q_OBJECT |
|
42 |
|
43 public: |
|
44 |
|
45 /** |
|
46 * Constructor |
|
47 */ |
|
48 explicit DraftsModel(QObject* parent = 0); |
|
49 |
|
50 public: |
|
51 |
|
52 /** |
|
53 * Destructor |
|
54 */ |
|
55 virtual ~DraftsModel(); |
|
56 |
|
57 /** |
|
58 * Method for mapping the data in the Model to the UI |
|
59 * @param index index for which data needs to be fetched |
|
60 * @param role defined for the data |
|
61 * @return QVariant as the data |
|
62 */ |
|
63 QVariant data(const QModelIndex & index, int role) const; |
|
64 |
|
65 /** |
|
66 * Add a new row to thedrafts model. |
|
67 * Overwrite the row if the message already exists. |
|
68 * @param entry, TMsvEntry |
|
69 * |
|
70 */ |
|
71 void addRow(const TMsvEntry& entry); |
|
72 |
|
73 /** |
|
74 * Delete a row from drafts model. |
|
75 * @param msgId, message Id. |
|
76 */ |
|
77 void deleteRow(int msgId); |
|
78 |
|
79 /** |
|
80 * sets model flag to true after initail fetch completion. |
|
81 */ |
|
82 void setReady(); |
|
83 |
|
84 /* |
|
85 * Returns true if initial fetch is completed. |
|
86 */ |
|
87 bool isReady(); |
|
88 |
|
89 private: |
|
90 |
|
91 /** |
|
92 * Populate an item in model from TMsvEntry. |
|
93 * @param item, QStandardItem |
|
94 * @param entry, TMsvEntry |
|
95 * |
|
96 */ |
|
97 void populateItem(QStandardItem& item, |
|
98 const TMsvEntry& entry); |
|
99 |
|
100 private: |
|
101 |
|
102 /* |
|
103 * Flag set after initail data fetch completion. |
|
104 * for dynamic event handling. |
|
105 */ |
|
106 bool mReady; |
|
107 |
|
108 }; |
|
109 |
|
110 #endif // DRAFTS_MODEL_H |