Changeset View
Changeset View
Standalone View
Standalone View
src/query.cpp
Show All 14 Lines | |||||
15 | * Lesser General Public License for more details. | 15 | * Lesser General Public License for more details. | ||
16 | * | 16 | * | ||
17 | * You should have received a copy of the GNU Lesser General Public | 17 | * You should have received a copy of the GNU Lesser General Public | ||
18 | * License along with this library. | 18 | * License along with this library. | ||
19 | * If not, see <http://www.gnu.org/licenses/>. | 19 | * If not, see <http://www.gnu.org/licenses/>. | ||
20 | */ | 20 | */ | ||
21 | 21 | | |||
22 | #include "query.h" | 22 | #include "query.h" | ||
23 | #include "common/specialvalues.h" | ||||
23 | #include <QDate> | 24 | #include <QDate> | ||
24 | #include <QDebug> | 25 | #include <QDebug> | ||
25 | 26 | | |||
26 | namespace KActivities { | 27 | namespace KActivities { | ||
27 | namespace Stats { | 28 | namespace Stats { | ||
28 | 29 | | |||
29 | namespace details { | 30 | namespace details { | ||
30 | inline void validateTypes(QStringList &types) | 31 | inline void validateTypes(QStringList &types) | ||
▲ Show 20 Lines • Show All 87 Lines • ▼ Show 20 Line(s) | 112 | return selection() == right.selection() && | |||
118 | dateEnd() == right.dateEnd(); | 119 | dateEnd() == right.dateEnd(); | ||
119 | } | 120 | } | ||
120 | 121 | | |||
121 | bool Query::operator!= (const Query &right) const | 122 | bool Query::operator!= (const Query &right) const | ||
122 | { | 123 | { | ||
123 | return !(*this == right); | 124 | return !(*this == right); | ||
124 | } | 125 | } | ||
125 | 126 | | |||
126 | #define IMPLEMENT_QUERY_LIST_FIELD(WHAT, What, Default) \ | 127 | #define IMPLEMENT_QUERY_LIST_FIELD(WHAT, What, Term, Default) \ | ||
127 | void Query::add##WHAT(const QStringList &What) \ | 128 | void Query::add##WHAT(const QStringList &What) \ | ||
128 | { \ | 129 | { \ | ||
129 | d->What << What; \ | 130 | d->What << What; \ | ||
130 | details::validate##WHAT(d->What); \ | 131 | details::validate##WHAT(d->What); \ | ||
131 | } \ | 132 | } \ | ||
132 | \ | 133 | \ | ||
134 | void Query::set##WHAT(const Terms::Term &What) \ | ||||
135 | { \ | ||||
136 | d->What = What.values; \ | ||||
137 | details::validate##WHAT(d->What); \ | ||||
138 | } \ | ||||
139 | \ | ||||
133 | QStringList Query::What() const \ | 140 | QStringList Query::What() const \ | ||
134 | { \ | 141 | { \ | ||
135 | return d->What.size() ? d->What : Default; \ | 142 | return d->What.size() ? d->What : Default; \ | ||
136 | } \ | 143 | } \ | ||
137 | \ | 144 | \ | ||
138 | void Query::clear##WHAT() \ | 145 | void Query::clear##WHAT() \ | ||
139 | { \ | 146 | { \ | ||
140 | d->What.clear(); \ | 147 | d->What.clear(); \ | ||
141 | } | 148 | } | ||
142 | 149 | | |||
143 | IMPLEMENT_QUERY_LIST_FIELD(Types, types, QStringList(QStringLiteral(":any"))) | 150 | IMPLEMENT_QUERY_LIST_FIELD(Types, types, Type, QStringList(ANY_TYPE_TAG)) | ||
144 | IMPLEMENT_QUERY_LIST_FIELD(Agents, agents, QStringList(QStringLiteral(":current"))) | 151 | IMPLEMENT_QUERY_LIST_FIELD(Agents, agents, Agent, QStringList(CURRENT_AGENT_TAG)) | ||
145 | IMPLEMENT_QUERY_LIST_FIELD(Activities, activities, QStringList(QStringLiteral(":current"))) | 152 | IMPLEMENT_QUERY_LIST_FIELD(Activities, activities, Activity, QStringList(CURRENT_ACTIVITY_TAG)) | ||
146 | IMPLEMENT_QUERY_LIST_FIELD(UrlFilters, urlFilters, QStringList(QStringLiteral("*"))) | 153 | IMPLEMENT_QUERY_LIST_FIELD(UrlFilters, urlFilters, Url, QStringList(QStringLiteral("*"))) | ||
147 | 154 | | |||
148 | #undef IMPLEMENT_QUERY_LIST_FIELD | 155 | #undef IMPLEMENT_QUERY_LIST_FIELD | ||
149 | 156 | | |||
150 | void Query::setOrdering(Terms::Order ordering) | 157 | void Query::setOrdering(Terms::Order ordering) | ||
151 | { | 158 | { | ||
152 | d->ordering = ordering; | 159 | d->ordering = ordering; | ||
153 | } | 160 | } | ||
154 | 161 | | |||
155 | void Query::setSelection(Terms::Select selection) | 162 | void Query::setSelection(Terms::Select selection) | ||
156 | { | 163 | { | ||
157 | d->selection = selection; | 164 | d->selection = selection; | ||
158 | } | 165 | } | ||
159 | 166 | | |||
160 | void Query::setLimit(int limit) | 167 | void Query::setLimit(int limit) | ||
161 | { | 168 | { | ||
162 | d->limit = limit; | 169 | d->limit = limit; | ||
163 | } | 170 | } | ||
164 | 171 | | |||
165 | void Query::setOffset(int offset) | 172 | void Query::setOffset(int offset) | ||
166 | { | 173 | { | ||
167 | d->offset = offset; | 174 | d->offset = offset; | ||
168 | } | 175 | } | ||
169 | 176 | | |||
177 | void Query::setDate(const Terms::Date &date) | ||||
178 | { | ||||
179 | d->start = date.start; | ||||
180 | d->end = date.end; | ||||
181 | } | ||||
182 | | ||||
170 | void Query::setDateStart(QDate start) | 183 | void Query::setDateStart(QDate start) | ||
171 | { | 184 | { | ||
172 | d->start = start; | 185 | d->start = start; | ||
173 | } | 186 | } | ||
174 | 187 | | |||
175 | void Query::setDateEnd(QDate end) | 188 | void Query::setDateEnd(QDate end) | ||
176 | { | 189 | { | ||
177 | d->end = end; | 190 | d->end = end; | ||
▲ Show 20 Lines • Show All 55 Lines • Show Last 20 Lines |