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

List:       kde-commits
Subject:    kdenonbeta/krecipes/src/dialogs
From:       Jason Kivlighn <confederacy2 () excite ! com>
Date:       2004-02-02 3:41:04
Message-ID: 20040202034104.EA2A1993C () office ! kde ! org
[Download RAW message or body]

CVS commit by jkivlighn: 

USDA import now checks that the ingredient doesn't already have the given property \
before adding it.  If it does, the current amount is updated.


  M +6 -3      usdadatadialog.cpp   1.2


--- kdenonbeta/krecipes/src/dialogs/usdadatadialog.cpp  #1.1:1.2
@@ -183,4 +183,5 @@ void USDADataDialog::importSelected()
 
                 IngredientPropertyList property_list; database->loadProperties( \
&property_list ); +                IngredientPropertyList existing_ing_props; \
database->loadProperties(&existing_ing_props,ingredient.id);  
                 int i = 0;
@@ -190,11 +191,13 @@ void USDADataDialog::importSelected()
                         if ( property_id == -1 )
                         {
-                                //TODO: check that the property doesn't already \
                exist and update it if it does
                                 database->addProperty(property_data_list[i].name, \
property_data_list[i].unit);  property_id = database->lastInsertID();
                         }
 
-                        double amount = (*it).toDouble()/100.0; //data givin in 100g \
so divide by 100 to get the amount in 1 gram +                        double amount = \
(*it).toDouble()/100.0; //data givin per 100g so divide by 100 to get the amount in 1 \
gram  
+                        if ( existing_ing_props.find(property_id) != -1 ) //property \
already added to ingredient, so just update +                                \
database->changePropertyAmountToIngredient(ingredient.id,property_id,amount,grams_id);
 +                        else
                         \
database->addPropertyToIngredient(ingredient.id,property_id,amount,grams_id);  }


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

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