void IngredientMatcherDialog::haveSelectedItems() { QList<int> list = actionHandler->recipeIDs(); if ( list.isEmpty() ) emit recipeSelected( false ); else emit recipeSelected( true ); }
void RecipeActionsHandler::selectionChangedSlot() { const QList<Q3ListViewItem*> items = parentListView->selectedItems(); if ( (items.count() == 1) && (items.first()->rtti() == 1000) ) { // We have a single recipe as our selection RecipeListItem * recipe_it = ( RecipeListItem* ) items.first(); emit recipeSelected( recipe_it->recipeID(), 4 ); emit recipeSelected( true ); } else { emit recipeSelected( 0, 5 ); //id doesn't matter here emit recipeSelected( false ); } }
void Krecipes::updateActions( KrePanel panel, bool show ) { switch ( panel ) { case RecipeView: { exportAction->setEnabled( show ); printAction->setEnabled( show ); reloadAction->setEnabled( show ); copyToClipboardAction->setEnabled( show ); showRecipeAction->setEnabled( false ); //can't edit when there are multiple recipes loaded if ( show && m_view->viewPanel->recipesLoaded() == 1 ) { editAction->setEnabled( true ); } else editAction->setEnabled( false ); break; } case RecipeEdit: { printAction->setEnabled( show ); exportAction->setEnabled( false ); showRecipeAction->setEnabled( show ); break; } case SelectP: { printAction->setEnabled( show ); exportAction->setEnabled( show ); if (show) m_view->selectPanel->haveSelectedItems(); else recipeSelected( false ); break; } case MatcherP: { printAction->setEnabled( show ); exportAction->setEnabled( show ); if (show) m_view->ingredientMatcherPanel->haveSelectedItems(); else recipeSelected( false ); break; } default: break; } }
Krecipes::Krecipes(): KXmlGuiWindow( 0 ) { m_view = new KrecipesView( this ); setObjectName( "Krecipes" ); // accept dnd setAcceptDrops( true ); // tell the KMainWindow that this is indeed the main widget setCentralWidget( m_view ); // then, setup our actions setupActions(); // and a status bar statusBar() ->show(); statusLabel = new QLabel; statusBar()->addPermanentWidget( statusLabel ); // apply the saved mainwindow settings, if any, and ask the mainwindow // to automatically save settings if changed: window size, toolbar // position, icon size, etc. setAutoSaveSettings(); // allow the view to change the statusbar and caption connect( m_view, SIGNAL( signalChangeStatusbar( const QString& ) ), this, SLOT( changeStatusbar( const QString& ) ) ); connect( m_view, SIGNAL( signalChangeCaption( const QString& ) ), this, SLOT( changeCaption( const QString& ) ) ); connect( m_view, SIGNAL( panelShown( KrePanel, bool ) ), SLOT( updateActions( KrePanel, bool ) ) ); connect( m_view, SIGNAL( recipeSelected(bool) ), SLOT( recipeSelected(bool) ) ); // Enable/Disable the Save Button (Initialize disabled, and connect signal) connect( m_view, SIGNAL( enableSaveOption( bool ) ), this, SLOT( enableSaveOption( bool ) ) ); enableSaveOption( false ); // Disables saving initially recipeSelected( false ); //nothing is selected initially parsing_file_dlg = new KDialog( this ); parsing_file_dlg->setObjectName( "parsing_file_dlg" ); parsing_file_dlg->setModal( true ); //parsing_file_dlg->setWindowFlags ( Qt::WX11BypassWM ); QLabel *parsing_file_dlg_label = new QLabel( i18n( "Gathering recipe data from file.\nPlease wait..." ), parsing_file_dlg ); parsing_file_dlg_label->setFrameStyle( QFrame::Box | QFrame::Raised ); //( new QVBoxLayout( parsing_file_dlg ) ) ->addWidget( parsing_file_dlg_label ); parsing_file_dlg->setMainWidget( parsing_file_dlg_label ); parsing_file_dlg->adjustSize(); //parsing_file_dlg->setFixedSize(parsing_file_dlg->size()); convertDialog = new ConversionDialog(this,m_view->database); }
void RecipeActionsHandler::edit() { QList<Q3ListViewItem *> items = parentListView->selectedItems(); if ( items.count() > 1 ) KMessageBox::sorry( kapp->mainWidget(), i18n("Please select only one recipe."), i18n("Edit Recipe") ); else if ( items.count() == 1 && items.at(0)->rtti() == 1000 ) { RecipeListItem * recipe_it = ( RecipeListItem* ) items.at(0); emit recipeSelected( recipe_it->recipeID(), 1 ); } else //either nothing was selected or a category was selected KMessageBox::sorry( kapp->mainWidget(), i18n("No recipes selected."), i18n("Edit Recipe") ); }
void RecipeActionsHandler::addToShoppingList() { QList<Q3ListViewItem *> items = parentListView->selectedItems(); if ( items.count() > 0 ) { QListIterator<Q3ListViewItem *> it(items); Q3ListViewItem *item; while ( it.hasNext() ) { item = it.next(); if ( item->parent() != 0 ) { RecipeListItem * recipe_it = ( RecipeListItem* ) item; emit recipeSelected( recipe_it->recipeID(), 3 ); } } } }
void RecipeActionsHandler::open() { const QList<Q3ListViewItem*> items = parentListView->selectedItems(); if ( items.count() > 0 ) { QList<int> ids = recipeIDs(items); if ( ids.count() == 1 ) emit recipeSelected(ids.first(),0); else if ( ids.count() > 0 ) emit recipesSelected(ids,0); #if 0 else if ( it->rtti() == 1001 && it->firstChild() ) //CategoryListItem and not empty { QList<int> ids; //do this to only iterate over children of 'it' Q3ListViewItem *pEndItem = NULL; Q3ListViewItem *pStartItem = it; do { if ( pStartItem->nextSibling() ) pEndItem = pStartItem->nextSibling(); else pStartItem = pStartItem->parent(); } while ( pStartItem && !pEndItem ); Q3ListViewItemIterator iterator( it ); while ( iterator.current() != pEndItem ) { if ( iterator.current() ->rtti() == 1000 ) { RecipeListItem * recipe_it = ( RecipeListItem* ) iterator.current(); if ( ids.indexOf( recipe_it->recipeID() ) == -1 ) { ids.append( recipe_it->recipeID() ); } } ++iterator; } emit recipesSelected( ids, 0 ); } #endif } }