Changeset View
Changeset View
Standalone View
Standalone View
src/plugins/reports/krscriptfunctions.cpp
Show All 15 Lines | |||||
16 | * 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 | ||
17 | * 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/>. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | #include "krscriptfunctions.h" | 20 | #include "krscriptfunctions.h" | ||
21 | 21 | | |||
22 | #include <KDbConnection> | 22 | #include <KDbConnection> | ||
23 | #include <KDbCursor> | 23 | #include <KDbCursor> | ||
24 | #include <KDbNativeStatementBuilder> | ||||
24 | 25 | | |||
25 | #include <QDebug> | 26 | #include <QDebug> | ||
26 | 27 | | |||
27 | KRScriptFunctions::KRScriptFunctions(const KReportDataSource* kodata, KDbConnection* conn) | 28 | KRScriptFunctions::KRScriptFunctions(const KReportDataSource* datasource, KDbConnection* conn) | ||
28 | { | 29 | { | ||
29 | m_cursor = kodata; | 30 | m_cursor = datasource; | ||
30 | m_connection = conn; | 31 | m_connection = conn; | ||
31 | 32 | | |||
32 | if (kodata) { | 33 | if (datasource) { | ||
33 | m_source = kodata->sourceName(); | 34 | if (m_connection->containsTable(datasource->sourceName()) == true) { | ||
staniek: tableSchema() -> `containsTable() == true` | |||||
35 | m_source = datasource->sourceName(); | ||||
36 | } else if (m_connection->querySchema(datasource->sourceName())) { | ||||
37 | KDbNativeStatementBuilder builder(conn); | ||||
38 | KDbEscapedString source; | ||||
39 | if (builder.generateSelectStatement(&source, m_connection->querySchema(datasource->sourceName()))) { | ||||
staniek: It won't support query parameters but let's ignore that atm... | |||||
40 | m_source = source.toByteArray(); | ||||
41 | } | ||||
42 | } | ||||
34 | } | 43 | } | ||
35 | } | 44 | } | ||
36 | 45 | | |||
37 | KRScriptFunctions::~KRScriptFunctions() | 46 | KRScriptFunctions::~KRScriptFunctions() | ||
38 | { | 47 | { | ||
39 | } | 48 | } | ||
40 | 49 | | |||
41 | void KRScriptFunctions::setGroupData(const QMap<QString, QVariant>& groupData) | 50 | void KRScriptFunctions::setGroupData(const QMap<QString, QVariant>& groupData) | ||
▲ Show 20 Lines • Show All 81 Lines • Show Last 20 Lines |
tableSchema() -> containsTable() == true