[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-24 22:55:51
Message-ID: 20040324225551.6A9D899B4 () office ! kde ! org
[Download RAW message or body]

CVS commit by uga: 

Let the user choose to show ingredients missing 1/2/3/any ingredients. Still the \
output is not classified by ammount of missing ingredients, and the missing \
ingredients are not shown


  M +33 -3     ingredientmatcherdialog.cpp   1.5
  M +11 -0     ingredientmatcherdialog.h   1.3


--- kdenonbeta/krecipes/src/dialogs/ingredientmatcherdialog.cpp  #1.4:1.5
@@ -16,8 +16,9 @@
 #include "widgets/krelistview.h"
 
-#include <qhbox.h>
 #include <qpainter.h>
+#include <qstringlist.h>
 #include <kiconloader.h>
 #include <klocale.h>
+#include <iostream>
 
 IngredientMatcherDialog::IngredientMatcherDialog(QWidget *parent,RecipeDB \
*db):QVBox(parent) @@ -29,10 +30,23 @@ IngredientMatcherDialog::IngredientMatch
         setSpacing(10);
         
+                // Ingredient list
         ingredientListView=new KreListView(this,i18n("Ingredients"),true,1);
         ingredientListView->listView()->setAllColumnsShowFocus(true);
         ingredientListView->listView()->addColumn("*");
         ingredientListView->listView()->addColumn(i18n("Ingredient"));
+                // Box to select allowed number of missing ingredients
+        missingBox=new QHBox(this);
+        missingNumberLabel=new QLabel(missingBox);
+        missingNumberLabel->setText(i18n("Missing ingredients allowed:"));
+        missingNumberCombo=new KComboBox(missingBox);
+        QStringList optionsList;
+        optionsList.append("1");
+        optionsList+="2";
+        optionsList+="3";
+        optionsList+=i18n("any");
+        missingNumberCombo->insertStringList(optionsList);
         
-        recipeListView=new KreListView(this,i18n("Matching Recipes"));
+                // Found recipe list
+        recipeListView=new KreListView(this,i18n("Matching \
Recipes"),false,1,missingBox);  \
recipeListView->listView()->setAllColumnsShowFocus(true);  \
recipeListView->listView()->addColumn(i18n("Title")); @@ -95,4 +109,5 @@ void \
IngredientMatcherDialog::findRecipe  // of ingredients
         RecipeList incompleteRecipes;
+        QValueList <int> missingNumbers;
         
         RecipeList::Iterator it;
@@ -106,4 +121,5 @@ void IngredientMatcherDialog::findRecipe
                         }
                 else incompleteRecipes.append(*it);
+                missingNumbers.append(missing.count()); \
std::cerr<<missing.count()<<"\n";  }
 
@@ -111,8 +127,22 @@ void IngredientMatcherDialog::findRecipe
         new SectionItem(recipeListView->listView(),i18n("You are missing some \
ingredients for:"));  
+        QValueList<int>::Iterator nit;
+        if (this->missingNumberCombo->currentItem()==3) // Any
+        {
         for (it=incompleteRecipes.begin();it!=incompleteRecipes.end();++it)
                 {
                         new RecipeListItem(recipeListView->listView(),*it);
                 }
+        }
+        else // 1..3
+        {
+                int missingNoAllowed=missingNumberCombo->currentText().toInt();
+                nit=missingNumbers.begin();     
+                for \
(it=incompleteRecipes.begin();it!=incompleteRecipes.end();++it,++nit) +               \
{ +                        if ((*nit)<=missingNoAllowed)
+                                new RecipeListItem(recipeListView->listView(),*it);
+                }
+        }
 }
 

--- kdenonbeta/krecipes/src/dialogs/ingredientmatcherdialog.h  #1.2:1.3
@@ -15,8 +15,12 @@
 #include "recipe.h"
 
+#include <qlabel.h>
 #include <qlistview.h>
 #include <qpushbutton.h>
+#include <qhbox.h>
 #include <qvbox.h>
 
+#include <kcombobox.h>
+
 class KreListView;
 class RecipeDB;
@@ -118,8 +122,15 @@ private:
         
         //Widgets
+        
         KreListView *ingredientListView;
+        
         KreListView *recipeListView;
+        QHBox *missingBox;
+        QLabel *missingNumberLabel;
+        KComboBox *missingNumberCombo;
+        
         QPushButton *okButton;
         QPushButton *clearButton;
+        
 private slots:
         void findRecipes(void);


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

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