[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdenonbeta/krecipes/src
From: Unai Garro <ugarro () telefonica ! net>
Date: 2004-03-23 20:21:33
Message-ID: 20040323202133.CBA8599AC () office ! kde ! org
[Download RAW message or body]
CVS commit by uga:
Show recipes that have missing ingredients. Later I'll have to add the code to filter \
those missing 1,2,3... ingredients
M +8 -3 ingredientlist.cpp 1.20
M +1 -1 ingredientlist.h 1.20
M +13 -3 dialogs/ingredientmatcherdialog.cpp 1.4
--- kdenonbeta/krecipes/src/ingredientlist.cpp #1.19:1.20
@@ -26,7 +26,10 @@ return(find(ing.ingredientID)!=-1);
}
-bool IngredientList::containsSubSet(IngredientList &il)
+bool IngredientList::containsSubSet(IngredientList &il,IngredientList &missing)
{
+missing.empty();
+bool contained=true;
IngredientList::Iterator it;
+
for (it=il.begin();it!=il.end();++it)
{
@@ -31,7 +34,9 @@ IngredientList::Iterator it;
for (it=il.begin();it!=il.end();++it)
{
- if (!contains(*it)) return false;
+ if (!contains(*it)) contained=false;
+ missing.append(*it);
}
-return true;
+
+return contained;
}
--- kdenonbeta/krecipes/src/ingredientlist.h #1.19:1.20
@@ -27,5 +27,5 @@ public:
~IngredientList();
bool contains(Ingredient &ing) const;
- bool containsSubSet(IngredientList &il);
+ bool containsSubSet(IngredientList &il,IngredientList &missing);
void move(int index1,int index2);
void empty(void);
--- kdenonbeta/krecipes/src/dialogs/ingredientmatcherdialog.cpp #1.3:1.4
@@ -94,14 +94,24 @@ void IngredientMatcherDialog::findRecipe
// Now show the recipes with ingredients that are contained in the previous \
set // of ingredients
+ RecipeList incompleteRecipes;
+
RecipeList::Iterator it;
for (it=rlist.begin();it!=rlist.end();++it)
{
IngredientList il=(*it).ingList;
-
- if (ilist.containsSubSet(il))
+ IngredientList missing;
+ if (ilist.containsSubSet(il,missing))
{
new RecipeListItem(recipeListView->listView(),*it);
}
+ else incompleteRecipes.append(*it);
+ }
+
+ // Show recipes with missing ingredients
+ new SectionItem(recipeListView->listView(),i18n("You are missing some \
ingredients for:"));
+ for (it=incompleteRecipes.begin();it!=incompleteRecipes.end();++it)
+ {
+ new RecipeListItem(recipeListView->listView(),*it);
}
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic