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

List:       kde-commits
Subject:    [krecipes] src/dialogs/recipeinput: Skip the headers when updating ingredients altered in the databa
From:       José_Manuel_Santamaría_Lema <panfaust () gmail ! com>
Date:       2016-04-01 9:56:56
Message-ID: E1alvp2-0008L1-5J () scm ! kde ! org
[Download RAW message or body]

Git commit 94256f5a7be2852b15b7900ecf160ecd240dc571 by José Manuel Santamaría Lema.
Committed on 01/04/2016 at 09:54.
Pushed by joselema into branch 'master'.

Skip the headers when updating ingredients altered in the database.

M  +15   -0    src/dialogs/recipeinput/ingredientseditor.cpp

http://commits.kde.org/krecipes/94256f5a7be2852b15b7900ecf160ecd240dc571

diff --git a/src/dialogs/recipeinput/ingredientseditor.cpp \
b/src/dialogs/recipeinput/ingredientseditor.cpp index 98954d4..7afeb92 100644
--- a/src/dialogs/recipeinput/ingredientseditor.cpp
+++ b/src/dialogs/recipeinput/ingredientseditor.cpp
@@ -630,6 +630,7 @@ void IngredientsEditor::ingredientCreatedDBSlot( const Element & \
newIngredient )  this, SIGNAL(changed()) );
 
 	QModelIndex index;
+	bool isHeader;
 	QStandardItem * item;
 	QStandardItem * child;
 	int rowCount = m_sourceModel->rowCount();
@@ -642,6 +643,10 @@ void IngredientsEditor::ingredientCreatedDBSlot( const Element & \
newIngredient )  //which was just created in the database so we won't have nonsense \
duplicates.  for ( int i = 0; i < rowCount; ++i ) {
 		index = m_sourceModel->index( i, ingredientColumn() );
+		isHeader = m_sourceModel->data( index, IsHeaderRole ).toBool();
+		if ( isHeader ) {
+			continue;
+		}
 		item = m_sourceModel->itemFromIndex( index );
 		modelIngredientId = m_sourceModel->data( index, IdRole ).toInt();
 		modelIngredientName = m_sourceModel->data( index, Qt::DisplayRole ).toString();
@@ -678,6 +683,7 @@ void IngredientsEditor::ingredientModifiedDBSlot( const \
Ingredient & newIngredie  this, SIGNAL(changed()) );
 
 	QModelIndex index;
+	bool isHeader;
 	QStandardItem * item;
 	QStandardItem * child;
 	int rowCount = m_sourceModel->rowCount();
@@ -686,6 +692,10 @@ void IngredientsEditor::ingredientModifiedDBSlot( const \
Ingredient & newIngredie  //Find the modified ingredient in the model and update its \
name  for ( int i = 0; i < rowCount; ++i ) {
 		index = m_sourceModel->index( i, ingredientColumn() );
+		isHeader = m_sourceModel->data( index, IsHeaderRole ).toBool();
+		if ( isHeader ) {
+			continue;
+		}
 		item = m_sourceModel->itemFromIndex( index );
 		modelIngredientId = m_sourceModel->data( index, IdRole ).toInt();
 		if ( newIngredient.ingredientID == modelIngredientId ) {
@@ -714,6 +724,7 @@ void IngredientsEditor::ingredientRemovedDBSlot( RecipeDB::IdType \
ingredientRemo  this, SIGNAL(changed()) );
 
 	QModelIndex index;
+	bool isHeader;
 	QStandardItem * item;
 	QStandardItem * child;
 	RecipeDB::IdType modelIngredientId;
@@ -724,6 +735,10 @@ void IngredientsEditor::ingredientRemovedDBSlot( \
RecipeDB::IdType ingredientRemo  //recipe.
 	for ( int i = 0; i < rowCount; ++i ) {
 		index = m_sourceModel->index( i, ingredientColumn() );
+		isHeader = m_sourceModel->data( index, IsHeaderRole ).toBool();
+		if ( isHeader ) {
+			continue;
+		}
 		item = m_sourceModel->itemFromIndex( index );
 		modelIngredientId = m_sourceModel->data( index, IdRole ).toInt();
 		if ( ingredientRemovedId == modelIngredientId ) {


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

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