summaryrefslogtreecommitdiffstats
path: root/krecipes/src/exporters/htmlexporter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'krecipes/src/exporters/htmlexporter.cpp')
-rw-r--r--krecipes/src/exporters/htmlexporter.cpp244
1 files changed, 122 insertions, 122 deletions
diff --git a/krecipes/src/exporters/htmlexporter.cpp b/krecipes/src/exporters/htmlexporter.cpp
index 0d56c98..31e8c40 100644
--- a/krecipes/src/exporters/htmlexporter.cpp
+++ b/krecipes/src/exporters/htmlexporter.cpp
@@ -14,14 +14,14 @@
#include "htmlexporter.h"
-#include <qptrdict.h>
-#include <qimage.h>
-#include <qfileinfo.h>
-#include <qdir.h>
-#include <qstylesheet.h> //for QStyleSheet::escape() to escape for HTML
+#include <ntqptrdict.h>
+#include <ntqimage.h>
+#include <ntqfileinfo.h>
+#include <ntqdir.h>
+#include <ntqstylesheet.h> //for TQStyleSheet::escape() to escape for HTML
#include <dom/dom_element.h>
-#include <qpainter.h>
-#include <qfileinfo.h>
+#include <ntqpainter.h>
+#include <ntqfileinfo.h>
#include <kconfig.h>
#include <kdebug.h>
@@ -42,15 +42,15 @@
#include <cmath> //for ceil()
-HTMLExporter::HTMLExporter( const QString& filename, const QString &format ) :
+HTMLExporter::HTMLExporter( const TQString& filename, const TQString &format ) :
BaseExporter( filename, format )
{
KConfig *config = KGlobal::config();
config->setGroup( "Page Setup" );
//let's do everything we can to be sure at least some layout is loaded
- QString template_filename = config->readEntry( "Template", locate( "appdata", "layouts/Default.template" ) );
- if ( template_filename.isEmpty() || !QFile::exists( template_filename ) )
+ TQString template_filename = config->readEntry( "Template", locate( "appdata", "layouts/Default.template" ) );
+ if ( template_filename.isEmpty() || !TQFile::exists( template_filename ) )
template_filename = locate( "appdata", "layouts/Default.template" );
kdDebug() << "Using template file: " << template_filename << endl;
@@ -58,7 +58,7 @@ HTMLExporter::HTMLExporter( const QString& filename, const QString &format ) :
//let's do everything we can to be sure at least some layout is loaded
m_layoutFilename = config->readEntry( "Layout", locate( "appdata", "layouts/Default.klo" ) );
- if ( m_layoutFilename.isEmpty() || !QFile::exists( m_layoutFilename ) )
+ if ( m_layoutFilename.isEmpty() || !TQFile::exists( m_layoutFilename ) )
m_layoutFilename = locate( "appdata", "layouts/Default.klo" );
kdDebug() << "Using layout file: " << m_layoutFilename << endl;
}
@@ -67,18 +67,18 @@ HTMLExporter::~HTMLExporter()
{
}
-void HTMLExporter::setTemplate( const QString &filename )
+void HTMLExporter::setTemplate( const TQString &filename )
{
- QFile templateFile( filename );
+ TQFile templateFile( filename );
if ( templateFile.open( IO_ReadOnly ) ) {
m_templateFilename = filename;
- m_templateContent = QString( templateFile.readAll() );
+ m_templateContent = TQString( templateFile.readAll() );
}
else
kdDebug()<<"couldn't find/open template file"<<endl;
}
-void HTMLExporter::setStyle( const QString &filename )
+void HTMLExporter::setStyle( const TQString &filename )
{
m_layoutFilename = filename;
}
@@ -87,16 +87,16 @@ int HTMLExporter::supportedItems() const
{
int items = RecipeDB::All ^ RecipeDB::Properties;
- QMap<QString,bool>::const_iterator it = m_visibilityMap.find("properties");
+ TQMap<TQString,bool>::const_iterator it = m_visibilityMap.find("properties");
if ( it == m_visibilityMap.end() || it.data() == true )
items |= RecipeDB::Properties;
return RecipeDB::All;
}
-QString HTMLExporter::createContent( const Recipe& recipe )
+TQString HTMLExporter::createContent( const Recipe& recipe )
{
- QString templateCopy = m_templateContent;
+ TQString templateCopy = m_templateContent;
storePhoto( recipe );
@@ -104,9 +104,9 @@ QString HTMLExporter::createContent( const Recipe& recipe )
return templateCopy;
}
-QString HTMLExporter::createContent( const RecipeList& recipes )
+TQString HTMLExporter::createContent( const RecipeList& recipes )
{
- QString fileContent;
+ TQString fileContent;
RecipeList::const_iterator recipe_it;
for ( recipe_it = recipes.begin(); recipe_it != recipes.end(); ++recipe_it ) {
@@ -116,7 +116,7 @@ QString HTMLExporter::createContent( const RecipeList& recipes )
return fileContent;
}
-QString HTMLExporter::createHeader( const RecipeList & )
+TQString HTMLExporter::createHeader( const RecipeList & )
{
m_visibilityMap.clear();
m_columnsMap.clear();
@@ -127,7 +127,7 @@ QString HTMLExporter::createHeader( const RecipeList & )
m_error = false;
if ( m_templateContent.isEmpty() ) {
- QString errorStr = i18n("<html><body>\n"
+ TQString errorStr = i18n("<html><body>\n"
"<p><b>Error: </b>Unable to find a layout file, which is"
" needed to view the recipe.</p>"
"<p>Krecipes was probably not properly installed.</p>"
@@ -136,9 +136,9 @@ QString HTMLExporter::createHeader( const RecipeList & )
return errorStr;
}
- QFile layoutFile( m_layoutFilename );
- QString error; int line; int column;
- QDomDocument doc;
+ TQFile layoutFile( m_layoutFilename );
+ TQString error; int line; int column;
+ TQDomDocument doc;
if ( !doc.setContent( &layoutFile, &error, &line, &column ) ) {
kdDebug()<<"Unable to load style information. Will create HTML without it..."<<endl;
}
@@ -146,34 +146,34 @@ QString HTMLExporter::createHeader( const RecipeList & )
processDocument(doc);
//put all the recipe photos into this directory
- QDir dir;
- QFileInfo fi(fileName());
+ TQDir dir;
+ TQFileInfo fi(fileName());
dir.mkdir( fi.dirPath(true) + "/" + fi.baseName() + "_photos" );
RecipeList::const_iterator recipe_it;
KLocale*loc = KGlobal::locale();
- QString encoding = loc->encoding();
+ TQString encoding = loc->encoding();
- QString output = "<html>";
+ TQString output = "<html>";
output += "<head>";
output += "<meta name=\"lang\" content=\"" + loc->language() + "\">\n";
output += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n";
- output += QString( "<title>%1</title>" ).arg( i18n( "Krecipes Recipes" ) );
+ output += TQString( "<title>%1</title>" ).arg( i18n( "Krecipes Recipes" ) );
output += "<style type=\"text/css\">\n";
- QString cssContent;
- QFileInfo info(m_templateFilename);
- QFile cssFile(info.dirPath(true) + "/" + info.baseName() + ".css");
+ TQString cssContent;
+ TQFileInfo info(m_templateFilename);
+ TQFile cssFile(info.dirPath(true) + "/" + info.baseName() + ".css");
kdDebug()<<info.dirPath(true) + "/" + info.baseName() + ".css"<<endl;
if ( cssFile.open( IO_ReadOnly ) ) {
- cssContent = QString( cssFile.readAll() );
+ cssContent = TQString( cssFile.readAll() );
}
output += cssContent;
output += m_cachedCSS;
- m_cachedCSS = QString::null;
+ m_cachedCSS = TQString::null;
output += "</style>";
output += "</head>";
output += "<body class=\"background\">";
@@ -181,7 +181,7 @@ QString HTMLExporter::createHeader( const RecipeList & )
return output;
}
-void HTMLExporter::beginObject( const QString &object )
+void HTMLExporter::beginObject( const TQString &object )
{
m_cachedCSS += "."+object+" { \n";
}
@@ -191,83 +191,83 @@ void HTMLExporter::endObject()
m_cachedCSS += " } \n";
}
-void HTMLExporter::loadBackgroundColor( const QString &/*object*/, const QColor& color )
+void HTMLExporter::loadBackgroundColor( const TQString &/*object*/, const TQColor& color )
{
m_cachedCSS += bgColorAsCSS(color);
}
-void HTMLExporter::loadFont( const QString &/*object*/, const QFont& font )
+void HTMLExporter::loadFont( const TQString &/*object*/, const TQFont& font )
{
m_cachedCSS += fontAsCSS(font);
}
-void HTMLExporter::loadTextColor( const QString &/*object*/, const QColor& color )
+void HTMLExporter::loadTextColor( const TQString &/*object*/, const TQColor& color )
{
m_cachedCSS += textColorAsCSS(color);
}
-void HTMLExporter::loadVisibility( const QString &object, bool visible )
+void HTMLExporter::loadVisibility( const TQString &object, bool visible )
{
m_cachedCSS += visibilityAsCSS(visible);
m_visibilityMap.insert(object,visible);
}
-void HTMLExporter::loadAlignment( const QString &/*object*/, int alignment )
+void HTMLExporter::loadAlignment( const TQString &/*object*/, int alignment )
{
m_cachedCSS += alignmentAsCSS(alignment);
}
-void HTMLExporter::loadBorder( const QString &/*object*/, const KreBorder& border )
+void HTMLExporter::loadBorder( const TQString &/*object*/, const KreBorder& border )
{
m_cachedCSS += borderAsCSS(border);
}
-void HTMLExporter::loadColumns( const QString & object, int cols )
+void HTMLExporter::loadColumns( const TQString & object, int cols )
{
m_columnsMap.insert(object,cols);
kdDebug()<<object<<" has "<<cols<<" columns"<<endl;
}
-QString HTMLExporter::createFooter()
+TQString HTMLExporter::createFooter()
{
if ( m_error )
- return QString::null;
+ return TQString::null;
return "</body></html>";
}
void HTMLExporter::storePhoto( const Recipe &recipe )
{
- QImage image;
- QString photo_name;
+ TQImage image;
+ TQString photo_name;
if ( recipe.photo.isNull() ) {
- image = QImage( defaultPhoto );
+ image = TQImage( defaultPhoto );
photo_name = "default_photo";
}
else {
image = recipe.photo.convertToImage();
- photo_name = QString::number(recipe.recipeID);
+ photo_name = TQString::number(recipe.recipeID);
}
- QPixmap pm = image;//image.smoothScale( phwidth, 0, QImage::ScaleMax );
+ TQPixmap pm = image;//image.smoothScale( phwidth, 0, TQImage::ScaleMax );
- QFileInfo fi(fileName());
- QString photo_path = fi.dirPath(true) + "/" + fi.baseName() + "_photos/" + photo_name + ".png";
- if ( !QFile::exists( photo_path ) ) {
+ TQFileInfo fi(fileName());
+ TQString photo_path = fi.dirPath(true) + "/" + fi.baseName() + "_photos/" + photo_name + ".png";
+ if ( !TQFile::exists( photo_path ) ) {
pm.save( photo_path, "PNG" );
}
}
-QString HTMLExporter::HTMLIfVisible( const QString &name, const QString &html )
+TQString HTMLExporter::HTMLIfVisible( const TQString &name, const TQString &html )
{
- QMap<QString,bool>::const_iterator it = m_visibilityMap.find(name);
+ TQMap<TQString,bool>::const_iterator it = m_visibilityMap.find(name);
if ( it == m_visibilityMap.end() || it.data() == true )
return html;
else
- return QString::null;
+ return TQString::null;
}
-void HTMLExporter::populateTemplate( const Recipe &recipe, QString &content )
+void HTMLExporter::populateTemplate( const Recipe &recipe, TQString &content )
{
KConfig * config = KGlobal::config();
@@ -275,72 +275,72 @@ void HTMLExporter::populateTemplate( const Recipe &recipe, QString &content )
content = content.replace("**TITLE**",HTMLIfVisible("title",recipe.title));
//=======================INSTRUCTIONS======================//
- QString instr_html = QStyleSheet::escape( recipe.instructions );
+ TQString instr_html = TQStyleSheet::escape( recipe.instructions );
instr_html.replace( "\n", "<br />" );
content = content.replace( "**INSTRUCTIONS**", HTMLIfVisible("instructions",instr_html) );
//=======================SERVINGS======================//
- QString yield_html = QString( "<b>%1: </b>%2" ).arg( i18n( "Yield" ) ).arg( recipe.yield.toString() );
+ TQString yield_html = TQString( "<b>%1: </b>%2" ).arg( i18n( "Yield" ) ).arg( recipe.yield.toString() );
content = content.replace( "**YIELD**", HTMLIfVisible("yield",yield_html) );
//=======================PREP TIME======================//
- QString preptime_html;
+ TQString preptime_html;
if ( !recipe.prepTime.isNull() && recipe.prepTime.isValid() )
- preptime_html = QString( "<b>%1: </b>%2" ).arg( i18n( "Preparation Time" ) ).arg( recipe.prepTime.toString( "h:mm" ) );
+ preptime_html = TQString( "<b>%1: </b>%2" ).arg( i18n( "Preparation Time" ) ).arg( recipe.prepTime.toString( "h:mm" ) );
content = content.replace( "**PREP_TIME**", HTMLIfVisible("prep_time",preptime_html) );
//========================PHOTO========================//
- QString photo_name;
+ TQString photo_name;
if ( recipe.photo.isNull() )
photo_name = "default_photo";
else
- photo_name = QString::number(recipe.recipeID);
+ photo_name = TQString::number(recipe.recipeID);
- QFileInfo fi(fileName());
- QString image_url = fi.baseName() + "_photos/" + escape( photo_name ) + ".png";
+ TQFileInfo fi(fileName());
+ TQString image_url = fi.baseName() + "_photos/" + escape( photo_name ) + ".png";
image_url = KURL::encode_string( image_url );
content = content.replace( "**PHOTO**", HTMLIfVisible("photo",image_url) );
//=======================AUTHORS======================//
- QString authors_html;
+ TQString authors_html;
int counter = 0;
for ( ElementList::const_iterator author_it = recipe.authorList.begin(); author_it != recipe.authorList.end(); ++author_it ) {
if ( counter )
authors_html += ", ";
- authors_html += QStyleSheet::escape( ( *author_it ).name );
+ authors_html += TQStyleSheet::escape( ( *author_it ).name );
counter++;
}
if ( !authors_html.isEmpty() )
- authors_html.prepend( QString( "<b>%1: </b>" ).arg( i18n( "Authors" ) ) );
+ authors_html.prepend( TQString( "<b>%1: </b>" ).arg( i18n( "Authors" ) ) );
content = content.replace( "**AUTHORS**", HTMLIfVisible("authors",authors_html) );
//=======================CATEGORIES======================//
- QString categories_html;
+ TQString categories_html;
counter = 0;
for ( ElementList::const_iterator cat_it = recipe.categoryList.begin(); cat_it != recipe.categoryList.end(); ++cat_it ) {
if ( counter )
categories_html += ", ";
- categories_html += QStyleSheet::escape( ( *cat_it ).name );
+ categories_html += TQStyleSheet::escape( ( *cat_it ).name );
counter++;
}
if ( !categories_html.isEmpty() )
- categories_html.prepend( QString( "<b>%1: </b>" ).arg( i18n( "Categories" ) ) );
+ categories_html.prepend( TQString( "<b>%1: </b>" ).arg( i18n( "Categories" ) ) );
content = content.replace( "**CATEGORIES**", HTMLIfVisible("categories",categories_html) );
//=======================INGREDIENTS======================//
- QString ingredients_html;
+ TQString ingredients_html;
config->setGroup( "Formatting" );
bool useAbbreviations = config->readBoolEntry("AbbreviateUnits");
MixedNumber::Format number_format = ( config->readBoolEntry( "Fraction" ) ) ? MixedNumber::MixedNumberFormat : MixedNumber::DecimalFormat;
- QString ingredient_format = config->readEntry( "Ingredient", "%n%p: %a %u" );
+ TQString ingredient_format = config->readEntry( "Ingredient", "%n%p: %a %u" );
- QMap<QString,int>::const_iterator cols_it = m_columnsMap.find("ingredients");
+ TQMap<TQString,int>::const_iterator cols_it = m_columnsMap.find("ingredients");
int cols = 1;
if ( cols_it != m_columnsMap.end() )
cols = cols_it.data();
@@ -351,7 +351,7 @@ void HTMLExporter::populateTemplate( const Recipe &recipe, QString &content )
int count = 0;
IngredientList list_copy = recipe.ingList; //simple workaround until I fix iterating over the list dealing with groups
for ( IngredientList group_list = list_copy.firstGroup(); group_list.count() != 0; group_list = list_copy.nextGroup() ) {
- QString group = group_list[ 0 ].group; //just use the first's name... they're all the same
+ TQString group = group_list[ 0 ].group; //just use the first's name... they're all the same
bool loneHeader = false;
if ( count != 0 && count % per_col == 0 ) {
@@ -376,48 +376,48 @@ void HTMLExporter::populateTemplate( const Recipe &recipe, QString &content )
ingredients_html += "<ul>";
}
- QString amount_str = MixedNumber( ( *ing_it ).amount ).toString( number_format );
+ TQString amount_str = MixedNumber( ( *ing_it ).amount ).toString( number_format );
if ( (*ing_it).amount_offset > 0 )
amount_str += "-"+MixedNumber( ( *ing_it ).amount + ( *ing_it ).amount_offset ).toString( number_format );
else if ( ( *ing_it ).amount <= 1e-10 )
amount_str = "";
- QString unit = ( *ing_it ).units.determineName( ( *ing_it ).amount + ( *ing_it ).amount_offset, useAbbreviations );
+ TQString unit = ( *ing_it ).units.determineName( ( *ing_it ).amount + ( *ing_it ).amount_offset, useAbbreviations );
- QString tmp_format( ingredient_format );
- tmp_format.replace( QRegExp( QString::fromLatin1( "%n" ) ), QStyleSheet::escape( ( *ing_it ).name ) );
- tmp_format.replace( QRegExp( QString::fromLatin1( "%a" ) ), amount_str );
- tmp_format.replace( QRegExp( QString::fromLatin1( "%u" ) ), QStyleSheet::escape(unit) );
- tmp_format.replace( QRegExp( QString::fromLatin1( "%p" ) ), ( ( *ing_it ).prepMethodList.count() == 0 ) ?
- QString::fromLatin1( "" ) : QString::fromLatin1( "; " ) + QStyleSheet::escape( ( *ing_it ).prepMethodList.join(",") ) );
+ TQString tmp_format( ingredient_format );
+ tmp_format.replace( TQRegExp( TQString::fromLatin1( "%n" ) ), TQStyleSheet::escape( ( *ing_it ).name ) );
+ tmp_format.replace( TQRegExp( TQString::fromLatin1( "%a" ) ), amount_str );
+ tmp_format.replace( TQRegExp( TQString::fromLatin1( "%u" ) ), TQStyleSheet::escape(unit) );
+ tmp_format.replace( TQRegExp( TQString::fromLatin1( "%p" ) ), ( ( *ing_it ).prepMethodList.count() == 0 ) ?
+ TQString::fromLatin1( "" ) : TQString::fromLatin1( "; " ) + TQStyleSheet::escape( ( *ing_it ).prepMethodList.join(",") ) );
if ( (*ing_it).substitutes.count() > 0 )
tmp_format += ", "+i18n("or");
- ingredients_html += QString( "<li>%1</li>" ).arg( tmp_format );
+ ingredients_html += TQString( "<li>%1</li>" ).arg( tmp_format );
- for ( QValueList<IngredientData>::const_iterator sub_it = (*ing_it).substitutes.begin(); sub_it != (*ing_it).substitutes.end(); ) {
- QString amount_str = MixedNumber( ( *sub_it ).amount ).toString( number_format );
+ for ( TQValueList<IngredientData>::const_iterator sub_it = (*ing_it).substitutes.begin(); sub_it != (*ing_it).substitutes.end(); ) {
+ TQString amount_str = MixedNumber( ( *sub_it ).amount ).toString( number_format );
if ( (*ing_it).amount_offset > 0 )
amount_str += "-"+MixedNumber( ( *sub_it ).amount + ( *sub_it ).amount_offset ).toString( number_format );
else if ( ( *sub_it ).amount <= 1e-10 )
amount_str = "";
- QString unit = ( *sub_it ).units.determineName( ( *sub_it ).amount + ( *sub_it ).amount_offset, config->readBoolEntry("AbbreviateUnits") );
+ TQString unit = ( *sub_it ).units.determineName( ( *sub_it ).amount + ( *sub_it ).amount_offset, config->readBoolEntry("AbbreviateUnits") );
- QString tmp_format( ingredient_format );
- tmp_format.replace( QRegExp( QString::fromLatin1( "%n" ) ), QStyleSheet::escape( ( *sub_it ).name ) );
- tmp_format.replace( QRegExp( QString::fromLatin1( "%a" ) ), amount_str );
- tmp_format.replace( QRegExp( QString::fromLatin1( "%u" ) ), QStyleSheet::escape(unit) );
- tmp_format.replace( QRegExp( QString::fromLatin1( "%p" ) ), ( ( *sub_it ).prepMethodList.count() == 0 ) ?
- QString::fromLatin1( "" ) : QString::fromLatin1( "; " ) + QStyleSheet::escape( ( *sub_it ).prepMethodList.join(",") ) );
+ TQString tmp_format( ingredient_format );
+ tmp_format.replace( TQRegExp( TQString::fromLatin1( "%n" ) ), TQStyleSheet::escape( ( *sub_it ).name ) );
+ tmp_format.replace( TQRegExp( TQString::fromLatin1( "%a" ) ), amount_str );
+ tmp_format.replace( TQRegExp( TQString::fromLatin1( "%u" ) ), TQStyleSheet::escape(unit) );
+ tmp_format.replace( TQRegExp( TQString::fromLatin1( "%p" ) ), ( ( *sub_it ).prepMethodList.count() == 0 ) ?
+ TQString::fromLatin1( "" ) : TQString::fromLatin1( "; " ) + TQStyleSheet::escape( ( *sub_it ).prepMethodList.join(",") ) );
++sub_it;
if ( sub_it != (*ing_it).substitutes.end() )
tmp_format += ", "+i18n("or");
- ingredients_html += QString( "<li>%1</li>" ).arg( tmp_format );
+ ingredients_html += TQString( "<li>%1</li>" ).arg( tmp_format );
}
}
@@ -431,9 +431,9 @@ void HTMLExporter::populateTemplate( const Recipe &recipe, QString &content )
content = content.replace( "**INGREDIENTS**", HTMLIfVisible("ingredients",ingredients_html) );
//=======================PROPERTIES======================//
- QString properties_html;
+ TQString properties_html;
- QStringList hiddenList = config->readListEntry("HiddenProperties");
+ TQStringList hiddenList = config->readListEntry("HiddenProperties");
IngredientPropertyList visibleProperties;
for ( IngredientPropertyList::const_iterator prop_it = recipe.properties.begin(); prop_it != recipe.properties.end(); ++prop_it ) {
if ( hiddenList.find((*prop_it).name) == hiddenList.end() )
@@ -455,20 +455,20 @@ void HTMLExporter::populateTemplate( const Recipe &recipe, QString &content )
// if the amount given is <0, it means the property calculator found that the property was undefined for some ingredients, so the amount will be actually bigger
- QString amount_str;
+ TQString amount_str;
double prop_amount = (*prop_it).amount;
if ( prop_amount > 0 ) { //TODO: make the precision configuratble
- prop_amount = double( qRound( prop_amount * 10.0 ) ) / 10.0; //not a "chemistry experiment" ;) Let's only have one decimal place
+ prop_amount = double( tqRound( prop_amount * 10.0 ) ) / 10.0; //not a "chemistry experiment" ;) Let's only have one decimal place
amount_str = beautify( KGlobal::locale() ->formatNumber( prop_amount, 5 ) );
}
else
amount_str = "0";
- properties_html += QString( "<li>%1: <nobr>%2 %3</nobr></li>" )
- .arg( QStyleSheet::escape( (*prop_it).name ) )
+ properties_html += TQString( "<li>%1: <nobr>%2 %3</nobr></li>" )
+ .arg( TQStyleSheet::escape( (*prop_it).name ) )
.arg( amount_str )
- .arg( QStyleSheet::escape( (*prop_it).units ) );
+ .arg( TQStyleSheet::escape( (*prop_it).units ) );
++count;
}
@@ -480,9 +480,9 @@ void HTMLExporter::populateTemplate( const Recipe &recipe, QString &content )
content = content.replace( "**PROPERTIES**", HTMLIfVisible("properties",properties_html) );
//=======================RATINGS======================//
- QString ratings_html;
+ TQString ratings_html;
if ( recipe.ratingList.count() > 0 )
- ratings_html += QString("<b>%1:</b>").arg(i18n("Ratings"));
+ ratings_html += TQString("<b>%1:</b>").arg(i18n("Ratings"));
int rating_total = 0;
double rating_sum = 0;
@@ -495,11 +495,11 @@ void HTMLExporter::populateTemplate( const Recipe &recipe, QString &content )
if ( (*rating_it).ratingCriteriaList.count() > 0 )
ratings_html += "<table>";
for ( RatingCriteriaList::const_iterator rc_it = (*rating_it).ratingCriteriaList.begin(); rc_it != (*rating_it).ratingCriteriaList.end(); ++rc_it ) {
- QString image_url = fi.baseName() + "_photos/" + QString::number((*rc_it).stars) + "-stars.png";
+ TQString image_url = fi.baseName() + "_photos/" + TQString::number((*rc_it).stars) + "-stars.png";
image_url = KURL::encode_string( image_url );
ratings_html += "<tr><td>"+(*rc_it).name+":</td><td><img src=\""+image_url+"\" /></td></tr>";
- if ( !QFile::exists( fi.dirPath(true) + "/" + image_url ) ) {
- QPixmap starPixmap = Rating::starsPixmap((*rc_it).stars,true);
+ if ( !TQFile::exists( fi.dirPath(true) + "/" + image_url ) ) {
+ TQPixmap starPixmap = Rating::starsPixmap((*rc_it).stars,true);
starPixmap.save( fi.dirPath(true) + "/" + image_url, "PNG" );
}
@@ -514,57 +514,57 @@ void HTMLExporter::populateTemplate( const Recipe &recipe, QString &content )
}
content = content.replace( "**RATINGS**", HTMLIfVisible("ratings",ratings_html) );
- QString overall_html;
+ TQString overall_html;
if ( rating_total > 0 ) {
double average = int(2*rating_sum/rating_total)/2;
- overall_html += QString("<b>%1:</b>").arg(i18n("Overall Rating"));
- QString image_url = fi.baseName() + "_photos/" + QString::number(average) + "-stars.png";
+ overall_html += TQString("<b>%1:</b>").arg(i18n("Overall Rating"));
+ TQString image_url = fi.baseName() + "_photos/" + TQString::number(average) + "-stars.png";
image_url = KURL::encode_string( image_url );
overall_html += "<img src=\""+image_url+"\" />";
- if ( !QFile::exists( fi.dirPath(true) + "/" + image_url ) ) {
- QPixmap starPixmap = Rating::starsPixmap(average,true);
+ if ( !TQFile::exists( fi.dirPath(true) + "/" + image_url ) ) {
+ TQPixmap starPixmap = Rating::starsPixmap(average,true);
starPixmap.save( fi.dirPath(true) + "/" + image_url, "PNG" );
}
}
content = content.replace( "**OVERALL_RATING**", HTMLIfVisible("overall_rating",overall_html) );
}
-void HTMLExporter::removeHTMLFiles( const QString &filename, int recipe_id )
+void HTMLExporter::removeHTMLFiles( const TQString &filename, int recipe_id )
{
- QValueList<int> id;
+ TQValueList<int> id;
id << recipe_id;
removeHTMLFiles( filename, id );
}
-void HTMLExporter::removeHTMLFiles( const QString &filename, const QValueList<int> &recipe_ids )
+void HTMLExporter::removeHTMLFiles( const TQString &filename, const TQValueList<int> &recipe_ids )
{
//remove HTML file
- QFile old_file( filename + ".html" );
+ TQFile old_file( filename + ".html" );
if ( old_file.exists() )
old_file.remove();
//remove photos
- for ( QValueList<int>::const_iterator it = recipe_ids.begin(); it != recipe_ids.end(); ++it ) {
- QFile photo( filename + "_photos/" + QString::number(*it) + ".png" );
+ for ( TQValueList<int>::const_iterator it = recipe_ids.begin(); it != recipe_ids.end(); ++it ) {
+ TQFile photo( filename + "_photos/" + TQString::number(*it) + ".png" );
if ( photo.exists() )
photo.remove(); //remove photos in directory before removing it
}
//take care of the default photo
- QFile photo( filename + "_photos/default_photo.png" );
+ TQFile photo( filename + "_photos/default_photo.png" );
if ( photo.exists() ) photo.remove();
//remove photo directory
- QDir photo_dir;
+ TQDir photo_dir;
photo_dir.rmdir( filename + "_photos" );
for ( double d = 0.5; d < 5.5; d += 0.5 ) {
- if ( QFile::exists(filename+"_photos/"+QString::number(d)+"-stars.png") ) photo.remove(filename+"_photos/"+QString::number(d)+"-stars.png");
+ if ( TQFile::exists(filename+"_photos/"+TQString::number(d)+"-stars.png") ) photo.remove(filename+"_photos/"+TQString::number(d)+"-stars.png");
}
}
-QString HTMLExporter::escape( const QString & str )
+TQString HTMLExporter::escape( const TQString & str )
{
- QString tmp( str );
+ TQString tmp( str );
return tmp.replace( '/', "_" );
}