summaryrefslogtreecommitdiffstats
path: root/krecipes/src/backends/qsqlrecipedb.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'krecipes/src/backends/qsqlrecipedb.cpp')
-rw-r--r--krecipes/src/backends/qsqlrecipedb.cpp1224
1 files changed, 612 insertions, 612 deletions
diff --git a/krecipes/src/backends/qsqlrecipedb.cpp b/krecipes/src/backends/qsqlrecipedb.cpp
index 1192f43..3291f44 100644
--- a/krecipes/src/backends/qsqlrecipedb.cpp
+++ b/krecipes/src/backends/qsqlrecipedb.cpp
@@ -21,9 +21,9 @@
#include "propertycalculator.h"
-#include <qbuffer.h>
-#include <qtextcodec.h>
-#include <qvariant.h>
+#include <ntqbuffer.h>
+#include <ntqtextcodec.h>
+#include <ntqvariant.h>
#include <kapplication.h>
#include <kdebug.h>
@@ -33,10 +33,10 @@
#include <kmessagebox.h>
#include <kmdcodec.h>
-int QSqlRecipeDB::m_refCount = 0;
+int TQSqlRecipeDB::m_refCount = 0;
-QSqlRecipeDB::QSqlRecipeDB( const QString &host, const QString &user, const QString &pass, const QString &name, int port ) : RecipeDB(),
- connectionName("connection" + QString::number( m_refCount+1 ))
+TQSqlRecipeDB::TQSqlRecipeDB( const TQString &host, const TQString &user, const TQString &pass, const TQString &name, int port ) : RecipeDB(),
+ connectionName("connection" + TQString::number( m_refCount+1 ))
{
DBuser = user;
DBpass = pass;
@@ -47,22 +47,22 @@ QSqlRecipeDB::QSqlRecipeDB( const QString &host, const QString &user, const QStr
dbOK = false; //it isn't ok until we've connect()'ed
++m_refCount;
- QTextCodec::setCodecForCStrings(QTextCodec::codecForName("Latin1")); //this is the default, but let's explicitly set this to be sure
+ TQTextCodec::setCodecForCStrings(TQTextCodec::codecForName("Latin1")); //this is the default, but let's explicitly set this to be sure
}
-QSqlRecipeDB::~QSqlRecipeDB()
+TQSqlRecipeDB::~TQSqlRecipeDB()
{
if ( dbOK ) {
database->close();
}
- QSqlDatabase::removeDatabase( connectionName );
+ TQSqlDatabase::removeDatabase( connectionName );
--m_refCount;
}
-void QSqlRecipeDB::connect( bool create_db, bool create_tables )
+void TQSqlRecipeDB::connect( bool create_db, bool create_tables )
{
- kdDebug() << i18n( "QSqlRecipeDB: Opening Database..." ) << endl;
+ kdDebug() << i18n( "TQSqlRecipeDB: Opening Database..." ) << endl;
kdDebug() << "Parameters: \n\thost: " << DBhost << "\n\tuser: " << DBuser << "\n\ttable: " << DBname << endl;
bool driver_found = false;
@@ -70,8 +70,8 @@ void QSqlRecipeDB::connect( bool create_db, bool create_tables )
if ( qsqlDriver() ) //we're using a built-in driver
driver_found = true;
else {
- QStringList drivers = QSqlDatabase::drivers();
- for ( QStringList::const_iterator it = drivers.begin(); it != drivers.end(); ++it ) {
+ TQStringList drivers = TQSqlDatabase::drivers();
+ for ( TQStringList::const_iterator it = drivers.begin(); it != drivers.end(); ++it ) {
if ( ( *it ) == qsqlDriverPlugin() ) {
driver_found = true;
break;
@@ -80,15 +80,15 @@ void QSqlRecipeDB::connect( bool create_db, bool create_tables )
}
if ( !driver_found ) {
- dbErr = QString( i18n( "The Qt database plug-in (%1) is not installed. This plug-in is required for using this database backend." ) ).arg( qsqlDriverPlugin() );
+ dbErr = TQString( i18n( "The TQt database plug-in (%1) is not installed. This plug-in is required for using this database backend." ) ).arg( qsqlDriverPlugin() );
return ;
}
- //we need to have a unique connection name for each QSqlRecipeDB class as multiple db's may be open at once (db to db transfer)
+ //we need to have a unique connection name for each TQSqlRecipeDB class as multiple db's may be open at once (db to db transfer)
if ( qsqlDriver() )
- database = QSqlDatabase::addDatabase( qsqlDriver(), connectionName );
+ database = TQSqlDatabase::addDatabase( qsqlDriver(), connectionName );
else if ( !qsqlDriverPlugin().isEmpty() )
- database = QSqlDatabase::addDatabase( qsqlDriverPlugin(), connectionName );
+ database = TQSqlDatabase::addDatabase( qsqlDriverPlugin(), connectionName );
else
kdDebug()<<"Fatal internal error! Backend incorrectly written!"<<endl;
@@ -111,21 +111,21 @@ void QSqlRecipeDB::connect( bool create_db, bool create_tables )
}
else {
// Handle the error (passively)
- dbErr = QString( i18n( "Krecipes could not open the database using the driver '%2' (with username: \"%1\"). You may not have the necessary permissions, or the server may be down." ) ).arg( DBuser ).arg( qsqlDriverPlugin() );
+ dbErr = TQString( i18n( "Krecipes could not open the database using the driver '%2' (with username: \"%1\"). You may not have the necessary permissions, or the server may be down." ) ).arg( DBuser ).arg( qsqlDriverPlugin() );
}
//Now Reopen the Database and signal & exit if it fails
if ( !database->open() ) {
- QString error = i18n( "Database message: %1" ).arg( database->lastError().databaseText() );
+ TQString error = i18n( "Database message: %1" ).arg( database->lastError().databaseText() );
kdDebug() << i18n( "Failing to open database. Exiting\n" ).latin1();
// Handle the error (passively)
- dbErr = QString( i18n( "Krecipes could not open the database using the driver '%2' (with username: \"%1\"). You may not have the necessary permissions, or the server may be down." ) ).arg( DBuser ).arg( qsqlDriverPlugin() );
+ dbErr = TQString( i18n( "Krecipes could not open the database using the driver '%2' (with username: \"%1\"). You may not have the necessary permissions, or the server may be down." ) ).arg( DBuser ).arg( qsqlDriverPlugin() );
return ;
}
}
- if ( int( qRound( databaseVersion() * 1e5 ) ) > int( qRound( latestDBVersion() * 1e5 ) ) ) { //correct for float's imprecision
+ if ( int( tqRound( databaseVersion() * 1e5 ) ) > int( tqRound( latestDBVersion() * 1e5 ) ) ) { //correct for float's imprecision
dbErr = i18n( "This database was created with a newer version of Krecipes and cannot be opened." );
return ;
}
@@ -140,30 +140,30 @@ void QSqlRecipeDB::connect( bool create_db, bool create_tables )
}
// Database was opened correctly
- m_query = QSqlQuery( QString::null, database );
+ m_query = TQSqlQuery( TQString::null, database );
m_query.setForwardOnly(true);
dbOK = true;
}
-void QSqlRecipeDB::execSQL( const QString &command )
+void TQSqlRecipeDB::execSQL( const TQString &command )
{
database->exec( command );
}
-void QSqlRecipeDB::loadRecipes( RecipeList *rlist, int items, QValueList<int> ids )
+void TQSqlRecipeDB::loadRecipes( RecipeList *rlist, int items, TQValueList<int> ids )
{
// Empty the recipe first
rlist->empty();
- QMap <int, RecipeList::Iterator> recipeIterators; // Stores the iterator of each recipe in the list;
+ TQMap <int, RecipeList::Iterator> recipeIterators; // Stores the iterator of each recipe in the list;
- QString command;
+ TQString command;
- QString current_timestamp = QDateTime::currentDateTime().toString(Qt::ISODate);
+ TQString current_timestamp = TQDateTime::currentDateTime().toString(TQt::ISODate);
- QStringList ids_str;
- for ( QValueList<int>::const_iterator it = ids.begin(); it != ids.end(); ++it ) {
- QString number_str = QString::number(*it);
+ TQStringList ids_str;
+ for ( TQValueList<int>::const_iterator it = ids.begin(); it != ids.end(); ++it ) {
+ TQString number_str = TQString::number(*it);
ids_str << number_str;
if ( !(items & RecipeDB::Noatime) )
@@ -178,7 +178,7 @@ void QSqlRecipeDB::loadRecipes( RecipeList *rlist, int items, QValueList<int> id
if ( items & RecipeDB::Yield ) command += ",yield_amount,yield_amount_offset,yield_type_id";
command += " FROM recipes"+(ids_str.count()!=0?" WHERE id IN ("+ids_str.join(",")+")":"");
- QSqlQuery recipeQuery(command,database);
+ TQSqlQuery recipeQuery(command,database);
if ( recipeQuery.isActive() ) {
while ( recipeQuery.next() ) {
int row_at = 0;
@@ -203,8 +203,8 @@ void QSqlRecipeDB::loadRecipes( RecipeList *rlist, int items, QValueList<int> id
recipe.yield.amount_offset = recipeQuery.value( row_at ).toDouble(); ++row_at;
recipe.yield.type_id = recipeQuery.value( row_at ).toInt(); ++row_at;
if ( recipe.yield.type_id != -1 ) {
- QString y_command = QString("SELECT name FROM yield_types WHERE id=%1;").arg(recipe.yield.type_id);
- QSqlQuery yield_query(y_command,database);
+ TQString y_command = TQString("SELECT name FROM yield_types WHERE id=%1;").arg(recipe.yield.type_id);
+ TQSqlQuery yield_query(y_command,database);
if ( yield_query.isActive() && yield_query.first() )
recipe.yield.type = unescapeAndDecode(yield_query.value( 0 ).toCString());
else
@@ -224,14 +224,14 @@ void QSqlRecipeDB::loadRecipes( RecipeList *rlist, int items, QValueList<int> id
for ( RecipeList::iterator recipe_it = rlist->begin(); recipe_it != rlist->end(); ++recipe_it ) {
if ( items & RecipeDB::NamesOnly ) {
if ( items & IngredientAmounts )
- command = QString( "SELECT il.ingredient_id,i.name,il.substitute_for,il.amount,il.amount_offset,u.id,u.type FROM ingredients i, ingredient_list il, units u WHERE il.recipe_id=%1 AND i.id=il.ingredient_id AND u.id=il.unit_id ORDER BY il.order_index" ).arg( (*recipe_it).recipeID );
+ command = TQString( "SELECT il.ingredient_id,i.name,il.substitute_for,il.amount,il.amount_offset,u.id,u.type FROM ingredients i, ingredient_list il, units u WHERE il.recipe_id=%1 AND i.id=il.ingredient_id AND u.id=il.unit_id ORDER BY il.order_index" ).arg( (*recipe_it).recipeID );
else
- command = QString( "SELECT il.ingredient_id,i.name,il.substitute_for FROM ingredients i, ingredient_list il WHERE il.recipe_id=%1 AND i.id=il.ingredient_id" ).arg( (*recipe_it).recipeID );
+ command = TQString( "SELECT il.ingredient_id,i.name,il.substitute_for FROM ingredients i, ingredient_list il WHERE il.recipe_id=%1 AND i.id=il.ingredient_id" ).arg( (*recipe_it).recipeID );
}
else
- command = QString( "SELECT il.ingredient_id,i.name,il.substitute_for,il.amount,il.amount_offset,u.id,u.name,u.plural,u.name_abbrev,u.plural_abbrev,u.type,il.group_id,il.id FROM ingredients i, ingredient_list il, units u WHERE il.recipe_id=%1 AND i.id=il.ingredient_id AND u.id=il.unit_id ORDER BY il.order_index" ).arg( (*recipe_it).recipeID );
+ command = TQString( "SELECT il.ingredient_id,i.name,il.substitute_for,il.amount,il.amount_offset,u.id,u.name,u.plural,u.name_abbrev,u.plural_abbrev,u.type,il.group_id,il.id FROM ingredients i, ingredient_list il, units u WHERE il.recipe_id=%1 AND i.id=il.ingredient_id AND u.id=il.unit_id ORDER BY il.order_index" ).arg( (*recipe_it).recipeID );
- QSqlQuery ingredientQuery( command, database );
+ TQSqlQuery ingredientQuery( command, database );
if ( ingredientQuery.isActive() ) {
RecipeList::Iterator it = recipeIterators[ (*recipe_it).recipeID ];
while ( ingredientQuery.next() ) {
@@ -265,13 +265,13 @@ void QSqlRecipeDB::loadRecipes( RecipeList *rlist, int items, QValueList<int> id
ing.groupID = ingredientQuery.value( 11 ).toInt();
if ( ing.groupID != -1 ) {
- QSqlQuery toLoad( QString( "SELECT name FROM ingredient_groups WHERE id=%1" ).arg( ing.groupID ), database );
+ TQSqlQuery toLoad( TQString( "SELECT name FROM ingredient_groups WHERE id=%1" ).arg( ing.groupID ), database );
if ( toLoad.isActive() && toLoad.first() )
ing.group = unescapeAndDecode( toLoad.value( 0 ).toCString() );
}
- command = QString("SELECT pl.prep_method_id,p.name FROM prep_methods p, prep_method_list pl WHERE pl.ingredient_list_id=%1 AND p.id=pl.prep_method_id ORDER BY pl.order_index;").arg(ingredientQuery.value( 12 ).toInt());
- QSqlQuery ingPrepMethodsQuery( command, database );
+ command = TQString("SELECT pl.prep_method_id,p.name FROM prep_methods p, prep_method_list pl WHERE pl.ingredient_list_id=%1 AND p.id=pl.prep_method_id ORDER BY pl.order_index;").arg(ingredientQuery.value( 12 ).toInt());
+ TQSqlQuery ingPrepMethodsQuery( command, database );
if ( ingPrepMethodsQuery.isActive() ) {
while ( ingPrepMethodsQuery.next() ) {
ing.prepMethodList.append( Element( unescapeAndDecode(ingPrepMethodsQuery.value(1).toCString()),ingPrepMethodsQuery.value(0).toInt()) );
@@ -305,7 +305,7 @@ void QSqlRecipeDB::loadRecipes( RecipeList *rlist, int items, QValueList<int> id
for ( RecipeList::iterator recipe_it = rlist->begin(); recipe_it != rlist->end(); ++recipe_it ) {
RecipeList::iterator it = recipeIterators[ (*recipe_it).recipeID ];
- command = QString( "SELECT cl.category_id,c.name FROM category_list cl, categories c WHERE recipe_id=%1 AND cl.category_id=c.id;" ).arg( (*it).recipeID );
+ command = TQString( "SELECT cl.category_id,c.name FROM category_list cl, categories c WHERE recipe_id=%1 AND cl.category_id=c.id;" ).arg( (*it).recipeID );
m_query.exec( command );
if ( m_query.isActive() ) {
@@ -324,7 +324,7 @@ void QSqlRecipeDB::loadRecipes( RecipeList *rlist, int items, QValueList<int> id
for ( RecipeList::iterator recipe_it = rlist->begin(); recipe_it != rlist->end(); ++recipe_it ) {
RecipeList::iterator it = recipeIterators[ (*recipe_it).recipeID ];
- command = QString( "SELECT al.author_id,a.name FROM author_list al, authors a WHERE recipe_id=%1 AND al.author_id=a.id;" ).arg( (*it).recipeID );
+ command = TQString( "SELECT al.author_id,a.name FROM author_list al, authors a WHERE recipe_id=%1 AND al.author_id=a.id;" ).arg( (*it).recipeID );
m_query.exec( command );
if ( m_query.isActive() ) {
@@ -343,8 +343,8 @@ void QSqlRecipeDB::loadRecipes( RecipeList *rlist, int items, QValueList<int> id
for ( RecipeList::iterator recipe_it = rlist->begin(); recipe_it != rlist->end(); ++recipe_it ) {
RecipeList::iterator it = recipeIterators[ (*recipe_it).recipeID ];
- command = QString( "SELECT id,comment,rater FROM ratings WHERE recipe_id=%1 ORDER BY created DESC" ).arg( (*it).recipeID );
- QSqlQuery query( command, database );
+ command = TQString( "SELECT id,comment,rater FROM ratings WHERE recipe_id=%1 ORDER BY created DESC" ).arg( (*it).recipeID );
+ TQSqlQuery query( command, database );
if ( query.isActive() ) {
while ( query.next() ) {
Rating r;
@@ -352,8 +352,8 @@ void QSqlRecipeDB::loadRecipes( RecipeList *rlist, int items, QValueList<int> id
r.comment = unescapeAndDecode( query.value( 1 ).toCString() );
r.rater = unescapeAndDecode( query.value( 2 ).toCString() );
- command = QString( "SELECT rc.id,rc.name,rl.stars FROM rating_criteria rc, rating_criterion_list rl WHERE rating_id=%1 AND rl.rating_criterion_id=rc.id" ).arg(r.id);
- QSqlQuery criterionQuery( command, database );
+ command = TQString( "SELECT rc.id,rc.name,rl.stars FROM rating_criteria rc, rating_criterion_list rl WHERE rating_id=%1 AND rl.rating_criterion_id=rc.id" ).arg(r.id);
+ TQSqlQuery criterionQuery( command, database );
if ( criterionQuery.isActive() ) {
while ( criterionQuery.next() ) {
RatingCriteria rc;
@@ -378,11 +378,11 @@ void QSqlRecipeDB::loadRecipes( RecipeList *rlist, int items, QValueList<int> id
}
}
-void QSqlRecipeDB::loadIngredientGroups( ElementList *list )
+void TQSqlRecipeDB::loadIngredientGroups( ElementList *list )
{
list->clear();
- QString command = "SELECT id,name FROM ingredient_groups ORDER BY name;";
+ TQString command = "SELECT id,name FROM ingredient_groups ORDER BY name;";
m_query.exec( command );
if ( m_query.isActive() ) {
@@ -395,12 +395,12 @@ void QSqlRecipeDB::loadIngredientGroups( ElementList *list )
}
}
-void QSqlRecipeDB::loadIngredients( ElementList *list, int limit, int offset )
+void TQSqlRecipeDB::loadIngredients( ElementList *list, int limit, int offset )
{
list->clear();
- QString command = "SELECT id,name FROM ingredients ORDER BY name"
- +((limit==-1)?"":" LIMIT "+QString::number(limit)+" OFFSET "+QString::number(offset));
+ TQString command = "SELECT id,name FROM ingredients ORDER BY name"
+ +((limit==-1)?"":" LIMIT "+TQString::number(limit)+" OFFSET "+TQString::number(offset));
m_query.exec( command );
if ( m_query.isActive() ) {
@@ -413,12 +413,12 @@ void QSqlRecipeDB::loadIngredients( ElementList *list, int limit, int offset )
}
}
-void QSqlRecipeDB::loadPrepMethods( ElementList *list, int limit, int offset )
+void TQSqlRecipeDB::loadPrepMethods( ElementList *list, int limit, int offset )
{
list->clear();
- QString command = "SELECT id,name FROM prep_methods ORDER BY name"
- +((limit==-1)?"":" LIMIT "+QString::number(limit)+" OFFSET "+QString::number(offset));
+ TQString command = "SELECT id,name FROM prep_methods ORDER BY name"
+ +((limit==-1)?"":" LIMIT "+TQString::number(limit)+" OFFSET "+TQString::number(offset));
m_query.exec( command );
if ( m_query.isActive() ) {
@@ -431,12 +431,12 @@ void QSqlRecipeDB::loadPrepMethods( ElementList *list, int limit, int offset )
}
}
-void QSqlRecipeDB::loadYieldTypes( ElementList *list, int limit, int offset )
+void TQSqlRecipeDB::loadYieldTypes( ElementList *list, int limit, int offset )
{
list->clear();
- QString command = "SELECT id,name FROM yield_types ORDER BY name"
- +((limit==-1)?"":" LIMIT "+QString::number(limit)+" OFFSET "+QString::number(offset));
+ TQString command = "SELECT id,name FROM yield_types ORDER BY name"
+ +((limit==-1)?"":" LIMIT "+TQString::number(limit)+" OFFSET "+TQString::number(offset));
m_query.exec( command );
if ( m_query.isActive() ) {
@@ -449,48 +449,48 @@ void QSqlRecipeDB::loadYieldTypes( ElementList *list, int limit, int offset )
}
}
-void QSqlRecipeDB::createNewPrepMethod( const QString &prepMethodName )
+void TQSqlRecipeDB::createNewPrepMethod( const TQString &prepMethodName )
{
- QString command;
- QString real_name = prepMethodName.left( maxPrepMethodNameLength() );
+ TQString command;
+ TQString real_name = prepMethodName.left( maxPrepMethodNameLength() );
- command = QString( "INSERT INTO prep_methods VALUES(%2,'%1');" ).arg( escapeAndEncode( real_name ) ).arg( getNextInsertIDStr( "prep_methods", "id" ) );
- QSqlQuery prepMethodToCreate( command, database );
+ command = TQString( "INSERT INTO prep_methods VALUES(%2,'%1');" ).arg( escapeAndEncode( real_name ) ).arg( getNextInsertIDStr( "prep_methods", "id" ) );
+ TQSqlQuery prepMethodToCreate( command, database );
emit prepMethodCreated( Element( real_name, lastInsertID() ) );
}
-void QSqlRecipeDB::modPrepMethod( int prepMethodID, const QString &newLabel )
+void TQSqlRecipeDB::modPrepMethod( int prepMethodID, const TQString &newLabel )
{
- QString command;
+ TQString command;
- command = QString( "UPDATE prep_methods SET name='%1' WHERE id=%2;" ).arg( escapeAndEncode( newLabel ) ).arg( prepMethodID );
- QSqlQuery prepMethodToCreate( command, database );
+ command = TQString( "UPDATE prep_methods SET name='%1' WHERE id=%2;" ).arg( escapeAndEncode( newLabel ) ).arg( prepMethodID );
+ TQSqlQuery prepMethodToCreate( command, database );
emit prepMethodRemoved( prepMethodID );
emit prepMethodCreated( Element( newLabel, prepMethodID ) );
}
-void QSqlRecipeDB::modProperty( int propertyID, const QString &newLabel )
+void TQSqlRecipeDB::modProperty( int propertyID, const TQString &newLabel )
{
- QString command;
+ TQString command;
- command = QString( "UPDATE ingredient_properties SET name='%1' WHERE id=%2;" ).arg( escapeAndEncode( newLabel ) ).arg( propertyID );
- QSqlQuery createQuery( command, database );
+ command = TQString( "UPDATE ingredient_properties SET name='%1' WHERE id=%2;" ).arg( escapeAndEncode( newLabel ) ).arg( propertyID );
+ TQSqlQuery createQuery( command, database );
emit propertyRemoved( propertyID );
emit propertyCreated( propertyName( propertyID ) );
}
-void QSqlRecipeDB::loadPossibleUnits( int ingredientID, UnitList *list )
+void TQSqlRecipeDB::loadPossibleUnits( int ingredientID, UnitList *list )
{
list->clear();
- QString command;
+ TQString command;
- command = QString( "SELECT u.id,u.name,u.plural,u.name_abbrev,u.plural_abbrev,u.type FROM unit_list ul, units u WHERE ul.ingredient_id=%1 AND ul.unit_id=u.id;" ).arg( ingredientID );
+ command = TQString( "SELECT u.id,u.name,u.plural,u.name_abbrev,u.plural_abbrev,u.type FROM unit_list ul, units u WHERE ul.ingredient_id=%1 AND ul.unit_id=u.id;" ).arg( ingredientID );
- QSqlQuery unitToLoad( command, database );
+ TQSqlQuery unitToLoad( command, database );
if ( unitToLoad.isActive() ) {
while ( unitToLoad.next() ) {
@@ -509,28 +509,28 @@ void QSqlRecipeDB::loadPossibleUnits( int ingredientID, UnitList *list )
}
-void QSqlRecipeDB::storePhoto( int recipeID, const QByteArray &data )
+void TQSqlRecipeDB::storePhoto( int recipeID, const TQByteArray &data )
{
- QSqlQuery query( QString::null, database );
+ TQSqlQuery query( TQString::null, database );
- query.prepare( "UPDATE recipes SET photo=?,ctime=ctime,atime=atime,mtime=mtime WHERE id=" + QString::number( recipeID ) );
+ query.prepare( "UPDATE recipes SET photo=?,ctime=ctime,atime=atime,mtime=mtime WHERE id=" + TQString::number( recipeID ) );
query.addBindValue( KCodecs::base64Encode( data ) );
query.exec();
}
-void QSqlRecipeDB::loadPhoto( int recipeID, QPixmap &photo )
+void TQSqlRecipeDB::loadPhoto( int recipeID, TQPixmap &photo )
{
- QString command = QString( "SELECT photo FROM recipes WHERE id=%1;" ).arg( recipeID );
- QSqlQuery query( command, database );
+ TQString command = TQString( "SELECT photo FROM recipes WHERE id=%1;" ).arg( recipeID );
+ TQSqlQuery query( command, database );
if ( query.isActive() && query.first() ) {
- QCString decodedPic;
- QPixmap pix;
+ TQCString decodedPic;
+ TQPixmap pix;
KCodecs::base64Decode( query.value( 0 ).toCString(), decodedPic );
int len = decodedPic.size();
if ( len > 0 ) {
- QByteArray picData( len );
+ TQByteArray picData( len );
memcpy( picData.data(), decodedPic.data(), len );
bool ok = pix.loadFromData( picData, "JPEG" );
@@ -540,11 +540,11 @@ void QSqlRecipeDB::loadPhoto( int recipeID, QPixmap &photo )
}
}
-void QSqlRecipeDB::loadRecipeMetadata( Recipe *recipe )
+void TQSqlRecipeDB::loadRecipeMetadata( Recipe *recipe )
{
- QString command = "SELECT ctime,mtime,atime FROM recipes WHERE id="+QString::number(recipe->recipeID);
+ TQString command = "SELECT ctime,mtime,atime FROM recipes WHERE id="+TQString::number(recipe->recipeID);
- QSqlQuery query( command, database );
+ TQSqlQuery query( command, database );
if ( query.isActive() && query.first() ) {
recipe->ctime = query.value(0).toDateTime();
recipe->mtime = query.value(1).toDateTime();
@@ -552,7 +552,7 @@ void QSqlRecipeDB::loadRecipeMetadata( Recipe *recipe )
}
}
-void QSqlRecipeDB::saveRecipe( Recipe *recipe )
+void TQSqlRecipeDB::saveRecipe( Recipe *recipe )
{
// Check if it's a new recipe or it exists (supossedly) already.
@@ -561,14 +561,14 @@ void QSqlRecipeDB::saveRecipe( Recipe *recipe )
// First check if the recipe ID is set, if so, update (not create)
// Be carefull, first check if the recipe hasn't been deleted while changing.
- QSqlQuery recipeToSave( QString::null, database );
+ TQSqlQuery recipeToSave( TQString::null, database );
- QString command;
+ TQString command;
- QDateTime current_datetime = QDateTime::currentDateTime();
- QString current_timestamp = current_datetime.toString(Qt::ISODate);
+ TQDateTime current_datetime = TQDateTime::currentDateTime();
+ TQString current_timestamp = current_datetime.toString(TQt::ISODate);
if ( newRecipe ) {
- command = QString( "INSERT INTO recipes VALUES ("+getNextInsertIDStr("recipes","id")+",'%1',%2,'%3','%4','%5',NULL,'%6','%7','%8','%9');" ) // Id is autoincremented
+ command = TQString( "INSERT INTO recipes VALUES ("+getNextInsertIDStr("recipes","id")+",'%1',%2,'%3','%4','%5',NULL,'%6','%7','%8','%9');" ) // Id is autoincremented
.arg( escapeAndEncode( recipe->title ) )
.arg( recipe->yield.amount )
.arg( recipe->yield.amount_offset )
@@ -581,7 +581,7 @@ void QSqlRecipeDB::saveRecipe( Recipe *recipe )
recipe->mtime = recipe->ctime = recipe->atime = current_datetime;
}
else {
- command = QString( "UPDATE recipes SET title='%1',yield_amount='%2',yield_amount_offset='%3',yield_type_id='%4',instructions='%5',prep_time='%6',mtime='%8',ctime=ctime,atime=atime WHERE id=%7;" )
+ command = TQString( "UPDATE recipes SET title='%1',yield_amount='%2',yield_amount_offset='%3',yield_type_id='%4',instructions='%5',prep_time='%6',mtime='%8',ctime=ctime,atime=atime WHERE id=%7;" )
.arg( escapeAndEncode( recipe->title ) )
.arg( recipe->yield.amount )
.arg( recipe->yield.amount_offset )
@@ -596,16 +596,16 @@ void QSqlRecipeDB::saveRecipe( Recipe *recipe )
if ( !newRecipe ) {
// Clean up yield_types which have no recipe that they belong to
- QStringList ids;
- command = QString( "SELECT DISTINCT(yield_type_id) FROM recipes" );
+ TQStringList ids;
+ command = TQString( "SELECT DISTINCT(yield_type_id) FROM recipes" );
recipeToSave.exec( command );
if ( recipeToSave.isActive() ) {
while ( recipeToSave.next() ) {
if ( recipeToSave.value( 0 ).toInt() != -1 )
- ids << QString::number( recipeToSave.value( 0 ).toInt() );
+ ids << TQString::number( recipeToSave.value( 0 ).toInt() );
}
}
- command = QString( "DELETE FROM yield_types WHERE id NOT IN ( %1 )" ).arg( ( ids.count() == 0 ) ? "-1" : ids.join( "," ) );
+ command = TQString( "DELETE FROM yield_types WHERE id NOT IN ( %1 )" ).arg( ( ids.count() == 0 ) ? "-1" : ids.join( "," ) );
recipeToSave.exec( command );
}
@@ -620,39 +620,39 @@ void QSqlRecipeDB::saveRecipe( Recipe *recipe )
// Let's begin storing the Image!
if ( !recipe->photo.isNull() ) {
- QByteArray ba;
- QBuffer buffer( ba );
+ TQByteArray ba;
+ TQBuffer buffer( ba );
buffer.open( IO_WriteOnly );
- QImageIO iio( &buffer, "JPEG" );
+ TQImageIO iio( &buffer, "JPEG" );
iio.setImage( recipe->photo.convertToImage() );
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( recipeID, ba );
}
else {
- recipeToSave.exec( "UPDATE recipes SET photo=NULL, mtime=mtime, ctime=ctime, atime=atime WHERE id=" + QString::number( recipeID ) );
+ recipeToSave.exec( "UPDATE recipes SET photo=NULL, mtime=mtime, ctime=ctime, atime=atime WHERE id=" + TQString::number( recipeID ) );
}
// Save the ingredient list (first delete if we are updating)
- command = QString( "SELECT id FROM ingredient_list WHERE recipe_id=%1" ).arg(recipeID);
+ command = TQString( "SELECT id FROM ingredient_list WHERE recipe_id=%1" ).arg(recipeID);
recipeToSave.exec( command );
if ( recipeToSave.isActive() ) {
while ( recipeToSave.next() ) {
- command = QString("DELETE FROM prep_method_list WHERE ingredient_list_id=%1")
+ command = TQString("DELETE FROM prep_method_list WHERE ingredient_list_id=%1")
.arg(recipeToSave.value(0).toInt());
database->exec(command);
}
}
- command = QString( "DELETE FROM ingredient_list WHERE recipe_id=%1;" )
+ command = TQString( "DELETE FROM ingredient_list WHERE recipe_id=%1;" )
.arg( recipeID );
recipeToSave.exec( command );
int order_index = 0;
for ( IngredientList::const_iterator ing_it = recipe->ingList.begin(); ing_it != recipe->ingList.end(); ++ing_it ) {
order_index++;
- QString ing_list_id_str = getNextInsertIDStr("ingredient_list","id");
- command = QString( "INSERT INTO ingredient_list VALUES (%1,%2,%3,%4,%5,%6,%7,%8,NULL);" )
+ TQString ing_list_id_str = getNextInsertIDStr("ingredient_list","id");
+ command = TQString( "INSERT INTO ingredient_list VALUES (%1,%2,%3,%4,%5,%6,%7,%8,NULL);" )
.arg( ing_list_id_str )
.arg( recipeID )
.arg( ( *ing_it ).ingredientID )
@@ -667,17 +667,17 @@ void QSqlRecipeDB::saveRecipe( Recipe *recipe )
int prep_order_index = 0;
for ( ElementList::const_iterator prep_it = (*ing_it).prepMethodList.begin(); prep_it != (*ing_it).prepMethodList.end(); ++prep_it ) {
prep_order_index++;
- command = QString( "INSERT INTO prep_method_list VALUES (%1,%2,%3);" )
+ command = TQString( "INSERT INTO prep_method_list VALUES (%1,%2,%3);" )
.arg( ing_list_id )
.arg( ( *prep_it ).id )
.arg( prep_order_index );
recipeToSave.exec( command );
}
- for ( QValueList<IngredientData>::const_iterator sub_it = (*ing_it).substitutes.begin(); sub_it != (*ing_it).substitutes.end(); ++sub_it ) {
+ for ( TQValueList<IngredientData>::const_iterator sub_it = (*ing_it).substitutes.begin(); sub_it != (*ing_it).substitutes.end(); ++sub_it ) {
order_index++;
- QString ing_list_id_str = getNextInsertIDStr("ingredient_list","id");
- command = QString( "INSERT INTO ingredient_list VALUES (%1,%2,%3,%4,%5,%6,%7,%8,%9);" )
+ TQString ing_list_id_str = getNextInsertIDStr("ingredient_list","id");
+ command = TQString( "INSERT INTO ingredient_list VALUES (%1,%2,%3,%4,%5,%6,%7,%8,%9);" )
.arg( ing_list_id_str )
.arg( recipeID )
.arg( ( *sub_it ).ingredientID )
@@ -693,7 +693,7 @@ void QSqlRecipeDB::saveRecipe( Recipe *recipe )
int prep_order_index = 0;
for ( ElementList::const_iterator prep_it = (*sub_it).prepMethodList.begin(); prep_it != (*sub_it).prepMethodList.end(); ++prep_it ) {
prep_order_index++;
- command = QString( "INSERT INTO prep_method_list VALUES (%1,%2,%3);" )
+ command = TQString( "INSERT INTO prep_method_list VALUES (%1,%2,%3);" )
.arg( ing_list_id )
.arg( ( *prep_it ).id )
.arg( prep_order_index );
@@ -703,14 +703,14 @@ void QSqlRecipeDB::saveRecipe( Recipe *recipe )
}
// Save the category list for the recipe (first delete, in case we are updating)
- command = QString( "DELETE FROM category_list WHERE recipe_id=%1;" )
+ command = TQString( "DELETE FROM category_list WHERE recipe_id=%1;" )
.arg( recipeID );
recipeToSave.exec( command );
ElementList::const_iterator cat_it = recipe->categoryList.end(); // Start from last, mysql seems to work in lifo format... so it's read first the latest inserted one (newest)
--cat_it;
for ( unsigned int i = 0; i < recipe->categoryList.count(); i++ ) {
- command = QString( "INSERT INTO category_list VALUES (%1,%2);" )
+ command = TQString( "INSERT INTO category_list VALUES (%1,%2);" )
.arg( recipeID )
.arg( ( *cat_it ).id );
recipeToSave.exec( command );
@@ -720,20 +720,20 @@ void QSqlRecipeDB::saveRecipe( Recipe *recipe )
//Add the default category -1 to ease and speed up searches
- command = QString( "INSERT INTO category_list VALUES (%1,-1);" )
+ command = TQString( "INSERT INTO category_list VALUES (%1,-1);" )
.arg( recipeID );
recipeToSave.exec( command );
// Save the author list for the recipe (first delete, in case we are updating)
- command = QString( "DELETE FROM author_list WHERE recipe_id=%1;" )
+ command = TQString( "DELETE FROM author_list WHERE recipe_id=%1;" )
.arg( recipeID );
recipeToSave.exec( command );
ElementList::const_iterator author_it = recipe->authorList.end(); // Start from last, mysql seems to work in lifo format... so it's read first the latest inserted one (newest)
--author_it;
for ( unsigned int i = 0; i < recipe->authorList.count(); i++ ) {
- command = QString( "INSERT INTO author_list VALUES (%1,%2);" )
+ command = TQString( "INSERT INTO author_list VALUES (%1,%2);" )
.arg( recipeID )
.arg( ( *author_it ).id );
recipeToSave.exec( command );
@@ -742,45 +742,45 @@ void QSqlRecipeDB::saveRecipe( Recipe *recipe )
}
// Save the ratings (first delete criterion list if we are updating)
- command = QString( "SELECT id FROM ratings WHERE recipe_id=%1" ).arg(recipeID);
+ command = TQString( "SELECT id FROM ratings WHERE recipe_id=%1" ).arg(recipeID);
recipeToSave.exec( command );
if ( recipeToSave.isActive() ) {
while ( recipeToSave.next() ) {
- command = QString("DELETE FROM rating_criterion_list WHERE rating_id=%1")
+ command = TQString("DELETE FROM rating_criterion_list WHERE rating_id=%1")
.arg(recipeToSave.value(0).toInt());
database->exec(command);
}
}
- QStringList ids;
+ TQStringList ids;
for ( RatingList::iterator rating_it = recipe->ratingList.begin(); rating_it != recipe->ratingList.end(); ++rating_it ) {
//double average = (*rating_it).average();
if ( (*rating_it).id == -1 ) //new rating
- command ="INSERT INTO ratings VALUES("+QString(getNextInsertIDStr("ratings","id"))+","+QString::number(recipeID)+",'"+QString(escapeAndEncode((*rating_it).comment))+"','"+QString(escapeAndEncode((*rating_it).rater))+/*"','"+QString::number(average)+*/"','"+current_timestamp+"')";
+ command ="INSERT INTO ratings VALUES("+TQString(getNextInsertIDStr("ratings","id"))+","+TQString::number(recipeID)+",'"+TQString(escapeAndEncode((*rating_it).comment))+"','"+TQString(escapeAndEncode((*rating_it).rater))+/*"','"+TQString::number(average)+*/"','"+current_timestamp+"')";
else //existing rating
command = "UPDATE ratings SET "
- "comment='"+QString(escapeAndEncode((*rating_it).comment))+"',"
- "rater='"+QString(escapeAndEncode((*rating_it).rater))+"',"
+ "comment='"+TQString(escapeAndEncode((*rating_it).comment))+"',"
+ "rater='"+TQString(escapeAndEncode((*rating_it).rater))+"',"
"created=created "
- "WHERE id="+QString::number((*rating_it).id);
+ "WHERE id="+TQString::number((*rating_it).id);
recipeToSave.exec( command );
if ( (*rating_it).id == -1 )
(*rating_it).id = lastInsertID();
- for ( QValueList<RatingCriteria>::const_iterator rc_it = (*rating_it).ratingCriteriaList.begin(); rc_it != (*rating_it).ratingCriteriaList.end(); ++rc_it ) {
- command = QString( "INSERT INTO rating_criterion_list VALUES("+QString::number((*rating_it).id)+","+QString::number((*rc_it).id)+","+QString::number((*rc_it).stars)+")" );
+ for ( TQValueList<RatingCriteria>::const_iterator rc_it = (*rating_it).ratingCriteriaList.begin(); rc_it != (*rating_it).ratingCriteriaList.end(); ++rc_it ) {
+ command = TQString( "INSERT INTO rating_criterion_list VALUES("+TQString::number((*rating_it).id)+","+TQString::number((*rc_it).id)+","+TQString::number((*rc_it).stars)+")" );
recipeToSave.exec( command );
}
- ids << QString::number((*rating_it).id);
+ ids << TQString::number((*rating_it).id);
}
// only delete those ratings that don't exist anymore
- command = QString( "DELETE FROM ratings WHERE recipe_id=%1 AND id NOT IN( %2 )" )
+ command = TQString( "DELETE FROM ratings WHERE recipe_id=%1 AND id NOT IN( %2 )" )
.arg( recipeID ).arg( ids.join(",") );
recipeToSave.exec( command );
@@ -790,17 +790,17 @@ void QSqlRecipeDB::saveRecipe( Recipe *recipe )
emit recipeModified( Element( recipe->title.left( maxRecipeTitleLength() ), recipeID ), recipe->categoryList );
}
-void QSqlRecipeDB::loadRecipeList( ElementList *list, int categoryID, bool recursive )
+void TQSqlRecipeDB::loadRecipeList( ElementList *list, int categoryID, bool recursive )
{
- QString command;
+ TQString command;
if ( categoryID == -1 ) // load just the list
command = "SELECT id,title FROM recipes;";
else // load the list of those in the specified category
- command = QString( "SELECT r.id,r.title FROM recipes r,category_list cl WHERE r.id=cl.recipe_id AND cl.category_id=%1 ORDER BY r.title" ).arg( categoryID );
+ command = TQString( "SELECT r.id,r.title FROM recipes r,category_list cl WHERE r.id=cl.recipe_id AND cl.category_id=%1 ORDER BY r.title" ).arg( categoryID );
if ( recursive ) {
- QSqlQuery subcategories( QString("SELECT id FROM categories WHERE parent_id='%1'").arg(categoryID), database );
+ TQSqlQuery subcategories( TQString("SELECT id FROM categories WHERE parent_id='%1'").arg(categoryID), database );
if ( subcategories.isActive() ) {
while ( subcategories.next() ) {
loadRecipeList(list,subcategories.value( 0 ).toInt(),true);
@@ -808,7 +808,7 @@ void QSqlRecipeDB::loadRecipeList( ElementList *list, int categoryID, bool recur
}
}
- QSqlQuery recipeToLoad( command, database );
+ TQSqlQuery recipeToLoad( command, database );
if ( recipeToLoad.isActive() ) {
while ( recipeToLoad.next() ) {
@@ -821,11 +821,11 @@ void QSqlRecipeDB::loadRecipeList( ElementList *list, int categoryID, bool recur
}
-void QSqlRecipeDB::loadUncategorizedRecipes( ElementList *list )
+void TQSqlRecipeDB::loadUncategorizedRecipes( ElementList *list )
{
list->clear();
- QString command = "SELECT r.id,r.title FROM recipes r,category_list cl WHERE r.id=cl.recipe_id GROUP BY id HAVING COUNT(*)=1 ORDER BY r.title DESC";
+ TQString command = "SELECT r.id,r.title FROM recipes r,category_list cl WHERE r.id=cl.recipe_id GROUP BY id HAVING COUNT(*)=1 ORDER BY r.title DESC";
m_query.exec( command );
if ( m_query.isActive() ) {
while ( m_query.next() ) {
@@ -839,157 +839,157 @@ void QSqlRecipeDB::loadUncategorizedRecipes( ElementList *list )
-void QSqlRecipeDB::removeRecipe( int id )
+void TQSqlRecipeDB::removeRecipe( int id )
{
emit recipeRemoved( id );
- QString command;
+ TQString command;
- command = QString( "DELETE FROM recipes WHERE id=%1;" ).arg( id );
- QSqlQuery recipeToRemove( command, database );
- command = QString( "DELETE FROM ingredient_list WHERE recipe_id=%1;" ).arg( id );
+ command = TQString( "DELETE FROM recipes WHERE id=%1;" ).arg( id );
+ TQSqlQuery recipeToRemove( command, database );
+ command = TQString( "DELETE FROM ingredient_list WHERE recipe_id=%1;" ).arg( id );
recipeToRemove.exec( command );
- command = QString( "DELETE FROM category_list WHERE recipe_id=%1;" ).arg( id );
+ command = TQString( "DELETE FROM category_list WHERE recipe_id=%1;" ).arg( id );
recipeToRemove.exec( command );
// Clean up ingredient_groups which have no recipe that they belong to
// MySQL doesn't support subqueries until 4.1, so we'll do this the long way
// (Easy way: DELETE FROM ingredient_groups WHERE id NOT IN ( SELECT DISTINCT(group_id) FROM ingredient_list );)
- QStringList ids;
- command = QString( "SELECT DISTINCT(group_id) FROM ingredient_list;" );
+ TQStringList ids;
+ command = TQString( "SELECT DISTINCT(group_id) FROM ingredient_list;" );
recipeToRemove.exec( command );
if ( recipeToRemove.isActive() ) {
while ( recipeToRemove.next() ) {
if ( recipeToRemove.value( 0 ).toInt() != -1 )
- ids << QString::number( recipeToRemove.value( 0 ).toInt() );
+ ids << TQString::number( recipeToRemove.value( 0 ).toInt() );
}
}
- command = QString( "DELETE FROM ingredient_groups WHERE id NOT IN ( %1 );" ).arg( ( ids.count() == 0 ) ? "-1" : ids.join( "," ) );
+ command = TQString( "DELETE FROM ingredient_groups WHERE id NOT IN ( %1 );" ).arg( ( ids.count() == 0 ) ? "-1" : ids.join( "," ) );
recipeToRemove.exec( command );
// Clean up yield_types which have no recipe that they belong to
ids.clear();
- command = QString( "SELECT DISTINCT(yield_type_id) FROM recipes" );
+ command = TQString( "SELECT DISTINCT(yield_type_id) FROM recipes" );
recipeToRemove.exec( command );
if ( recipeToRemove.isActive() ) {
while ( recipeToRemove.next() ) {
if ( recipeToRemove.value( 0 ).toInt() != -1 )
- ids << QString::number( recipeToRemove.value( 0 ).toInt() );
+ ids << TQString::number( recipeToRemove.value( 0 ).toInt() );
}
}
- command = QString( "DELETE FROM yield_types WHERE id NOT IN ( %1 );" ).arg( ( ids.count() == 0 ) ? "-1" : ids.join( "," ) );
+ command = TQString( "DELETE FROM yield_types WHERE id NOT IN ( %1 );" ).arg( ( ids.count() == 0 ) ? "-1" : ids.join( "," ) );
recipeToRemove.exec( command );
}
-void QSqlRecipeDB::removeRecipeFromCategory( int recipeID, int categoryID )
+void TQSqlRecipeDB::removeRecipeFromCategory( int recipeID, int categoryID )
{
- QString command;
- command = QString( "DELETE FROM category_list WHERE recipe_id=%1 AND category_id=%2;" ).arg( recipeID ).arg( categoryID );
- QSqlQuery recipeToRemove( command, database );
+ TQString command;
+ command = TQString( "DELETE FROM category_list WHERE recipe_id=%1 AND category_id=%2;" ).arg( recipeID ).arg( categoryID );
+ TQSqlQuery recipeToRemove( command, database );
emit recipeRemoved( recipeID, categoryID );
}
-void QSqlRecipeDB::categorizeRecipe( int recipeID, const ElementList &categoryList )
+void TQSqlRecipeDB::categorizeRecipe( int recipeID, const ElementList &categoryList )
{
- QString command;
+ TQString command;
//emit recipeRemoved( recipeID, -1 );
for ( ElementList::const_iterator it = categoryList.begin(); it != categoryList.end(); ++it ) {
- command = QString( "INSERT INTO category_list VALUES(%1,%2)" ).arg( recipeID ).arg( (*it).id );
+ command = TQString( "INSERT INTO category_list VALUES(%1,%2)" ).arg( recipeID ).arg( (*it).id );
database->exec( command );
}
emit recipeModified( Element(recipeTitle(recipeID),recipeID), categoryList );
}
-void QSqlRecipeDB::createNewIngGroup( const QString &name )
+void TQSqlRecipeDB::createNewIngGroup( const TQString &name )
{
- QString command;
- QString real_name = name.left( maxIngGroupNameLength() );
+ TQString command;
+ TQString real_name = name.left( maxIngGroupNameLength() );
- command = QString( "INSERT INTO ingredient_groups VALUES(%2,'%1');" ).arg( escapeAndEncode( real_name ) ).arg( getNextInsertIDStr( "ingredient_groups", "id" ) );
- QSqlQuery query( command, database );
+ command = TQString( "INSERT INTO ingredient_groups VALUES(%2,'%1');" ).arg( escapeAndEncode( real_name ) ).arg( getNextInsertIDStr( "ingredient_groups", "id" ) );
+ TQSqlQuery query( command, database );
emit ingGroupCreated( Element( real_name, lastInsertID() ) );
}
-void QSqlRecipeDB::createNewIngredient( const QString &ingredientName )
+void TQSqlRecipeDB::createNewIngredient( const TQString &ingredientName )
{
- QString command;
- QString real_name = ingredientName.left( maxIngredientNameLength() );
+ TQString command;
+ TQString real_name = ingredientName.left( maxIngredientNameLength() );
- command = QString( "INSERT INTO ingredients VALUES(%2,'%1');" ).arg( escapeAndEncode( real_name ) ).arg( getNextInsertIDStr( "ingredients", "id" ) );
- QSqlQuery ingredientToCreate( command, database );
+ command = TQString( "INSERT INTO ingredients VALUES(%2,'%1');" ).arg( escapeAndEncode( real_name ) ).arg( getNextInsertIDStr( "ingredients", "id" ) );
+ TQSqlQuery ingredientToCreate( command, database );
emit ingredientCreated( Element( real_name, lastInsertID() ) );
}
-void QSqlRecipeDB::createNewRating( const QString &rating )
+void TQSqlRecipeDB::createNewRating( const TQString &rating )
{
- QString command;
- QString real_name = rating/*.left( maxIngredientNameLength() )*/;
+ TQString command;
+ TQString real_name = rating/*.left( maxIngredientNameLength() )*/;
- command = QString( "INSERT INTO rating_criteria VALUES(%2,'%1');" ).arg( escapeAndEncode( real_name ) ).arg( getNextInsertIDStr( "rating_criteria", "id" ) );
- QSqlQuery toCreate( command, database );
+ command = TQString( "INSERT INTO rating_criteria VALUES(%2,'%1');" ).arg( escapeAndEncode( real_name ) ).arg( getNextInsertIDStr( "rating_criteria", "id" ) );
+ TQSqlQuery toCreate( command, database );
emit ratingCriteriaCreated( Element( real_name, lastInsertID() ) );
}
-void QSqlRecipeDB::createNewYieldType( const QString &name )
+void TQSqlRecipeDB::createNewYieldType( const TQString &name )
{
- QString command;
- QString real_name = name.left( maxYieldTypeLength() );
+ TQString command;
+ TQString real_name = name.left( maxYieldTypeLength() );
- command = QString( "INSERT INTO yield_types VALUES(%2,'%1');" ).arg( escapeAndEncode( real_name ) ).arg( getNextInsertIDStr( "yield_types", "id" ) );
+ command = TQString( "INSERT INTO yield_types VALUES(%2,'%1');" ).arg( escapeAndEncode( real_name ) ).arg( getNextInsertIDStr( "yield_types", "id" ) );
database->exec(command);
//emit yieldTypeCreated( Element( real_name, lastInsertID() ) );
}
-void QSqlRecipeDB::modIngredientGroup( int groupID, const QString &newLabel )
+void TQSqlRecipeDB::modIngredientGroup( int groupID, const TQString &newLabel )
{
- QString command;
+ TQString command;
- command = QString( "UPDATE ingredient_groups SET name='%1' WHERE id=%2;" ).arg( escapeAndEncode( newLabel ) ).arg( groupID );
- QSqlQuery ingredientToCreate( command, database );
+ command = TQString( "UPDATE ingredient_groups SET name='%1' WHERE id=%2;" ).arg( escapeAndEncode( newLabel ) ).arg( groupID );
+ TQSqlQuery ingredientToCreate( command, database );
emit ingGroupRemoved( groupID );
emit ingGroupCreated( Element( newLabel, groupID ) );
}
-void QSqlRecipeDB::modIngredient( int ingredientID, const QString &newLabel )
+void TQSqlRecipeDB::modIngredient( int ingredientID, const TQString &newLabel )
{
- QString command;
+ TQString command;
- command = QString( "UPDATE ingredients SET name='%1' WHERE id=%2;" ).arg( escapeAndEncode( newLabel ) ).arg( ingredientID );
- QSqlQuery ingredientToCreate( command, database );
+ command = TQString( "UPDATE ingredients SET name='%1' WHERE id=%2;" ).arg( escapeAndEncode( newLabel ) ).arg( ingredientID );
+ TQSqlQuery ingredientToCreate( command, database );
emit ingredientRemoved( ingredientID );
emit ingredientCreated( Element( newLabel, ingredientID ) );
}
-void QSqlRecipeDB::addUnitToIngredient( int ingredientID, int unitID )
+void TQSqlRecipeDB::addUnitToIngredient( int ingredientID, int unitID )
{
- QString command;
+ TQString command;
- command = QString( "INSERT INTO unit_list VALUES(%1,%2);" ).arg( ingredientID ).arg( unitID );
- QSqlQuery ingredientToCreate( command, database );
+ command = TQString( "INSERT INTO unit_list VALUES(%1,%2);" ).arg( ingredientID ).arg( unitID );
+ TQSqlQuery ingredientToCreate( command, database );
}
-void QSqlRecipeDB::loadUnits( UnitList *list, Unit::Type type, int limit, int offset )
+void TQSqlRecipeDB::loadUnits( UnitList *list, Unit::Type type, int limit, int offset )
{
list->clear();
- QString command;
+ TQString command;
command = "SELECT id,name,name_abbrev,plural,plural_abbrev,type FROM units "
- +((type==Unit::All)?"":"WHERE type="+QString::number(type))
+ +((type==Unit::All)?"":"WHERE type="+TQString::number(type))
+" ORDER BY name"
- +((limit==-1)?"":" LIMIT "+QString::number(limit)+" OFFSET "+QString::number(offset));
+ +((limit==-1)?"":" LIMIT "+TQString::number(limit)+" OFFSET "+TQString::number(offset));
- QSqlQuery unitToLoad( command, database );
+ TQSqlQuery unitToLoad( command, database );
if ( unitToLoad.isActive() ) {
while ( unitToLoad.next() ) {
@@ -1005,167 +1005,167 @@ void QSqlRecipeDB::loadUnits( UnitList *list, Unit::Type type, int limit, int of
}
}
-void QSqlRecipeDB::removeUnitFromIngredient( int ingredientID, int unitID )
+void TQSqlRecipeDB::removeUnitFromIngredient( int ingredientID, int unitID )
{
- QString command;
+ TQString command;
- command = QString( "DELETE FROM unit_list WHERE ingredient_id=%1 AND unit_id=%2;" ).arg( ingredientID ).arg( unitID );
- QSqlQuery unitToRemove( command, database );
+ command = TQString( "DELETE FROM unit_list WHERE ingredient_id=%1 AND unit_id=%2;" ).arg( ingredientID ).arg( unitID );
+ TQSqlQuery unitToRemove( command, database );
// Remove any recipe using that combination of ingredients also (user must have been warned before calling this function!)
- command = QString( "SELECT r.id FROM recipes r,ingredient_list il WHERE r.id=il.recipe_id AND il.ingredient_id=%1 AND il.unit_id=%2;" ).arg( ingredientID ).arg( unitID );
+ command = TQString( "SELECT r.id FROM recipes r,ingredient_list il WHERE r.id=il.recipe_id AND il.ingredient_id=%1 AND il.unit_id=%2;" ).arg( ingredientID ).arg( unitID );
unitToRemove.exec( command );
if ( unitToRemove.isActive() ) {
while ( unitToRemove.next() ) {
emit recipeRemoved( unitToRemove.value( 0 ).toInt() );
- database->exec( QString( "DELETE FROM recipes WHERE id=%1;" ).arg( unitToRemove.value( 0 ).toInt() ) );
+ database->exec( TQString( "DELETE FROM recipes WHERE id=%1;" ).arg( unitToRemove.value( 0 ).toInt() ) );
}
}
// Remove any ingredient in ingredient_list which has references to this unit and ingredient
- command = QString( "DELETE FROM ingredient_list WHERE ingredient_id=%1 AND unit_id=%2;" ).arg( ingredientID ).arg( unitID );
+ command = TQString( "DELETE FROM ingredient_list WHERE ingredient_id=%1 AND unit_id=%2;" ).arg( ingredientID ).arg( unitID );
unitToRemove.exec( command );
// Remove any ingredient properties from ingredient_info where the this ingredient+unit is being used (user must have been warned before calling this function!)
- command = QString( "DELETE FROM ingredient_info ii WHERE ii.ingredient_id=%1 AND ii.per_units=%2;" ).arg( ingredientID ).arg( unitID );
+ command = TQString( "DELETE FROM ingredient_info ii WHERE ii.ingredient_id=%1 AND ii.per_units=%2;" ).arg( ingredientID ).arg( unitID );
unitToRemove.exec( command );
// Clean up ingredient_list which have no recipe that they belong to
// MySQL doesn't support subqueries until 4.1, so we'll do this the long way
// (Easy way: DELETE FROM ingredient_list WHERE recipe_id NOT IN ( SELECT id FROM recipes );)
- QStringList ids;
- command = QString( "SELECT id FROM recipes;" );
+ TQStringList ids;
+ command = TQString( "SELECT id FROM recipes;" );
unitToRemove.exec( command );
if ( unitToRemove.isActive() ) {
while ( unitToRemove.next() ) {
- ids << QString::number( unitToRemove.value( 0 ).toInt() );
+ ids << TQString::number( unitToRemove.value( 0 ).toInt() );
}
}
- command = QString( "DELETE FROM ingredient_list WHERE recipe_id NOT IN ( %1 );" ).arg( ( ids.count() == 0 ) ? "-1" : ids.join( "," ) );
+ command = TQString( "DELETE FROM ingredient_list WHERE recipe_id NOT IN ( %1 );" ).arg( ( ids.count() == 0 ) ? "-1" : ids.join( "," ) );
unitToRemove.exec( command );
// Clean up category_list which have no recipe that they belong to
- command = QString( "DELETE FROM category_list WHERE recipe_id NOT IN ( %1 );" ).arg( ( ids.count() == 0 ) ? "-1" : ids.join( "," ) );
+ command = TQString( "DELETE FROM category_list WHERE recipe_id NOT IN ( %1 );" ).arg( ( ids.count() == 0 ) ? "-1" : ids.join( "," ) );
unitToRemove.exec( command );
// Clean up ingredient_groups which have no recipe that they belong to
// MySQL doesn't support subqueries until 4.1, so we'll do this the long way
// (Easy way: DELETE FROM ingredient_groups WHERE id NOT IN ( SELECT DISTINCT(group_id) FROM ingredient_list );)
ids.clear();
- command = QString( "SELECT DISTINCT(group_id) FROM ingredient_list;" );
+ command = TQString( "SELECT DISTINCT(group_id) FROM ingredient_list;" );
unitToRemove.exec( command );
if ( unitToRemove.isActive() ) {
while ( unitToRemove.next() ) {
if ( unitToRemove.value( 0 ).toInt() != -1 )
- ids << QString::number( unitToRemove.value( 0 ).toInt() );
+ ids << TQString::number( unitToRemove.value( 0 ).toInt() );
}
}
- command = QString( "DELETE FROM ingredient_groups WHERE id NOT IN ( %1 );" ).arg( ( ids.count() == 0 ) ? "-1" : ids.join( "," ) );
+ command = TQString( "DELETE FROM ingredient_groups WHERE id NOT IN ( %1 );" ).arg( ( ids.count() == 0 ) ? "-1" : ids.join( "," ) );
unitToRemove.exec( command );
}
-void QSqlRecipeDB::removeIngredientGroup( int groupID )
+void TQSqlRecipeDB::removeIngredientGroup( int groupID )
{
- QString command;
+ TQString command;
// First remove the ingredient
- command = QString( "DELETE FROM ingredient_groups WHERE id=%1" ).arg( groupID );
- QSqlQuery toDelete( command, database );
+ command = TQString( "DELETE FROM ingredient_groups WHERE id=%1" ).arg( groupID );
+ TQSqlQuery toDelete( command, database );
// Remove all the unit entries for this ingredient
- command = QString( "UPDATE ingredient_list SET group_id='-1' WHERE group_id=%1" ).arg( groupID );
+ command = TQString( "UPDATE ingredient_list SET group_id='-1' WHERE group_id=%1" ).arg( groupID );
toDelete.exec( command );
emit ingGroupRemoved( groupID );
}
-void QSqlRecipeDB::removeIngredient( int ingredientID )
+void TQSqlRecipeDB::removeIngredient( int ingredientID )
{
- QString command;
+ TQString command;
// First remove the ingredient
- command = QString( "DELETE FROM ingredients WHERE id=%1;" ).arg( ingredientID );
- QSqlQuery ingredientToDelete( command, database );
+ command = TQString( "DELETE FROM ingredients WHERE id=%1;" ).arg( ingredientID );
+ TQSqlQuery ingredientToDelete( command, database );
// Remove all the unit entries for this ingredient
- command = QString( "DELETE FROM unit_list WHERE ingredient_id=%1;" ).arg( ingredientID );
+ command = TQString( "DELETE FROM unit_list WHERE ingredient_id=%1;" ).arg( ingredientID );
ingredientToDelete.exec( command );
// Remove any recipe using that ingredient
- command = QString( "SELECT r.id FROM recipes r,ingredient_list il WHERE r.id=il.recipe_id AND il.ingredient_id=%1;" ).arg( ingredientID );
+ command = TQString( "SELECT r.id FROM recipes r,ingredient_list il WHERE r.id=il.recipe_id AND il.ingredient_id=%1;" ).arg( ingredientID );
ingredientToDelete.exec( command );
if ( ingredientToDelete.isActive() ) {
while ( ingredientToDelete.next() ) {
emit recipeRemoved( ingredientToDelete.value( 0 ).toInt() );
- database->exec( QString( "DELETE FROM recipes WHERE id=%1;" ).arg( ingredientToDelete.value( 0 ).toInt() ) );
+ database->exec( TQString( "DELETE FROM recipes WHERE id=%1;" ).arg( ingredientToDelete.value( 0 ).toInt() ) );
}
}
// Remove any ingredient in ingredient_list which has references to this ingredient
- command = QString( "DELETE FROM ingredient_list WHERE ingredient_id=%1;" ).arg( ingredientID );
+ command = TQString( "DELETE FROM ingredient_list WHERE ingredient_id=%1;" ).arg( ingredientID );
ingredientToDelete.exec( command );
// Clean up ingredient_list which have no recipe that they belong to
// MySQL doesn't support subqueries until 4.1, so we'll do this the long way
// (Easy way: DELETE FROM ingredient_list WHERE recipe_id NOT IN ( SELECT id FROM recipes );)
- QStringList ids;
- command = QString( "SELECT id FROM recipes;" );
+ TQStringList ids;
+ command = TQString( "SELECT id FROM recipes;" );
ingredientToDelete.exec( command );
if ( ingredientToDelete.isActive() ) {
while ( ingredientToDelete.next() ) {
- ids << QString::number( ingredientToDelete.value( 0 ).toInt() );
+ ids << TQString::number( ingredientToDelete.value( 0 ).toInt() );
}
}
- command = QString( "DELETE FROM ingredient_list WHERE recipe_id NOT IN ( %1 );" ).arg( ( ids.count() == 0 ) ? "-1" : ids.join( "," ) );
+ command = TQString( "DELETE FROM ingredient_list WHERE recipe_id NOT IN ( %1 );" ).arg( ( ids.count() == 0 ) ? "-1" : ids.join( "," ) );
ingredientToDelete.exec( command );
// Clean up category_list which have no recipe that they belong to. Same method as above
- command = QString( "DELETE FROM category_list WHERE recipe_id NOT IN ( %1 );" ).arg( ( ids.count() == 0 ) ? "-1" : ids.join( "," ) );
+ command = TQString( "DELETE FROM category_list WHERE recipe_id NOT IN ( %1 );" ).arg( ( ids.count() == 0 ) ? "-1" : ids.join( "," ) );
ingredientToDelete.exec( command );
// Clean up ingredient_groups which have no recipe that they belong to
// MySQL doesn't support subqueries until 4.1, so we'll do this the long way
// (Easy way: DELETE FROM ingredient_groups WHERE id NOT IN ( SELECT DISTINCT(group_id) FROM ingredient_list );)
ids.clear();
- command = QString( "SELECT DISTINCT(group_id) FROM ingredient_list;" );
+ command = TQString( "SELECT DISTINCT(group_id) FROM ingredient_list;" );
ingredientToDelete.exec( command );
if ( ingredientToDelete.isActive() ) {
while ( ingredientToDelete.next() ) {
if ( ingredientToDelete.value( 0 ).toInt() != -1 )
- ids << QString::number( ingredientToDelete.value( 0 ).toInt() );
+ ids << TQString::number( ingredientToDelete.value( 0 ).toInt() );
}
}
- command = QString( "DELETE FROM ingredient_groups WHERE id NOT IN ( %1 );" ).arg( ( ids.count() == 0 ) ? "-1" : ids.join( "," ) );
+ command = TQString( "DELETE FROM ingredient_groups WHERE id NOT IN ( %1 );" ).arg( ( ids.count() == 0 ) ? "-1" : ids.join( "," ) );
ingredientToDelete.exec( command );
// Remove property list of this ingredient
- command = QString( "DELETE FROM ingredient_info WHERE ingredient_id=%1;" ).arg( ingredientID );
+ command = TQString( "DELETE FROM ingredient_info WHERE ingredient_id=%1;" ).arg( ingredientID );
ingredientToDelete.exec( command );
emit ingredientRemoved( ingredientID );
}
-void QSqlRecipeDB::removeIngredientWeight( int id )
+void TQSqlRecipeDB::removeIngredientWeight( int id )
{
- QString command;
+ TQString command;
// First remove the ingredient
- command = QString( "DELETE FROM ingredient_weights WHERE id=%1" ).arg( id );
- QSqlQuery toDelete( command, database );
+ command = TQString( "DELETE FROM ingredient_weights WHERE id=%1" ).arg( id );
+ TQSqlQuery toDelete( command, database );
}
-void QSqlRecipeDB::addIngredientWeight( const Weight &w )
+void TQSqlRecipeDB::addIngredientWeight( const Weight &w )
{
- QString command;
+ TQString command;
if ( w.id != -1 ) {
- command = QString( "UPDATE ingredient_weights SET ingredient_id=%1,amount=%2,unit_id=%3,weight=%4,weight_unit_id=%5,prep_method_id=%7 WHERE id=%6" )
+ command = TQString( "UPDATE ingredient_weights SET ingredient_id=%1,amount=%2,unit_id=%3,weight=%4,weight_unit_id=%5,prep_method_id=%7 WHERE id=%6" )
.arg(w.ingredientID)
.arg(w.perAmount)
.arg(w.perAmountUnitID)
@@ -1175,7 +1175,7 @@ void QSqlRecipeDB::addIngredientWeight( const Weight &w )
.arg(w.prepMethodID);
}
else {
- command = QString( "INSERT INTO ingredient_weights VALUES(%6,%1,%2,%3,%4,%5,%7)" )
+ command = TQString( "INSERT INTO ingredient_weights VALUES(%6,%1,%2,%3,%4,%5,%7)" )
.arg(w.ingredientID)
.arg(w.perAmount)
.arg(w.perAmountUnitID)
@@ -1184,45 +1184,45 @@ void QSqlRecipeDB::addIngredientWeight( const Weight &w )
.arg(getNextInsertIDStr( "ingredient_weights", "id" ))
.arg(w.prepMethodID);
}
- QSqlQuery query( command, database );
+ TQSqlQuery query( command, database );
}
-void QSqlRecipeDB::addProperty( const QString &name, const QString &units )
+void TQSqlRecipeDB::addProperty( const TQString &name, const TQString &units )
{
- QString command;
- QString real_name = name.left( maxPropertyNameLength() );
+ TQString command;
+ TQString real_name = name.left( maxPropertyNameLength() );
- command = QString( "INSERT INTO ingredient_properties VALUES(%3,'%1','%2');" )
+ command = TQString( "INSERT INTO ingredient_properties VALUES(%3,'%1','%2');" )
.arg( escapeAndEncode( real_name ) )
.arg( escapeAndEncode( units ) )
.arg( getNextInsertIDStr( "ingredient_properties", "id" ) );
- QSqlQuery propertyToAdd( command, database );
+ TQSqlQuery propertyToAdd( command, database );
emit propertyCreated( IngredientProperty( real_name, units, lastInsertID() ) );
}
-void QSqlRecipeDB::loadProperties( IngredientPropertyList *list, int ingredientID )
+void TQSqlRecipeDB::loadProperties( IngredientPropertyList *list, int ingredientID )
{
list->clear();
- QString command;
+ TQString command;
bool usePerUnit;
if ( ingredientID >= 0 ) // Load properties of this ingredient
{
usePerUnit = true;
- command = QString( "SELECT ip.id,ip.name,ip.units,ii.per_units,u.name,u.type,ii.amount,ii.ingredient_id FROM ingredient_properties ip, ingredient_info ii, units u WHERE ii.ingredient_id=%1 AND ii.property_id=ip.id AND ii.per_units=u.id;" ).arg( ingredientID );
+ command = TQString( "SELECT ip.id,ip.name,ip.units,ii.per_units,u.name,u.type,ii.amount,ii.ingredient_id FROM ingredient_properties ip, ingredient_info ii, units u WHERE ii.ingredient_id=%1 AND ii.property_id=ip.id AND ii.per_units=u.id;" ).arg( ingredientID );
}
else if ( ingredientID == -1 ) // Load the properties of all the ingredients
{
usePerUnit = true;
- command = QString( "SELECT ip.id,ip.name,ip.units,ii.per_units,u.name,u.type,ii.amount,ii.ingredient_id FROM ingredient_properties ip, ingredient_info ii, units u WHERE ii.property_id=ip.id AND ii.per_units=u.id;" );
+ command = TQString( "SELECT ip.id,ip.name,ip.units,ii.per_units,u.name,u.type,ii.amount,ii.ingredient_id FROM ingredient_properties ip, ingredient_info ii, units u WHERE ii.property_id=ip.id AND ii.per_units=u.id;" );
}
else // Load the whole property list (just the list of possible properties, not the ingredient properties)
{
usePerUnit = false;
- command = QString( "SELECT id,name,units FROM ingredient_properties;" );
+ command = TQString( "SELECT id,name,units FROM ingredient_properties;" );
}
- QSqlQuery propertiesToLoad ( command, database );
+ TQSqlQuery propertiesToLoad ( command, database );
// Load the results into the list
if ( propertiesToLoad.isActive() ) {
while ( propertiesToLoad.next() ) {
@@ -1249,183 +1249,183 @@ void QSqlRecipeDB::loadProperties( IngredientPropertyList *list, int ingredientI
}
}
-void QSqlRecipeDB::changePropertyAmountToIngredient( int ingredientID, int propertyID, double amount, int per_units )
+void TQSqlRecipeDB::changePropertyAmountToIngredient( int ingredientID, int propertyID, double amount, int per_units )
{
- QString command;
- command = QString( "UPDATE ingredient_info SET amount=%1 WHERE ingredient_id=%2 AND property_id=%3 AND per_units=%4;" ).arg( amount ).arg( ingredientID ).arg( propertyID ).arg( per_units );
- QSqlQuery infoToChange( command, database );
+ TQString command;
+ command = TQString( "UPDATE ingredient_info SET amount=%1 WHERE ingredient_id=%2 AND property_id=%3 AND per_units=%4;" ).arg( amount ).arg( ingredientID ).arg( propertyID ).arg( per_units );
+ TQSqlQuery infoToChange( command, database );
}
-void QSqlRecipeDB::addPropertyToIngredient( int ingredientID, int propertyID, double amount, int perUnitsID )
+void TQSqlRecipeDB::addPropertyToIngredient( int ingredientID, int propertyID, double amount, int perUnitsID )
{
- QString command;
+ TQString command;
- command = QString( "INSERT INTO ingredient_info VALUES(%1,%2,%3,%4);" ).arg( ingredientID ).arg( propertyID ).arg( amount ).arg( perUnitsID );
- QSqlQuery propertyToAdd( command, database );
+ command = TQString( "INSERT INTO ingredient_info VALUES(%1,%2,%3,%4);" ).arg( ingredientID ).arg( propertyID ).arg( amount ).arg( perUnitsID );
+ TQSqlQuery propertyToAdd( command, database );
}
-void QSqlRecipeDB::removePropertyFromIngredient( int ingredientID, int propertyID, int perUnitID )
+void TQSqlRecipeDB::removePropertyFromIngredient( int ingredientID, int propertyID, int perUnitID )
{
- QString command;
+ TQString command;
// remove property from ingredient info. Note that there could be duplicates with different units (per_units). Remove just the one especified.
- command = QString( "DELETE FROM ingredient_info WHERE ingredient_id=%1 AND property_id=%2 AND per_units=%3;" ).arg( ingredientID ).arg( propertyID ).arg( perUnitID );
- QSqlQuery propertyToRemove( command, database );
+ command = TQString( "DELETE FROM ingredient_info WHERE ingredient_id=%1 AND property_id=%2 AND per_units=%3;" ).arg( ingredientID ).arg( propertyID ).arg( perUnitID );
+ TQSqlQuery propertyToRemove( command, database );
}
-void QSqlRecipeDB::removeProperty( int propertyID )
+void TQSqlRecipeDB::removeProperty( int propertyID )
{
- QString command;
+ TQString command;
// Remove property from the ingredient_properties
- command = QString( "DELETE FROM ingredient_properties WHERE id=%1;" ).arg( propertyID );
- QSqlQuery propertyToRemove( command, database );
+ command = TQString( "DELETE FROM ingredient_properties WHERE id=%1;" ).arg( propertyID );
+ TQSqlQuery propertyToRemove( command, database );
// Remove any ingredient info that uses this property
- command = QString( "DELETE FROM ingredient_info WHERE property_id=%1;" ).arg( propertyID );
+ command = TQString( "DELETE FROM ingredient_info WHERE property_id=%1;" ).arg( propertyID );
propertyToRemove.exec( command );
emit propertyRemoved( propertyID );
}
-void QSqlRecipeDB::removeUnit( int unitID )
+void TQSqlRecipeDB::removeUnit( int unitID )
{
- QString command;
+ TQString command;
// Remove the unit first
- command = QString( "DELETE FROM units WHERE id=%1;" ).arg( unitID );
- QSqlQuery unitToRemove( command, database );
+ command = TQString( "DELETE FROM units WHERE id=%1;" ).arg( unitID );
+ TQSqlQuery unitToRemove( command, database );
//Remove the unit from ingredients using it
- command = QString( "DELETE FROM unit_list WHERE unit_id=%1;" ).arg( unitID );
+ command = TQString( "DELETE FROM unit_list WHERE unit_id=%1;" ).arg( unitID );
unitToRemove.exec( command );
// Remove any recipe using that unit in the ingredient list (user must have been warned before calling this function!)
- command = QString( "SELECT r.id FROM recipes r,ingredient_list il WHERE r.id=il.recipe_id AND il.unit_id=%1;" ).arg( unitID );
+ command = TQString( "SELECT r.id FROM recipes r,ingredient_list il WHERE r.id=il.recipe_id AND il.unit_id=%1;" ).arg( unitID );
unitToRemove.exec( command );
if ( unitToRemove.isActive() ) {
while ( unitToRemove.next() ) {
emit recipeRemoved( unitToRemove.value( 0 ).toInt() );
- database->exec( QString( "DELETE FROM recipes WHERE id=%1;" ).arg( unitToRemove.value( 0 ).toInt() ) );
+ database->exec( TQString( "DELETE FROM recipes WHERE id=%1;" ).arg( unitToRemove.value( 0 ).toInt() ) );
}
}
// Remove any ingredient in ingredient_list which has references to this unit
- command = QString( "DELETE FROM ingredient_list WHERE unit_id=%1;" ).arg( unitID );
+ command = TQString( "DELETE FROM ingredient_list WHERE unit_id=%1;" ).arg( unitID );
unitToRemove.exec( command );
// Clean up ingredient_list which have no recipe that they belong to
// MySQL doesn't support subqueries until 4.1, so we'll do this the long way
// (Easy way: DELETE FROM ingredient_list WHERE recipe_id NOT IN ( SELECT id FROM recipes );)
- QStringList ids;
- command = QString( "SELECT id FROM recipes;" );
+ TQStringList ids;
+ command = TQString( "SELECT id FROM recipes;" );
unitToRemove.exec( command );
if ( unitToRemove.isActive() ) {
while ( unitToRemove.next() ) {
- ids << QString::number( unitToRemove.value( 0 ).toInt() );
+ ids << TQString::number( unitToRemove.value( 0 ).toInt() );
}
}
- command = QString( "DELETE FROM ingredient_list WHERE recipe_id NOT IN ( %1 );" ).arg( ( ids.count() == 0 ) ? "-1" : ids.join( "," ) );
+ command = TQString( "DELETE FROM ingredient_list WHERE recipe_id NOT IN ( %1 );" ).arg( ( ids.count() == 0 ) ? "-1" : ids.join( "," ) );
unitToRemove.exec( command );
// Clean up category_list which have no recipe that they belong to. Same method as above
- command = QString( "DELETE FROM category_list WHERE recipe_id NOT IN ( %1 );" ).arg( ( ids.count() == 0 ) ? "-1" : ids.join( "," ) );
+ command = TQString( "DELETE FROM category_list WHERE recipe_id NOT IN ( %1 );" ).arg( ( ids.count() == 0 ) ? "-1" : ids.join( "," ) );
unitToRemove.exec( command );
// Clean up ingredient_groups which have no recipe that they belong to
// MySQL doesn't support subqueries until 4.1, so we'll do this the long way
// (Easy way: DELETE FROM ingredient_groups WHERE id NOT IN ( SELECT DISTINCT(group_id) FROM ingredient_list );)
ids.clear();
- command = QString( "SELECT DISTINCT(group_id) FROM ingredient_list;" );
+ command = TQString( "SELECT DISTINCT(group_id) FROM ingredient_list;" );
unitToRemove.exec( command );
if ( unitToRemove.isActive() ) {
while ( unitToRemove.next() ) {
if ( unitToRemove.value( 0 ).toInt() != -1 )
- ids << QString::number( unitToRemove.value( 0 ).toInt() );
+ ids << TQString::number( unitToRemove.value( 0 ).toInt() );
}
}
- command = QString( "DELETE FROM ingredient_groups WHERE id NOT IN ( %1 );" ).arg( ( ids.count() == 0 ) ? "-1" : ids.join( "," ) );
+ command = TQString( "DELETE FROM ingredient_groups WHERE id NOT IN ( %1 );" ).arg( ( ids.count() == 0 ) ? "-1" : ids.join( "," ) );
unitToRemove.exec( command );
// Remove the ingredient properties using this unit (user must be warned before calling this function)
- command = QString( "DELETE FROM ingredient_info WHERE per_units=%1;" ).arg( unitID );
+ command = TQString( "DELETE FROM ingredient_info WHERE per_units=%1;" ).arg( unitID );
unitToRemove.exec( command );
// Remove the unit conversion ratios with this unit
- command = QString( "DELETE FROM units_conversion WHERE unit1_id=%1 OR unit2_id=%2;" ).arg( unitID ).arg( unitID );
+ command = TQString( "DELETE FROM units_conversion WHERE unit1_id=%1 OR unit2_id=%2;" ).arg( unitID ).arg( unitID );
unitToRemove.exec( command );
// Remove associated ingredient weights
- command = QString( "DELETE FROM ingredient_weights WHERE unit_id=%1" ).arg( unitID );
+ command = TQString( "DELETE FROM ingredient_weights WHERE unit_id=%1" ).arg( unitID );
unitToRemove.exec( command );
emit unitRemoved( unitID );
}
-void QSqlRecipeDB::removePrepMethod( int prepMethodID )
+void TQSqlRecipeDB::removePrepMethod( int prepMethodID )
{
- QString command;
+ TQString command;
// Remove the prep method first
- command = QString( "DELETE FROM prep_methods WHERE id=%1;" ).arg( prepMethodID );
- QSqlQuery prepMethodToRemove( command, database );
+ command = TQString( "DELETE FROM prep_methods WHERE id=%1;" ).arg( prepMethodID );
+ TQSqlQuery prepMethodToRemove( command, database );
// Remove any recipe using that prep method in the ingredient list (user must have been warned before calling this function!)
- command = QString( "SELECT DISTINCT r.id FROM recipes r,ingredient_list il, prep_method_list pl WHERE r.id=il.recipe_id AND pl.ingredient_list_id=il.id AND pl.prep_method_id=%1;" ).arg( prepMethodID );
+ command = TQString( "SELECT DISTINCT r.id FROM recipes r,ingredient_list il, prep_method_list pl WHERE r.id=il.recipe_id AND pl.ingredient_list_id=il.id AND pl.prep_method_id=%1;" ).arg( prepMethodID );
prepMethodToRemove.exec( command );
if ( prepMethodToRemove.isActive() ) {
while ( prepMethodToRemove.next() ) {
emit recipeRemoved( prepMethodToRemove.value( 0 ).toInt() );
- database->exec( QString( "DELETE FROM recipes WHERE id=%1;" ).arg( prepMethodToRemove.value( 0 ).toInt() ) );
+ database->exec( TQString( "DELETE FROM recipes WHERE id=%1;" ).arg( prepMethodToRemove.value( 0 ).toInt() ) );
}
}
// Clean up ingredient_list which have no recipe that they belong to
// MySQL doesn't support subqueries until 4.1, so we'll do this the long way
// (Easy way: DELETE FROM ingredient_list WHERE recipe_id NOT IN ( SELECT id FROM recipes );)
- QStringList ids;
- command = QString( "SELECT id FROM recipes;" );
+ TQStringList ids;
+ command = TQString( "SELECT id FROM recipes;" );
prepMethodToRemove.exec( command );
if ( prepMethodToRemove.isActive() ) {
while ( prepMethodToRemove.next() ) {
- ids << QString::number( prepMethodToRemove.value( 0 ).toInt() );
+ ids << TQString::number( prepMethodToRemove.value( 0 ).toInt() );
}
}
- command = QString( "DELETE FROM ingredient_list WHERE recipe_id NOT IN ( %1 );" ).arg( ( ids.count() == 0 ) ? "-1" : ids.join( "," ) );
+ command = TQString( "DELETE FROM ingredient_list WHERE recipe_id NOT IN ( %1 );" ).arg( ( ids.count() == 0 ) ? "-1" : ids.join( "," ) );
prepMethodToRemove.exec( command );
// Clean up category_list which have no recipe that they belong to. Same method as above
- command = QString( "DELETE FROM category_list WHERE recipe_id NOT IN ( %1 );" ).arg( ( ids.count() == 0 ) ? "-1" : ids.join( "," ) );
+ command = TQString( "DELETE FROM category_list WHERE recipe_id NOT IN ( %1 );" ).arg( ( ids.count() == 0 ) ? "-1" : ids.join( "," ) );
prepMethodToRemove.exec( command );
// Clean up ingredient_groups which have no recipe that they belong to
// MySQL doesn't support subqueries until 4.1, so we'll do this the long way
// (Easy way: DELETE FROM ingredient_groups WHERE id NOT IN ( SELECT DISTINCT(group_id) FROM ingredient_list );)
ids.clear();
- command = QString( "SELECT DISTINCT(group_id) FROM ingredient_list;" );
+ command = TQString( "SELECT DISTINCT(group_id) FROM ingredient_list;" );
prepMethodToRemove.exec( command );
if ( prepMethodToRemove.isActive() ) {
while ( prepMethodToRemove.next() ) {
if ( prepMethodToRemove.value( 0 ).toInt() != -1 )
- ids << QString::number( prepMethodToRemove.value( 0 ).toInt() );
+ ids << TQString::number( prepMethodToRemove.value( 0 ).toInt() );
}
}
- command = QString( "DELETE FROM ingredient_groups WHERE id NOT IN ( %1 );" ).arg( ( ids.count() == 0 ) ? "-1" : ids.join( "," ) );
+ command = TQString( "DELETE FROM ingredient_groups WHERE id NOT IN ( %1 );" ).arg( ( ids.count() == 0 ) ? "-1" : ids.join( "," ) );
prepMethodToRemove.exec( command );
emit prepMethodRemoved( prepMethodID );
}
-void QSqlRecipeDB::createNewUnit( const Unit &unit )
+void TQSqlRecipeDB::createNewUnit( const Unit &unit )
{
- QString real_name = unit.name.left( maxUnitNameLength() ).stripWhiteSpace();
- QString real_plural = unit.plural.left( maxUnitNameLength() ).stripWhiteSpace();
- QString real_name_abbrev = unit.name_abbrev.left( maxUnitNameLength() ).stripWhiteSpace();
- QString real_plural_abbrev = unit.plural_abbrev.left( maxUnitNameLength() ).stripWhiteSpace();
+ TQString real_name = unit.name.left( maxUnitNameLength() ).stripWhiteSpace();
+ TQString real_plural = unit.plural.left( maxUnitNameLength() ).stripWhiteSpace();
+ TQString real_name_abbrev = unit.name_abbrev.left( maxUnitNameLength() ).stripWhiteSpace();
+ TQString real_plural_abbrev = unit.plural_abbrev.left( maxUnitNameLength() ).stripWhiteSpace();
Unit new_unit( real_name, real_plural );
new_unit.name_abbrev = real_name_abbrev;
@@ -1447,29 +1447,29 @@ void QSqlRecipeDB::createNewUnit( const Unit &unit )
real_plural_abbrev = "'"+escapeAndEncode(real_plural_abbrev)+"'";
- QString command = "INSERT INTO units VALUES(" + getNextInsertIDStr( "units", "id" )
+ TQString command = "INSERT INTO units VALUES(" + getNextInsertIDStr( "units", "id" )
+ ",'" + escapeAndEncode( real_name )
+ "'," + real_name_abbrev
+ ",'" + escapeAndEncode( real_plural )
+ "'," + real_plural_abbrev
- + "," + QString::number(unit.type)
+ + "," + TQString::number(unit.type)
+ ");";
- QSqlQuery unitToCreate( command, database );
+ TQSqlQuery unitToCreate( command, database );
new_unit.id = lastInsertID();
emit unitCreated( new_unit );
}
-void QSqlRecipeDB::modUnit( const Unit &unit )
+void TQSqlRecipeDB::modUnit( const Unit &unit )
{
- QSqlQuery unitQuery( QString::null, database );
+ TQSqlQuery unitQuery( TQString::null, database );
- QString real_name = unit.name.left( maxUnitNameLength() ).stripWhiteSpace();
- QString real_plural = unit.plural.left( maxUnitNameLength() ).stripWhiteSpace();
- QString real_name_abbrev = unit.name_abbrev.left( maxUnitNameLength() ).stripWhiteSpace();
- QString real_plural_abbrev = unit.plural_abbrev.left( maxUnitNameLength() ).stripWhiteSpace();
+ TQString real_name = unit.name.left( maxUnitNameLength() ).stripWhiteSpace();
+ TQString real_plural = unit.plural.left( maxUnitNameLength() ).stripWhiteSpace();
+ TQString real_name_abbrev = unit.name_abbrev.left( maxUnitNameLength() ).stripWhiteSpace();
+ TQString real_plural_abbrev = unit.plural_abbrev.left( maxUnitNameLength() ).stripWhiteSpace();
Unit newUnit( real_name, real_plural, unit.id );
newUnit.type = unit.type;
@@ -1485,7 +1485,7 @@ void QSqlRecipeDB::modUnit( const Unit &unit )
else
real_plural_abbrev = "'"+escapeAndEncode(real_plural_abbrev)+"'";
- QString command = QString("UPDATE units SET name='%1',name_abbrev=%2,plural='%3',plural_abbrev=%4,type=%6 WHERE id='%5'")
+ TQString command = TQString("UPDATE units SET name='%1',name_abbrev=%2,plural='%3',plural_abbrev=%4,type=%6 WHERE id='%5'")
.arg(escapeAndEncode(real_name))
.arg(real_name_abbrev)
.arg(escapeAndEncode(real_plural))
@@ -1498,10 +1498,10 @@ void QSqlRecipeDB::modUnit( const Unit &unit )
emit unitCreated( newUnit );
}
-void QSqlRecipeDB::findUseOfIngGroupInRecipes( ElementList *results, int groupID )
+void TQSqlRecipeDB::findUseOfIngGroupInRecipes( ElementList *results, int groupID )
{
- QString command = QString( "SELECT DISTINCT r.id,r.title FROM recipes r,ingredient_list il WHERE r.id=il.recipe_id AND il.group_id=%1" ).arg( groupID );
- QSqlQuery query( command, database );
+ TQString command = TQString( "SELECT DISTINCT r.id,r.title FROM recipes r,ingredient_list il WHERE r.id=il.recipe_id AND il.group_id=%1" ).arg( groupID );
+ TQSqlQuery query( command, database );
// Populate data
if ( query.isActive() ) {
@@ -1514,10 +1514,10 @@ void QSqlRecipeDB::findUseOfIngGroupInRecipes( ElementList *results, int groupID
}
}
-void QSqlRecipeDB::findUseOfCategoryInRecipes( ElementList *results, int catID )
+void TQSqlRecipeDB::findUseOfCategoryInRecipes( ElementList *results, int catID )
{
- QString command = QString( "SELECT r.id,r.title FROM recipes r,category_list cl WHERE r.id=cl.recipe_id AND cl.category_id=%1" ).arg( catID );
- QSqlQuery query( command, database );
+ TQString command = TQString( "SELECT r.id,r.title FROM recipes r,category_list cl WHERE r.id=cl.recipe_id AND cl.category_id=%1" ).arg( catID );
+ TQSqlQuery query( command, database );
// Populate data
if ( query.isActive() ) {
@@ -1530,8 +1530,8 @@ void QSqlRecipeDB::findUseOfCategoryInRecipes( ElementList *results, int catID )
}
//recursively find dependenacies in subcategories
- command = QString( "SELECT id FROM categories WHERE parent_id=%1" ).arg( catID );
- QSqlQuery findDeps = database->exec( command );
+ command = TQString( "SELECT id FROM categories WHERE parent_id=%1" ).arg( catID );
+ TQSqlQuery findDeps = database->exec( command );
if ( findDeps.isActive() ) {
while ( findDeps.next() ) {
findUseOfCategoryInRecipes(results,findDeps.value( 0 ).toInt() );
@@ -1539,10 +1539,10 @@ void QSqlRecipeDB::findUseOfCategoryInRecipes( ElementList *results, int catID )
}
}
-void QSqlRecipeDB::findUseOfAuthorInRecipes( ElementList *results, int authorID )
+void TQSqlRecipeDB::findUseOfAuthorInRecipes( ElementList *results, int authorID )
{
- QString command = QString( "SELECT r.id,r.title FROM recipes r,author_list al WHERE r.id=al.recipe_id AND al.author_id=%1" ).arg( authorID );
- QSqlQuery query( command, database );
+ TQString command = TQString( "SELECT r.id,r.title FROM recipes r,author_list al WHERE r.id=al.recipe_id AND al.author_id=%1" ).arg( authorID );
+ TQSqlQuery query( command, database );
// Populate data
if ( query.isActive() ) {
@@ -1555,16 +1555,16 @@ void QSqlRecipeDB::findUseOfAuthorInRecipes( ElementList *results, int authorID
}
}
-void QSqlRecipeDB::loadUnitRatios( UnitRatioList *ratioList, Unit::Type type )
+void TQSqlRecipeDB::loadUnitRatios( UnitRatioList *ratioList, Unit::Type type )
{
ratioList->clear();
- QString command;
+ TQString command;
if ( type == Unit::All )
command = "SELECT unit1_id,unit2_id,ratio FROM units_conversion";
else
- command = "SELECT unit1_id,unit2_id,ratio FROM units_conversion,units unit1,units unit2 WHERE unit1_id=unit1.id AND unit1.type="+QString::number(type)+" AND unit2_id=unit2.id AND unit2.type="+QString::number(type);
- QSqlQuery ratiosToLoad( command, database );
+ command = "SELECT unit1_id,unit2_id,ratio FROM units_conversion,units unit1,units unit2 WHERE unit1_id=unit1.id AND unit1.type="+TQString::number(type)+" AND unit2_id=unit2.id AND unit2.type="+TQString::number(type);
+ TQSqlQuery ratiosToLoad( command, database );
if ( ratiosToLoad.isActive() ) {
while ( ratiosToLoad.next() ) {
@@ -1577,38 +1577,38 @@ void QSqlRecipeDB::loadUnitRatios( UnitRatioList *ratioList, Unit::Type type )
}
}
-void QSqlRecipeDB::saveUnitRatio( const UnitRatio *ratio )
+void TQSqlRecipeDB::saveUnitRatio( const UnitRatio *ratio )
{
- QString command;
+ TQString command;
// Check if it's a new ratio or it exists already.
- command = QString( "SELECT * FROM units_conversion WHERE unit1_id=%1 AND unit2_id=%2" ).arg( ratio->uID1 ).arg( ratio->uID2 ); // Find ratio between units
+ command = TQString( "SELECT * FROM units_conversion WHERE unit1_id=%1 AND unit2_id=%2" ).arg( ratio->uID1 ).arg( ratio->uID2 ); // Find ratio between units
- QSqlQuery ratioFound( command, database ); // Find the entries
+ TQSqlQuery ratioFound( command, database ); // Find the entries
bool newRatio = ( ratioFound.size() == 0 );
if ( newRatio )
- command = QString( "INSERT INTO units_conversion VALUES(%1,%2,%3);" ).arg( ratio->uID1 ).arg( ratio->uID2 ).arg( ratio->ratio );
+ command = TQString( "INSERT INTO units_conversion VALUES(%1,%2,%3);" ).arg( ratio->uID1 ).arg( ratio->uID2 ).arg( ratio->ratio );
else
- command = QString( "UPDATE units_conversion SET ratio=%3 WHERE unit1_id=%1 AND unit2_id=%2" ).arg( ratio->uID1 ).arg( ratio->uID2 ).arg( ratio->ratio );
+ command = TQString( "UPDATE units_conversion SET ratio=%3 WHERE unit1_id=%1 AND unit2_id=%2" ).arg( ratio->uID1 ).arg( ratio->uID2 ).arg( ratio->ratio );
ratioFound.exec( command ); // Enter the new ratio
}
-void QSqlRecipeDB::removeUnitRatio( int unitID1, int unitID2 )
+void TQSqlRecipeDB::removeUnitRatio( int unitID1, int unitID2 )
{
- database->exec(QString( "DELETE FROM units_conversion WHERE unit1_id=%1 AND unit2_id=%2" ).arg( unitID1 ).arg( unitID2 ));
+ database->exec(TQString( "DELETE FROM units_conversion WHERE unit1_id=%1 AND unit2_id=%2" ).arg( unitID1 ).arg( unitID2 ));
}
-double QSqlRecipeDB::unitRatio( int unitID1, int unitID2 )
+double TQSqlRecipeDB::unitRatio( int unitID1, int unitID2 )
{
if ( unitID1 == unitID2 )
return ( 1.0 );
- QString command;
+ TQString command;
- command = QString( "SELECT ratio FROM units_conversion WHERE unit1_id=%1 AND unit2_id=%2;" ).arg( unitID1 ).arg( unitID2 );
- QSqlQuery ratioToLoad( command, database );
+ command = TQString( "SELECT ratio FROM units_conversion WHERE unit1_id=%1 AND unit2_id=%2;" ).arg( unitID1 ).arg( unitID2 );
+ TQSqlQuery ratioToLoad( command, database );
if ( ratioToLoad.isActive() && ratioToLoad.next() )
return ( ratioToLoad.value( 0 ).toDouble() );
@@ -1616,13 +1616,13 @@ double QSqlRecipeDB::unitRatio( int unitID1, int unitID2 )
return ( -1 );
}
-double QSqlRecipeDB::ingredientWeight( const Ingredient &ing, bool *wasApproximated )
+double TQSqlRecipeDB::ingredientWeight( const Ingredient &ing, bool *wasApproximated )
{
- QString command = QString( "SELECT amount,weight,prep_method_id,unit_id FROM ingredient_weights WHERE ingredient_id=%1 AND (unit_id=%2 OR weight_unit_id=%3)" )
+ TQString command = TQString( "SELECT amount,weight,prep_method_id,unit_id FROM ingredient_weights WHERE ingredient_id=%1 AND (unit_id=%2 OR weight_unit_id=%3)" )
.arg( ing.ingredientID )
.arg( ing.units.id ).arg( ing.units.id );
- QSqlQuery query( command, database );
+ TQSqlQuery query( command, database );
if ( query.isActive() ) {
//store the amount for the entry with no prep method. If no other suitable entry is found, we'll guesstimate
@@ -1664,12 +1664,12 @@ double QSqlRecipeDB::ingredientWeight( const Ingredient &ing, bool *wasApproxima
return -1;
}
-WeightList QSqlRecipeDB::ingredientWeightUnits( int ingID )
+WeightList TQSqlRecipeDB::ingredientWeightUnits( int ingID )
{
WeightList list;
- QString command = QString( "SELECT id,amount,unit_id,weight,weight_unit_id,prep_method_id FROM ingredient_weights WHERE ingredient_id=%1" ).arg( ingID );
- QSqlQuery query( command, database );
+ TQString command = TQString( "SELECT id,amount,unit_id,weight,weight_unit_id,prep_method_id FROM ingredient_weights WHERE ingredient_id=%1" ).arg( ingID );
+ TQSqlQuery query( command, database );
if ( query.isActive() ) {
while ( query.next() ) {
Weight w;
@@ -1688,48 +1688,48 @@ WeightList QSqlRecipeDB::ingredientWeightUnits( int ingID )
}
//Finds data dependant on this Ingredient/Unit combination
-void QSqlRecipeDB::findIngredientUnitDependancies( int ingredientID, int unitID, ElementList *recipes, ElementList *ingredientInfo )
+void TQSqlRecipeDB::findIngredientUnitDependancies( int ingredientID, int unitID, ElementList *recipes, ElementList *ingredientInfo )
{
// Recipes using that combination
- QString command = QString( "SELECT DISTINCT r.id,r.title FROM recipes r,ingredient_list il WHERE r.id=il.recipe_id AND il.ingredient_id=%1 AND il.unit_id=%2;" ).arg( ingredientID ).arg( unitID );
- QSqlQuery unitToRemove( command, database );
+ TQString command = TQString( "SELECT DISTINCT r.id,r.title FROM recipes r,ingredient_list il WHERE r.id=il.recipe_id AND il.ingredient_id=%1 AND il.unit_id=%2;" ).arg( ingredientID ).arg( unitID );
+ TQSqlQuery unitToRemove( command, database );
loadElementList( recipes, &unitToRemove );
// Ingredient info using that combination
- command = QString( "SELECT i.name,ip.name,ip.units,u.name FROM ingredients i, ingredient_info ii, ingredient_properties ip, units u WHERE i.id=ii.ingredient_id AND ii.ingredient_id=%1 AND ii.per_units=%2 AND ii.property_id=ip.id AND ii.per_units=u.id;" ).arg( ingredientID ).arg( unitID );
+ command = TQString( "SELECT i.name,ip.name,ip.units,u.name FROM ingredients i, ingredient_info ii, ingredient_properties ip, units u WHERE i.id=ii.ingredient_id AND ii.ingredient_id=%1 AND ii.per_units=%2 AND ii.property_id=ip.id AND ii.per_units=u.id;" ).arg( ingredientID ).arg( unitID );
unitToRemove.exec( command );
loadPropertyElementList( ingredientInfo, &unitToRemove );
}
-void QSqlRecipeDB::findIngredientDependancies( int ingredientID, ElementList *recipes )
+void TQSqlRecipeDB::findIngredientDependancies( int ingredientID, ElementList *recipes )
{
- QString command = QString( "SELECT DISTINCT r.id,r.title FROM recipes r,ingredient_list il WHERE r.id=il.recipe_id AND il.ingredient_id=%1" ).arg( ingredientID );
+ TQString command = TQString( "SELECT DISTINCT r.id,r.title FROM recipes r,ingredient_list il WHERE r.id=il.recipe_id AND il.ingredient_id=%1" ).arg( ingredientID );
- QSqlQuery ingredientToRemove( command, database );
+ TQSqlQuery ingredientToRemove( command, database );
loadElementList( recipes, &ingredientToRemove );
}
//Finds data dependant on the removal of this Unit
-void QSqlRecipeDB::findUnitDependancies( int unitID, ElementList *properties, ElementList *recipes, ElementList *weights )
+void TQSqlRecipeDB::findUnitDependancies( int unitID, ElementList *properties, ElementList *recipes, ElementList *weights )
{
// Ingredient-Info (ingredient->property) using this Unit
- QString command = QString( "SELECT i.name,ip.name,ip.units,u.name FROM ingredients i, ingredient_info ii, ingredient_properties ip, units u WHERE i.id=ii.ingredient_id AND ii.per_units=%1 AND ii.property_id=ip.id AND ii.per_units=u.id;" ).arg( unitID );
- QSqlQuery unitToRemove( command, database );
+ TQString command = TQString( "SELECT i.name,ip.name,ip.units,u.name FROM ingredients i, ingredient_info ii, ingredient_properties ip, units u WHERE i.id=ii.ingredient_id AND ii.per_units=%1 AND ii.property_id=ip.id AND ii.per_units=u.id;" ).arg( unitID );
+ TQSqlQuery unitToRemove( command, database );
loadPropertyElementList( properties, &unitToRemove );
// Recipes using this Unit
- command = QString( "SELECT DISTINCT r.id,r.title FROM recipes r,ingredient_list il WHERE r.id=il.recipe_id AND il.unit_id=%1;" ).arg( unitID ); // Without "DISTINCT" we get duplicates since ingredient_list has no unique recipe_id's
+ command = TQString( "SELECT DISTINCT r.id,r.title FROM recipes r,ingredient_list il WHERE r.id=il.recipe_id AND il.unit_id=%1;" ).arg( unitID ); // Without "DISTINCT" we get duplicates since ingredient_list has no unique recipe_id's
unitToRemove.exec( command );
loadElementList( recipes, &unitToRemove );
// Weights using this unit
- command = QString( "SELECT i.name,weight_u.name,per_u.name,w.prep_method_id FROM ingredients i,ingredient_weights w,units weight_u,units per_u WHERE i.id=w.ingredient_id AND w.unit_id=per_u.id AND w.weight_unit_id=weight_u.id AND (weight_u.id=%1 OR per_u.id=%2)" )
+ command = TQString( "SELECT i.name,weight_u.name,per_u.name,w.prep_method_id FROM ingredients i,ingredient_weights w,units weight_u,units per_u WHERE i.id=w.ingredient_id AND w.unit_id=per_u.id AND w.weight_unit_id=weight_u.id AND (weight_u.id=%1 OR per_u.id=%2)" )
.arg( unitID )
.arg( unitID );
unitToRemove.exec( command );
@@ -1737,48 +1737,48 @@ void QSqlRecipeDB::findUnitDependancies( int unitID, ElementList *properties, El
while ( unitToRemove.next() ) {
Element el;
- QString ingName = unescapeAndDecode( unitToRemove.value( 0 ).toCString() );
- QString weightUnit = unescapeAndDecode( unitToRemove.value( 1 ).toCString() );
- QString perUnit = unescapeAndDecode( unitToRemove.value( 2 ).toCString() );
+ TQString ingName = unescapeAndDecode( unitToRemove.value( 0 ).toCString() );
+ TQString weightUnit = unescapeAndDecode( unitToRemove.value( 1 ).toCString() );
+ TQString perUnit = unescapeAndDecode( unitToRemove.value( 2 ).toCString() );
int prepID = unitToRemove.value( 3 ).toInt();
- QString prep;
+ TQString prep;
if ( prepID != -1 ) {
- command = QString( "SELECT p.name FROM prep_methods p, ingredient_weights w WHERE p.id = w.prep_method_id AND w.prep_method_id=%1" )
+ command = TQString( "SELECT p.name FROM prep_methods p, ingredient_weights w WHERE p.id = w.prep_method_id AND w.prep_method_id=%1" )
.arg( prepID );
- QSqlQuery query( command, database );
+ TQSqlQuery query( command, database );
if ( query.isActive() && query.first() )
prep = unescapeAndDecode( query.value( 0 ).toCString() );
}
- el.name = QString( i18n("In ingredient '%1': weight [%2/%3%4]") ).arg( ingName ).arg( weightUnit ).arg( perUnit ).arg( (prepID == -1)?QString::null:"; "+prep );
+ el.name = TQString( i18n("In ingredient '%1': weight [%2/%3%4]") ).arg( ingName ).arg( weightUnit ).arg( perUnit ).arg( (prepID == -1)?TQString::null:"; "+prep );
weights->append( el );
}
}
}
-void QSqlRecipeDB::findPrepMethodDependancies( int prepMethodID, ElementList *recipes )
+void TQSqlRecipeDB::findPrepMethodDependancies( int prepMethodID, ElementList *recipes )
{
//get just the ids first so that we can use DISTINCT
- QString command = QString( "SELECT DISTINCT r.id FROM recipes r,ingredient_list il, prep_method_list pl WHERE r.id=il.recipe_id AND pl.ingredient_list_id=il.id AND pl.prep_method_id=%1;" ).arg( prepMethodID );
+ TQString command = TQString( "SELECT DISTINCT r.id FROM recipes r,ingredient_list il, prep_method_list pl WHERE r.id=il.recipe_id AND pl.ingredient_list_id=il.id AND pl.prep_method_id=%1;" ).arg( prepMethodID );
- QStringList ids;
- QSqlQuery query( command, database );
+ TQStringList ids;
+ TQSqlQuery query( command, database );
if ( query.isActive() ) {
while ( query.next() ) {
- ids << QString::number(query.value( 0 ).toInt());
+ ids << TQString::number(query.value( 0 ).toInt());
}
}
//now get the titles of the ids
- command = QString( "SELECT r.id, r.title FROM recipes r WHERE r.id IN ("+ids.join(",")+")" );
- QSqlQuery prepMethodToRemove( command, database );
+ command = TQString( "SELECT r.id, r.title FROM recipes r WHERE r.id IN ("+ids.join(",")+")" );
+ TQSqlQuery prepMethodToRemove( command, database );
loadElementList( recipes, &prepMethodToRemove );
}
-void QSqlRecipeDB::loadElementList( ElementList *elList, QSqlQuery *query )
+void TQSqlRecipeDB::loadElementList( ElementList *elList, TQSqlQuery *query )
{
if ( query->isActive() ) {
while ( query->next() ) {
@@ -1790,18 +1790,18 @@ void QSqlRecipeDB::loadElementList( ElementList *elList, QSqlQuery *query )
}
}
// See function "findUnitDependancies" for use
-void QSqlRecipeDB::loadPropertyElementList( ElementList *elList, QSqlQuery *query )
+void TQSqlRecipeDB::loadPropertyElementList( ElementList *elList, TQSqlQuery *query )
{
if ( query->isActive() ) {
while ( query->next() ) {
Element el;
el.id = -1; // There's no ID for the ingredient-property combination
- QString ingName = unescapeAndDecode( query->value( 0 ).toCString() );
- QString propName = unescapeAndDecode( query->value( 1 ).toCString() );
- QString propUnits = unescapeAndDecode( query->value( 2 ).toCString() );
- QString propPerUnits = unescapeAndDecode( query->value( 3 ).toCString() );
+ TQString ingName = unescapeAndDecode( query->value( 0 ).toCString() );
+ TQString propName = unescapeAndDecode( query->value( 1 ).toCString() );
+ TQString propUnits = unescapeAndDecode( query->value( 2 ).toCString() );
+ TQString propPerUnits = unescapeAndDecode( query->value( 3 ).toCString() );
- el.name = QString( i18n("In ingredient '%1': property \"%2\" [%3/%4]") ).arg( ingName ).arg( propName ).arg( propUnits ).arg( propPerUnits );
+ el.name = TQString( i18n("In ingredient '%1': property \"%2\" [%3/%4]") ).arg( ingName ).arg( propName ).arg( propUnits ).arg( propPerUnits );
elList->append( el );
}
}
@@ -1809,87 +1809,87 @@ void QSqlRecipeDB::loadPropertyElementList( ElementList *elList, QSqlQuery *quer
//The string going into the database is utf8 text interpreted as latin1
-QString QSqlRecipeDB::escapeAndEncode( const QString &s ) const
+TQString TQSqlRecipeDB::escapeAndEncode( const TQString &s ) const
{
- QString s_escaped = s;
+ TQString s_escaped = s;
s_escaped.replace ( "'", "\\'" );
s_escaped.replace ( ";", "\";@" ); // Small trick for only for parsing later on
- return QString::fromLatin1( s_escaped.utf8() );
+ return TQString::fromLatin1( s_escaped.utf8() );
}
//The string coming out of the database is utf8 text, interpreted as though latin1. Calling fromUtf8() on this gives us back the original utf8.
-QString QSqlRecipeDB::unescapeAndDecode( const QCString &s ) const
+TQString TQSqlRecipeDB::unescapeAndDecode( const TQCString &s ) const
{
- return QString::fromUtf8( s ).replace( "\";@", ";" ); // Use unicode encoding
+ return TQString::fromUtf8( s ).replace( "\";@", ";" ); // Use unicode encoding
}
-bool QSqlRecipeDB::ingredientContainsUnit( int ingredientID, int unitID )
+bool TQSqlRecipeDB::ingredientContainsUnit( int ingredientID, int unitID )
{
- QString command = QString( "SELECT * FROM unit_list WHERE ingredient_id= %1 AND unit_id=%2;" ).arg( ingredientID ).arg( unitID );
- QSqlQuery recipeToLoad( command, database );
+ TQString command = TQString( "SELECT * FROM unit_list WHERE ingredient_id= %1 AND unit_id=%2;" ).arg( ingredientID ).arg( unitID );
+ TQSqlQuery recipeToLoad( command, database );
if ( recipeToLoad.isActive() ) {
return ( recipeToLoad.size() > 0 );
}
return false;
}
-bool QSqlRecipeDB::ingredientContainsProperty( int ingredientID, int propertyID, int perUnitsID )
+bool TQSqlRecipeDB::ingredientContainsProperty( int ingredientID, int propertyID, int perUnitsID )
{
- QString command = QString( "SELECT * FROM ingredient_info WHERE ingredient_id=%1 AND property_id=%2 AND per_units=%3;" ).arg( ingredientID ).arg( propertyID ).arg( perUnitsID );
- QSqlQuery recipeToLoad( command, database );
+ TQString command = TQString( "SELECT * FROM ingredient_info WHERE ingredient_id=%1 AND property_id=%2 AND per_units=%3;" ).arg( ingredientID ).arg( propertyID ).arg( perUnitsID );
+ TQSqlQuery recipeToLoad( command, database );
if ( recipeToLoad.isActive() ) {
return ( recipeToLoad.size() > 0 );
}
return false;
}
-QString QSqlRecipeDB::categoryName( int ID )
+TQString TQSqlRecipeDB::categoryName( int ID )
{
- QString command = QString( "SELECT name FROM categories WHERE id=%1;" ).arg( ID );
- QSqlQuery toLoad( command, database );
+ TQString command = TQString( "SELECT name FROM categories WHERE id=%1;" ).arg( ID );
+ TQSqlQuery toLoad( command, database );
if ( toLoad.isActive() && toLoad.next() ) // Go to the first record (there should be only one anyway.
return ( unescapeAndDecode( toLoad.value( 0 ).toCString() ) );
- return ( QString::null );
+ return ( TQString::null );
}
-QString QSqlRecipeDB::ingredientName( int ID )
+TQString TQSqlRecipeDB::ingredientName( int ID )
{
- QString command = QString( "SELECT name FROM ingredients WHERE id=%1" ).arg( ID );
- QSqlQuery toLoad( command, database );
+ TQString command = TQString( "SELECT name FROM ingredients WHERE id=%1" ).arg( ID );
+ TQSqlQuery toLoad( command, database );
if ( toLoad.isActive() && toLoad.next() ) // Go to the first record (there should be only one anyway.
return ( unescapeAndDecode( toLoad.value( 0 ).toCString() ) );
- return ( QString::null );
+ return ( TQString::null );
}
-QString QSqlRecipeDB::prepMethodName( int ID )
+TQString TQSqlRecipeDB::prepMethodName( int ID )
{
- QString command = QString( "SELECT name FROM prep_methods WHERE id=%1" ).arg( ID );
- QSqlQuery toLoad( command, database );
+ TQString command = TQString( "SELECT name FROM prep_methods WHERE id=%1" ).arg( ID );
+ TQSqlQuery toLoad( command, database );
if ( toLoad.isActive() && toLoad.next() ) // Go to the first record (there should be only one anyway.
return ( unescapeAndDecode( toLoad.value( 0 ).toCString() ) );
- return ( QString::null );
+ return ( TQString::null );
}
-IngredientProperty QSqlRecipeDB::propertyName( int ID )
+IngredientProperty TQSqlRecipeDB::propertyName( int ID )
{
- QString command = QString( "SELECT name,units FROM ingredient_properties WHERE id=%1;" ).arg( ID );
- QSqlQuery toLoad( command, database );
+ TQString command = TQString( "SELECT name,units FROM ingredient_properties WHERE id=%1;" ).arg( ID );
+ TQSqlQuery toLoad( command, database );
if ( toLoad.isActive() && toLoad.next() ) { // Go to the first record (there should be only one anyway.
return ( IngredientProperty( unescapeAndDecode( toLoad.value( 0 ).toCString() ), unescapeAndDecode( toLoad.value( 1 ).toCString() ), ID ) );
}
- return ( IngredientProperty( QString::null, QString::null ) );
+ return ( IngredientProperty( TQString::null, TQString::null ) );
}
-Unit QSqlRecipeDB::unitName( int ID )
+Unit TQSqlRecipeDB::unitName( int ID )
{
- QString command = QString( "SELECT name,plural,name_abbrev,plural_abbrev,type FROM units WHERE id=%1" ).arg( ID );
- QSqlQuery toLoad( command, database );
+ TQString command = TQString( "SELECT name,plural,name_abbrev,plural_abbrev,type FROM units WHERE id=%1" ).arg( ID );
+ TQSqlQuery toLoad( command, database );
if ( toLoad.isActive() && toLoad.next() ) { // Go to the first record (there should be only one anyway.
Unit unit( unescapeAndDecode( toLoad.value( 0 ).toCString() ), unescapeAndDecode( toLoad.value( 1 ).toCString() ) );
@@ -1910,10 +1910,10 @@ Unit QSqlRecipeDB::unitName( int ID )
return Unit();
}
-int QSqlRecipeDB::getCount( const QString &table_name )
+int TQSqlRecipeDB::getCount( const TQString &table_name )
{
m_command = "SELECT COUNT(1) FROM "+table_name;
- QSqlQuery count( m_command, database );
+ TQSqlQuery count( m_command, database );
if ( count.isActive() && count.next() ) { // Go to the first record (there should be only one anyway.
return count.value( 0 ).toInt();
}
@@ -1921,10 +1921,10 @@ int QSqlRecipeDB::getCount( const QString &table_name )
return -1;
}
-int QSqlRecipeDB::categoryTopLevelCount()
+int TQSqlRecipeDB::categoryTopLevelCount()
{
m_command = "SELECT COUNT(1) FROM categories WHERE parent_id='-1'";
- QSqlQuery count( m_command, database );
+ TQSqlQuery count( m_command, database );
if ( count.isActive() && count.next() ) { // Go to the first record (there should be only one anyway.
return count.value( 0 ).toInt();
}
@@ -1932,19 +1932,19 @@ int QSqlRecipeDB::categoryTopLevelCount()
return -1;
}
-bool QSqlRecipeDB::checkIntegrity( void )
+bool TQSqlRecipeDB::checkIntegrity( void )
{
// Check existence of the necessary tables (the database may be created, but empty)
- QStringList tables;
+ TQStringList tables;
tables << "ingredient_info" << "ingredient_list" << "ingredient_properties" << "ingredient_weights" << "ingredients" << "recipes" << "unit_list" << "units" << "units_conversion" << "categories" << "category_list" << "authors" << "author_list" << "db_info" << "prep_methods" << "ingredient_groups" << "yield_types" << "prep_method_list" << "ratings" << "rating_criteria" << "rating_criterion_list";
- QStringList existingTableList = database->tables();
- for ( QStringList::Iterator it = tables.begin(); it != tables.end(); ++it ) {
+ TQStringList existingTableList = database->tables();
+ for ( TQStringList::Iterator it = tables.begin(); it != tables.end(); ++it ) {
bool found = false;
- for ( QStringList::Iterator ex_it = existingTableList.begin(); ( ( ex_it != existingTableList.end() ) && ( !found ) ); ++ex_it ) {
+ for ( TQStringList::Iterator ex_it = existingTableList.begin(); ( ( ex_it != existingTableList.end() ) && ( !found ) ); ++ex_it ) {
found = ( *ex_it == *it );
}
@@ -1954,7 +1954,7 @@ bool QSqlRecipeDB::checkIntegrity( void )
}
}
- QStringList newTableList = database->tables();
+ TQStringList newTableList = database->tables();
if ( newTableList.isEmpty() )
return false;
@@ -1965,10 +1965,10 @@ bool QSqlRecipeDB::checkIntegrity( void )
float version = databaseVersion();
kdDebug() << "version found... " << version << " \n";
kdDebug() << "latest version... " << latestDBVersion() << endl;
- if ( int( qRound( databaseVersion() * 1e5 ) ) < int( qRound( latestDBVersion() * 1e5 ) ) ) { //correct for float's imprecision
+ if ( int( tqRound( databaseVersion() * 1e5 ) ) < int( tqRound( latestDBVersion() * 1e5 ) ) ) { //correct for float's imprecision
switch ( KMessageBox::questionYesNo( 0, i18n( "<!doc>The database was created with a previous version of Krecipes. Would you like Krecipes to update this database to work with this version of Krecipes? Depending on the number of recipes and amount of data, this could take some time.<br><br><b>Warning: After updating, this database will no longer be compatible with previous versions of Krecipes.<br><br>Cancelling this operation may result in corrupting the database.</b>" ) ) ) {
case KMessageBox::Yes:
- emit progressBegin(0,QString::null,i18n("Porting database structure..."),50);
+ emit progressBegin(0,TQString::null,i18n("Porting database structure..."),50);
portOldDatabases( version );
emit progressDone();
break;
@@ -1980,19 +1980,19 @@ bool QSqlRecipeDB::checkIntegrity( void )
return true;
}
-void QSqlRecipeDB::splitCommands( QString& s, QStringList& sl )
+void TQSqlRecipeDB::splitCommands( TQString& s, TQStringList& sl )
{
- sl = QStringList::split( QRegExp( ";{1}(?!@)" ), s );
+ sl = TQStringList::split( TQRegExp( ";{1}(?!@)" ), s );
}
-void QSqlRecipeDB::portOldDatabases( float /* version */ )
+void TQSqlRecipeDB::portOldDatabases( float /* version */ )
{}
-float QSqlRecipeDB::databaseVersion( void )
+float TQSqlRecipeDB::databaseVersion( void )
{
- QString command = "SELECT ver FROM db_info";
- QSqlQuery dbVersion( command, database );
+ TQString command = "SELECT ver FROM db_info";
+ TQSqlQuery dbVersion( command, database );
if ( dbVersion.isActive() && dbVersion.next() )
return ( dbVersion.value( 0 ).toDouble() ); // There should be only one (or none for old DB) element, so go to first
@@ -2000,13 +2000,13 @@ float QSqlRecipeDB::databaseVersion( void )
return ( 0.2 ); // if table is empty, assume oldest (0.2), and port
}
-void QSqlRecipeDB::loadRatingCriterion( ElementList *list, int limit, int offset )
+void TQSqlRecipeDB::loadRatingCriterion( ElementList *list, int limit, int offset )
{
list->clear();
- QString command = "SELECT id,name FROM rating_criteria ORDER BY name"
- +((limit==-1)?"":" LIMIT "+QString::number(limit)+" OFFSET "+QString::number(offset));
- QSqlQuery toLoad( command, database );
+ TQString command = "SELECT id,name FROM rating_criteria ORDER BY name"
+ +((limit==-1)?"":" LIMIT "+TQString::number(limit)+" OFFSET "+TQString::number(offset));
+ TQSqlQuery toLoad( command, database );
if ( toLoad.isActive() ) {
while ( toLoad.next() ) {
Element el;
@@ -2017,13 +2017,13 @@ void QSqlRecipeDB::loadRatingCriterion( ElementList *list, int limit, int offset
}
}
-void QSqlRecipeDB::loadCategories( ElementList *list, int limit, int offset )
+void TQSqlRecipeDB::loadCategories( ElementList *list, int limit, int offset )
{
list->clear();
m_command = "SELECT id,name FROM categories ORDER BY name"
- +((limit==-1)?"":" LIMIT "+QString::number(limit)+" OFFSET "+QString::number(offset));
- QSqlQuery categoryToLoad( m_command, database );
+ +((limit==-1)?"":" LIMIT "+TQString::number(limit)+" OFFSET "+TQString::number(offset));
+ TQSqlQuery categoryToLoad( m_command, database );
if ( categoryToLoad.isActive() ) {
while ( categoryToLoad.next() ) {
Element el;
@@ -2034,20 +2034,20 @@ void QSqlRecipeDB::loadCategories( ElementList *list, int limit, int offset )
}
}
-void QSqlRecipeDB::loadCategories( CategoryTree *list, int limit, int offset, int parent_id, bool recurse )
+void TQSqlRecipeDB::loadCategories( CategoryTree *list, int limit, int offset, int parent_id, bool recurse )
{
- QString limit_str;
+ TQString limit_str;
if ( parent_id == -1 ) {
- emit progressBegin(0,QString::null,i18n("Loading category list"));
+ emit progressBegin(0,TQString::null,i18n("Loading category list"));
list->clear();
//only limit the number of top-level categories
- limit_str = (limit==-1)?"":" LIMIT "+QString::number(limit)+" OFFSET "+QString::number(offset);
+ limit_str = (limit==-1)?"":" LIMIT "+TQString::number(limit)+" OFFSET "+TQString::number(offset);
}
- m_command = "SELECT id,name,parent_id FROM categories WHERE parent_id='"+QString::number(parent_id)+"' ORDER BY name "+limit_str;
+ m_command = "SELECT id,name,parent_id FROM categories WHERE parent_id='"+TQString::number(parent_id)+"' ORDER BY name "+limit_str;
- QSqlQuery categoryToLoad( QString::null, database );
+ TQSqlQuery categoryToLoad( TQString::null, database );
//categoryToLoad.setForwardOnly(true); //FIXME? Subcategories aren't loaded if this is enabled, even though we only go forward
categoryToLoad.exec(m_command);
@@ -2063,7 +2063,7 @@ void QSqlRecipeDB::loadCategories( CategoryTree *list, int limit, int offset, in
CategoryTree *list_child = list->add( el );
if ( recurse ) {
- //QTime dbg_timer; dbg_timer.start(); kdDebug()<<" calling QSqlRecipeDB::loadCategories"<<endl;
+ //TQTime dbg_timer; dbg_timer.start(); kdDebug()<<" calling TQSqlRecipeDB::loadCategories"<<endl;
loadCategories( list_child, -1, -1, id ); //limit and offset won't be used
// kdDebug()<<" done in "<<dbg_timer.elapsed()<<" ms"<<endl;
}
@@ -2074,48 +2074,48 @@ void QSqlRecipeDB::loadCategories( CategoryTree *list, int limit, int offset, in
emit progressDone();
}
-void QSqlRecipeDB::createNewCategory( const QString &categoryName, int parent_id )
+void TQSqlRecipeDB::createNewCategory( const TQString &categoryName, int parent_id )
{
- QString command;
- QString real_name = categoryName.left( maxCategoryNameLength() );
+ TQString command;
+ TQString real_name = categoryName.left( maxCategoryNameLength() );
- command = QString( "INSERT INTO categories VALUES(%3,'%1',%2);" )
+ command = TQString( "INSERT INTO categories VALUES(%3,'%1',%2);" )
.arg( escapeAndEncode( real_name ) )
.arg( parent_id )
.arg( getNextInsertIDStr( "categories", "id" ) );
- QSqlQuery categoryToCreate( command, database );
+ TQSqlQuery categoryToCreate( command, database );
emit categoryCreated( Element( real_name, lastInsertID() ), parent_id );
}
-void QSqlRecipeDB::modCategory( int categoryID, const QString &newLabel )
+void TQSqlRecipeDB::modCategory( int categoryID, const TQString &newLabel )
{
- QString command = QString( "UPDATE categories SET name='%1' WHERE id=%2;" ).arg( escapeAndEncode( newLabel ) ).arg( categoryID );
- QSqlQuery categoryToUpdate( command, database );
+ TQString command = TQString( "UPDATE categories SET name='%1' WHERE id=%2;" ).arg( escapeAndEncode( newLabel ) ).arg( categoryID );
+ TQSqlQuery categoryToUpdate( command, database );
emit categoryModified( Element( newLabel, categoryID ) );
}
-void QSqlRecipeDB::modCategory( int categoryID, int new_parent_id )
+void TQSqlRecipeDB::modCategory( int categoryID, int new_parent_id )
{
- QString command = QString( "UPDATE categories SET parent_id=%1 WHERE id=%2;" ).arg( new_parent_id ).arg( categoryID );
- QSqlQuery categoryToUpdate( command, database );
+ TQString command = TQString( "UPDATE categories SET parent_id=%1 WHERE id=%2;" ).arg( new_parent_id ).arg( categoryID );
+ TQSqlQuery categoryToUpdate( command, database );
emit categoryModified( categoryID, new_parent_id );
}
-void QSqlRecipeDB::removeCategory( int categoryID )
+void TQSqlRecipeDB::removeCategory( int categoryID )
{
- QString command;
+ TQString command;
- command = QString( "DELETE FROM categories WHERE id=%1;" ).arg( categoryID );
- QSqlQuery categoryToRemove( command, database );
+ command = TQString( "DELETE FROM categories WHERE id=%1;" ).arg( categoryID );
+ TQSqlQuery categoryToRemove( command, database );
- command = QString( "DELETE FROM category_list WHERE category_id=%1;" ).arg( categoryID );
+ command = TQString( "DELETE FROM category_list WHERE category_id=%1;" ).arg( categoryID );
categoryToRemove.exec( command );
//recursively delete subcategories
- command = QString( "SELECT id FROM categories WHERE parent_id=%1;" ).arg( categoryID );
+ command = TQString( "SELECT id FROM categories WHERE parent_id=%1;" ).arg( categoryID );
categoryToRemove.exec( command );
if ( categoryToRemove.isActive() ) {
while ( categoryToRemove.next() ) {
@@ -2127,12 +2127,12 @@ void QSqlRecipeDB::removeCategory( int categoryID )
}
-void QSqlRecipeDB::loadAuthors( ElementList *list, int limit, int offset )
+void TQSqlRecipeDB::loadAuthors( ElementList *list, int limit, int offset )
{
list->clear();
- QString command = "SELECT id,name FROM authors ORDER BY name"
- +((limit==-1)?"":" LIMIT "+QString::number(limit)+" OFFSET "+QString::number(offset));
- QSqlQuery authorToLoad( command, database );
+ TQString command = "SELECT id,name FROM authors ORDER BY name"
+ +((limit==-1)?"":" LIMIT "+TQString::number(limit)+" OFFSET "+TQString::number(offset));
+ TQSqlQuery authorToLoad( command, database );
if ( authorToLoad.isActive() ) {
while ( authorToLoad.next() ) {
Element el;
@@ -2143,44 +2143,44 @@ void QSqlRecipeDB::loadAuthors( ElementList *list, int limit, int offset )
}
}
-void QSqlRecipeDB::createNewAuthor( const QString &authorName )
+void TQSqlRecipeDB::createNewAuthor( const TQString &authorName )
{
- QString command;
- QString real_name = authorName.left( maxAuthorNameLength() );
+ TQString command;
+ TQString real_name = authorName.left( maxAuthorNameLength() );
- command = QString( "INSERT INTO authors VALUES(%2,'%1');" ).arg( escapeAndEncode( real_name ) ).arg( getNextInsertIDStr( "authors", "id" ) );
- QSqlQuery authorToCreate( command, database );
+ command = TQString( "INSERT INTO authors VALUES(%2,'%1');" ).arg( escapeAndEncode( real_name ) ).arg( getNextInsertIDStr( "authors", "id" ) );
+ TQSqlQuery authorToCreate( command, database );
emit authorCreated( Element( real_name, lastInsertID() ) );
}
-void QSqlRecipeDB::modAuthor( int authorID, const QString &newLabel )
+void TQSqlRecipeDB::modAuthor( int authorID, const TQString &newLabel )
{
- QString command;
+ TQString command;
- command = QString( "UPDATE authors SET name='%1' WHERE id=%2;" ).arg( escapeAndEncode( newLabel ) ).arg( authorID );
- QSqlQuery authorToCreate( command, database );
+ command = TQString( "UPDATE authors SET name='%1' WHERE id=%2;" ).arg( escapeAndEncode( newLabel ) ).arg( authorID );
+ TQSqlQuery authorToCreate( command, database );
emit authorRemoved( authorID );
emit authorCreated( Element( newLabel, authorID ) );
}
-void QSqlRecipeDB::removeAuthor( int authorID )
+void TQSqlRecipeDB::removeAuthor( int authorID )
{
- QString command;
+ TQString command;
- command = QString( "DELETE FROM authors WHERE id=%1;" ).arg( authorID );
- QSqlQuery authorToRemove( command, database );
+ command = TQString( "DELETE FROM authors WHERE id=%1;" ).arg( authorID );
+ TQSqlQuery authorToRemove( command, database );
emit authorRemoved( authorID );
}
-int QSqlRecipeDB::findExistingAuthorByName( const QString& name )
+int TQSqlRecipeDB::findExistingAuthorByName( const TQString& name )
{
- QString search_str = escapeAndEncode( name.left( maxAuthorNameLength() ) ); //truncate to the maximum size db holds
+ TQString search_str = escapeAndEncode( name.left( maxAuthorNameLength() ) ); //truncate to the maximum size db holds
- QString command = QString( "SELECT id FROM authors WHERE name LIKE '%1';" ).arg( search_str );
- QSqlQuery elementToLoad( command, database ); // Run the query
+ TQString command = TQString( "SELECT id FROM authors WHERE name LIKE '%1';" ).arg( search_str );
+ TQSqlQuery elementToLoad( command, database ); // Run the query
int id = -1;
if ( elementToLoad.isActive() && elementToLoad.first() )
@@ -2189,12 +2189,12 @@ int QSqlRecipeDB::findExistingAuthorByName( const QString& name )
return id;
}
-int QSqlRecipeDB::findExistingCategoryByName( const QString& name )
+int TQSqlRecipeDB::findExistingCategoryByName( const TQString& name )
{
- QString search_str = escapeAndEncode( name.left( maxCategoryNameLength() ) ); //truncate to the maximum size db holds
+ TQString search_str = escapeAndEncode( name.left( maxCategoryNameLength() ) ); //truncate to the maximum size db holds
- QString command = QString( "SELECT id FROM categories WHERE name LIKE '%1';" ).arg( search_str );
- QSqlQuery elementToLoad( command, database ); // Run the query
+ TQString command = TQString( "SELECT id FROM categories WHERE name LIKE '%1';" ).arg( search_str );
+ TQSqlQuery elementToLoad( command, database ); // Run the query
int id = -1;
if ( elementToLoad.isActive() && elementToLoad.first() )
@@ -2203,12 +2203,12 @@ int QSqlRecipeDB::findExistingCategoryByName( const QString& name )
return id;
}
-int QSqlRecipeDB::findExistingIngredientGroupByName( const QString& name )
+int TQSqlRecipeDB::findExistingIngredientGroupByName( const TQString& name )
{
- QString search_str = escapeAndEncode( name.left( maxIngGroupNameLength() ) ); //truncate to the maximum size db holds
+ TQString search_str = escapeAndEncode( name.left( maxIngGroupNameLength() ) ); //truncate to the maximum size db holds
- QString command = QString( "SELECT id FROM ingredient_groups WHERE name LIKE '%1';" ).arg( search_str );
- QSqlQuery elementToLoad( command, database ); // Run the query
+ TQString command = TQString( "SELECT id FROM ingredient_groups WHERE name LIKE '%1';" ).arg( search_str );
+ TQSqlQuery elementToLoad( command, database ); // Run the query
int id = -1;
if ( elementToLoad.isActive() && elementToLoad.first() )
@@ -2217,12 +2217,12 @@ int QSqlRecipeDB::findExistingIngredientGroupByName( const QString& name )
return id;
}
-int QSqlRecipeDB::findExistingIngredientByName( const QString& name )
+int TQSqlRecipeDB::findExistingIngredientByName( const TQString& name )
{
- QString search_str = escapeAndEncode( name.left( maxIngredientNameLength() ) ); //truncate to the maximum size db holds
+ TQString search_str = escapeAndEncode( name.left( maxIngredientNameLength() ) ); //truncate to the maximum size db holds
- QString command = QString( "SELECT id FROM ingredients WHERE name LIKE '%1';" ).arg( search_str );
- QSqlQuery elementToLoad( command, database ); // Run the query
+ TQString command = TQString( "SELECT id FROM ingredients WHERE name LIKE '%1';" ).arg( search_str );
+ TQSqlQuery elementToLoad( command, database ); // Run the query
int id = -1;
if ( elementToLoad.isActive() && elementToLoad.first() )
@@ -2231,12 +2231,12 @@ int QSqlRecipeDB::findExistingIngredientByName( const QString& name )
return id;
}
-int QSqlRecipeDB::findExistingPrepByName( const QString& name )
+int TQSqlRecipeDB::findExistingPrepByName( const TQString& name )
{
- QString search_str = escapeAndEncode( name.left( maxPrepMethodNameLength() ) ); //truncate to the maximum size db holds
+ TQString search_str = escapeAndEncode( name.left( maxPrepMethodNameLength() ) ); //truncate to the maximum size db holds
- QString command = QString( "SELECT id FROM prep_methods WHERE name LIKE '%1';" ).arg( search_str );
- QSqlQuery elementToLoad( command, database ); // Run the query
+ TQString command = TQString( "SELECT id FROM prep_methods WHERE name LIKE '%1';" ).arg( search_str );
+ TQSqlQuery elementToLoad( command, database ); // Run the query
int id = -1;
if ( elementToLoad.isActive() && elementToLoad.first() )
@@ -2245,12 +2245,12 @@ int QSqlRecipeDB::findExistingPrepByName( const QString& name )
return id;
}
-int QSqlRecipeDB::findExistingPropertyByName( const QString& name )
+int TQSqlRecipeDB::findExistingPropertyByName( const TQString& name )
{
- QString search_str = escapeAndEncode( name.left( maxPropertyNameLength() ) ); //truncate to the maximum size db holds
+ TQString search_str = escapeAndEncode( name.left( maxPropertyNameLength() ) ); //truncate to the maximum size db holds
- QString command = QString( "SELECT id FROM ingredient_properties WHERE name LIKE '%1';" ).arg( search_str );
- QSqlQuery elementToLoad( command, database ); // Run the query
+ TQString command = TQString( "SELECT id FROM ingredient_properties WHERE name LIKE '%1';" ).arg( search_str );
+ TQSqlQuery elementToLoad( command, database ); // Run the query
int id = -1;
if ( elementToLoad.isActive() && elementToLoad.first() )
@@ -2259,17 +2259,17 @@ int QSqlRecipeDB::findExistingPropertyByName( const QString& name )
return id;
}
-int QSqlRecipeDB::findExistingUnitByName( const QString& name )
+int TQSqlRecipeDB::findExistingUnitByName( const TQString& name )
{
- QString search_str = escapeAndEncode( name.left( maxUnitNameLength() ) ); //truncate to the maximum size db holds
+ TQString search_str = escapeAndEncode( name.left( maxUnitNameLength() ) ); //truncate to the maximum size db holds
- QString command = "SELECT id FROM units WHERE name LIKE '" + search_str
+ TQString command = "SELECT id FROM units WHERE name LIKE '" + search_str
+ "' OR plural LIKE '" + search_str
+ "' OR name_abbrev LIKE '" + search_str
+ "' OR plural_abbrev LIKE '" + search_str
+ "'";
- QSqlQuery elementToLoad( command, database ); // Run the query
+ TQSqlQuery elementToLoad( command, database ); // Run the query
int id = -1;
if ( elementToLoad.isActive() && elementToLoad.first() )
@@ -2278,12 +2278,12 @@ int QSqlRecipeDB::findExistingUnitByName( const QString& name )
return id;
}
-int QSqlRecipeDB::findExistingRatingByName( const QString& name )
+int TQSqlRecipeDB::findExistingRatingByName( const TQString& name )
{
- QString search_str = escapeAndEncode( name ); //truncate to the maximum size db holds
+ TQString search_str = escapeAndEncode( name ); //truncate to the maximum size db holds
- QString command = QString( "SELECT id FROM rating_criteria WHERE name LIKE '%1'" ).arg( search_str );
- QSqlQuery elementToLoad( command, database ); // Run the query
+ TQString command = TQString( "SELECT id FROM rating_criteria WHERE name LIKE '%1'" ).arg( search_str );
+ TQSqlQuery elementToLoad( command, database ); // Run the query
int id = -1;
if ( elementToLoad.isActive() && elementToLoad.first() )
@@ -2292,12 +2292,12 @@ int QSqlRecipeDB::findExistingRatingByName( const QString& name )
return id;
}
-int QSqlRecipeDB::findExistingRecipeByName( const QString& name )
+int TQSqlRecipeDB::findExistingRecipeByName( const TQString& name )
{
- QString search_str = escapeAndEncode( name.left( maxRecipeTitleLength() ) ); //truncate to the maximum size db holds
+ TQString search_str = escapeAndEncode( name.left( maxRecipeTitleLength() ) ); //truncate to the maximum size db holds
- QString command = QString( "SELECT id FROM recipes WHERE title LIKE '%1';" ).arg( search_str );
- QSqlQuery elementToLoad( command, database ); // Run the query
+ TQString command = TQString( "SELECT id FROM recipes WHERE title LIKE '%1';" ).arg( search_str );
+ TQSqlQuery elementToLoad( command, database ); // Run the query
int id = -1;
if ( elementToLoad.isActive() && elementToLoad.first() )
@@ -2306,12 +2306,12 @@ int QSqlRecipeDB::findExistingRecipeByName( const QString& name )
return id;
}
-int QSqlRecipeDB::findExistingYieldTypeByName( const QString& name )
+int TQSqlRecipeDB::findExistingYieldTypeByName( const TQString& name )
{
- QString search_str = escapeAndEncode( name.left( maxYieldTypeLength() ) ); //truncate to the maximum size db holds
+ TQString search_str = escapeAndEncode( name.left( maxYieldTypeLength() ) ); //truncate to the maximum size db holds
- QString command = QString( "SELECT id FROM yield_types WHERE name LIKE '%1';" ).arg( search_str );
- QSqlQuery elementToLoad( command, database ); // Run the query
+ TQString command = TQString( "SELECT id FROM yield_types WHERE name LIKE '%1';" ).arg( search_str );
+ TQSqlQuery elementToLoad( command, database ); // Run the query
int id = -1;
if ( elementToLoad.isActive() && elementToLoad.first() )
@@ -2320,18 +2320,18 @@ int QSqlRecipeDB::findExistingYieldTypeByName( const QString& name )
return id;
}
-void QSqlRecipeDB::mergeAuthors( int id1, int id2 )
+void TQSqlRecipeDB::mergeAuthors( int id1, int id2 )
{
- QSqlQuery update( QString::null, database );
+ TQSqlQuery update( TQString::null, database );
//change all instances of 'id2' to 'id1'
- QString command = QString( "UPDATE author_list SET author_id=%1 WHERE author_id=%2" )
+ TQString command = TQString( "UPDATE author_list SET author_id=%1 WHERE author_id=%2" )
.arg( id1 )
.arg( id2 );
update.exec( command );
//and ensure no duplicates were created in this process
- command = QString( "SELECT recipe_id FROM author_list WHERE author_id=%1 ORDER BY recipe_id" )
+ command = TQString( "SELECT recipe_id FROM author_list WHERE author_id=%1 ORDER BY recipe_id" )
.arg( id1 );
update.exec( command );
int last_id = -1;
@@ -2340,19 +2340,19 @@ void QSqlRecipeDB::mergeAuthors( int id1, int id2 )
int current_id = update.value( 0 ).toInt();
if ( last_id == current_id ) {
int count = -1;
- command = QString( "SELECT COUNT(1) FROM author_list WHERE author_id=%1 AND recipe_id=%2" )
+ command = TQString( "SELECT COUNT(1) FROM author_list WHERE author_id=%1 AND recipe_id=%2" )
.arg( id1 )
.arg( last_id );
- QSqlQuery remove( command, database);
+ TQSqlQuery remove( command, database);
if ( remove.isActive() && remove.first() )
count = remove.value(0).toInt();
if ( count > 1 ) {
- command = QString( "DELETE FROM author_list WHERE author_id=%1 AND recipe_id=%2" )
+ command = TQString( "DELETE FROM author_list WHERE author_id=%1 AND recipe_id=%2" )
.arg( id1 )
.arg( last_id );
database->exec( command );
- command = QString( "INSERT INTO author_list VALUES(%1,%2)" )
+ command = TQString( "INSERT INTO author_list VALUES(%1,%2)" )
.arg( id1 )
.arg( last_id );
database->exec( command );
@@ -2363,23 +2363,23 @@ void QSqlRecipeDB::mergeAuthors( int id1, int id2 )
}
//remove author with id 'id2'
- command = QString( "DELETE FROM authors WHERE id=%1" ).arg( id2 );
+ command = TQString( "DELETE FROM authors WHERE id=%1" ).arg( id2 );
update.exec( command );
emit authorRemoved( id2 );
}
-void QSqlRecipeDB::mergeCategories( int id1, int id2 )
+void TQSqlRecipeDB::mergeCategories( int id1, int id2 )
{
- QSqlQuery update( QString::null, database );
+ TQSqlQuery update( TQString::null, database );
//change all instances of 'id2' to 'id1'
- QString command = QString( "UPDATE category_list SET category_id=%1 WHERE category_id=%2" )
+ TQString command = TQString( "UPDATE category_list SET category_id=%1 WHERE category_id=%2" )
.arg( id1 )
.arg( id2 );
update.exec( command );
//and ensure no duplicates were created in this process
- command = QString( "SELECT recipe_id FROM category_list WHERE category_id=%1 ORDER BY recipe_id" )
+ command = TQString( "SELECT recipe_id FROM category_list WHERE category_id=%1 ORDER BY recipe_id" )
.arg( id1 );
update.exec( command );
int last_id = -1;
@@ -2388,19 +2388,19 @@ void QSqlRecipeDB::mergeCategories( int id1, int id2 )
int current_id = update.value( 0 ).toInt();
if ( last_id == current_id ) {
int count = -1;
- command = QString( "SELECT COUNT(1) FROM category_list WHERE category_id=%1 AND recipe_id=%2" )
+ command = TQString( "SELECT COUNT(1) FROM category_list WHERE category_id=%1 AND recipe_id=%2" )
.arg( id1 )
.arg( last_id );
- QSqlQuery remove( command, database);
+ TQSqlQuery remove( command, database);
if ( remove.isActive() && remove.first() )
count = remove.value(0).toInt();
if ( count > 1 ) {
- command = QString( "DELETE FROM category_list WHERE category_id=%1 AND recipe_id=%2" )
+ command = TQString( "DELETE FROM category_list WHERE category_id=%1 AND recipe_id=%2" )
.arg( id1 )
.arg( last_id );
database->exec( command );
- command = QString( "INSERT INTO category_list VALUES(%1,%2)" )
+ command = TQString( "INSERT INTO category_list VALUES(%1,%2)" )
.arg( id1 )
.arg( last_id );
database->exec( command );
@@ -2410,61 +2410,61 @@ void QSqlRecipeDB::mergeCategories( int id1, int id2 )
}
}
- command = QString( "UPDATE categories SET parent_id=%1 WHERE parent_id=%2" )
+ command = TQString( "UPDATE categories SET parent_id=%1 WHERE parent_id=%2" )
.arg( id1 )
.arg( id2 );
update.exec( command );
//we don't want to have a category be its own parent...
- command = QString( "UPDATE categories SET parent_id=-1 WHERE parent_id=id" );
+ command = TQString( "UPDATE categories SET parent_id=-1 WHERE parent_id=id" );
update.exec( command );
//remove category with id 'id2'
- command = QString( "DELETE FROM categories WHERE id=%1" ).arg( id2 );
+ command = TQString( "DELETE FROM categories WHERE id=%1" ).arg( id2 );
update.exec( command );
emit categoriesMerged( id1, id2 );
}
-void QSqlRecipeDB::mergeIngredientGroups( int id1, int id2 )
+void TQSqlRecipeDB::mergeIngredientGroups( int id1, int id2 )
{
- QSqlQuery update( QString::null, database );
+ TQSqlQuery update( TQString::null, database );
//change all instances of 'id2' to 'id1'
- QString command = QString( "UPDATE ingredient_list SET group_id=%1 WHERE group_id=%2" )
+ TQString command = TQString( "UPDATE ingredient_list SET group_id=%1 WHERE group_id=%2" )
.arg( id1 )
.arg( id2 );
update.exec( command );
//remove ingredient with id 'id2'
- command = QString( "DELETE FROM ingredient_groups WHERE id=%1" ).arg( id2 );
+ command = TQString( "DELETE FROM ingredient_groups WHERE id=%1" ).arg( id2 );
update.exec( command );
emit ingGroupRemoved( id2 );
}
-void QSqlRecipeDB::mergeIngredients( int id1, int id2 )
+void TQSqlRecipeDB::mergeIngredients( int id1, int id2 )
{
- QSqlQuery update( QString::null, database );
+ TQSqlQuery update( TQString::null, database );
//change all instances of 'id2' to 'id1'
- QString command = QString( "UPDATE ingredient_list SET ingredient_id=%1 WHERE ingredient_id=%2" )
+ TQString command = TQString( "UPDATE ingredient_list SET ingredient_id=%1 WHERE ingredient_id=%2" )
.arg( id1 )
.arg( id2 );
update.exec( command );
//delete nutrient info associated with ingredient with id 'id2'
- command = QString( "DELETE FROM ingredient_info WHERE ingredient_id=%1" )
+ command = TQString( "DELETE FROM ingredient_info WHERE ingredient_id=%1" )
.arg( id2 );
update.exec( command );
//update the unit_list
- command = QString( "UPDATE unit_list SET ingredient_id=%1 WHERE ingredient_id=%2" )
+ command = TQString( "UPDATE unit_list SET ingredient_id=%1 WHERE ingredient_id=%2" )
.arg( id1 )
.arg( id2 );
update.exec( command );
//and ensure no duplicates were created in this process
- command = QString( "SELECT unit_id FROM unit_list WHERE ingredient_id=%1 ORDER BY unit_id" )
+ command = TQString( "SELECT unit_id FROM unit_list WHERE ingredient_id=%1 ORDER BY unit_id" )
.arg( id1 );
update.exec( command );
int last_id = -1;
@@ -2473,19 +2473,19 @@ void QSqlRecipeDB::mergeIngredients( int id1, int id2 )
int current_id = update.value( 0 ).toInt();
if ( last_id == current_id ) {
int count = -1;
- command = QString( "SELECT COUNT(1) FROM unit_list WHERE ingredient_id=%1 AND unit_id=%2" )
+ command = TQString( "SELECT COUNT(1) FROM unit_list WHERE ingredient_id=%1 AND unit_id=%2" )
.arg( id1 )
.arg( last_id );
- QSqlQuery remove( command, database);
+ TQSqlQuery remove( command, database);
if ( remove.isActive() && remove.first() )
count = remove.value(0).toInt();
if ( count > 1 ) {
- command = QString( "DELETE FROM unit_list WHERE ingredient_id=%1 AND unit_id=%2" )
+ command = TQString( "DELETE FROM unit_list WHERE ingredient_id=%1 AND unit_id=%2" )
.arg( id1 )
.arg( last_id );
database->exec( command );
- command = QString( "INSERT INTO unit_list VALUES(%1,%2)" )
+ command = TQString( "INSERT INTO unit_list VALUES(%1,%2)" )
.arg( id1 )
.arg( last_id );
database->exec( command );
@@ -2496,14 +2496,14 @@ void QSqlRecipeDB::mergeIngredients( int id1, int id2 )
}
//update ingredient info
- command = QString( "UPDATE ingredient_info SET ingredient_id=%1 WHERE ingredient_id=%2" )
+ command = TQString( "UPDATE ingredient_info SET ingredient_id=%1 WHERE ingredient_id=%2" )
.arg( id1 )
.arg( id2 );
update.exec( command );
//and ensure no duplicates were created in this process
//info associated with one ingredient will be lost... they should be the same ingredient and thus info anyways
- command = QString( "SELECT property_id FROM ingredient_info WHERE ingredient_id=%1 ORDER BY property_id" )
+ command = TQString( "SELECT property_id FROM ingredient_info WHERE ingredient_id=%1 ORDER BY property_id" )
.arg( id1 );
update.exec( command );
last_id = -1;
@@ -2512,19 +2512,19 @@ void QSqlRecipeDB::mergeIngredients( int id1, int id2 )
int current_id = update.value( 0 ).toInt();
if ( last_id == current_id ) {
int count = -1;
- command = QString( "SELECT COUNT(1) FROM ingredient_info WHERE ingredient_id=%1 AND property_id=%2" )
+ command = TQString( "SELECT COUNT(1) FROM ingredient_info WHERE ingredient_id=%1 AND property_id=%2" )
.arg( id1 )
.arg( last_id );
- QSqlQuery remove( command, database);
+ TQSqlQuery remove( command, database);
if ( remove.isActive() && remove.first() )
count = remove.value(0).toInt();
if ( count > 1 ) {
- command = QString( "DELETE FROM ingredient_info WHERE ingredient_id=%1 AND property_id=%2" )
+ command = TQString( "DELETE FROM ingredient_info WHERE ingredient_id=%1 AND property_id=%2" )
.arg( id1 )
.arg( last_id );
database->exec( command );
- command = QString( "INSERT INTO ingredient_info VALUES(%1,%2)" )
+ command = TQString( "INSERT INTO ingredient_info VALUES(%1,%2)" )
.arg( id1 )
.arg( last_id );
database->exec( command );
@@ -2536,72 +2536,72 @@ void QSqlRecipeDB::mergeIngredients( int id1, int id2 )
}
//remove ingredient with id 'id2'
- command = QString( "DELETE FROM ingredients WHERE id=%1" ).arg( id2 );
+ command = TQString( "DELETE FROM ingredients WHERE id=%1" ).arg( id2 );
update.exec( command );
emit ingredientRemoved( id2 );
}
-void QSqlRecipeDB::mergePrepMethods( int id1, int id2 )
+void TQSqlRecipeDB::mergePrepMethods( int id1, int id2 )
{
- QSqlQuery update( QString::null, database );
+ TQSqlQuery update( TQString::null, database );
//change all instances of 'id2' to 'id1' in ingredient list
- QString command = QString( "UPDATE prep_method_list SET prep_method_id=%1 WHERE prep_method_id=%2" )
+ TQString command = TQString( "UPDATE prep_method_list SET prep_method_id=%1 WHERE prep_method_id=%2" )
.arg( id1 )
.arg( id2 );
update.exec( command );
//change all instances of 'id2' to 'id1' in ingredient weights
- command = QString( "UPDATE ingredient_weights SET prep_method_id=%1 WHERE prep_method_id=%2" )
+ command = TQString( "UPDATE ingredient_weights SET prep_method_id=%1 WHERE prep_method_id=%2" )
.arg( id1 )
.arg( id2 );
update.exec( command );
//remove prep method with id 'id2'
- command = QString( "DELETE FROM prep_methods WHERE id=%1" ).arg( id2 );
+ command = TQString( "DELETE FROM prep_methods WHERE id=%1" ).arg( id2 );
update.exec( command );
emit prepMethodRemoved( id2 );
}
-void QSqlRecipeDB::mergeProperties( int id1, int id2 )
+void TQSqlRecipeDB::mergeProperties( int id1, int id2 )
{
- QSqlQuery update( QString::null, database );
+ TQSqlQuery update( TQString::null, database );
//change all instances of 'id2' to 'id1'
- QString command = QString( "UPDATE ingredient_properties SET id=%1 WHERE id=%2" )
+ TQString command = TQString( "UPDATE ingredient_properties SET id=%1 WHERE id=%2" )
.arg( id1 )
.arg( id2 );
update.exec( command );
- command = QString( "UPDATE ingredient_info SET property_id=%1 WHERE property_id=%2" )
+ command = TQString( "UPDATE ingredient_info SET property_id=%1 WHERE property_id=%2" )
.arg( id1 )
.arg( id2 );
update.exec( command );
//remove prep method with id 'id2'
- command = QString( "DELETE FROM ingredient_properties WHERE id=%1" ).arg( id2 );
+ command = TQString( "DELETE FROM ingredient_properties WHERE id=%1" ).arg( id2 );
update.exec( command );
emit propertyRemoved( id2 );
}
-void QSqlRecipeDB::mergeUnits( int id1, int id2 )
+void TQSqlRecipeDB::mergeUnits( int id1, int id2 )
{
- QSqlQuery update( QString::null, database );
+ TQSqlQuery update( TQString::null, database );
//change all instances of 'id2' to 'id1' in unit list
- QString command = QString( "UPDATE unit_list SET unit_id=%1 WHERE unit_id=%2" )
+ TQString command = TQString( "UPDATE unit_list SET unit_id=%1 WHERE unit_id=%2" )
.arg( id1 )
.arg( id2 );
update.exec( command );
//change all instances of 'id2' to 'id1' in ingredient list
- command = QString( "UPDATE ingredient_list SET unit_id=%1 WHERE unit_id=%2" )
+ command = TQString( "UPDATE ingredient_list SET unit_id=%1 WHERE unit_id=%2" )
.arg( id1 )
.arg( id2 );
update.exec( command );
//and ensure no duplicates were created in this process
- command = QString( "SELECT ingredient_id FROM unit_list WHERE unit_id=%1 ORDER BY ingredient_id" )
+ command = TQString( "SELECT ingredient_id FROM unit_list WHERE unit_id=%1 ORDER BY ingredient_id" )
.arg( id1 );
update.exec( command );
int last_id = -1;
@@ -2610,19 +2610,19 @@ void QSqlRecipeDB::mergeUnits( int id1, int id2 )
int current_id = update.value( 0 ).toInt();
if ( last_id == current_id ) {
int count = -1;
- command = QString( "SELECT COUNT(1) FROM unit_list WHERE ingredient_id=%1 AND unit_id=%2" )
+ command = TQString( "SELECT COUNT(1) FROM unit_list WHERE ingredient_id=%1 AND unit_id=%2" )
.arg( id1 )
.arg( last_id );
- QSqlQuery remove( command, database);
+ TQSqlQuery remove( command, database);
if ( remove.isActive() && remove.first() )
count = remove.value(0).toInt();
if ( count > 1 ) {
- command = QString( "DELETE FROM unit_list WHERE ingredient_id=%1 AND unit_id=%2" )
+ command = TQString( "DELETE FROM unit_list WHERE ingredient_id=%1 AND unit_id=%2" )
.arg( id1 )
.arg( last_id );
database->exec( command );
- command = QString( "INSERT INTO unit_list VALUES(%1,%2)" )
+ command = TQString( "INSERT INTO unit_list VALUES(%1,%2)" )
.arg( id1 )
.arg( last_id );
database->exec( command );
@@ -2633,107 +2633,107 @@ void QSqlRecipeDB::mergeUnits( int id1, int id2 )
}
//update ingredient info
- command = QString( "UPDATE ingredient_info SET per_units=%1 WHERE per_units=%2" )
+ command = TQString( "UPDATE ingredient_info SET per_units=%1 WHERE per_units=%2" )
.arg( id1 )
.arg( id2 );
update.exec( command );
//change all instances of 'id2' to 'id1' in unit_conversion
- command = QString( "UPDATE units_conversion SET unit1_id=%1 WHERE unit1_id=%2" )
+ command = TQString( "UPDATE units_conversion SET unit1_id=%1 WHERE unit1_id=%2" )
.arg( id1 )
.arg( id2 );
update.exec( command );
- command = QString( "UPDATE units_conversion SET unit2_id=%1 WHERE unit2_id=%2" )
+ command = TQString( "UPDATE units_conversion SET unit2_id=%1 WHERE unit2_id=%2" )
.arg( id1 )
.arg( id2 );
update.exec( command );
//and ensure that the one to one ratio wasn't created
- command = QString( "DELETE FROM units_conversion WHERE unit1_id=unit2_id" );
+ command = TQString( "DELETE FROM units_conversion WHERE unit1_id=unit2_id" );
update.exec( command );
//update ingredient weights
- command = QString( "UPDATE ingredient_weights SET unit_id=%1 WHERE unit_id=%2" )
+ command = TQString( "UPDATE ingredient_weights SET unit_id=%1 WHERE unit_id=%2" )
.arg( id1 )
.arg( id2 );
update.exec( command );
- command = QString( "UPDATE ingredient_weights SET weight_unit_id=%1 WHERE weight_unit_id=%2" )
+ command = TQString( "UPDATE ingredient_weights SET weight_unit_id=%1 WHERE weight_unit_id=%2" )
.arg( id1 )
.arg( id2 );
update.exec( command );
//change all instances of 'id2' to 'id1' in ingredient weights
- command = QString( "UPDATE ingredient_weights SET unit_id=%1 WHERE unit_id=%2" )
+ command = TQString( "UPDATE ingredient_weights SET unit_id=%1 WHERE unit_id=%2" )
.arg( id1 )
.arg( id2 );
update.exec( command );
- command = QString( "UPDATE ingredient_weights SET weight_unit_id=%1 WHERE weight_unit_id=%2" )
+ command = TQString( "UPDATE ingredient_weights SET weight_unit_id=%1 WHERE weight_unit_id=%2" )
.arg( id1 )
.arg( id2 );
update.exec( command );
//remove units with id 'id2'
- command = QString( "DELETE FROM units WHERE id=%1" ).arg( id2 );
+ command = TQString( "DELETE FROM units WHERE id=%1" ).arg( id2 );
update.exec( command );
emit unitRemoved( id2 );
}
-QString QSqlRecipeDB::getUniqueRecipeTitle( const QString &recipe_title )
+TQString TQSqlRecipeDB::getUniqueRecipeTitle( const TQString &recipe_title )
{
//already is unique
if ( findExistingRecipeByName( recipe_title ) == -1 )
return recipe_title;
- QString return_title = recipe_title; //If any error is produced, just go for default value (always return something)
+ TQString return_title = recipe_title; //If any error is produced, just go for default value (always return something)
- QString command = QString( "SELECT COUNT(1) FROM recipes WHERE title LIKE '%1 (%)';" ).arg( escapeAndEncode( recipe_title ) );
+ TQString command = TQString( "SELECT COUNT(1) FROM recipes WHERE title LIKE '%1 (%)';" ).arg( escapeAndEncode( recipe_title ) );
- QSqlQuery alikeRecipes( command, database );
+ TQSqlQuery alikeRecipes( command, database );
if ( alikeRecipes.isActive() && alikeRecipes.first() )
{
int count = alikeRecipes.value( 0 ).toInt();
- return_title = QString( "%1 (%2)" ).arg( recipe_title ).arg( count + 2 );
+ return_title = TQString( "%1 (%2)" ).arg( recipe_title ).arg( count + 2 );
//make sure this newly created title is unique (just in case)
while ( findExistingRecipeByName( return_title ) != -1 ) {
count--; //go down to find the skipped recipe(s)
- return_title = QString( "%1 (%2)" ).arg( recipe_title ).arg( count + 2 );
+ return_title = TQString( "%1 (%2)" ).arg( recipe_title ).arg( count + 2 );
}
}
return return_title;
}
-QString QSqlRecipeDB::recipeTitle( int recipeID )
+TQString TQSqlRecipeDB::recipeTitle( int recipeID )
{
- QString command = QString( "SELECT title FROM recipes WHERE id=%1;" ).arg( recipeID );
- QSqlQuery recipeToLoad( command, database );
+ TQString command = TQString( "SELECT title FROM recipes WHERE id=%1;" ).arg( recipeID );
+ TQSqlQuery recipeToLoad( command, database );
if ( recipeToLoad.isActive() && recipeToLoad.next() ) // Go to the first record (there should be only one anyway.
return ( unescapeAndDecode(recipeToLoad.value( 0 ).toCString()) );
- return ( QString::null );
+ return ( TQString::null );
}
-void QSqlRecipeDB::emptyData( void )
+void TQSqlRecipeDB::emptyData( void )
{
- QStringList tables;
+ TQStringList tables;
tables << "ingredient_info" << "ingredient_list" << "ingredient_properties" << "ingredients" << "recipes" << "unit_list" << "units" << "units_conversion" << "categories" << "category_list" << "authors" << "author_list" << "prep_methods" << "ingredient_groups" << "yield_types" << "ratings" << "rating_criteria" << "rating_criterion_list";
- QSqlQuery tablesToEmpty( QString::null, database );
- for ( QStringList::Iterator it = tables.begin(); it != tables.end(); ++it ) {
- QString command = QString( "DELETE FROM %1;" ).arg( *it );
+ TQSqlQuery tablesToEmpty( TQString::null, database );
+ for ( TQStringList::Iterator it = tables.begin(); it != tables.end(); ++it ) {
+ TQString command = TQString( "DELETE FROM %1;" ).arg( *it );
tablesToEmpty.exec( command );
}
}
-void QSqlRecipeDB::empty( void )
+void TQSqlRecipeDB::empty( void )
{
- QSqlQuery tablesToEmpty( QString::null, database );
+ TQSqlQuery tablesToEmpty( TQString::null, database );
- QStringList list = database->tables();
- QStringList::const_iterator it = list.begin();
+ TQStringList list = database->tables();
+ TQStringList::const_iterator it = list.begin();
while( it != list.end() ) {
- QString command = QString( "DROP TABLE %1;" ).arg( *it );
+ TQString command = TQString( "DROP TABLE %1;" ).arg( *it );
tablesToEmpty.exec( command );
if ( !tablesToEmpty.isActive() )
@@ -2743,25 +2743,25 @@ void QSqlRecipeDB::empty( void )
}
}
-QString QSqlRecipeDB::getNextInsertIDStr( const QString &table, const QString &column )
+TQString TQSqlRecipeDB::getNextInsertIDStr( const TQString &table, const TQString &column )
{
int next_id = getNextInsertID( table, column );
- QString id_str;
+ TQString id_str;
if ( next_id == -1 )
id_str = "NULL";
else
- id_str = QString::number( next_id );
+ id_str = TQString::number( next_id );
return id_str;
}
-void QSqlRecipeDB::search( RecipeList *list, int items, const RecipeSearchParameters &parameters )
+void TQSqlRecipeDB::search( RecipeList *list, int items, const RecipeSearchParameters &parameters )
{
- QString query = buildSearchQuery(parameters);
+ TQString query = buildSearchQuery(parameters);
- QValueList<int> ids;
- QSqlQuery recipeToLoad( query, database );
+ TQValueList<int> ids;
+ TQSqlQuery recipeToLoad( query, database );
if ( recipeToLoad.isActive() ) {
while ( recipeToLoad.next() ) {
ids << recipeToLoad.value( 0 ).toInt();