[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: 2003-11-28 23:34:21
[Download RAW message or body]
CVS commit by jkivlighn:
Convenience function to determine whether a listviewitem is a recipe (and not a \
category)
M +15 -14 selectrecipedialog.cpp 1.62
M +1 -0 selectrecipedialog.h 1.32
--- kdenonbeta/krecipes/src/dialogs/selectrecipedialog.cpp #1.61:1.62
@@ -200,6 +200,5 @@ it=recipeListView->selectedItem();
if ( it )
{
- bool is_recipe; it->text(1).toInt(&is_recipe);
- if ( !it->firstChild() && is_recipe )
+ if ( !it->firstChild() && itemIsRecipe(it) )
emit recipeSelected(it->text(1).toInt(),0);
}
@@ -249,6 +248,4 @@ void SelectRecipeDialog::filter(const QS
for (QListViewItem *it=recipeListView->firstChild();it;it=it->nextSibling())
{
- bool is_recipe; it->text(1).toInt(&is_recipe);
-
if ( s.isNull() || s == "" ) // Don't filter if the filter text is empty
{
@@ -386,6 +383,5 @@ void SelectRecipeDialog::haveSelectedIte
if( recipeListView->selectedItem() )
{
- bool is_recipe; \
recipeListView->selectedItem()->text(1).toInt(&is_recipe);
- if ( is_recipe || recipeListView->selectedItem()->firstChild() )
+ if ( itemIsRecipe(recipeListView->selectedItem()) || \
recipeListView->selectedItem()->firstChild() ) emit recipeSelected(true);
else
@@ -396,10 +392,6 @@ void SelectRecipeDialog::haveSelectedIte
void SelectRecipeDialog::getCurrentRecipe( Recipe *recipe )
{
- if (recipeListView->selectedItem())
- {
- bool is_recipe; \
recipeListView->selectedItem()->text(1).toInt(&is_recipe);
- if( is_recipe )
+ if (recipeListView->selectedItem() && \
itemIsRecipe(recipeListView->selectedItem()) )
database->loadRecipe( recipe, \
(recipeListView->selectedItem())->text(1).toInt() );
- }
}
@@ -407,6 +399,5 @@ void SelectRecipeDialog::showPopup( KLis
if (i) // Check if the QListViewItem actually exists
{
- bool is_recipe; i->text(1).toInt(&is_recipe);
- if ( is_recipe )
+ if ( itemIsRecipe(i) )
kpop->exec(p);
else if ( i->firstChild() ) //is a category... don't pop-up for an \
empty category though @@ -453,3 +444,13 @@ void SelectRecipeDialog::collapseAll(){
it->setOpen(false);
}
+}
+
+//item is a recipe if the 2nd column is an integer (the recipe's ID)
+bool SelectRecipeDialog::itemIsRecipe( const QListViewItem *item )
+{
+ bool is_recipe = false;
+ if ( item )
+ item->text(1).toInt(&is_recipe);
+
+ return is_recipe;
}
--- kdenonbeta/krecipes/src/dialogs/selectrecipedialog.h #1.31:1.32
@@ -77,4 +77,5 @@ private:
void loadRecipeList(void);
void loadCategoryCombo(void);
+ bool itemIsRecipe( const QListViewItem *item );
void exportRecipes( const QValueList<int> &ids, const QString & caption, const \
QString &selection );
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic