Changeset View
Changeset View
Standalone View
Standalone View
src/plugins/reports/kexireportpart.cpp
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) 2011-2015 Jarosław Staniek <staniek@kde.org> | 4 | * Copyright (C) 2011-2017 Jarosław Staniek <staniek@kde.org> | ||
5 | * | 5 | * | ||
6 | * This library is free software; you can redistribute it and/or | 6 | * This library is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU Lesser General Public | 7 | * modify it under the terms of the GNU Lesser General Public | ||
8 | * License as published by the Free Software Foundation; either | 8 | * License as published by the Free Software Foundation; either | ||
9 | * 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. | ||
10 | * | 10 | * | ||
11 | * 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, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
Show All 16 Lines | |||||
29 | 29 | | |||
30 | #include <KexiIcon.h> | 30 | #include <KexiIcon.h> | ||
31 | #include <core/KexiWindow.h> | 31 | #include <core/KexiWindow.h> | ||
32 | #include "kexireportview.h" | 32 | #include "kexireportview.h" | ||
33 | #include "kexireportdesignview.h" | 33 | #include "kexireportdesignview.h" | ||
34 | #include <core/KexiMainWindowIface.h> | 34 | #include <core/KexiMainWindowIface.h> | ||
35 | #include "kexisourceselector.h" | 35 | #include "kexisourceselector.h" | ||
36 | #include <widget/properties/KexiCustomPropertyFactory.h> | 36 | #include <widget/properties/KexiCustomPropertyFactory.h> | ||
37 | #include <kexiutils/utils.h> | ||||
37 | 38 | | |||
38 | //! @internal | 39 | //! @internal | ||
39 | class Q_DECL_HIDDEN KexiReportPart::Private | 40 | class Q_DECL_HIDDEN KexiReportPart::Private | ||
40 | { | 41 | { | ||
41 | public: | 42 | public: | ||
42 | Private() : toolboxActionGroup(0) | 43 | Private() : toolboxActionGroup(0) | ||
43 | { | 44 | { | ||
44 | sourceSelector = 0; | 45 | sourceSelector = 0; | ||
▲ Show 20 Lines • Show All 107 Lines • ▼ Show 20 Line(s) | 152 | if (temp->connectionDefinition.isNull()) { | |||
152 | qWarning() << "no report report:content element found in report" << window->partItem()->name(); | 153 | qWarning() << "no report report:content element found in report" << window->partItem()->name(); | ||
153 | return 0; | 154 | return 0; | ||
154 | } | 155 | } | ||
155 | return KexiPart::Part::loadSchemaObject(window, object, viewMode, ownedByWindow); | 156 | return KexiPart::Part::loadSchemaObject(window, object, viewMode, ownedByWindow); | ||
156 | } | 157 | } | ||
157 | 158 | | |||
158 | KexiWindowData* KexiReportPart::createWindowData(KexiWindow* window) | 159 | KexiWindowData* KexiReportPart::createWindowData(KexiWindow* window) | ||
159 | { | 160 | { | ||
160 | return new KexiReportPartTempData(window); | 161 | KexiMainWindowIface *win = KexiMainWindowIface::global(); | ||
162 | return new KexiReportPartTempData(window, win->project()->dbConnection()); | ||||
163 | } | ||||
164 | | ||||
165 | //---------------- | ||||
166 | | ||||
167 | class Q_DECL_HIDDEN KexiReportPartTempData::Private | ||||
168 | { | ||||
169 | public: | ||||
170 | Private() | ||||
171 | { | ||||
161 | } | 172 | } | ||
173 | KDbConnection *conn; | ||||
174 | }; | ||||
162 | 175 | | |||
163 | KexiReportPartTempData::KexiReportPartTempData(KexiWindow* parent) | 176 | KexiReportPartTempData::KexiReportPartTempData(KexiWindow* parent, KDbConnection *conn) | ||
164 | : KexiWindowData(parent) | 177 | : KexiWindowData(parent) | ||
165 | , reportSchemaChangedInPreviousView(true /*to force reloading on startup*/) | 178 | , reportSchemaChangedInPreviousView(true /*to force reloading on startup*/) | ||
179 | , d(new Private) | ||||
180 | { | ||||
181 | d->conn = conn; | ||||
182 | setName(KexiUtils::localizedStringToHtmlSubstring( | ||||
183 | kxi18nc("@info", "Report <resource>%1</resource>").subs(parent->partItem()->name()))); | ||||
184 | } | ||||
185 | | ||||
186 | KexiReportPartTempData::~KexiReportPartTempData() | ||||
187 | { | ||||
188 | KDbTableSchemaChangeListener::unregisterForChanges(d->conn, this); | ||||
189 | delete d; | ||||
190 | } | ||||
191 | | ||||
192 | KDbConnection* KexiReportPartTempData::connection() | ||||
193 | { | ||||
194 | return d->conn; | ||||
195 | } | ||||
196 | | ||||
197 | tristate KexiReportPartTempData::closeListener() | ||||
166 | { | 198 | { | ||
199 | KexiWindow* window = static_cast<KexiWindow*>(parent()); | ||||
200 | qDebug() << window->partItem()->name(); | ||||
201 | return KexiMainWindowIface::global()->closeWindow(window); | ||||
167 | } | 202 | } | ||
168 | 203 | | |||
169 | void KexiReportPart::setupCustomPropertyPanelTabs(QTabWidget *tab) | 204 | void KexiReportPart::setupCustomPropertyPanelTabs(QTabWidget *tab) | ||
170 | { | 205 | { | ||
171 | if (!d->sourceSelector) { | 206 | if (!d->sourceSelector) { | ||
172 | d->sourceSelector = new KexiSourceSelector(KexiMainWindowIface::global()->project(), tab); | 207 | d->sourceSelector = new KexiSourceSelector(KexiMainWindowIface::global()->project(), tab); | ||
173 | } | 208 | } | ||
174 | tab->addTab(d->sourceSelector, koIcon("server-database"), QString()); | 209 | tab->addTab(d->sourceSelector, koIcon("server-database"), QString()); | ||
▲ Show 20 Lines • Show All 129 Lines • Show Last 20 Lines |