summaryrefslogtreecommitdiffstats
path: root/kjsembed/bindings/sql_imp.h
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit90825e2392b2d70e43c7a25b8a3752299a933894 (patch)
treee33aa27f02b74604afbfd0ea4f1cfca8833d882a /kjsembed/bindings/sql_imp.h
downloadtdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.tar.gz
tdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebindings@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kjsembed/bindings/sql_imp.h')
-rw-r--r--kjsembed/bindings/sql_imp.h141
1 files changed, 141 insertions, 0 deletions
diff --git a/kjsembed/bindings/sql_imp.h b/kjsembed/bindings/sql_imp.h
new file mode 100644
index 00000000..78e54756
--- /dev/null
+++ b/kjsembed/bindings/sql_imp.h
@@ -0,0 +1,141 @@
+/*
+ * Copyright (C) 2003, Ian Reinhart Geiser <geiseri@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef KJSEMBED_SQL_IMP_H
+#define KJSEMBED_SQL_IMP_H
+
+#include "bindingobject.h"
+#include <qsqlquery.h>
+#include <qsqldatabase.h>
+
+namespace KJSEmbed {
+namespace Bindings {
+
+/**
+ * QObject Binding for QSQLQuery.
+ *
+ * @author Ian Reinhart Geiser, geiseri@kde.org
+ * @version $Id$
+ */
+class SqlQuery : public BindingObject
+{
+ Q_OBJECT
+ Q_PROPERTY( int size READ size)
+ Q_PROPERTY( int at READ at)
+ Q_PROPERTY( int numRowsAffected READ numRowsAffected )
+ Q_PROPERTY( bool select READ isSelect)
+ Q_PROPERTY( bool valid READ isValid)
+ Q_PROPERTY( bool active READ isActive)
+ Q_PROPERTY( QString lastError READ lastError)
+ Q_PROPERTY( QString lastQuery READ lastQuery)
+
+public:
+ SqlQuery( QObject *parent=0, const char *name=0 );
+ SqlQuery( QObject *parent, const char *name, const QSqlQuery &q );
+ //SqlQuery( const SqlQuery &copy);
+ virtual ~SqlQuery();
+
+ QSqlQuery query(){ return m_query; }
+ void setQuery(const QSqlQuery &q) {m_query = QSqlQuery(q); }
+
+ int size () const;
+ bool isSelect () const;
+ bool isValid () const;
+ bool isActive () const;
+ int at () const;
+ int numRowsAffected () const;
+ QString lastError () const;
+ QString lastQuery () const;
+
+public slots:
+
+
+
+ bool isNull ( int field );
+ bool exec ( const QString & m_query );
+ QVariant value ( int i );
+ bool seek ( int i, bool relative = FALSE );
+ bool next ();
+ bool prev ();
+ bool first ();
+ bool last ();
+
+private:
+ QSqlQuery m_query;
+};
+
+/**
+ * QObject Binding for QSQLDatabase.
+ *
+ * @author Ian Reinhart Geiser, geiseri@kde.org
+ * @version $Id$
+ */
+class SqlDatabase : public BindingObject
+{
+ Q_OBJECT
+ Q_PROPERTY( QString databaseName READ databaseName WRITE setDatabaseName)
+ Q_PROPERTY( QString userName READ userName WRITE setUserName)
+ Q_PROPERTY( QString password READ password WRITE setPassword)
+ Q_PROPERTY( QString hostName READ hostName WRITE setHostName)
+ Q_PROPERTY( int port READ port WRITE setPort)
+ Q_PROPERTY( QString driverName READ driverName)
+ Q_PROPERTY( QString lastError READ lastError)
+
+public:
+ SqlDatabase( QObject *parent=0, const char *name=0 );
+ virtual ~SqlDatabase();
+
+
+public slots:
+ void setDatabaseName (const QString &name );
+ void setUserName (const QString &name );
+ void setPassword (const QString &password );
+ void setHostName (const QString &host );
+ void setPort ( int p );
+ QString databaseName () const;
+ QString userName () const;
+ QString password () const;
+ QString hostName () const;
+ int port () const;
+ QString driverName () const;
+
+ bool addDatabase ( const QString & type, const QString & connectionName = QSqlDatabase::defaultConnection );
+ QStringList drivers ();
+ bool open ();
+ bool open ( const QString &user, const QString &password );
+ void close ();
+ bool isOpen ();
+ bool isOpenError ();
+ QStringList tables ();
+ SqlQuery *exec( const QString &query );
+ QString lastError () const;
+ bool transaction ();
+ bool commit ();
+ bool rollback ();
+
+private:
+ QString connectionName;
+ //QSqlDatabase *db;
+};
+
+
+} // namespace KJSEmbed::Bindings
+} // namespace KJSEmbed
+
+#endif // KJSEMBED_SQL_IMP_H