|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef CONVERSATIONS_SUMMARY_MODEL_H |
|
19 #define CONVERSATIONS_SUMMARY_MODEL_H |
|
20 |
|
21 // INCLUDES |
|
22 #include <QObject> |
|
23 #include <QStandardItemModel> |
|
24 #include <ccsdefs.h> |
|
25 |
|
26 // FORWARD DECLARATIONS |
|
27 class CCsClientConversation; |
|
28 |
|
29 /** |
|
30 * This class implements the model of the model/view framework. |
|
31 * The model holds data for the conversations list fetched from the |
|
32 * server. |
|
33 * |
|
34 * Data from server is mapped to UI via Model |
|
35 * |
|
36 */ |
|
37 |
|
38 class ConversationsSummaryModel : public QStandardItemModel |
|
39 { |
|
40 Q_OBJECT |
|
41 |
|
42 public: |
|
43 |
|
44 /** |
|
45 * Constructor |
|
46 */ |
|
47 explicit ConversationsSummaryModel(QObject* parent = 0); |
|
48 |
|
49 public: |
|
50 |
|
51 /** |
|
52 * Destructor |
|
53 */ |
|
54 virtual ~ConversationsSummaryModel(); |
|
55 |
|
56 /** |
|
57 * Method for mapping the data in the Model to the UI |
|
58 * @param index index for which data needs to be fetched |
|
59 * @param role defined for the data |
|
60 * @return QVariant as the data |
|
61 */ |
|
62 QVariant data(const QModelIndex & index, int role) const; |
|
63 |
|
64 /** |
|
65 * Add a new row to the conversation summary model. |
|
66 * Overwrite the row if the message already exists. |
|
67 * @param conversation, CCsClientConversation |
|
68 * |
|
69 */ |
|
70 void addRow(const CCsClientConversation& conversation); |
|
71 |
|
72 /** |
|
73 * Delete a row from conversation summary model. |
|
74 * @param conversationId, conversation Id |
|
75 */ |
|
76 void deleteRow(qint64 conversationId); |
|
77 |
|
78 private: |
|
79 |
|
80 /** |
|
81 * Populate an item in model from CCsClientConversation. |
|
82 * @param item, QStandardItem |
|
83 * @param conversation, CCsClientConversation |
|
84 * |
|
85 */ |
|
86 void populateItem(QStandardItem& item, |
|
87 const CCsClientConversation& conversation); |
|
88 |
|
89 }; |
|
90 |
|
91 #endif // CONVERSATIONS_SUMMARY_MODEL_H |