Changeset View
Changeset View
Standalone View
Standalone View
src/plugins/reports/kexisourceselector.cpp
Show All 14 Lines | |||||
15 | * | 15 | * | ||
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 "kexisourceselector.h" | 20 | #include "kexisourceselector.h" | ||
21 | #include "KexiDataSourceComboBox.h" | 21 | #include "KexiDataSourceComboBox.h" | ||
22 | #include <kexiproject.h> | 22 | #include <kexiproject.h> | ||
23 | #include <kexiutils/utils.h> | | |||
24 | 23 | | |||
25 | #include <KLocalizedString> | 24 | #include <KLocalizedString> | ||
26 | 25 | | |||
27 | #include <QDebug> | 26 | #include <QDebug> | ||
28 | #include <QLabel> | 27 | #include <QLabel> | ||
29 | #include <QDomElement> | 28 | #include <QDomElement> | ||
30 | #include <QVBoxLayout> | 29 | #include <QVBoxLayout> | ||
31 | 30 | | |||
Show All 33 Lines | 50 | { | |||
65 | setLayout(d->layout); | 64 | setLayout(d->layout); | ||
66 | } | 65 | } | ||
67 | 66 | | |||
68 | KexiSourceSelector::~KexiSourceSelector() | 67 | KexiSourceSelector::~KexiSourceSelector() | ||
69 | { | 68 | { | ||
70 | delete d; | 69 | delete d; | ||
71 | } | 70 | } | ||
72 | 71 | | |||
73 | void KexiSourceSelector::setConnectionData(const QDomElement &c) | 72 | QString KexiSourceSelector::selectedPluginId() const | ||
74 | { | 73 | { | ||
75 | qDebug() << c; | 74 | return d->dataSource->selectedPluginId(); | ||
76 | if (c.attribute("type") == "internal") { | | |||
77 | QString sourceClass(c.attribute("class")); | | |||
78 | if (sourceClass != "org.kexi-project.table" && sourceClass != "org.kexi-project.query") { | | |||
79 | sourceClass.clear(); // KexiDataSourceComboBox will try to find table, then query | | |||
80 | } | | |||
81 | d->dataSource->setDataSource(sourceClass, c.attribute("source")); | | |||
82 | emit dataSourceChanged(); | | |||
83 | } | | |||
84 | } | 75 | } | ||
85 | 76 | | |||
86 | QDomElement KexiSourceSelector::connectionData() | 77 | QString KexiSourceSelector::selectedName() const | ||
87 | { | 78 | { | ||
88 | QDomDocument dd; | 79 | return d->dataSource->selectedName(); | ||
89 | QDomElement conndata = dd.createElement("connection"); | | |||
90 | conndata.setAttribute("type", "internal"); // for backward compatibility, currently always | | |||
91 | // internal, we used to have "external" in old Kexi | | |||
92 | conndata.setAttribute("source", d->dataSource->selectedName()); | | |||
93 | conndata.setAttribute("class", d->dataSource->selectedPluginId()); | | |||
94 | return conndata; | | |||
95 | } | 80 | } | ||
96 | 81 | | |||
97 | KReportDataSource* KexiSourceSelector::createDataSource() const | 82 | bool KexiSourceSelector::isSelectionValid() const | ||
98 | { | 83 | { | ||
99 | if (d->dataSource->isSelectionValid()) { | 84 | return d->dataSource->isSelectionValid(); | ||
100 | return new KexiDBReportDataSource(d->dataSource->selectedName(), | | |||
101 | d->dataSource->selectedPluginId(), d->conn); | | |||
102 | } | | |||
103 | return nullptr; | | |||
104 | } | 85 | } | ||
105 | 86 | | |||
87 | void KexiSourceSelector::setDataSource(const QString& pluginId, const QString& name) | ||||
88 | { | ||||
89 | d->dataSource->setDataSource(pluginId, name); | ||||
90 | } |