Changeset View
Changeset View
Standalone View
Standalone View
src/plugins/scripting/kexidb/kexidbconnection.h
Show All 20 Lines | |||||
21 | #define SCRIPTING_KEXIDBCONNECTION_H | 21 | #define SCRIPTING_KEXIDBCONNECTION_H | ||
22 | 22 | | |||
23 | #include <QString> | 23 | #include <QString> | ||
24 | #include <QObject> | 24 | #include <QObject> | ||
25 | #include <QPointer> | 25 | #include <QPointer> | ||
26 | 26 | | |||
27 | #include <KDbConnection> | 27 | #include <KDbConnection> | ||
28 | 28 | | |||
29 | #include "kexidbconnectiondata.h" | ||||
30 | | ||||
29 | namespace Scripting | 31 | namespace Scripting | ||
30 | { | 32 | { | ||
31 | 33 | | |||
32 | // Forward declarations. | 34 | // Forward declarations. | ||
33 | class KexiDBDriver; | 35 | class KexiDBDriver; | ||
34 | class KexiDBConnectionData; | | |||
35 | class KexiDBCursor; | 36 | class KexiDBCursor; | ||
36 | class KexiDBTableSchema; | 37 | class KexiDBTableSchema; | ||
37 | class KexiDBQuerySchema; | 38 | class KexiDBQuerySchema; | ||
38 | class KexiDBParser; | 39 | class KexiDBParser; | ||
39 | 40 | | |||
40 | /** | 41 | /** | ||
41 | * A connection to a database. | 42 | * A connection to a database. | ||
42 | * | 43 | * | ||
Show All 12 Lines | |||||
55 | * # Create the connection now. | 56 | * # Create the connection now. | ||
56 | * connection = driver.createConnection(connectiondata) | 57 | * connection = driver.createConnection(connectiondata) | ||
57 | * # Establish the connection. | 58 | * # Establish the connection. | ||
58 | * if not connection.connect(): raise("Failed to connect with db") | 59 | * if not connection.connect(): raise("Failed to connect with db") | ||
59 | * # Open database for usage. The filebased driver uses the filename as databasename. | 60 | * # Open database for usage. The filebased driver uses the filename as databasename. | ||
60 | * if not connection.useDatabase("/home/user/kexisqlite3file.kexi"): raise("Failed to use db") | 61 | * if not connection.useDatabase("/home/user/kexisqlite3file.kexi"): raise("Failed to use db") | ||
61 | * @endcode | 62 | * @endcode | ||
62 | */ | 63 | */ | ||
63 | class KexiDBConnection : public QObject | 64 | class KexiDBConnection : public QObject | ||
staniek: Clarification: I would say KDb-related scripting would go to KDb 4... | |||||
piggz: Ok, so we woill keep these wrappers for Kexi 3? | |||||
Whether or not we keep them I think it's better to disable scripting by deafult in KEXI 3. Good thing in this patch is restoring the script plugin with editor. I am looking towards porting useful things (or techniques) to KDb. staniek: Whether or not we keep them I think it's better to disable scripting by deafult in KEXI 3. Good… | |||||
64 | { | 65 | { | ||
65 | Q_OBJECT | 66 | Q_OBJECT | ||
66 | public: | 67 | public: | ||
67 | KexiDBConnection(KDbConnection* connection, KexiDBDriver* driver = 0, KexiDBConnectionData* connectiondata = 0); | 68 | KexiDBConnection(KDbConnection* connection, KexiDBConnectionData* connectiondata, KexiDBDriver* driver = 0); | ||
69 | KexiDBConnection(KDbConnection* connection, KexiDBDriver* driver = 0); | ||||
68 | virtual ~KexiDBConnection(); | 70 | virtual ~KexiDBConnection(); | ||
69 | 71 | | |||
70 | public Q_SLOTS: | 72 | public Q_SLOTS: | ||
71 | 73 | | |||
72 | /** Return true if there was an error during last operation on the database. */ | 74 | /** Return true if there was an error during last operation on the database. */ | ||
73 | bool hadError() const; | 75 | bool hadError() const; | ||
74 | /** Return the last errormessage. */ | 76 | /** Return the last errormessage. */ | ||
75 | const QString lastError() const; | 77 | QString lastError() const; | ||
76 | 78 | | |||
77 | /** Return the \a KexiDBConnectionData object used to create this connection. */ | 79 | /** Return the \a KexiDBConnectionData object used to create this connection. */ | ||
78 | QObject* data(); | 80 | QObject* data(); | ||
79 | /** Return the \a KexiDBDriver object this connection belongs too. */ | 81 | /** Return the \a KexiDBDriver object this connection belongs too. */ | ||
80 | QObject* driver(); | 82 | QObject* driver(); | ||
81 | 83 | | |||
82 | /** Try to connect and return true if we are successfully connected now. */ | 84 | /** Try to connect and return true if we are successfully connected now. */ | ||
83 | bool connect(); | 85 | bool connect(); | ||
84 | /** Return true if we are connected. */ | 86 | /** Return true if we are connected. */ | ||
85 | bool isConnected(); | 87 | bool isConnected(); | ||
86 | /** Disconnect and return true if we are successfully disconnected now. */ | 88 | /** Disconnect and return true if we are successfully disconnected now. */ | ||
87 | bool disconnect(); | 89 | bool disconnect(); | ||
88 | 90 | | |||
89 | /** Returns true if the connection is read-only. */ | 91 | /** Returns true if the connection is read-only. */ | ||
90 | bool isReadOnly() const; | 92 | bool isReadOnly() const; | ||
91 | 93 | | |||
92 | /** Return true if the as argument passed databasename exists. */ | 94 | /** Return true if the as argument passed databasename exists. */ | ||
93 | bool databaseExists(const QString& dbname); | 95 | bool databaseExists(const QString& dbname); | ||
94 | /** Return the name of currently used database for this connection or empty | 96 | /** Return the name of currently used database for this connection or empty | ||
95 | string if there is no used database. */ | 97 | string if there is no used database. */ | ||
96 | const QString currentDatabase() const; | 98 | QString currentDatabase() const; | ||
97 | /** Return list of database names for opened connection. */ | 99 | /** Return list of database names for opened connection. */ | ||
98 | const QStringList databaseNames() const; | 100 | const QStringList databaseNames() const; | ||
99 | /** Return true if connection is properly established. */ | 101 | /** Return true if connection is properly established. */ | ||
100 | bool isDatabaseUsed() const; | 102 | bool isDatabaseUsed() const; | ||
101 | /** Opens an existing database specified by the as argument passed databasename | 103 | /** Opens an existing database specified by the as argument passed databasename | ||
102 | and returns true if the database is used now. */ | 104 | and returns true if the database is used now. */ | ||
103 | bool useDatabase(const QString& dbname); | 105 | bool useDatabase(const QString& dbname); | ||
104 | /** Closes currently used database for this connection. */ | 106 | /** Closes currently used database for this connection. */ | ||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Line(s) | |||||
153 | be changed even when connection is not established. */ | 155 | be changed even when connection is not established. */ | ||
154 | bool setAutoCommit(bool enabled); | 156 | bool setAutoCommit(bool enabled); | ||
155 | 157 | | |||
156 | /** Return a \a KexiDBParser object. */ | 158 | /** Return a \a KexiDBParser object. */ | ||
157 | QObject* parser(); | 159 | QObject* parser(); | ||
158 | 160 | | |||
159 | private: | 161 | private: | ||
160 | KDbConnection* m_connection; | 162 | KDbConnection* m_connection; | ||
161 | QPointer<KexiDBConnectionData> m_connectiondata; | 163 | KexiDBConnectionData* m_connectiondata; | ||
162 | QPointer<KexiDBDriver> m_driver; | 164 | QPointer<KexiDBDriver> m_driver; | ||
163 | }; | 165 | }; | ||
164 | 166 | | |||
165 | } | 167 | } | ||
166 | 168 | | |||
167 | #endif | 169 | #endif | ||
168 | 170 | |
Clarification: I would say KDb-related scripting would go to KDb 4...