diff options
Diffstat (limited to 'krecipes/src/backends/SQLite/literecipedb.cpp')
-rw-r--r-- | krecipes/src/backends/SQLite/literecipedb.cpp | 210 |
1 files changed, 105 insertions, 105 deletions
diff --git a/krecipes/src/backends/SQLite/literecipedb.cpp b/krecipes/src/backends/SQLite/literecipedb.cpp index ccd88ce..f0d46c7 100644 --- a/krecipes/src/backends/SQLite/literecipedb.cpp +++ b/krecipes/src/backends/SQLite/literecipedb.cpp @@ -14,7 +14,7 @@ #include "literecipedb.h" -#include <qbuffer.h> +#include <ntqbuffer.h> #include <kdebug.h> #include <kconfig.h> @@ -33,9 +33,9 @@ //keep these two around for porting old databases int sqlite_decode_binary( const unsigned char *in, unsigned char *out ); -QString escape( const QString &s ); +TQString escape( const TQString &s ); -LiteRecipeDB::LiteRecipeDB( const QString &_dbFile ) : QSqlRecipeDB( QString::null, QString::null, QString::null, _dbFile ) +LiteRecipeDB::LiteRecipeDB( const TQString &_dbFile ) : TQSqlRecipeDB( TQString::null, TQString::null, TQString::null, _dbFile ) { /* KConfig * config = KGlobal::config(); config->setGroup( "Server" ); @@ -52,7 +52,7 @@ LiteRecipeDB::~LiteRecipeDB() int LiteRecipeDB::lastInsertID() { int lastID = -1; - QSqlQuery query("SELECT lastInsertID()",database); + TQSqlQuery query("SELECT lastInsertID()",database); if ( query.isActive() && query.first() ) lastID = query.value(0).toInt(); @@ -61,36 +61,36 @@ int LiteRecipeDB::lastInsertID() return lastID; } -QStringList LiteRecipeDB::backupCommand() const +TQStringList LiteRecipeDB::backupCommand() const { #if HAVE_SQLITE - QString binary = "sqlite"; + TQString binary = "sqlite"; #elif HAVE_SQLITE3 - QString binary = "sqlite3"; + TQString binary = "sqlite3"; #endif KConfig * config = KGlobal::config(); config->setGroup( "Server" ); binary = config->readEntry( "SQLitePath", binary ); - QStringList command; + TQStringList command; command<<binary<<database->databaseName()<<".dump"; return command; } -QStringList LiteRecipeDB::restoreCommand() const +TQStringList LiteRecipeDB::restoreCommand() const { #if HAVE_SQLITE - QString binary = "sqlite"; + TQString binary = "sqlite"; #elif HAVE_SQLITE3 - QString binary = "sqlite3"; + TQString binary = "sqlite3"; #endif KConfig * config = KGlobal::config(); config->setGroup( "Server" ); binary = config->readEntry( "SQLitePath", binary ); - QStringList command; + TQStringList command; command<<binary<<database->databaseName(); return command; } @@ -100,16 +100,16 @@ void LiteRecipeDB::createDB() //The file is created by SQLite automatically } -void LiteRecipeDB::createTable( const QString &tableName ) +void LiteRecipeDB::createTable( const TQString &tableName ) { - QStringList commands; + TQStringList commands; if ( tableName == "recipes" ) - commands << QString( "CREATE TABLE recipes (id INTEGER NOT NULL,title VARCHAR(%1), yield_amount FLOAT, yield_amount_offset FLOAT, yield_type_id INTEGER DEFAULT '-1', instructions TEXT, photo BLOB, prep_time TIME, ctime TIMESTAMP, mtime TIMESTAMP, atime TIMESTAMP, PRIMARY KEY (id));" ).arg( maxRecipeTitleLength() ); + commands << TQString( "CREATE TABLE recipes (id INTEGER NOT NULL,title VARCHAR(%1), yield_amount FLOAT, yield_amount_offset FLOAT, yield_type_id INTEGER DEFAULT '-1', instructions TEXT, photo BLOB, prep_time TIME, ctime TIMESTAMP, mtime TIMESTAMP, atime TIMESTAMP, PRIMARY KEY (id));" ).arg( maxRecipeTitleLength() ); else if ( tableName == "ingredients" ) - commands << QString( "CREATE TABLE ingredients (id INTEGER NOT NULL, name VARCHAR(%1), PRIMARY KEY (id));" ).arg( maxIngredientNameLength() ); + commands << TQString( "CREATE TABLE ingredients (id INTEGER NOT NULL, name VARCHAR(%1), PRIMARY KEY (id));" ).arg( maxIngredientNameLength() ); else if ( tableName == "ingredient_list" ) { commands << "CREATE TABLE ingredient_list (id INTEGER NOT NULL, recipe_id INTEGER, ingredient_id INTEGER, amount FLOAT, amount_offset FLOAT, unit_id INTEGER, order_index INTEGER, group_id INTEGER, substitute_for INTEGER, PRIMARY KEY(id) );" @@ -122,11 +122,11 @@ void LiteRecipeDB::createTable( const QString &tableName ) commands << "CREATE TABLE unit_list (ingredient_id INTEGER, unit_id INTEGER);"; else if ( tableName == "units" ) - commands << QString( "CREATE TABLE units (id INTEGER NOT NULL, name VARCHAR(%1), name_abbrev VARCHAR(%2), plural VARCHAR(%3), plural_abbrev VARCHAR(%4), type INTEGER NOT NULL DEFAULT '0',PRIMARY KEY (id));" ) + commands << TQString( "CREATE TABLE units (id INTEGER NOT NULL, name VARCHAR(%1), name_abbrev VARCHAR(%2), plural VARCHAR(%3), plural_abbrev VARCHAR(%4), type INTEGER NOT NULL DEFAULT '0',PRIMARY KEY (id));" ) .arg( maxUnitNameLength() ).arg( maxUnitNameLength() ).arg( maxUnitNameLength() ).arg( maxUnitNameLength() ); else if ( tableName == "prep_methods" ) - commands << QString( "CREATE TABLE prep_methods (id INTEGER NOT NULL, name VARCHAR(%1), PRIMARY KEY (id));" ).arg( maxPrepMethodNameLength() ); + commands << TQString( "CREATE TABLE prep_methods (id INTEGER NOT NULL, name VARCHAR(%1), PRIMARY KEY (id));" ).arg( maxPrepMethodNameLength() ); else if ( tableName == "prep_method_list" ) { commands << "CREATE TABLE prep_method_list (ingredient_list_id INTEGER NOT NULL,prep_method_id INTEGER NOT NULL, order_index INTEGER );" @@ -153,7 +153,7 @@ void LiteRecipeDB::createTable( const QString &tableName ) commands << "CREATE TABLE units_conversion (unit1_id INTEGER, unit2_id INTEGER, ratio FLOAT);"; else if ( tableName == "categories" ) { - commands << QString( "CREATE TABLE categories (id INTEGER NOT NULL, name varchar(%1) default NULL, parent_id INGEGER NOT NULL default -1, PRIMARY KEY (id));" ).arg( maxCategoryNameLength() ); + commands << TQString( "CREATE TABLE categories (id INTEGER NOT NULL, name varchar(%1) default NULL, parent_id INGEGER NOT NULL default -1, PRIMARY KEY (id));" ).arg( maxCategoryNameLength() ); commands << "CREATE index parent_id_index ON categories(parent_id);"; } else if ( tableName == "category_list" ) { @@ -163,20 +163,20 @@ void LiteRecipeDB::createTable( const QString &tableName ) } else if ( tableName == "authors" ) - commands << QString( "CREATE TABLE authors (id INTEGER NOT NULL, name varchar(%1) default NULL,PRIMARY KEY (id));" ).arg( maxAuthorNameLength() ); + commands << TQString( "CREATE TABLE authors (id INTEGER NOT NULL, name varchar(%1) default NULL,PRIMARY KEY (id));" ).arg( maxAuthorNameLength() ); else if ( tableName == "author_list" ) commands << "CREATE TABLE author_list (recipe_id INTEGER NOT NULL,author_id INTEGER NOT NULL);"; else if ( tableName == "db_info" ) { commands << "CREATE TABLE db_info (ver FLOAT NOT NULL,generated_by varchar(200) default NULL);"; - commands << QString( "INSERT INTO db_info VALUES(%1,'Krecipes %2');" ).arg( latestDBVersion() ).arg( krecipes_version() ); + commands << TQString( "INSERT INTO db_info VALUES(%1,'Krecipes %2');" ).arg( latestDBVersion() ).arg( krecipes_version() ); } else if ( tableName == "ingredient_groups" ) { - commands << QString( "CREATE TABLE ingredient_groups (id INTEGER NOT NULL, name varchar(%1), PRIMARY KEY (id));" ).arg( maxIngGroupNameLength() ); + commands << TQString( "CREATE TABLE ingredient_groups (id INTEGER NOT NULL, name varchar(%1), PRIMARY KEY (id));" ).arg( maxIngGroupNameLength() ); } else if ( tableName == "yield_types" ) { - commands << QString( "CREATE TABLE yield_types (id INTEGER NOT NULL, name varchar(%1), PRIMARY KEY (id));" ).arg( maxYieldTypeLength() ); + commands << TQString( "CREATE TABLE yield_types (id INTEGER NOT NULL, name varchar(%1), PRIMARY KEY (id));" ).arg( maxYieldTypeLength() ); } else if ( tableName == "ratings" ) @@ -192,22 +192,22 @@ void LiteRecipeDB::createTable( const QString &tableName ) return ; // execute the queries - for ( QStringList::const_iterator it = commands.begin(); it != commands.end(); ++it ) + for ( TQStringList::const_iterator it = commands.begin(); it != commands.end(); ++it ) database->exec( *it ); } void LiteRecipeDB::portOldDatabases( float version ) { - QString command; - if ( qRound(version*10) < 5 ) { + TQString command; + if ( tqRound(version*10) < 5 ) { //===========add prep_method_id to ingredient_list table //There's no ALTER command in SQLite, so we have to copy all data to a new table and then recreate the table with the prep_method_id database->exec( "CREATE TABLE ingredient_list_copy (recipe_id INTEGER, ingredient_id INTEGER, amount FLOAT, unit_id INTEGER, order_index INTEGER);" ); - QSqlQuery copyQuery( "SELECT recipe_id,ingredient_id,amount,unit_id,order_index FROM ingredient_list;", database ); + TQSqlQuery copyQuery( "SELECT recipe_id,ingredient_id,amount,unit_id,order_index FROM ingredient_list;", database ); if ( copyQuery.isActive() ) { while ( copyQuery.next() ) { - command = QString( "INSERT INTO ingredient_list_copy VALUES(%1,%2,%3,%4,%5);" ) + command = TQString( "INSERT INTO ingredient_list_copy VALUES(%1,%2,%3,%4,%5);" ) .arg( copyQuery.value( 0 ).toInt() ) .arg( copyQuery.value( 1 ).toInt() ) .arg( copyQuery.value( 2 ).toDouble() ) @@ -223,7 +223,7 @@ void LiteRecipeDB::portOldDatabases( float version ) copyQuery = database->exec( "SELECT * FROM ingredient_list_copy" ); if ( copyQuery.isActive() ) { while ( copyQuery.next() ) { - command = QString( "INSERT INTO ingredient_list VALUES(%1,%2,%3,%4,%5,%6);" ) + command = TQString( "INSERT INTO ingredient_list VALUES(%1,%2,%3,%4,%5,%6);" ) .arg( copyQuery.value( 0 ).toInt() ) .arg( copyQuery.value( 1 ).toInt() ) .arg( copyQuery.value( 2 ).toDouble() ) @@ -247,7 +247,7 @@ void LiteRecipeDB::portOldDatabases( float version ) if ( copyQuery.isActive() ) { while ( copyQuery.next() ) { - command = QString( "INSERT INTO authors_copy VALUES(%1,'%2');" ) + command = TQString( "INSERT INTO authors_copy VALUES(%1,'%2');" ) .arg( copyQuery.value( 0 ).toInt() ) .arg( escape( copyQuery.value( 1 ).toString() ) ); database->exec( command ); @@ -261,7 +261,7 @@ void LiteRecipeDB::portOldDatabases( float version ) if ( copyQuery.isActive() ) { while ( copyQuery.next() ) { - command = QString( "INSERT INTO authors VALUES(%1,'%2');" ) + command = TQString( "INSERT INTO authors VALUES(%1,'%2');" ) .arg( copyQuery.value( 0 ).toInt() ) .arg( escape( copyQuery.value( 1 ).toString() ) ); database->exec( command ); @@ -278,7 +278,7 @@ void LiteRecipeDB::portOldDatabases( float version ) if ( copyQuery.isActive() ) { while ( copyQuery.next() ) { - command = QString( "INSERT INTO categories_copy VALUES(%1,'%2');" ) + command = TQString( "INSERT INTO categories_copy VALUES(%1,'%2');" ) .arg( copyQuery.value( 0 ).toInt() ) .arg( escape( copyQuery.value( 1 ).toString() ) ); database->exec( command ); @@ -292,7 +292,7 @@ void LiteRecipeDB::portOldDatabases( float version ) if ( copyQuery.isActive() ) { while ( copyQuery.next() ) { - command = QString( "INSERT INTO categories VALUES(%1,'%2');" ) + command = TQString( "INSERT INTO categories VALUES(%1,'%2');" ) .arg( copyQuery.value( 0 ).toInt() ) .arg( escape( copyQuery.value( 1 ).toString() ) ); database->exec( command ); @@ -309,14 +309,14 @@ void LiteRecipeDB::portOldDatabases( float version ) database->exec( command ); } - if ( qRound(version*10) < 6 ) { + if ( tqRound(version*10) < 6 ) { //==================add a column to 'categories' to allow subcategories database->exec( "CREATE TABLE categories_copy (id INTEGER, name varchar(40));" ); - QSqlQuery copyQuery = database->exec( "SELECT * FROM categories;" ); + TQSqlQuery copyQuery = database->exec( "SELECT * FROM categories;" ); if ( copyQuery.isActive() ) { while ( copyQuery.next() ) { - command = QString( "INSERT INTO categories_copy VALUES(%1,'%2');" ) + command = TQString( "INSERT INTO categories_copy VALUES(%1,'%2');" ) .arg( copyQuery.value( 0 ).toInt() ) .arg( escape( copyQuery.value( 1 ).toString() ) ); database->exec( command ); @@ -330,7 +330,7 @@ void LiteRecipeDB::portOldDatabases( float version ) if ( copyQuery.isActive() ) { while ( copyQuery.next() ) { - command = QString( "INSERT INTO categories VALUES(%1,'%2',-1);" ) + command = TQString( "INSERT INTO categories VALUES(%1,'%2',-1);" ) .arg( copyQuery.value( 0 ).toInt() ) .arg( escape( copyQuery.value( 1 ).toString() ) ); database->exec( command ); @@ -347,14 +347,14 @@ void LiteRecipeDB::portOldDatabases( float version ) database->exec( command ); } - if ( qRound(version*100) < 61 ) { + if ( tqRound(version*100) < 61 ) { //==================add a column to 'recipes' to allow prep time database->exec( "CREATE TABLE recipes_copy (id INTEGER NOT NULL,title VARCHAR(200),persons INTEGER,instructions TEXT, photo BLOB, PRIMARY KEY (id));" ); - QSqlQuery copyQuery = database->exec( "SELECT * FROM recipes;" ); + TQSqlQuery copyQuery = database->exec( "SELECT * FROM recipes;" ); if ( copyQuery.isActive() ) { while ( copyQuery.next() ) { - command = QString( "INSERT INTO recipes_copy VALUES(%1,'%2','%3','%4','%5');" ) + command = TQString( "INSERT INTO recipes_copy VALUES(%1,'%2','%3','%4','%5');" ) .arg( escape( copyQuery.value( 0 ).toString() ) ) .arg( escape( copyQuery.value( 1 ).toString() ) ) .arg( escape( copyQuery.value( 2 ).toString() ) ) @@ -371,7 +371,7 @@ void LiteRecipeDB::portOldDatabases( float version ) if ( copyQuery.isActive() ) { while ( copyQuery.next() ) { - command = QString( "INSERT INTO recipes VALUES(%1,'%2','%3','%4','%5',NULL);" ) + command = TQString( "INSERT INTO recipes VALUES(%1,'%2','%3','%4','%5',NULL);" ) .arg( escape( copyQuery.value( 0 ).toString() ) ) .arg( escape( copyQuery.value( 1 ).toString() ) ) .arg( escape( copyQuery.value( 2 ).toString() ) ) @@ -392,12 +392,12 @@ void LiteRecipeDB::portOldDatabases( float version ) database->exec( command ); } - if ( qRound(version*100) < 62 ) { + if ( tqRound(version*100) < 62 ) { database->transaction(); //==================add a column to 'ingredient_list' to allow grouping ingredients database->exec( "CREATE TABLE ingredient_list_copy (recipe_id INTEGER, ingredient_id INTEGER, amount FLOAT, unit_id INTEGER, prep_method_id INTEGER, order_index INTEGER);" ); - QSqlQuery copyQuery = database->exec( "SELECT * FROM ingredient_list;" ); + TQSqlQuery copyQuery = database->exec( "SELECT * FROM ingredient_list;" ); if ( copyQuery.isActive() ) { while ( copyQuery.next() ) { @@ -441,12 +441,12 @@ void LiteRecipeDB::portOldDatabases( float version ) database->commit(); } - if ( qRound(version*100) < 63 ) { + if ( tqRound(version*100) < 63 ) { database->transaction(); //==================add a column to 'units' to allow handling plurals database->exec( "CREATE TABLE units_copy (id INTEGER NOT NULL, name VARCHAR(20), PRIMARY KEY (id));" ); - QSqlQuery copyQuery = database->exec( "SELECT id,name FROM units;" ); + TQSqlQuery copyQuery = database->exec( "SELECT id,name FROM units;" ); if ( copyQuery.isActive() ) { while ( copyQuery.next() ) { @@ -473,10 +473,10 @@ void LiteRecipeDB::portOldDatabases( float version ) } database->exec( "DROP TABLE units_copy" ); - QSqlQuery result = database->exec( "SELECT id,name FROM units WHERE plural ISNULL;" ); + TQSqlQuery result = database->exec( "SELECT id,name FROM units WHERE plural ISNULL;" ); if ( result.isActive() ) { while ( result.next() ) { - command = "UPDATE units SET plural='" + escape( result.value( 1 ).toString() ) + "' WHERE id=" + QString::number( result.value( 0 ).toInt() ); + command = "UPDATE units SET plural='" + escape( result.value( 1 ).toString() ) + "' WHERE id=" + TQString::number( result.value( 0 ).toInt() ); database->exec( command ); emit progress(); @@ -491,11 +491,11 @@ void LiteRecipeDB::portOldDatabases( float version ) database->commit(); } - if ( qRound(version*10) < 7 ) { //simply call 0.63 -> 0.7 + if ( tqRound(version*10) < 7 ) { //simply call 0.63 -> 0.7 database->exec( "UPDATE db_info SET ver='0.7';" ); } - if ( qRound(version*100) < 81 ) { + if ( tqRound(version*100) < 81 ) { database->transaction(); addColumn("CREATE TABLE %1 (recipe_id INTEGER, ingredient_id INTEGER, amount FLOAT, %2 unit_id INTEGER, prep_method_id INTEGER, order_index INTEGER, group_id INTEGER)","amount_offset FLOAT","'0'","ingredient_list",3); @@ -507,12 +507,12 @@ void LiteRecipeDB::portOldDatabases( float version ) database->commit(); } - if ( qRound(version*100) < 82 ) { + if ( tqRound(version*100) < 82 ) { database->transaction(); //==================add a columns to 'recipes' to allow yield range + yield type database->exec( "CREATE TABLE recipes_copy (id INTEGER NOT NULL,title VARCHAR(200),persons INTEGER,instructions TEXT, photo BLOB, prep_time TIME, PRIMARY KEY (id));" ); - QSqlQuery copyQuery = database->exec( "SELECT id,title,persons,instructions,photo,prep_time FROM recipes;" ); + TQSqlQuery copyQuery = database->exec( "SELECT id,title,persons,instructions,photo,prep_time FROM recipes;" ); if ( copyQuery.isActive() ) { while ( copyQuery.next() ) { @@ -556,12 +556,12 @@ void LiteRecipeDB::portOldDatabases( float version ) database->commit(); } - if ( qRound(version*100) < 83 ) { + if ( tqRound(version*100) < 83 ) { database->transaction(); //====add a id columns to 'ingredient_list' to identify it for the prep method list database->exec( "CREATE TABLE ingredient_list_copy (recipe_id INTEGER, ingredient_id INTEGER, amount FLOAT, amount_offset FLOAT, unit_id INTEGER, prep_method_id INTEGER, order_index INTEGER, group_id INTEGER);" ); - QSqlQuery copyQuery = database->exec( "SELECT recipe_id,ingredient_id,amount,amount_offset,unit_id,prep_method_id,order_index,group_id FROM ingredient_list" ); + TQSqlQuery copyQuery = database->exec( "SELECT recipe_id,ingredient_id,amount,amount_offset,unit_id,prep_method_id,order_index,group_id FROM ingredient_list" ); if ( copyQuery.isActive() ) { while ( copyQuery.next() ) { @@ -588,7 +588,7 @@ void LiteRecipeDB::portOldDatabases( float version ) while ( copyQuery.next() ) { command = "INSERT INTO ingredient_list VALUES(" - + QString("NULL") + + TQString("NULL") + ",'" + escape( copyQuery.value( 0 ).toString() ) + "','" + escape( copyQuery.value( 1 ).toString() ) + "','" + escape( copyQuery.value( 2 ).toString() ) @@ -602,8 +602,8 @@ void LiteRecipeDB::portOldDatabases( float version ) int prep_method_id = copyQuery.value( 5 ).toInt(); if ( prep_method_id != -1 ) { command = "INSERT INTO prep_method_list VALUES('" - + QString::number(lastInsertID()) - + "','" + QString::number(prep_method_id) + + TQString::number(lastInsertID()) + + "','" + TQString::number(prep_method_id) + "','1" //order_index + "')"; database->exec( command ); @@ -622,12 +622,12 @@ void LiteRecipeDB::portOldDatabases( float version ) database->commit(); } - if ( qRound(version*100) < 84 ) { + if ( tqRound(version*100) < 84 ) { database->transaction(); //==================add a columns to 'recipes' to allow storing atime, mtime, ctime database->exec( "CREATE TABLE recipes_copy (id INTEGER NOT NULL,title VARCHAR(200), yield_amount FLOAT, yield_amount_offset FLOAT, yield_type_id INTEGER, instructions TEXT, photo BLOB, prep_time TIME, PRIMARY KEY (id));" ); - QSqlQuery copyQuery = database->exec( "SELECT id,title,yield_amount,yield_amount_offset,yield_type_id,instructions,photo,prep_time FROM recipes;" ); + TQSqlQuery copyQuery = database->exec( "SELECT id,title,yield_amount,yield_amount_offset,yield_type_id,instructions,photo,prep_time FROM recipes;" ); if ( copyQuery.isActive() ) { while ( copyQuery.next() ) { @@ -651,7 +651,7 @@ void LiteRecipeDB::portOldDatabases( float version ) copyQuery = database->exec( "SELECT id,title,yield_amount,yield_amount_offset,yield_type_id,instructions,photo,prep_time FROM recipes_copy" ); if ( copyQuery.isActive() ) { - QString current_timestamp = QDateTime::currentDateTime().toString(Qt::ISODate); + TQString current_timestamp = TQDateTime::currentDateTime().toString(TQt::ISODate); while ( copyQuery.next() ) { command = "INSERT INTO recipes VALUES('" + escape( copyQuery.value( 0 ).toString() ) @@ -677,15 +677,15 @@ void LiteRecipeDB::portOldDatabases( float version ) database->commit(); } - if ( qRound(version*100) < 85 ) { + if ( tqRound(version*100) < 85 ) { database->transaction(); - QSqlQuery query( "SELECT id,photo FROM recipes", database ); + TQSqlQuery query( "SELECT id,photo FROM recipes", database ); if ( query.isActive() ) { while ( query.next() ) { - QImage photo; - QString photoString = query.value(1).toString(); + TQImage photo; + TQString photoString = query.value(1).toString(); // Decode the photo uchar *photoArray = new uchar [ photoString.length() + 1 ]; @@ -697,13 +697,13 @@ void LiteRecipeDB::portOldDatabases( float version ) // picture will now have a ready-to-use image delete[] photoArray; - QByteArray ba; - QBuffer buffer( ba ); + TQByteArray ba; + TQBuffer buffer( ba ); buffer.open( IO_WriteOnly ); - QImageIO iio( &buffer, "JPEG" ); + TQImageIO iio( &buffer, "JPEG" ); iio.setImage( photo ); iio.write(); - //recipe->photo.save( &buffer, "JPEG" ); don't need QImageIO in QT 3.2 + //recipe->photo.save( &buffer, "JPEG" ); don't need TQImageIO in QT 3.2 storePhoto( query.value(0).toInt(), ba ); emit progress(); @@ -715,24 +715,24 @@ void LiteRecipeDB::portOldDatabases( float version ) database->commit(); } - if ( qRound(version*100) < 86 ) { + if ( tqRound(version*100) < 86 ) { database->transaction(); database->exec( "CREATE index gidil_index ON ingredient_list(group_id)" ); - QSqlQuery query( "SELECT id,name FROM ingredient_groups ORDER BY name", database ); + TQSqlQuery query( "SELECT id,name FROM ingredient_groups ORDER BY name", database ); - QString last; + TQString last; int lastID; if ( query.isActive() ) { while ( query.next() ) { - QString name = query.value(1).toString(); + TQString name = query.value(1).toString(); int id = query.value(0).toInt(); if ( last == name ) { - QString command = QString("UPDATE ingredient_list SET group_id=%1 WHERE group_id=%2").arg(lastID).arg(id); + TQString command = TQString("UPDATE ingredient_list SET group_id=%1 WHERE group_id=%2").arg(lastID).arg(id); database->exec(command); - command = QString("DELETE FROM ingredient_groups WHERE id=%1").arg(id); + command = TQString("DELETE FROM ingredient_groups WHERE id=%1").arg(id); database->exec(command); } last = name; @@ -747,32 +747,32 @@ void LiteRecipeDB::portOldDatabases( float version ) kdDebug()<<"Update to 0.86 failed. Maybe you should try again."<<endl; } - if ( qRound(version*100) < 87 ) { + if ( tqRound(version*100) < 87 ) { //Load this default data so the user knows what rating criteria is - database->exec( QString("INSERT INTO rating_criteria VALUES (1,'%1')").arg(i18n("Overall")) ); - database->exec( QString("INSERT INTO rating_criteria VALUES (2,'%1')").arg(i18n("Taste") ) ); - database->exec( QString("INSERT INTO rating_criteria VALUES (3,'%1')").arg(i18n("Appearance") ) ); - database->exec( QString("INSERT INTO rating_criteria VALUES (4,'%1')").arg(i18n("Originality") ) ); - database->exec( QString("INSERT INTO rating_criteria VALUES (5,'%1')").arg(i18n("Ease of Preparation") ) ); + database->exec( TQString("INSERT INTO rating_criteria VALUES (1,'%1')").arg(i18n("Overall")) ); + database->exec( TQString("INSERT INTO rating_criteria VALUES (2,'%1')").arg(i18n("Taste") ) ); + database->exec( TQString("INSERT INTO rating_criteria VALUES (3,'%1')").arg(i18n("Appearance") ) ); + database->exec( TQString("INSERT INTO rating_criteria VALUES (4,'%1')").arg(i18n("Originality") ) ); + database->exec( TQString("INSERT INTO rating_criteria VALUES (5,'%1')").arg(i18n("Ease of Preparation") ) ); database->exec( "UPDATE db_info SET ver='0.87',generated_by='Krecipes SVN (20051014)'" ); } - if ( qRound(version*100) < 90 ) { + if ( tqRound(version*100) < 90 ) { database->exec("UPDATE db_info SET ver='0.9',generated_by='Krecipes 0.9'"); } - if ( qRound(version*100) < 91 ) { + if ( tqRound(version*100) < 91 ) { database->exec("CREATE index parent_id_index ON categories(parent_id)"); database->exec("UPDATE db_info SET ver='0.91',generated_by='Krecipes SVN (20060526)'"); } - if ( qRound(version*100) < 92 ) { + if ( tqRound(version*100) < 92 ) { database->transaction(); //==================add a columns to 'units' to allow unit abbreviations database->exec( "CREATE TABLE units_copy (id INTEGER NOT NULL, name VARCHAR(20), plural VARCHAR(20))" ); - QSqlQuery copyQuery = database->exec( "SELECT id,name,plural FROM units" ); + TQSqlQuery copyQuery = database->exec( "SELECT id,name,plural FROM units" ); if ( copyQuery.isActive() ) { while ( copyQuery.next() ) { @@ -810,7 +810,7 @@ void LiteRecipeDB::portOldDatabases( float version ) kdDebug()<<"Update to 0.92 failed. Maybe you should try again."<<endl; } - if ( qRound(version*100) < 93 ) { + if ( tqRound(version*100) < 93 ) { database->transaction(); addColumn("CREATE TABLE %1 (id INTEGER NOT NULL, recipe_id INTEGER, ingredient_id INTEGER, amount FLOAT, amount_offset FLOAT, unit_id INTEGER, order_index INTEGER, group_id INTEGER, %2 PRIMARY KEY(id) )","substitute_for INTEGER","NULL","ingredient_list",8); @@ -823,23 +823,23 @@ void LiteRecipeDB::portOldDatabases( float version ) database->commit(); } - if ( qRound(version*100) < 94 ) { + if ( tqRound(version*100) < 94 ) { database->transaction(); //==================add a column to 'units' to allow specifying a type database->exec( "CREATE TABLE units_copy (id INTEGER NOT NULL, name VARCHAR(20), name_abbrev VARCHAR(20), plural VARCHAR(20), plural_abbrev VARCHAR(20))" ); - QSqlQuery copyQuery = database->exec( "SELECT id,name,name_abbrev,plural,plural_abbrev FROM units" ); + TQSqlQuery copyQuery = database->exec( "SELECT id,name,name_abbrev,plural,plural_abbrev FROM units" ); if ( copyQuery.isActive() ) { while ( copyQuery.next() ) { - QString name_abbrev = escape( copyQuery.value( 2 ).toString() ); + TQString name_abbrev = escape( copyQuery.value( 2 ).toString() ); if ( name_abbrev.isEmpty() ) name_abbrev = "NULL"; else { name_abbrev.prepend("'"); name_abbrev.append("'"); } - QString plural_abbrev = escape( copyQuery.value( 4 ).toString() ); + TQString plural_abbrev = escape( copyQuery.value( 4 ).toString() ); if ( plural_abbrev.isEmpty() ) plural_abbrev = "NULL"; else { @@ -865,14 +865,14 @@ void LiteRecipeDB::portOldDatabases( float version ) if ( copyQuery.isActive() ) { while ( copyQuery.next() ) { - QString name_abbrev = escape( copyQuery.value( 2 ).toString() ); + TQString name_abbrev = escape( copyQuery.value( 2 ).toString() ); if ( name_abbrev.isEmpty() ) name_abbrev = "NULL"; else { name_abbrev.prepend("'"); name_abbrev.append("'"); } - QString plural_abbrev = escape( copyQuery.value( 4 ).toString() ); + TQString plural_abbrev = escape( copyQuery.value( 4 ).toString() ); if ( plural_abbrev.isEmpty() ) plural_abbrev = "NULL"; else { @@ -899,32 +899,32 @@ void LiteRecipeDB::portOldDatabases( float version ) database->commit(); } - if ( qRound(version*100) < 95 ) { + if ( tqRound(version*100) < 95 ) { database->exec( "DROP TABLE ingredient_weights" ); createTable( "ingredient_weights" ); database->exec( "UPDATE db_info SET ver='0.95',generated_by='Krecipes SVN (20060726)'" ); } } -void LiteRecipeDB::addColumn( const QString &new_table_sql, const QString &new_col_info, const QString &default_value, const QString &table_name, int col_index ) +void LiteRecipeDB::addColumn( const TQString &new_table_sql, const TQString &new_col_info, const TQString &default_value, const TQString &table_name, int col_index ) { - QString command; + TQString command; - command = QString(new_table_sql).arg(table_name+"_copy").arg(QString::null); + command = TQString(new_table_sql).arg(table_name+"_copy").arg(TQString::null); kdDebug()<<"calling: "<<command<<endl; database->exec( command ); command = "SELECT * FROM "+table_name; kdDebug()<<"calling: "<<command<<endl; - QSqlQuery copyQuery = database->exec( command ); + TQSqlQuery copyQuery = database->exec( command ); if ( copyQuery.isActive() ) { while ( copyQuery.next() ) { - QStringList dataList; + TQStringList dataList; for ( int i = 0 ;; ++i ) { if ( copyQuery.value(i).isNull() ) break; - QString data = copyQuery.value(i).toString(); + TQString data = copyQuery.value(i).toString(); dataList << "'"+escape(data)+"'"; } @@ -936,11 +936,11 @@ void LiteRecipeDB::addColumn( const QString &new_table_sql, const QString &new_c } } database->exec( "DROP TABLE "+table_name ); - database->exec( QString(new_table_sql).arg(table_name).arg(new_col_info+",") ); + database->exec( TQString(new_table_sql).arg(table_name).arg(new_col_info+",") ); copyQuery = database->exec( "SELECT * FROM "+table_name+"_copy" ); if ( copyQuery.isActive() ) { while ( copyQuery.next() ) { - QStringList dataList; + TQStringList dataList; for ( int i = 0 ;; ++i ) { if ( i == col_index ) dataList << default_value; @@ -948,7 +948,7 @@ void LiteRecipeDB::addColumn( const QString &new_table_sql, const QString &new_c if ( copyQuery.value(i).isNull() ) break; - QString data = copyQuery.value(i).toString(); + TQString data = copyQuery.value(i).toString(); dataList << "'"+escape(data)+"'"; } @@ -962,12 +962,12 @@ void LiteRecipeDB::addColumn( const QString &new_table_sql, const QString &new_c database->exec( "DROP TABLE "+table_name+"_copy" ); } -QString LiteRecipeDB::escapeAndEncode( const QString &s ) const +TQString LiteRecipeDB::escapeAndEncode( const TQString &s ) const { - QString s_escaped; + TQString s_escaped; // Escape - s_escaped = escape( QString::fromLatin1(s.utf8()) ); + s_escaped = escape( TQString::fromLatin1(s.utf8()) ); // Return encoded return s_escaped.latin1(); // Note that the text has already been converted before escaping. @@ -1009,9 +1009,9 @@ int sqlite_decode_binary( const unsigned char *in, unsigned char *out ) return i; } -QString escape( const QString &s ) +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 |