summaryrefslogtreecommitdiff
path: root/src/viewer.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/viewer.cc')
-rw-r--r--src/viewer.cc55
1 files changed, 39 insertions, 16 deletions
diff --git a/src/viewer.cc b/src/viewer.cc
index e3c25be..b0b6f35 100644
--- a/src/viewer.cc
+++ b/src/viewer.cc
@@ -50,24 +50,33 @@ void Viewer::show(const Recipe& recipe)
instructions.replace("\n", "<br/>");
QString ingredients;
- for(const auto& ingredient : recipe.ingredients)
+ for(const auto& ingredient_group : recipe.ingredient_groups)
{
- if(ingredient.amount > 0)
+ if(ingredient_group.title != "")
{
- ingredients +=
- "<li>" +
- QString::number(ingredient.amount) + " " +
- QString::fromUtf8(ingredient.unit.data()) + " " +
- QString::fromUtf8(ingredient.item.data()) +
- "</li>";
+ ingredients += "<h3>" + QString::fromUtf8(ingredient_group.title.data()) + "</h3>";
}
- else
+ ingredients += "<ul>";
+ for(const auto& ingredient : ingredient_group.ingredients)
{
- ingredients +=
- "<li>" +
- QString::fromUtf8(ingredient.item.data()) +
- "</li>";
+ if(ingredient.amount > 0)
+ {
+ ingredients +=
+ "<li>" +
+ QString::number(ingredient.amount) + " " +
+ QString::fromUtf8(ingredient.unit.data()) + " " +
+ QString::fromUtf8(ingredient.item.data()) +
+ "</li>";
+ }
+ else
+ {
+ ingredients +=
+ "<li>" +
+ QString::fromUtf8(ingredient.item.data()) +
+ "</li>";
+ }
}
+ ingredients += "</ul>";
}
QByteArray image(recipe.image.data(), recipe.image.size());
@@ -76,6 +85,20 @@ void Viewer::show(const Recipe& recipe)
image = QByteArray::fromBase64(image);
}
+ QString db;
+ switch(recipe.db)
+ {
+ case DatabaseSource::KRecipes:
+ db = "KRecipes";
+ break;
+ case DatabaseSource::Gourmet:
+ db = "Gourmet";
+ break;
+ case DatabaseSource::Qookie:
+ db = "Qookie";
+ break;
+ }
+
QString html =
"<center><strong style=\"font-size:28px;\">" + QString::fromUtf8(recipe.title.data()) + "</strong></center><br/>"
"<table>"
@@ -83,6 +106,7 @@ void Viewer::show(const Recipe& recipe)
"<td>"
"<p>" + QString::fromUtf8(recipe.description.data()) + "</p>"
"<p>"
+ "Database: " + db + " (id:" + QString::number(recipe.id) + ")<br/>"
"Source: " + QString::fromUtf8(recipe.source.data()) + "<br/>"
"Cuisine: " + QString::fromUtf8(recipe.cuisine.data()) + "<br/>"
"Cooktime: " + QString::number(recipe.cooktime / 60) + "min<br/>"
@@ -90,15 +114,14 @@ void Viewer::show(const Recipe& recipe)
"Yields: " + QString::number(recipe.yields) + " " + QString::fromUtf8(recipe.yield_unit.data()) + "<br/>"
"Tags: " + QString::fromUtf8(recipe.tags[0].data()) + ""
"</p>"
- "<h2>Ingredients</h2>"
- "<ul>" + ingredients + "</ul>"
+ "<h2>Ingredienser</h2>" + ingredients +
"</td>"
"<td>"
"<img height=\"300\" src=\"data:image/png;base64," + image.toBase64() + "\"/>"
"</td>"
"</tr>"
"</table>"
- "<h2>Instructions</h2>"
+ "<h2>Instruktioner</h2>"
"<p>" + instructions + "</p>"
;
textEdit->setHtml(html);