[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [krecipes] src: Add completion objects for ingredient names.
From: José_Manuel_Santamaría_Lema <panfaust () gmail ! com>
Date: 2016-04-08 12:47:47
Message-ID: E1aoVpD-0005cJ-1q () scm ! kde ! org
[Download RAW message or body]
Git commit 1a23432b4ddb42f16c033d2cdf9231656662eceb by José Manuel Santamaría Lema.
Committed on 08/04/2016 at 11:53.
Pushed by joselema into branch 'master'.
Add completion objects for ingredient names.
M +4 -0 src/backends/qsqlrecipedb.cpp
M +13 -0 src/models/kreallingredientsmodels.cpp
M +4 -0 src/models/kreallingredientsmodels.h
http://commits.kde.org/krecipes/1a23432b4ddb42f16c033d2cdf9231656662eceb
diff --git a/src/backends/qsqlrecipedb.cpp b/src/backends/qsqlrecipedb.cpp
index 50e781a..91a4148 100644
--- a/src/backends/qsqlrecipedb.cpp
+++ b/src/backends/qsqlrecipedb.cpp
@@ -22,6 +22,7 @@
#include <KLocale>
#include <KMessageBox>
#include <KCodecs>
+#include <KCompletion>
#include <kdebug.h>
#include <QSqlQuery>
@@ -188,6 +189,8 @@ void QSqlRecipeDB::loadAllIngredientsModels()
QStandardItemModel * sourceModel = m_allIngredientsModels->sourceModel();
KreSingleColumnProxyModel * ingredientNameModel =
m_allIngredientsModels->ingredientNameModel();
+ KCompletion * ingredientNameCompletion =
+ m_allIngredientsModels->ingredientNameCompletion();
QSqlQuery query( "SELECT id,name FROM ingredients", *database);
query.exec();
@@ -205,6 +208,7 @@ void QSqlRecipeDB::loadAllIngredientsModels()
sourceModel->setData( index, query.value(0) );
index = sourceModel->index( row, 1 );
sourceModel->setData( index, query.value(1) );
+ ingredientNameCompletion->addItem( query.value(1).toString() );
++row;
}
diff --git a/src/models/kreallingredientsmodels.cpp b/src/models/kreallingredientsmodels.cpp
index 3ef16ac..aca6d89 100644
--- a/src/models/kreallingredientsmodels.cpp
+++ b/src/models/kreallingredientsmodels.cpp
@@ -11,6 +11,7 @@
#include "kresinglecolumnproxymodel.h"
+#include <KCompletion>
#include <QStandardItemModel>
@@ -21,6 +22,12 @@ KreAllIngredientsModels::KreAllIngredientsModels( RecipeDB * database ):
m_ingredientNameModel = new KreSingleColumnProxyModel( 1 );
m_ingredientNameModel->setSortCaseSensitivity( Qt::CaseInsensitive );
m_ingredientNameModel->setSourceModel( m_sourceModel );
+ m_ingredientNameCompletion = new KCompletion;
+}
+
+KreAllIngredientsModels::~KreAllIngredientsModels()
+{
+ delete m_ingredientNameCompletion;
}
QStandardItemModel * KreAllIngredientsModels::sourceModel()
@@ -32,3 +39,9 @@ KreSingleColumnProxyModel * KreAllIngredientsModels::ingredientNameModel()
{
return m_ingredientNameModel;
}
+
+KCompletion * KreAllIngredientsModels::ingredientNameCompletion()
+{
+ return m_ingredientNameCompletion;
+}
+
diff --git a/src/models/kreallingredientsmodels.h b/src/models/kreallingredientsmodels.h
index 1a0f7b9..dfab8c1 100644
--- a/src/models/kreallingredientsmodels.h
+++ b/src/models/kreallingredientsmodels.h
@@ -14,6 +14,7 @@
class RecipeDB;
class KreSingleColumnProxyModel;
+class KCompletion;
class QStandardItemModel;
class KreAllIngredientsModels: public QObject {
@@ -21,14 +22,17 @@ Q_OBJECT
public:
KreAllIngredientsModels( RecipeDB * database );
+ ~KreAllIngredientsModels();
QStandardItemModel * sourceModel();
KreSingleColumnProxyModel * ingredientNameModel();
+ KCompletion * ingredientNameCompletion();
private:
RecipeDB * m_database;
QStandardItemModel * m_sourceModel;
KreSingleColumnProxyModel * m_ingredientNameModel;
+ KCompletion * m_ingredientNameCompletion;
};
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic