31
|
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_MODEL_H
|
|
19 |
#define CONVERSATIONS_MODEL_H
|
|
20 |
|
|
21 |
// INCLUDES
|
|
22 |
#include <QObject>
|
|
23 |
#include <QStandardItemModel>
|
|
24 |
#include <ccsdefs.h>
|
|
25 |
#include <sqldb.h>
|
|
26 |
|
|
27 |
// FORWARD DECLARATIONS
|
|
28 |
class CCsConversationEntry;
|
|
29 |
class ConversationMsgStoreHandler;
|
|
30 |
class UniDataModelLoader;
|
|
31 |
class UniDataModelPluginInterface;
|
|
32 |
|
|
33 |
/**
|
|
34 |
* This class implements the model of the model/view framework.
|
|
35 |
* The model holds data for the conversations fetched from the
|
|
36 |
* server.
|
|
37 |
*
|
|
38 |
* Data from server is mapped to UI via Model
|
|
39 |
*
|
|
40 |
*/
|
|
41 |
|
|
42 |
class ConversationsModel: public QStandardItemModel
|
|
43 |
{
|
|
44 |
Q_OBJECT
|
|
45 |
|
|
46 |
public:
|
|
47 |
|
|
48 |
/**
|
|
49 |
* Constructor
|
|
50 |
*/
|
|
51 |
explicit ConversationsModel(ConversationMsgStoreHandler* msgStoreHandler, QObject* parent = 0);
|
|
52 |
|
|
53 |
/**
|
|
54 |
* Destructor
|
|
55 |
*/
|
|
56 |
virtual ~ConversationsModel();
|
|
57 |
|
|
58 |
/**
|
|
59 |
* Method for mapping the data in the Model to the UI
|
|
60 |
* @param index index for which data needs to be fetched
|
|
61 |
* @param role defined for the data
|
|
62 |
* @return QVariant as the data
|
|
63 |
*/
|
|
64 |
QVariant data(const QModelIndex& index, int role) const;
|
|
65 |
|
|
66 |
/**
|
|
67 |
* Add a new row to the conversations model.
|
|
68 |
* Overwrite the row if the message already exists.
|
|
69 |
* @param entry, CCsConversationEntry
|
|
70 |
* @param dynamicUpdate , true if it is a dynamic update event
|
|
71 |
*/
|
|
72 |
void addRow(const CCsConversationEntry& entry, bool dynamicUpdate = false);
|
|
73 |
|
|
74 |
/**
|
|
75 |
* Delete a row from conversations model.
|
|
76 |
* @param msgId, Message Id
|
|
77 |
*/
|
|
78 |
void deleteRow(int msgId);
|
|
79 |
|
|
80 |
/*
|
|
81 |
* Get SQL DB handle
|
|
82 |
* @param isOpen, set to true if open, check this before using the handle
|
|
83 |
*/
|
|
84 |
RSqlDatabase& getDBHandle(TBool& isOpen);
|
|
85 |
|
|
86 |
private:
|
|
87 |
|
|
88 |
/**
|
|
89 |
* Populate an item in model from CCsConversationEntry.
|
|
90 |
* @param item, QStandardItem
|
|
91 |
* @param entry, CCsConversationEntry
|
|
92 |
*/
|
|
93 |
void populateItem(QStandardItem& item, const CCsConversationEntry& entry);
|
|
94 |
|
|
95 |
/**
|
|
96 |
* Populate MMS related data into item.
|
|
97 |
* @param item, QStandardItem
|
|
98 |
* @param entry, CCsConversationEntry
|
|
99 |
*/
|
|
100 |
void handleMMS(QStandardItem& item, const CCsConversationEntry& entry);
|
|
101 |
|
|
102 |
/**
|
|
103 |
* Populate MMS Notification related data into item.
|
|
104 |
* @param item, QStandardItem
|
|
105 |
* @param entry, CCsConversationEntry
|
|
106 |
*/
|
|
107 |
void handleMMSNotification(QStandardItem& item,
|
|
108 |
const CCsConversationEntry& entry);
|
|
109 |
|
|
110 |
/**
|
|
111 |
* Populate BT message related data into item.
|
|
112 |
* @param item, QStandardItem
|
|
113 |
* @param entry, CCsConversationEntry
|
|
114 |
*/
|
|
115 |
void handleBlueToothMessages(QStandardItem& item,
|
|
116 |
const CCsConversationEntry& entry);
|
|
117 |
|
|
118 |
/**
|
|
119 |
* Populate Bio message related data into item.
|
|
120 |
* @param item, QStandardItem
|
|
121 |
* @param entry, CCsConversationEntry
|
|
122 |
*/
|
|
123 |
void handleBioMessages(QStandardItem& item,
|
|
124 |
const CCsConversationEntry& entry);
|
|
125 |
|
|
126 |
private:
|
|
127 |
|
|
128 |
/**
|
|
129 |
* Msg Store Handler
|
|
130 |
* Not Own
|
|
131 |
*/
|
|
132 |
ConversationMsgStoreHandler* mMsgStoreHandler;
|
|
133 |
|
|
134 |
/**
|
|
135 |
* UniDataModelLoader object
|
|
136 |
* Own
|
|
137 |
*/
|
|
138 |
UniDataModelLoader* iDataModelPluginLoader;
|
|
139 |
|
|
140 |
/**
|
|
141 |
* Mms Data model plugin interface
|
|
142 |
* Not Own
|
|
143 |
*/
|
|
144 |
UniDataModelPluginInterface* iMmsDataPlugin;
|
|
145 |
|
|
146 |
/**
|
|
147 |
* BioMsg Data model plugin interface
|
|
148 |
* Not Own
|
|
149 |
*/
|
|
150 |
UniDataModelPluginInterface* iBioMsgPlugin;
|
|
151 |
|
|
152 |
/*
|
|
153 |
* SQL DB handle
|
|
154 |
*/
|
|
155 |
RSqlDatabase iSqlDb;
|
|
156 |
|
|
157 |
/*
|
|
158 |
* DB open.
|
|
159 |
*/
|
|
160 |
TBool iSqlDbOpen;
|
|
161 |
};
|
|
162 |
|
|
163 |
#endif // CONVERSATIONS_MODEL_H
|