Changeset View
Changeset View
Standalone View
Standalone View
src/query.cpp
Show First 20 Lines • Show All 66 Lines • ▼ Show 20 Line(s) | 61 | public: | |||
---|---|---|---|---|---|
67 | } | 67 | } | ||
68 | 68 | | |||
69 | Terms::Select selection; | 69 | Terms::Select selection; | ||
70 | QStringList types; | 70 | QStringList types; | ||
71 | QStringList agents; | 71 | QStringList agents; | ||
72 | QStringList activities; | 72 | QStringList activities; | ||
73 | QStringList urlFilters; | 73 | QStringList urlFilters; | ||
74 | Terms::Order ordering; | 74 | Terms::Order ordering; | ||
75 | QDate date; | 75 | QDate start, end; | ||
76 | int limit; | 76 | int limit; | ||
77 | int offset; | 77 | int offset; | ||
78 | }; | 78 | }; | ||
79 | 79 | | |||
80 | Query::Query(Terms::Select selection) | 80 | Query::Query(Terms::Select selection) | ||
81 | : d(new QueryPrivate()) | 81 | : d(new QueryPrivate()) | ||
82 | { | 82 | { | ||
83 | d->selection = selection; | 83 | d->selection = selection; | ||
Show All 25 Lines | |||||
109 | bool Query::operator== (const Query &right) const | 109 | bool Query::operator== (const Query &right) const | ||
110 | { | 110 | { | ||
111 | return selection() == right.selection() && | 111 | return selection() == right.selection() && | ||
112 | types() == right.types() && | 112 | types() == right.types() && | ||
113 | agents() == right.agents() && | 113 | agents() == right.agents() && | ||
114 | activities() == right.activities() && | 114 | activities() == right.activities() && | ||
115 | selection() == right.selection() && | 115 | selection() == right.selection() && | ||
116 | urlFilters() == right.urlFilters() && | 116 | urlFilters() == right.urlFilters() && | ||
117 | date() == right.date(); | 117 | dateStart() == right.dateStart() && | ||
118 | dateEnd() == right.dateEnd(); | ||||
118 | } | 119 | } | ||
119 | 120 | | |||
120 | bool Query::operator!= (const Query &right) const | 121 | bool Query::operator!= (const Query &right) const | ||
121 | { | 122 | { | ||
122 | return !(*this == right); | 123 | return !(*this == right); | ||
123 | } | 124 | } | ||
124 | 125 | | |||
125 | #define IMPLEMENT_QUERY_LIST_FIELD(WHAT, What, Default) \ | 126 | #define IMPLEMENT_QUERY_LIST_FIELD(WHAT, What, Default) \ | ||
Show All 35 Lines | 161 | { | |||
161 | d->limit = limit; | 162 | d->limit = limit; | ||
162 | } | 163 | } | ||
163 | 164 | | |||
164 | void Query::setOffset(int offset) | 165 | void Query::setOffset(int offset) | ||
165 | { | 166 | { | ||
166 | d->offset = offset; | 167 | d->offset = offset; | ||
167 | } | 168 | } | ||
168 | 169 | | |||
169 | void Query::setDate(QDate date) | 170 | void Query::setDateStart(QDate start) | ||
170 | { | 171 | { | ||
171 | d->date = date; | 172 | d->start = start; | ||
173 | } | ||||
174 | | ||||
175 | void Query::setDateEnd(QDate end) | ||||
176 | { | ||||
177 | d->end = end; | ||||
172 | } | 178 | } | ||
173 | 179 | | |||
174 | Terms::Order Query::ordering() const | 180 | Terms::Order Query::ordering() const | ||
175 | { | 181 | { | ||
176 | return d->ordering; | 182 | return d->ordering; | ||
177 | } | 183 | } | ||
178 | 184 | | |||
179 | Terms::Select Query::selection() const | 185 | Terms::Select Query::selection() const | ||
180 | { | 186 | { | ||
181 | return d->selection; | 187 | return d->selection; | ||
182 | } | 188 | } | ||
183 | 189 | | |||
184 | int Query::limit() const | 190 | int Query::limit() const | ||
185 | { | 191 | { | ||
186 | return d->limit; | 192 | return d->limit; | ||
187 | } | 193 | } | ||
188 | 194 | | |||
189 | int Query::offset() const | 195 | int Query::offset() const | ||
190 | { | 196 | { | ||
191 | Q_ASSERT_X(d->limit > 0, "Query::offset", "Offset can only be specified if limit is set"); | 197 | Q_ASSERT_X(d->limit > 0, "Query::offset", "Offset can only be specified if limit is set"); | ||
192 | return d->offset; | 198 | return d->offset; | ||
193 | } | 199 | } | ||
194 | 200 | | |||
195 | QDate Query::date() const | 201 | QDate Query::dateStart() const | ||
202 | { | ||||
203 | return d->start; | ||||
204 | } | ||||
205 | | ||||
206 | QDate Query::dateEnd() const | ||||
196 | { | 207 | { | ||
197 | return d->date; | 208 | return d->end; | ||
198 | } | 209 | } | ||
199 | 210 | | |||
200 | } // namespace Stats | 211 | } // namespace Stats | ||
201 | } // namespace KActivities | 212 | } // namespace KActivities | ||
202 | 213 | | |||
203 | namespace KAStats = KActivities::Stats; | 214 | namespace KAStats = KActivities::Stats; | ||
204 | 215 | | |||
205 | QDebug operator<<(QDebug dbg, const KAStats::Query &query) | 216 | QDebug operator<<(QDebug dbg, const KAStats::Query &query) | ||
206 | { | 217 | { | ||
207 | using namespace KAStats::Terms; | 218 | using namespace KAStats::Terms; | ||
208 | 219 | | |||
209 | dbg.nospace() | 220 | dbg.nospace() | ||
210 | << "Query { " | 221 | << "Query { " | ||
211 | << query.selection() | 222 | << query.selection() | ||
212 | << ", " << Type(query.types()) | 223 | << ", " << Type(query.types()) | ||
213 | << ", " << Agent(query.agents()) | 224 | << ", " << Agent(query.agents()) | ||
214 | << ", " << Activity(query.activities()) | 225 | << ", " << Activity(query.activities()) | ||
215 | << ", " << Url(query.urlFilters()) | 226 | << ", " << Url(query.urlFilters()) | ||
216 | << ", " << Date(query.date()) | 227 | << ", " << Date(query.dateStart(), query.dateEnd()) | ||
217 | << ", " << query.ordering() | 228 | << ", " << query.ordering() | ||
218 | << ", Limit: " << query.limit() | 229 | << ", Limit: " << query.limit() | ||
219 | << " }"; | 230 | << " }"; | ||
220 | return dbg; | 231 | return dbg; | ||
221 | } | 232 | } |