Changeset View
Changeset View
Standalone View
Standalone View
src/plugins/reports/krscriptfunctions.h
1 | /* | 1 | /* | ||
---|---|---|---|---|---|
2 | * Kexi Report Plugin | 2 | * Kexi Report Plugin | ||
3 | * Copyright (C) 2007-2008 by Adam Pigg (adam@piggz.co.uk) | 3 | * Copyright (C) 2007-2008 by Adam Pigg (adam@piggz.co.uk) | ||
4 | * Copyright (C) 2012-2018 Jarosław Staniek <staniek@kde.org> | ||||
4 | * | 5 | * | ||
5 | * This library is free software; you can redistribute it and/or | 6 | * This library is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU Lesser General Public | 7 | * modify it under the terms of the GNU Lesser General Public | ||
7 | * License as published by the Free Software Foundation; either | 8 | * License as published by the Free Software Foundation; either | ||
8 | * version 2.1 of the License, or (at your option) any later version. | 9 | * version 2.1 of the License, or (at your option) any later version. | ||
9 | * | 10 | * | ||
10 | * This library is distributed in the hope that it will be useful, | 11 | * This library is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | * Lesser General Public License for more details. | 14 | * Lesser General Public License for more details. | ||
14 | * | 15 | * | ||
15 | * You should have received a copy of the GNU Lesser General Public | 16 | * You should have received a copy of the GNU Lesser General Public | ||
16 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | 17 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | 18 | */ | ||
18 | 19 | | |||
19 | #ifndef KRSCRIPTFUNCTIONS_H | 20 | #ifndef KRSCRIPTFUNCTIONS_H | ||
20 | #define KRSCRIPTFUNCTIONS_H | 21 | #define KRSCRIPTFUNCTIONS_H | ||
21 | 22 | | |||
22 | #include <KReportDataSource> | | |||
23 | #include <KReportGroupTracker> | 23 | #include <KReportGroupTracker> | ||
24 | 24 | | |||
25 | #include <KDbEscapedString> | 25 | #include <KDbEscapedString> | ||
26 | 26 | | |||
27 | #include <QMap> | ||||
28 | | ||||
29 | class KexiDBReportDataSource; | ||||
27 | class KDbConnection; | 30 | class KDbConnection; | ||
28 | class KDbCursor; | 31 | class KDbCursor; | ||
29 | 32 | | |||
30 | /** | 33 | /** | ||
31 | */ | 34 | */ | ||
32 | class KRScriptFunctions : public KReportGroupTracker | 35 | class KRScriptFunctions : public KReportGroupTracker | ||
33 | { | 36 | { | ||
34 | Q_OBJECT | 37 | Q_OBJECT | ||
35 | public: | 38 | public: | ||
36 | KRScriptFunctions(const KReportDataSource *, KDbConnection*); | 39 | KRScriptFunctions(KexiDBReportDataSource *dataSource); | ||
37 | 40 | | |||
38 | ~KRScriptFunctions(); | 41 | ~KRScriptFunctions(); | ||
39 | 42 | | |||
40 | private: | 43 | private: | ||
41 | KDbConnection *m_connection; | 44 | KexiDBReportDataSource * const m_dataSource; | ||
42 | const KReportDataSource *m_cursor; | | |||
43 | QString m_source; | 45 | QString m_source; | ||
46 | | ||||
47 | //! @todo Move SQL aggregate functions to KDb | ||||
44 | qreal math(const QString &, const QString &); | 48 | qreal math(const QString &, const QString &); | ||
45 | 49 | | |||
46 | QMap<QString, QVariant> m_groupData; | 50 | QMap<QString, QVariant> m_groupData; | ||
47 | 51 | | |||
48 | KDbEscapedString where(); | | |||
49 | | ||||
50 | public Q_SLOTS: | 52 | public Q_SLOTS: | ||
51 | virtual void setGroupData(const QMap<QString, QVariant> &groupData); | 53 | virtual void setGroupData(const QMap<QString, QVariant> &groupData); | ||
52 | 54 | | |||
53 | qreal sum(const QString &); | 55 | qreal sum(const QString &); | ||
54 | qreal avg(const QString &); | 56 | qreal avg(const QString &); | ||
55 | qreal min(const QString &); | 57 | qreal min(const QString &); | ||
56 | qreal max(const QString &); | 58 | qreal max(const QString &); | ||
57 | qreal count(const QString &); | 59 | qreal count(const QString &); | ||
58 | QVariant value(const QString &); | 60 | QVariant value(const QString &); | ||
59 | }; | 61 | }; | ||
60 | 62 | | |||
61 | #endif | 63 | #endif |