summaryrefslogtreecommitdiffstats
path: root/krecipes/src/backends/SQLite/qsql_sqlite.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'krecipes/src/backends/SQLite/qsql_sqlite.cpp')
-rw-r--r--krecipes/src/backends/SQLite/qsql_sqlite.cpp156
1 files changed, 78 insertions, 78 deletions
diff --git a/krecipes/src/backends/SQLite/qsql_sqlite.cpp b/krecipes/src/backends/SQLite/qsql_sqlite.cpp
index b39a10b..8c228ef 100644
--- a/krecipes/src/backends/SQLite/qsql_sqlite.cpp
+++ b/krecipes/src/backends/SQLite/qsql_sqlite.cpp
@@ -10,11 +10,11 @@
#include "qsql_sqlite.h"
-#include <qdatetime.h>
-#include <qregexp.h>
-#include <qfile.h>
+#include <ntqdatetime.h>
+#include <ntqregexp.h>
+#include <ntqfile.h>
-#include <qptrvector.h>
+#include <ntqptrvector.h>
#include <unistd.h>
#include <kdebug.h>
@@ -22,7 +22,7 @@
#include "libqsqlite/krecqsqlitedb.h"
#include "libqsqlite/krecqsqliteresult.h"
-#define QSQLITE_DRIVER_NAME "KRE_QSQLITE"
+#define TQSQLITE_DRIVER_NAME "KRE_QSQLITE"
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -35,43 +35,43 @@
#include <sqlite.h>
#endif
-class KreSQLiteResult : public QSqlResult
+class KreSQLiteResult : public TQSqlResult
{
public:
- KreSQLiteResult( const KreSQLiteDriver *d ): QSqlResult( d )
+ KreSQLiteResult( const KreSQLiteDriver *d ): TQSqlResult( d )
{
db = d->db;
}
~KreSQLiteResult() {}
protected:
- QVariant data( int );
- bool reset ( const QString& );
+ TQVariant data( int );
+ bool reset ( const TQString& );
bool fetch( int );
bool fetchFirst();
bool fetchNext();
bool fetchLast();
bool isNull( int );
- QSqlRecord record();
+ TQSqlRecord record();
int size();
int numRowsAffected();
private:
- QSQLiteResult result;
- QSQLiteResultRow row;
+ TQSQLiteResult result;
+ TQSQLiteResultRow row;
- QSQLiteDB *db;
+ TQSQLiteDB *db;
};
-QVariant KreSQLiteResult::data( int field )
+TQVariant KreSQLiteResult::data( int field )
{
if ( !isSelect() ) {
- //qWarning( "KreSQLiteResult::data: column %d out of range", field );
- qWarning( "KreSQLiteResult::data: not a select statement" );
- return QVariant();
+ //tqWarning( "KreSQLiteResult::data: column %d out of range", field );
+ tqWarning( "KreSQLiteResult::data: not a select statement" );
+ return TQVariant();
}
- return QVariant(row.data(field));
+ return TQVariant(row.data(field));
}
bool KreSQLiteResult::fetch( int i )
@@ -141,9 +141,9 @@ bool KreSQLiteResult::isNull( int i )
return false;
}
-QSqlRecord KreSQLiteResult::record()
+TQSqlRecord KreSQLiteResult::record()
{kdDebug()<<"record"<<endl;
- return QSqlRecord();
+ return TQSqlRecord();
}
int KreSQLiteResult::size()
@@ -160,7 +160,7 @@ int KreSQLiteResult::numRowsAffected()
/*
Execute \a query.
*/
-bool KreSQLiteResult::reset(const QString& query)
+bool KreSQLiteResult::reset(const TQString& query)
{
// this is where we build a query.
if (!driver())
@@ -178,7 +178,7 @@ bool KreSQLiteResult::reset(const QString& query)
int res = result.getStatus();
if (res != SQLITE_OK ) {
- setLastError(QSqlError("Unable to execute statement", result.getError(), QSqlError::Statement, res));
+ setLastError(TQSqlError("Unable to execute statement", result.getError(), TQSqlError::Statement, res));
}
setActive(true);
@@ -187,13 +187,13 @@ bool KreSQLiteResult::reset(const QString& query)
/////////////////////////////////////////////////////////
-KreSQLiteDriver::KreSQLiteDriver(QObject * parent, const char * name)
- : QSqlDriver(parent, name ? name : QSQLITE_DRIVER_NAME)
+KreSQLiteDriver::KreSQLiteDriver(TQObject * parent, const char * name)
+ : TQSqlDriver(parent, name ? name : TQSQLITE_DRIVER_NAME)
{
}
-KreSQLiteDriver::KreSQLiteDriver(QSQLiteDB *connection, QObject *parent, const char *name)
- : QSqlDriver(parent, name ? name : QSQLITE_DRIVER_NAME)
+KreSQLiteDriver::KreSQLiteDriver(TQSQLiteDB *connection, TQObject *parent, const char *name)
+ : TQSqlDriver(parent, name ? name : TQSQLITE_DRIVER_NAME)
{
db = connection;
setOpen(true);
@@ -221,7 +221,7 @@ bool KreSQLiteDriver::hasFeature(DriverFeature f) const
SQLite dbs have no user name, passwords, hosts or ports.
just file names.
*/
-bool KreSQLiteDriver::open(const QString & file, const QString &, const QString &, const QString &, int)
+bool KreSQLiteDriver::open(const TQString & file, const TQString &, const TQString &, const TQString &, int)
{
if (isOpen())
close();
@@ -229,9 +229,9 @@ bool KreSQLiteDriver::open(const QString & file, const QString &, const QString
if (file.isEmpty())
return false;
- db = new QSQLiteDB;
- if ( !db->open(QFile::encodeName(file)) ) {
- setLastError(QSqlError("Error to open database", 0, QSqlError::Connection));
+ db = new TQSQLiteDB;
+ if ( !db->open(TQFile::encodeName(file)) ) {
+ setLastError(TQSqlError("Error to open database", 0, TQSqlError::Connection));
setOpenError(true);
setOpen(false);
return false;
@@ -252,9 +252,9 @@ void KreSQLiteDriver::close()
}
}
-QSqlQuery KreSQLiteDriver::createQuery() const
+TQSqlQuery KreSQLiteDriver::createQuery() const
{
- return QSqlQuery(new KreSQLiteResult(this));
+ return TQSqlQuery(new KreSQLiteResult(this));
}
bool KreSQLiteDriver::beginTransaction()
@@ -262,12 +262,12 @@ bool KreSQLiteDriver::beginTransaction()
if (!isOpen() || isOpenError())
return false;
- QSQLiteResult result = db->executeQuery( "BEGIN" );
+ TQSQLiteResult result = db->executeQuery( "BEGIN" );
int status = result.getStatus();
- if (status == QSQLiteResult::Success)
+ if (status == TQSQLiteResult::Success)
return true;
- setLastError(QSqlError("Unable to begin transaction", result.getError(), QSqlError::Transaction, status));
+ setLastError(TQSqlError("Unable to begin transaction", result.getError(), TQSqlError::Transaction, status));
return false;
}
@@ -276,12 +276,12 @@ bool KreSQLiteDriver::commitTransaction()
if (!isOpen() || isOpenError())
return false;
- QSQLiteResult result = db->executeQuery( "COMMIT" );
+ TQSQLiteResult result = db->executeQuery( "COMMIT" );
int status = result.getStatus();
- if (status == QSQLiteResult::Success)
+ if (status == TQSQLiteResult::Success)
return true;
- setLastError(QSqlError("Unable to commit transaction", result.getError(), QSqlError::Transaction, status));
+ setLastError(TQSqlError("Unable to commit transaction", result.getError(), TQSqlError::Transaction, status));
return false;
}
@@ -290,31 +290,31 @@ bool KreSQLiteDriver::rollbackTransaction()
if (!isOpen() || isOpenError())
return false;
- QSQLiteResult result = db->executeQuery( "ROLLBACK" );
+ TQSQLiteResult result = db->executeQuery( "ROLLBACK" );
int status = result.getStatus();
if (status == SQLITE_OK)
return true;
- setLastError(QSqlError("Unable to rollback transaction", result.getError(), QSqlError::Transaction, status));
+ setLastError(TQSqlError("Unable to rollback transaction", result.getError(), TQSqlError::Transaction, status));
return false;
}
-QStringList KreSQLiteDriver::tables(const QString &typeName) const
+TQStringList KreSQLiteDriver::tables(const TQString &typeName) const
{
- QStringList res;
+ TQStringList res;
if (!isOpen())
return res;
int type = typeName.toInt();
- QSqlQuery q = createQuery();
+ TQSqlQuery q = createQuery();
q.setForwardOnly(true);
- #if (QT_VERSION-0 >= 0x030000)
- if ((type & (int)QSql::Tables) && (type & (int)QSql::Views))
+ #if (TQT_VERSION-0 >= 0x030000)
+ if ((type & (int)TQSql::Tables) && (type & (int)TQSql::Views))
q.exec("SELECT name FROM sqlite_master WHERE type='table' OR type='view'");
- else if (typeName.isEmpty() || (type & (int)QSql::Tables))
+ else if (typeName.isEmpty() || (type & (int)TQSql::Tables))
q.exec("SELECT name FROM sqlite_master WHERE type='table'");
- else if (type & (int)QSql::Views)
+ else if (type & (int)TQSql::Views)
q.exec("SELECT name FROM sqlite_master WHERE type='view'");
#else
q.exec("SELECT name FROM sqlite_master WHERE type='table' OR type='view'");
@@ -326,8 +326,8 @@ QStringList KreSQLiteDriver::tables(const QString &typeName) const
}
}
- #if (QT_VERSION-0 >= 0x030000)
- if (type & (int)QSql::SystemTables) {
+ #if (TQT_VERSION-0 >= 0x030000)
+ if (type & (int)TQSql::SystemTables) {
// there are no internal tables beside this one:
res.append("sqlite_master");
}
@@ -336,18 +336,18 @@ QStringList KreSQLiteDriver::tables(const QString &typeName) const
return res;
}
-QSqlIndex KreSQLiteDriver::primaryIndex(const QString &tblname) const
+TQSqlIndex KreSQLiteDriver::primaryIndex(const TQString &tblname) const
{
- QSqlRecordInfo rec(recordInfo(tblname)); // expensive :(
+ TQSqlRecordInfo rec(recordInfo(tblname)); // expensive :(
if (!isOpen())
- return QSqlIndex();
+ return TQSqlIndex();
- QSqlQuery q = createQuery();
+ TQSqlQuery q = createQuery();
q.setForwardOnly(true);
// finrst find a UNIQUE INDEX
q.exec("PRAGMA index_list('" + tblname + "');");
- QString indexname;
+ TQString indexname;
while(q.next()) {
if (q.value(2).toInt()==1) {
indexname = q.value(1).toString();
@@ -355,64 +355,64 @@ QSqlIndex KreSQLiteDriver::primaryIndex(const QString &tblname) const
}
}
if (indexname.isEmpty())
- return QSqlIndex();
+ return TQSqlIndex();
q.exec("PRAGMA index_info('" + indexname + "');");
- QSqlIndex index(tblname, indexname);
+ TQSqlIndex index(tblname, indexname);
while(q.next()) {
- QString name = q.value(2).toString();
- QSqlVariant::Type type = QSqlVariant::Invalid;
+ TQString name = q.value(2).toString();
+ TQSqlVariant::Type type = TQSqlVariant::Invalid;
if (rec.contains(name))
type = rec.find(name).type();
- index.append(QSqlField(name, type));
+ index.append(TQSqlField(name, type));
}
return index;
}
#if 0
-QSqlRecordInfo KreSQLiteDriver::recordInfo(const QString &tbl) const
+TQSqlRecordInfo KreSQLiteDriver::recordInfo(const TQString &tbl) const
{
if (!isOpen())
- return QSqlRecordInfo();
+ return TQSqlRecordInfo();
- QSqlQuery q = createQuery();
+ TQSqlQuery q = createQuery();
q.setForwardOnly(true);
q.exec("SELECT * FROM " + tbl + " LIMIT 1");
-return QSqlRecordInfo();
+return TQSqlRecordInfo();
// return recordInfo(q);
}
-QSqlRecord KreSQLiteDriver::record(const QString &tblname) const
+TQSqlRecord KreSQLiteDriver::record(const TQString &tblname) const
{
if (!isOpen())
- return QSqlRecord();
+ return TQSqlRecord();
return recordInfo(tblname).toRecord();
}
-QSqlRecord KreSQLiteDriver::record(const QSqlQuery& query) const
+TQSqlRecord KreSQLiteDriver::record(const TQSqlQuery& query) const
{
if (query.isActive() && query.driver() == this) {
KreSQLiteResult* result = (KreSQLiteResult*)query.result();
return result->rInf.toRecord();
}
- return QSqlRecord();
+ return TQSqlRecord();
}
-QSqlRecordInfo KreSQLiteDriver::recordInfo(const QSqlQuery& query) const
+TQSqlRecordInfo KreSQLiteDriver::recordInfo(const TQSqlQuery& query) const
{
if (query.isActive() && query.driver() == this) {
KreSQLiteResult* result = (KreSQLiteResult*)query.result();
return result->rInf;
}
- return QSqlRecordInfo();
+ return TQSqlRecordInfo();
}
//this would be used below in formatValue()
-static QString escape( const QString &s )
+static TQString escape( const TQString &s )
{
- QString s_escaped = s;
+ TQString s_escaped = s;
if ( !s_escaped.isEmpty() ) { //###: sqlite_mprintf() seems to fill an empty string with garbage
// Escape using SQLite's function
@@ -433,24 +433,24 @@ static QString escape( const QString &s )
}
-// Everything is considered a string given the implementation of this driver (we don't have field info). This would ruin a QByteArray (for the photo).
-QString KreSQLiteDriver::formatValue( const QSqlField* field, bool trimStrings ) const
+// Everything is considered a string given the implementation of this driver (we don't have field info). This would ruin a TQByteArray (for the photo).
+TQString KreSQLiteDriver::formatValue( const TQSqlField* field, bool trimStrings ) const
{
- QString r;
+ TQString r;
if ( field->isNull() ) {
r = nullText();
} else {
switch( field->type() ) {
- case QVariant::String:
- case QVariant::CString: {
+ case TQVariant::String:
+ case TQVariant::CString: {
// Escape '\' characters
- r = QSqlDriver::formatValue( field );
+ r = TQSqlDriver::formatValue( field );
//r = escape(r);
//kdDebug()<<"escaping sqlite string: "<<r<<endl;
break;
}
default:
- r = QSqlDriver::formatValue( field, trimStrings );
+ r = TQSqlDriver::formatValue( field, trimStrings );
}
}
return r;