void RecipeActionsHandler::categorize() { QList<Q3ListViewItem*> items = parentListView->selectedItems(); if ( items.count() > 0 ) { ElementList categoryList; QPointer<SelectCategoriesDialog> editCategoriesDialog = new SelectCategoriesDialog( parentListView, categoryList, database ); if ( editCategoriesDialog->exec() == QDialog::Accepted ) { // user presses Ok editCategoriesDialog->getSelectedCategories( &categoryList ); // get the category list chosen QListIterator<Q3ListViewItem *> it(items); Q3ListViewItem *item; while ( it.hasNext() ) { item = it.next(); if ( item->parent() != 0 ) { RecipeListItem * recipe_it = ( RecipeListItem* ) item; int recipe_id = recipe_it->recipeID(); database->categorizeRecipe( recipe_id, categoryList ); } } } delete editCategoriesDialog; } }