diff options
author | Michele Calgaro <[email protected]> | 2024-10-13 11:56:14 +0900 |
---|---|---|
committer | Michele Calgaro <[email protected]> | 2024-10-29 21:58:42 +0900 |
commit | 2879ff70be9271550477982a1a6371714db38562 (patch) | |
tree | c2054149dba923ab080fe7093432c7663a990111 /src/dialogs/ingredientmatcherdialog.h | |
parent | 3eb38d2556f676d1027746f20bf12a1dd74451ef (diff) | |
download | krecipes-2879ff70be9271550477982a1a6371714db38562.tar.gz krecipes-2879ff70be9271550477982a1a6371714db38562.zip |
Rearrange folders structure to remove unnecessary 'krecipes' second level subfolder
Signed-off-by: Michele Calgaro <[email protected]>
(cherry picked from commit 0c8ed6c9a4000af8f48581a81c4b5c2f5b9fd502)
Diffstat (limited to 'src/dialogs/ingredientmatcherdialog.h')
-rw-r--r-- | src/dialogs/ingredientmatcherdialog.h | 156 |
1 files changed, 156 insertions, 0 deletions
diff --git a/src/dialogs/ingredientmatcherdialog.h b/src/dialogs/ingredientmatcherdialog.h new file mode 100644 index 0000000..2bd54b3 --- /dev/null +++ b/src/dialogs/ingredientmatcherdialog.h @@ -0,0 +1,156 @@ +/*************************************************************************** +* Copyright (C) 2003 by * +* Unai Garro ([email protected]) * +* * +* Copyright (C) 2006 Jason Kivlighn ([email protected]) * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +***************************************************************************/ + +#ifndef INGREDIENTMATCHERDIALOG_H +#define INGREDIENTMATCHERDIALOG_H + +#include "datablocks/element.h" +#include "datablocks/ingredientlist.h" +#include "datablocks/recipe.h" +#include "widgets/recipelistview.h" +#include "widgets/dblistviewbase.h" + +#include <tqfontmetrics.h> +#include <tqlabel.h> +#include <tqlistview.h> +#include <tqpushbutton.h> +#include <tqhbox.h> +#include <tqvbox.h> + +#include <kstringhandler.h> +#include <tdelocale.h> + +class KreListView; +class KIntSpinBox; +class RecipeDB; +class MixedNumber; + +/** +@author Unai Garro +*/ + +class CustomRecipeListItem : public RecipeListItem +{ +public: + CustomRecipeListItem( TQListView* qlv, const Recipe &r, const IngredientList &il ) : RecipeListItem( qlv, r ) + { + ingredientListStored = new TQStringList(); + IngredientList::ConstIterator ili; + for ( ili = il.begin();ili != il.end();++ili ) { + if ( (*ili).substitutes.count() > 0 ) { + TQStringList subs; + subs << ( *ili ).name; + for ( TQValueList<IngredientData>::const_iterator it = (*ili).substitutes.begin(); it != (*ili).substitutes.end(); ++it ) { + subs << (*it).name; + } + ingredientListStored->append( subs.join(TQString(" %1 ").arg(i18n("OR"))) ); + } + else + ingredientListStored->append( ( *ili ).name ); + } + + moveItem( qlv->lastItem() ); + } + CustomRecipeListItem( TQListView* qlv, const Recipe &r ) : RecipeListItem( qlv, r ) + { + ingredientListStored = 0; + + moveItem( qlv->lastItem() ); + } + + ~CustomRecipeListItem( void ) + { + delete ingredientListStored; + } + +private: + TQStringList *ingredientListStored; + +public: + virtual TQString text( int column ) const + { + if ( column == 2 && ingredientListStored ) + return ingredientListStored->join ( "," ); + else + return ( RecipeListItem::text( column ) ); + } +}; + +class SectionItem: public TQListViewItem +{ +public: + SectionItem( TQListView* qlv, TQString sectionText ) : TQListViewItem( qlv, qlv->lastItem() ) + { + mText = sectionText; + } + + ~SectionItem( void ) + {} + virtual void paintCell ( TQPainter * p, const TQColorGroup & cg, int column, int width, int align ); + +private: + TQString mText; + +public: + virtual TQString text( int column ) const + { + if ( column == 0 ) + return ( mText ); + else + return ( TQString::null ); + } +}; +class IngredientMatcherDialog: public TQWidget +{ + + TQ_OBJECT + +public: + + IngredientMatcherDialog( TQWidget *parent, RecipeDB* db ); + ~IngredientMatcherDialog(); + void reload( ReloadFlags flag = Load ); + +signals: + void recipeSelected( int, int ); + +private: + //Private variables + RecipeDB *database; + + //Widgets + + KreListView *allIngListView; + KreListView *ingListView; + + KreListView *recipeListView; + TQHBox *missingBox; + TQLabel *missingNumberLabel; + KIntSpinBox *missingNumberSpinBox; + + TQPushButton *okButton; + TQPushButton *clearButton; + TQPushButton *addButton; + TQPushButton *removeButton; + + IngredientList m_ingredientList; + TQMap<TQListViewItem*, IngredientList::iterator> m_item_ing_map; + +private slots: + void findRecipes( void ); + void unselectIngredients(); + void addIngredient(); + void removeIngredient(); + void itemRenamed( TQListViewItem*, const TQPoint &, int col ); +}; + +#endif |