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

List:       kde-commits
Subject:    [krecipes] src/dialogs/recipeinput: Use the global completion objects in the delegate.
From:       José_Manuel_Santamaría_Lema <panfaust () gmail ! com>
Date:       2016-04-08 12:47:47
Message-ID: E1aoVpD-0005cJ-2P () scm ! kde ! org
[Download RAW message or body]

Git commit 21adedd4bca11875e67afd9d417c26a91c8a41fb by José Manuel Santamaría Lema.
Committed on 08/04/2016 at 11:55.
Pushed by joselema into branch 'master'.

Use the global completion objects in the delegate.

M  +6    -19   src/dialogs/recipeinput/ingredientnamedelegate.cpp

http://commits.kde.org/krecipes/21adedd4bca11875e67afd9d417c26a91c8a41fb

diff --git a/src/dialogs/recipeinput/ingredientnamedelegate.cpp \
b/src/dialogs/recipeinput/ingredientnamedelegate.cpp index 2a24b9f..d4934b3 100644
--- a/src/dialogs/recipeinput/ingredientnamedelegate.cpp
+++ b/src/dialogs/recipeinput/ingredientnamedelegate.cpp
@@ -102,26 +102,13 @@ QWidget * IngredientNameDelegate::createEditor(QWidget *parent, \
const QStyleOpti  editor->setEditable( true );
 	editor->setCompletionMode( KGlobalSettings::CompletionPopup );
 
-	//Order
-	editor->completionObject()->setOrder( KCompletion::Sorted );
-
-	editor->setModel( m_database->allIngredientsModels()->ingredientNameModel() );
-
-	//Fill the items and the completion objects
-	int i = 0;
-	QHash<RecipeDB::IdType,Element>::const_iterator it;
-	QHash<RecipeDB::IdType,Element>::const_iterator it_end;
-	if ( index.data(IngredientsEditor::IsHeaderRole).toBool() ) {
-		it = m_idToHeaderMap.constBegin();
-		it_end = m_idToHeaderMap.constEnd();
+	//Set the models and the completion objects
+	if ( !index.data(IngredientsEditor::IsHeaderRole).toBool() ) {
+		editor->setModel( m_database->allIngredientsModels()->ingredientNameModel() );
+		editor->setCompletionObject(
+			m_database->allIngredientsModels()->ingredientNameCompletion() );
 	} else {
-		it = m_idToIngredientMap.constBegin();
-		it_end = m_idToIngredientMap.constEnd();
-	}
-	while( it != it_end ) {
-		editor->completionObject()->addItem( it.value().name );
-		++i;
-		++it;
+		//TODO: set models and completion for headers
 	}
 
 	return editor;


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

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