/
callmodel.h
162 lines (141 loc) · 5.22 KB
/
callmodel.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/******************************************************************************
**
** This file is part of libcommhistory.
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Alexander Shalamov <alexander.shalamov@nokia.com>
**
** This library is free software; you can redistribute it and/or modify it
** under the terms of the GNU Lesser General Public License version 2.1 as
** published by the Free Software Foundation.
**
** This library is distributed in the hope that it will be useful, but
** WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
** or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
** License for more details.
**
** You should have received a copy of the GNU Lesser General Public License
** along with this library; if not, write to the Free Software Foundation, Inc.,
** 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
**
******************************************************************************/
#ifndef COMMHISTORY_CALLMODEL_H
#define COMMHISTORY_CALLMODEL_H
#include "eventmodel.h"
#include "event.h"
#include "callevent.h"
#include "group.h"
#include "libcommhistoryexport.h"
namespace CommHistory {
class CallModelPrivate;
/*!
* \class CallModel
*
* \brief Model for accessing the call history. Initialize with getEvents().
*
* CallModel is a model class to access call events. It uses a
* grouped tree mode by default. Flat mode can be used to get all the call
* events based on type and time filters. Call events are grouped together
* if they have the same call type (dialed, received, missed), they were initiated
* to/from the same remote party and directly follow eachother in the timeline.
* Furthermore sorting applies on the events: by time or by type. Sorting is set
* in the constructor, and can be modified later in the getEvents() method as
* parameter. If no sorting is specified, by contact is used as default.
*
* Tracking contact changes is enabled by default; call
* enableContactChanges(false) after creating the model to disable.
*
*/
class LIBCOMMHISTORY_EXPORT CallModel: public EventModel
{
Q_OBJECT
Q_ENUMS( Sorting )
public:
enum Sorting
{
SortByContact = 0,
SortByTime,
SortByType,
SortByService
};
public:
/*!
* \brief Model constructor.
*
* \param parent Parent object.
*/
CallModel(QObject *parent = 0);
/*!
* \brief Model constructor.
* \deprecated DO NOT use this method, it is deprecated. You should use CallModel( QObject* ) and setFilter(CallModel::Sorting, CallEvent::CallType, const QDateTime &) instead.
*
* \param sortBy Sorting of call events.
* \param parent Parent object.
*/
CallModel(CallModel::Sorting sorting, QObject* parent);
/*!
* Destructor.
*/
~CallModel();
/*!
* \brief Sets optional filters.
*
* Sets optional filters. It will result in a new tracker query if called
* after getEvents().
*
* \param sortBy Sets sorting of call events in the result set.
* \param type Only specified type events appear in result set, if other
* than CallEvent::UnknownCallType.
* \param referenceTime Only call events with newer startTime() are in
* result set if value is valid.
*
* \return true if successful; false, otherwise. Additionally, it sets
* lastError() on failure.
*/
bool setFilter(CallModel::Sorting sortBy = SortByContact,
CallEvent::CallType type = CallEvent::UnknownCallType,
const QDateTime &referenceTime = QDateTime());
/*!
* \brief Resets model and fetch call events.
*
* \return true if successful; false, otherwise. Additionally, it sets
* lastError() on failure.
*/
bool getEvents();
/*!
* \brief Sets optional filters.
* \deprecated DO NOT use this method, it is deprecated. You should use getEvents() and/or setFilter(CallModel::Sorting, CallEvent::CallType, const QDateTime &) instead.
*
* Sets optional filters. It will result in a new tracker query if called
* after getEvents().
*
* \param sortBy Sets sorting of call events in the result set.
* \param type Only specified type events appear in result set, if other
* than CallEvent::UnknownCallType.
* \param referenceTime Only call events with newer startTime() are in
* result set if value is valid.
*
* \return true if successful; false, otherwise. Additionally, it sets
* lastError() on failure.
*/
bool getEvents(CallModel::Sorting sortBy,
CallEvent::CallType type = CallEvent::UnknownCallType,
const QDateTime &referenceTime = QDateTime());
/*!
* \brief Deletes all call events from tracker and clears model.
*
* \return true if successful; false, otherwise.
*/
bool deleteAll();
// reimp
// Override - call model works in sync mode.
virtual void setQueryMode( EventModel::QueryMode mode );
virtual bool addEvent( Event &event );
virtual bool modifyEvent( Event &event );
virtual bool deleteEvent( int id );
virtual bool deleteEvent( Event &event );
private:
Q_DECLARE_PRIVATE(CallModel);
};
}
#endif