Changeset View
Changeset View
Standalone View
Standalone View
src/plugins/scripting/kexiscripting/kexiscriptadaptor.h
Show All 18 Lines | |||||
19 | 19 | | |||
20 | #ifndef KEXISCRIPTADAPTOR_H | 20 | #ifndef KEXISCRIPTADAPTOR_H | ||
21 | #define KEXISCRIPTADAPTOR_H | 21 | #define KEXISCRIPTADAPTOR_H | ||
22 | 22 | | |||
23 | #include <QObject> | 23 | #include <QObject> | ||
24 | #include <QMetaObject> | 24 | #include <QMetaObject> | ||
25 | #include <QAction> | 25 | #include <QAction> | ||
26 | 26 | | |||
27 | #include <Kross/Manager> | | |||
28 | | ||||
29 | #include <KDbConnection> | 27 | #include <KDbConnection> | ||
30 | 28 | | |||
31 | #include <kexi.h> | 29 | #include <kexi.h> | ||
32 | #include <kexipart.h> | 30 | #include <kexipart.h> | ||
33 | #include <kexiproject.h> | 31 | #include <kexiproject.h> | ||
34 | #include <KexiMainWindowIface.h> | 32 | #include <KexiMainWindowIface.h> | ||
35 | #include <KexiWindow.h> | 33 | #include <KexiWindow.h> | ||
36 | #include <KexiView.h> | 34 | #include <KexiView.h> | ||
37 | 35 | | |||
38 | /** | 36 | /** | ||
39 | * Adaptor class that provides Kexi specific functionality to | 37 | * Adaptor class that provides Kexi specific functionality to | ||
40 | * the scripting world. | 38 | * the scripting world. | ||
41 | */ | 39 | */ | ||
42 | class KexiScriptAdaptor : public QObject | 40 | class KexiScriptAdaptor : public QObject | ||
43 | { | 41 | { | ||
44 | Q_OBJECT | 42 | Q_OBJECT | ||
45 | public: | 43 | public: | ||
46 | explicit KexiScriptAdaptor() : m_kexidbmodule(0) { | 44 | explicit KexiScriptAdaptor() : m_kexidbmodule(0) { | ||
staniek: -explicit | |||||
47 | setObjectName("Kexi"); | 45 | setObjectName("Kexi"); | ||
48 | } | 46 | } | ||
49 | virtual ~KexiScriptAdaptor() {} | 47 | virtual ~KexiScriptAdaptor() {} | ||
50 | public Q_SLOTS: | 48 | public Q_SLOTS: | ||
51 | 49 | | |||
52 | /** | 50 | /** | ||
53 | * Returns the current KexiWindow widget. | 51 | * Returns the current KexiWindow widget. | ||
54 | */ | 52 | */ | ||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Line(s) | |||||
106 | } | 104 | } | ||
107 | 105 | | |||
108 | /** | 106 | /** | ||
109 | * Returns the KexiDBConnection object that belongs to the opened | 107 | * Returns the KexiDBConnection object that belongs to the opened | ||
110 | * project or return NULL if there was no project opened (no | 108 | * project or return NULL if there was no project opened (no | ||
111 | * connection established). | 109 | * connection established). | ||
112 | */ | 110 | */ | ||
113 | QObject* getConnection() { | 111 | QObject* getConnection() { | ||
112 | #if 0 | ||||
114 | if (! m_kexidbmodule) | 113 | if (! m_kexidbmodule) | ||
115 | m_kexidbmodule = Kross::Manager::self().module("kexidb"); | 114 | m_kexidbmodule = Kross::Manager::self().module("kexidb"); | ||
116 | KDbConnection *connection = project() ? project()->dbConnection() : 0; | 115 | KDbConnection *connection = project() ? project()->dbConnection() : 0; | ||
117 | if (m_kexidbmodule && connection) { | 116 | if (m_kexidbmodule && connection) { | ||
118 | QObject* result = 0; | 117 | QObject* result = 0; | ||
119 | if (QMetaObject::invokeMethod(m_kexidbmodule, "connectionWrapper", Q_RETURN_ARG(QObject*, result), Q_ARG(QObject*, connection))) | 118 | if (QMetaObject::invokeMethod(m_kexidbmodule, "connectionWrapper", Q_RETURN_ARG(QObject*, result), Q_ARG(QObject*, connection))) | ||
120 | return result; | 119 | return result; | ||
121 | } | 120 | } | ||
121 | #endif | ||||
122 | return 0; | 122 | return 0; | ||
123 | } | 123 | } | ||
124 | 124 | | |||
125 | /** | 125 | /** | ||
126 | * Returns a list of names of all items the part class provides. Possible | 126 | * Returns a list of names of all items the part class provides. Possible | ||
127 | * classes are for example "org.kexi-project.table", "org.kexi-project.query", | 127 | * classes are for example "org.kexi-project.table", "org.kexi-project.query", | ||
128 | * "org.kexi-project.form" or "org.kexi-project.script". | 128 | * "org.kexi-project.form" or "org.kexi-project.script". | ||
129 | * | 129 | * | ||
130 | * Python sample that prints all tables within the current project. | 130 | * Python sample that prints all tables within the current project. | ||
131 | * \code | 131 | * \code | ||
132 | * import Kexi | 132 | * import Kexi | ||
133 | * print Kexi.items("table") | 133 | * print Kexi.items("table") | ||
134 | * \endcode | 134 | * \endcode | ||
135 | */ | 135 | */ | ||
136 | QStringList items(const QString& pluginId) { | 136 | QStringList items(const QString& pluginId) { | ||
137 | QStringList list; | 137 | QStringList list; | ||
138 | #if 0 | ||||
138 | if (project()) { | 139 | if (project()) { | ||
139 | KexiPart::ItemList l; | 140 | KexiPart::ItemList l; | ||
140 | project()->getSortedItemsForPluginId(&l, pluginId(pluginId).toUtf8()); | 141 | project()->getSortedItemsForPluginId(&l, pluginId(pluginId).toUtf8()); | ||
141 | l.sort(); | 142 | l.sort(); | ||
142 | foreach(KexiPart::Item* i, l) { | 143 | foreach(KexiPart::Item* i, l) { | ||
143 | list << i->name(); | 144 | list << i->name(); | ||
144 | } | 145 | } | ||
145 | } | 146 | } | ||
147 | #endif | ||||
146 | return list; | 148 | return list; | ||
147 | } | 149 | } | ||
148 | 150 | | |||
149 | /** | 151 | /** | ||
150 | * Returns the caption for the item defined with \p pluginId and \p name . | 152 | * Returns the caption for the item defined with \p pluginId and \p name . | ||
151 | */ | 153 | */ | ||
152 | QString itemCaption(const QString& pluginId, const QString& name) const { | 154 | QString itemCaption(const QString& pluginId, const QString& name) const { | ||
153 | KexiPart::Item *item = partItem(pluginId(pluginId), name); | 155 | KexiPart::Item *item = partItem(pluginId(pluginId), name); | ||
▲ Show 20 Lines • Show All 174 Lines • Show Last 20 Lines |
-explicit