[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdenonbeta/krecipes/src/dialogs
From:       Unai Garro <ugarro () telefonica ! net>
Date:       2004-03-26 23:16:04
Message-ID: 20040326231604.08E9A99CD () office ! kde ! org
[Download RAW message or body]

CVS commit by uga: 

Show the missing ingredients in the list


  M +8 -3      ingredientmatcherdialog.cpp   1.11
  M +21 -3     ingredientmatcherdialog.h   1.4


--- kdenonbeta/krecipes/src/dialogs/ingredientmatcherdialog.cpp  #1.10:1.11
@@ -85,5 +85,5 @@ void IngredientMatcherDialog::findRecipe
         RecipeList rlist;
         IngredientList ilist;
-        database->loadRecipeDetails(&rlist,true,false);
+        database->loadRecipeDetails(&rlist,true,false,true);
         
         
@@ -110,4 +110,5 @@ void IngredientMatcherDialog::findRecipe
         RecipeList incompleteRecipes;
         QValueList <int> missingNumbers;
+        QValueList <IngredientList> missingIngredients;
         
         RecipeList::Iterator it;
@@ -123,4 +124,5 @@ void IngredientMatcherDialog::findRecipe
                         {
                         incompleteRecipes.append(*it);
+                        missingIngredients.append(missing);
                         missingNumbers.append(missing.count());
                         }
@@ -136,4 +138,5 @@ void IngredientMatcherDialog::findRecipe
         // Classify recipes with missing ingredients in different lists by ammount
         QValueList<int>::Iterator nit;
+        QValueList<IngredientList>::Iterator ilit;
         int missingNoAllowed;
         
@@ -149,7 +152,9 @@ void IngredientMatcherDialog::findRecipe
         {
                 nit=missingNumbers.begin();
+                ilit=missingIngredients.begin();
+                
                 bool titleShownYet=false;
                 
-                for \
(it=incompleteRecipes.begin();it!=incompleteRecipes.end();++it,++nit) +               \
for (it=incompleteRecipes.begin();it!=incompleteRecipes.end();++it,++nit,++ilit)  {
                         if ((*nit)==missingNo) 
@@ -160,5 +165,5 @@ void IngredientMatcherDialog::findRecipe
                                                 titleShownYet=true;
                                         }
-                                new RecipeListItem(recipeListView->listView(),*it);
+                                new \
RecipeListItem(recipeListView->listView(),*it,*ilit);  }
                 }

--- kdenonbeta/krecipes/src/dialogs/ingredientmatcherdialog.h  #1.3:1.4
@@ -13,6 +13,8 @@
 
 #include "element.h"
+#include "ingredientlist.h"
 #include "recipe.h"
 
+#include <qfontmetrics.h>
 #include <qlabel.h>
 #include <qlistview.h>
@@ -22,4 +24,5 @@
 
 #include <kcombobox.h>
+#include <kstringhandler.h>
 
 class KreListView;
@@ -63,10 +66,21 @@ class RecipeListItem:public QListViewIte
 {
 public:
-        RecipeListItem(QListView* qlv, const Recipe &r \
):QListViewItem(qlv,qlv->lastItem()) +        RecipeListItem(QListView* qlv, const \
Recipe &r, const IngredientList &il ):QListViewItem(qlv,qlv->lastItem()) +        {
+                recipeStored=new Recipe();
+                ingredientListStored=new QStringList();
+                recipeStored->recipeID=r.recipeID;
+                recipeStored->title=r.title;
+                IngredientList::ConstIterator ili;
+                for (ili=il.begin();ili!=il.end();++ili) \
ingredientListStored->append((*ili).name); +                
+        }
+        RecipeListItem(QListView* qlv, const Recipe \
&r):QListViewItem(qlv,qlv->lastItem())  {
-        // Initialize the ingredient  data with the the property data
                 recipeStored=new Recipe();
+                ingredientListStored=0;
                 recipeStored->recipeID=r.recipeID;
                 recipeStored->title=r.title;
+                
         }
 
@@ -74,8 +88,10 @@ public:
         {
         delete recipeStored;
+        delete ingredientListStored;
         }
 
 private:
         Recipe *recipeStored;
+        QStringList *ingredientListStored;
 
 public:
@@ -83,4 +99,6 @@ public:
                 {
                 if (column==0) return(recipeStored->title);
+                else if ((column==1) && ingredientListStored) 
+                        return \
(KStringHandler::rPixelSqueeze(ingredientListStored->join \
(","),listView()->fontMetrics(),150));  else return(QString::null);
                 }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic