|
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 LOGSMODEL_H |
|
19 #define LOGSMODEL_H |
|
20 |
|
21 #include <logsexport.h> |
|
22 #include <logsabstractmodel.h> |
|
23 |
|
24 class LogsEvent; |
|
25 class LogsDbConnector; |
|
26 class LogsMatchesModel; |
|
27 |
|
28 /** |
|
29 * Model for log events. |
|
30 * |
|
31 */ |
|
32 class LogsModel : public LogsAbstractModel |
|
33 { |
|
34 Q_OBJECT |
|
35 |
|
36 public: |
|
37 |
|
38 enum ClearType { |
|
39 TypeLogsClearAll = 0, |
|
40 TypeLogsClearReceived, |
|
41 TypeLogsClearCalled, |
|
42 TypeLogsClearMissed |
|
43 }; |
|
44 |
|
45 enum LogsModelType { |
|
46 LogsRecentModel, // Model handles recent events |
|
47 LogsFullModel // Model handles all events |
|
48 }; |
|
49 public: // The exported API |
|
50 |
|
51 /** |
|
52 * Constructor |
|
53 * @param modelType |
|
54 */ |
|
55 LOGSENGINE_EXPORT explicit LogsModel(LogsModelType modelType = LogsRecentModel); |
|
56 |
|
57 /** |
|
58 * Destructor |
|
59 */ |
|
60 LOGSENGINE_EXPORT ~LogsModel(); |
|
61 |
|
62 /** |
|
63 * Clear events. Clearing is async operation and completion is indicated |
|
64 * by clearingCompleted signal. |
|
65 * @param cleartype, type of events to be cleared |
|
66 * @return true if async clearing started |
|
67 */ |
|
68 LOGSENGINE_EXPORT bool clearList(LogsModel::ClearType cleartype); |
|
69 |
|
70 /** |
|
71 * Get matches model. |
|
72 * @return matches model |
|
73 */ |
|
74 LOGSENGINE_EXPORT LogsMatchesModel* logsMatchesModel(); |
|
75 |
|
76 /** |
|
77 * Mark events as seen. Operation is asycn and completion is indicated |
|
78 * by markingCompleted signal. |
|
79 * @param cleartype, type of events to be marked as seen |
|
80 * @return true if async marking started, false if marking did not start |
|
81 */ |
|
82 LOGSENGINE_EXPORT bool markEventsSeen(LogsModel::ClearType cleartype); |
|
83 |
|
84 /** |
|
85 * Clear missed calls counter |
|
86 * @return 0 if clearing was success |
|
87 */ |
|
88 LOGSENGINE_EXPORT int clearMissedCallsCounter(); |
|
89 |
|
90 public: // From QAbstractItemModel |
|
91 |
|
92 /** |
|
93 * Get number of events currently in the model. |
|
94 * @return number of events |
|
95 */ |
|
96 virtual int rowCount(const QModelIndex &parent) const; |
|
97 |
|
98 /** |
|
99 * Get various data from the model. Fetched data type is defined |
|
100 * by role input parameter. Besides standard Qt::DisplayRole and |
|
101 * Qt::DecorationRole, LogsAbstractModel::LogsModelRole defines |
|
102 * additional data types. |
|
103 */ |
|
104 virtual QVariant data(const QModelIndex &index, int role) const; |
|
105 |
|
106 signals: |
|
107 |
|
108 /** |
|
109 * Signaled once clearing has completed. |
|
110 * @param err, 0 if clearing was success |
|
111 */ |
|
112 void clearingCompleted(int err); |
|
113 |
|
114 /** |
|
115 * Signaled once marking has completed. |
|
116 * @param err, 0 if marking was success |
|
117 */ |
|
118 void markingCompleted(int err); |
|
119 |
|
120 |
|
121 public slots: |
|
122 |
|
123 void dataAdded(QList<int> addedIndexes); |
|
124 void dataUpdated(QList<int> updatedIndexes); |
|
125 void dataRemoved(QList<int> removedIndexes); |
|
126 |
|
127 private: |
|
128 |
|
129 /** |
|
130 * Find sequential indexes and place each sequence to own list. |
|
131 * @param indexes, index list |
|
132 * @return list of index sequence lists |
|
133 */ |
|
134 QList< QList<int> > findSequentialIndexes(const QList<int>& indexes); |
|
135 QString getCallerId(const LogsEvent& event) const; |
|
136 void initIcons(); |
|
137 bool matchEventWithClearType(const LogsEvent& event, LogsModel::ClearType clearType); |
|
138 |
|
139 private: //data |
|
140 |
|
141 LogsModelType mModelType; |
|
142 QList<LogsEvent*> mEvents; |
|
143 |
|
144 private: // Testing related friend definitions |
|
145 |
|
146 friend class UT_LogsModel; |
|
147 friend class UT_LogsFilter; |
|
148 friend class UT_LogsCustomFilter; |
|
149 friend class UT_LogsMatchesModel; |
|
150 |
|
151 }; |
|
152 |
|
153 #endif //LOGSMODEL_H |