[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [krecipes] src/dialogs/recipeinput: Delete old editor code: ingredient parser button.
From:       José_Manuel_Santamaría_Lema <panfaust () gmail ! com>
Date:       2016-04-01 13:27:31
Message-ID: E1alz6p-0003Wm-V2 () scm ! kde ! org
[Download RAW message or body]

Git commit ef2d73a51d08982902a0d649479493c904b16416 by José Manuel Santamaría Lema.
Committed on 01/04/2016 at 12:19.
Pushed by joselema into branch 'master'.

Delete old editor code: ingredient parser button.

M  +0    -102  src/dialogs/recipeinput/recipeinputdialog.cpp
M  +0    -5    src/dialogs/recipeinput/recipeinputdialog.h

http://commits.kde.org/krecipes/ef2d73a51d08982902a0d649479493c904b16416

diff --git a/src/dialogs/recipeinput/recipeinputdialog.cpp \
b/src/dialogs/recipeinput/recipeinputdialog.cpp index 6ffd690..9f0adbc 100644
--- a/src/dialogs/recipeinput/recipeinputdialog.cpp
+++ b/src/dialogs/recipeinput/recipeinputdialog.cpp
@@ -117,15 +117,6 @@ RecipeInputDialog::RecipeInputDialog( QWidget* parent, RecipeDB \
*db ) : KVBox( p  QSpacerItem* spacerToOtherButtons = new QSpacerItem( 10, 10, \
QSizePolicy::Minimum, QSizePolicy::Fixed );  ingredientsLayout->addItem( \
spacerToOtherButtons, 4, 5 );  
-	ingParserButton = new KPushButton( ingredientsTab );
-	ingParserButton->setFixedSize( QSize( 31, 31 ) );
-	ingParserButton->setIcon( KIcon( "edit-paste" ) );
-	ingParserButton->setIconSize( QSize( 16, 16 ) );
-	ingParserButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed \
                ) );
-	ingredientsLayout->addWidget( ingParserButton, 8, 5 );
-
-		ingParserButton->setToolTip( i18nc(  "@info:tooltip", "Paste Ingredients" ) );
-
 	// Ingredient List
 	ingredientList = new K3ListView( ingredientsTab );
 	ingredientList->addColumn( i18nc( "@title:column", "Ingredient" ) );
@@ -230,7 +221,6 @@ RecipeInputDialog::RecipeInputDialog( QWidget* parent, RecipeDB \
*db ) : KVBox( p  
 	connect( ingredientsEditor, SIGNAL(changed()), this, SLOT(recipeChanged()) );
 
-	connect( ingParserButton, SIGNAL( clicked() ), this, SLOT( slotIngredientParser() ) \
);  connect( this, SIGNAL( changed() ), this, SLOT( recipeChanged() ) );
 	connect( instructionsEdit, SIGNAL( textChanged() ), this, SLOT( recipeChanged() ) \
);  connect( ingredientList, SIGNAL( itemRenamed( Q3ListViewItem*, const QString &, \
int ) ), SLOT( syncListView( Q3ListViewItem*, const QString &, int ) ) ); @@ -638,98 \
+628,6 @@ int RecipeInputDialog::ingItemIndex( Q3ListView *listview, const \
Q3ListViewItem  }
 }
 
-void RecipeInputDialog::slotIngredientParser()
-{
-	UnitList units;
-	database->loadUnits(&units);
-	QPointer<IngredientParserDialog> dlg = new IngredientParserDialog(units,this);
-	if ( dlg->exec() == QDialog::Accepted ) {
-		IngredientList ings = dlg->ingredients();
-		QStringList usedGroups;
-		bool haveHeader = ingredientList->lastItem() && ingredientList->lastItem()->rtti() \
                == INGGRPLISTVIEWITEM_RTTI;
-		for ( IngredientList::iterator it = ings.begin(); it != ings.end(); ++it ) {
-			if ( !(*it).group.isEmpty() && usedGroups.indexOf((*it).group) == -1 ) {
-				int id = IngredientInputWidget::createNewGroupIfNecessary((*it).group,database);
-				addIngredientHeader( Element((*it).group, id) );
-				haveHeader = true;
-				usedGroups << (*it).group;
-			}
-			(*it).ingredientID = \
                IngredientInputWidget::createNewIngredientIfNecessary((*it).name,database);
                
-			(*it).units.setId(IngredientInputWidget::createNewUnitIfNecessary((*it).units.name(),false,(*it).ingredientID,(*it).units,database));
                
-
-			QList<int> prepIDs = \
                IngredientInputWidget::createNewPrepIfNecessary((*it).prepMethodList,database);
                
-			QList<int>::const_iterator prep_id_it = prepIDs.constBegin();
-			for ( ElementList::iterator prep_it = (*it).prepMethodList.begin(); prep_it != \
                (*it).prepMethodList.end(); ++prep_it, ++prep_id_it ) {
-				(*prep_it).id = *prep_id_it;
-			}
-
-			addIngredient( *it, !haveHeader );
-
-			if ( usedGroups.count() > 0 && (*it).group.isEmpty() ) {
-				Q3ListViewItem *last_item = ingredientList->lastItem();
-				if ( last_item->parent() ) {
-					last_item->parent()->takeItem( last_item );
-					ingredientList->insertItem( last_item );
-					last_item->moveItem( ingredientList->lastItem()->parent() );
-				}
-			}
-		}
-	}
-	delete dlg;
-}
-
-void RecipeInputDialog::addIngredient( const Ingredient &ing, bool noHeader )
-{
-	Ingredient ingCopy = ing;
-
-	//Append to the ListView
-	Q3ListViewItem* lastElement = ingredientList->lastItem();
-	while ( lastElement && lastElement->rtti() == INGSUBLISTVIEWITEM_RTTI )
-		lastElement = lastElement->itemAbove();
-
-	if ( noHeader && lastElement )
-		lastElement = (lastElement->parent())?lastElement->parent():lastElement;
-
-	if ( !noHeader && lastElement &&
-		( lastElement->rtti() == INGGRPLISTVIEWITEM_RTTI || ( lastElement->parent() && \
                lastElement->parent() ->rtti() == INGGRPLISTVIEWITEM_RTTI ) ) )
-	{
-		IngGrpListViewItem * header = ( lastElement->parent() ) ? ( IngGrpListViewItem* ) \
                lastElement->parent() : ( IngGrpListViewItem* ) lastElement;
-
-		ingCopy.groupID = header->id();
-
-		lastElement = new IngListViewItem( header, lastElement, ingCopy );
-		for ( Ingredient::SubstitutesList::const_iterator it = \
                ingCopy.substitutes.constBegin(); it != \
                ingCopy.substitutes.constEnd(); ++it ) {
-			new IngSubListViewItem( lastElement, *it );
-		}
-		lastElement->setOpen(true);
-	}
-	else {
-		lastElement = new IngListViewItem( ingredientList, lastElement, ingCopy );
-		for ( Ingredient::SubstitutesList::const_iterator it = \
                ing.substitutes.constBegin(); it != ing.substitutes.constEnd(); ++it \
                ) {
-			new IngSubListViewItem( lastElement, *it );
-		}
-		lastElement->setOpen(true);
-	}
-
-	//append to recipe
-	loadedRecipe->ingList.append( ingCopy );
-
-	//update the completion in the instructions edit
-	instructionsEdit->addCompletionItem( ingCopy.name );
-
-	emit changed();
-}
-
-void RecipeInputDialog::addIngredientHeader( const Element &header )
-{
-	Q3ListViewItem *last_item = ingredientList->lastItem();
-	if ( last_item && last_item->parent() )
-		last_item = last_item->parent();
-
-	IngGrpListViewItem *ing_header = new IngGrpListViewItem( ingredientList, last_item, \
                header.name, header.id );
-	ing_header->setOpen( true );
-}
-
 void RecipeInputDialog::reloadCheckSpelling()
 {
 	if ( instructionsEdit->checkSpellingEnabled() ) {                                   \
                
diff --git a/src/dialogs/recipeinput/recipeinputdialog.h \
b/src/dialogs/recipeinput/recipeinputdialog.h index 27cea84..392a38b 100644
--- a/src/dialogs/recipeinput/recipeinputdialog.h
+++ b/src/dialogs/recipeinput/recipeinputdialog.h
@@ -97,8 +97,6 @@ private:
 	QFrame *ingredientsTab;
 	IngredientsEditor * ingredientsEditor;
 
-	KPushButton* ingParserButton;
-
 	RatingListEditor * ratingListEditor;
 
 	//Function buttons
@@ -124,9 +122,6 @@ private slots:
 	void enableSaveButton( bool enabled );
 	void closeOptions( void );
 	void recipeRemoved( int id );
-	void slotIngredientParser();
-	void addIngredient( const Ingredient &ing, bool noHeader = false );
-	void addIngredientHeader( const Element &header );
 
 public slots:
 	bool save ( void ); // Activated when krecipes.cpp sends signal save()


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic