|
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 class CCsConversationEntry; |
|
29 |
|
30 /** |
|
31 * This class implements the model of the model/view framework. |
|
32 * The model holds data for the conversations list fetched from the |
|
33 * server. |
|
34 * |
|
35 * Data from server is mapped to UI via Model |
|
36 * |
|
37 */ |
|
38 |
|
39 class ConversationsSummaryModel : public QStandardItemModel |
|
40 { |
|
41 Q_OBJECT |
|
42 |
|
43 public: |
|
44 |
|
45 /** |
|
46 * Constructor |
|
47 */ |
|
48 explicit ConversationsSummaryModel(QObject* parent = 0); |
|
49 |
|
50 public: |
|
51 |
|
52 /** |
|
53 * Destructor |
|
54 */ |
|
55 virtual ~ConversationsSummaryModel(); |
|
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 the conversation summary model. |
|
67 * Overwrite the row if the message already exists. |
|
68 * @param conversation, CCsClientConversation |
|
69 * @param caching, initial caching flag |
|
70 * |
|
71 */ |
|
72 void addRow(const CCsClientConversation& conversation, bool caching = false); |
|
73 |
|
74 /** |
|
75 * Delete a row from conversation summary model. |
|
76 * @param conversationId, conversation Id |
|
77 */ |
|
78 void deleteRow(qint64 conversationId); |
|
79 |
|
80 private: |
|
81 |
|
82 /** |
|
83 * Populate an item in model from CCsClientConversation. |
|
84 * @param item, QStandardItem |
|
85 * @param conversation, CCsClientConversation |
|
86 * |
|
87 */ |
|
88 void populateItem(QStandardItem& item, |
|
89 const CCsClientConversation& conversation); |
|
90 |
|
91 /** |
|
92 * Populate BT message related data into item. |
|
93 * @param item, QStandardItem |
|
94 * @param entry, CCsConversationEntry |
|
95 */ |
|
96 void handleBlueToothMessages(QStandardItem& item, const CCsConversationEntry& entry); |
|
97 |
|
98 /** |
|
99 * Populate Bio message related data into item. |
|
100 * @param item, QStandardItem |
|
101 * @param entry, CCsConversationEntry |
|
102 */ |
|
103 void handleBioMessages(QStandardItem& item, const CCsConversationEntry& entry); |
|
104 |
|
105 |
|
106 }; |
|
107 |
|
108 #endif // CONVERSATIONS_SUMMARY_MODEL_H |