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

List:       kde-commits
Subject:    [krecipes] src: Remove obsolete actions handlers.
From:       José_Manuel_Santamaría_Lema <panfaust () gmail ! com>
Date:       2016-04-08 12:47:47
Message-ID: E1aoVpD-0005cJ-4n () scm ! kde ! org
[Download RAW message or body]

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

Remove obsolete actions handlers.

M  +0    -6    src/CMakeLists.txt
D  +0    -221  src/actionshandlers/categoryactionshandler.cpp
D  +0    -54   src/actionshandlers/categoryactionshandler.h
D  +0    -118  src/actionshandlers/headeractionshandler.cpp
D  +0    -41   src/actionshandlers/headeractionshandler.h
D  +0    -116  src/actionshandlers/ingredientactionshandler.cpp
D  +0    -40   src/actionshandlers/ingredientactionshandler.h
D  +0    -116  src/actionshandlers/prepmethodactionshandler.cpp
D  +0    -39   src/actionshandlers/prepmethodactionshandler.h
D  +0    -106  src/actionshandlers/propertyactionshandler.cpp
D  +0    -39   src/actionshandlers/propertyactionshandler.h
D  +0    -219  src/actionshandlers/unitactionshandler.cpp
D  +0    -47   src/actionshandlers/unitactionshandler.h
M  +0    -1    src/dialogs/unitsdialog.cpp
M  +0    -1    src/dialogs/unitsdialog.h

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

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b133f0a..02ddfd8 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -78,12 +78,6 @@ set(krecipesactionshandlers_SRCS
 
    #FIXME: The classes below are deprecated and must be removed sooner or later.
    actionshandlers/actionshandlerbase.cpp
-   actionshandlers/categoryactionshandler.cpp
-   actionshandlers/unitactionshandler.cpp
-   actionshandlers/propertyactionshandler.cpp
-   actionshandlers/prepmethodactionshandler.cpp
-   actionshandlers/ingredientactionshandler.cpp
-   actionshandlers/headeractionshandler.cpp
    actionshandlers/recipeactionshandler.cpp
 )
 
diff --git a/src/actionshandlers/categoryactionshandler.cpp \
b/src/actionshandlers/categoryactionshandler.cpp deleted file mode 100644
index e660b2a..0000000
--- a/src/actionshandlers/categoryactionshandler.cpp
+++ /dev/null
@@ -1,221 +0,0 @@
-/***************************************************************************
-*   Copyright  © 2004 Jason Kivlighn <jkivlighn@gmail.com>                 *
-*   Copyright  © 2004 Unai Garro <ugarro@gmail.com>                        *
-*   Copyright  © 2009 José Manuel Santamaría Lema <panfaust@gmail.com>     *
-*                                                                         *
-*   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.                                   *
-***************************************************************************/
-
-#include "categoryactionshandler.h"
-
-#include <KLocale>
-#include <K3ListView>
-#include <KMenu>
-#include <KAction>
-#include <KIcon>
-#include <QPointer>
-#include <KMessageBox>
-class Q3ListViewItem;
-
-#include "datablocks/elementlist.h"
-
-#include "backends/recipedb.h"
-
-#include "widgets/categorylistview.h"
-
-#include "dialogs/createcategorydialog.h"
-#include "dialogs/dependanciesdialog.h"
-
-
-CategoryActionsHandler::CategoryActionsHandler( StdCategoryListView \
                *_parentListView, RecipeDB *db ):
-	ActionsHandlerBase( _parentListView, db ),
-	clipboard_item( 0 ),
-	pasteAction( 0 ),
-	pasteAsSubAction( 0 )
-{
-	connect( kpop, SIGNAL( aboutToShow() ), SLOT( preparePopup() ) );
-	connect( parentListView,
-		SIGNAL( moved( Q3ListViewItem *, Q3ListViewItem *, Q3ListViewItem * ) ),
-		SLOT( changeCategoryParent( Q3ListViewItem *, Q3ListViewItem *, Q3ListViewItem * ) \
                )
-	);
-}
-
-void CategoryActionsHandler::setCategoryPasteAction( KAction * action )
-{
-	kpop->addAction( action );
-	pasteAction = action;
-}
-
-void CategoryActionsHandler::setPasteAsSubcategoryAction( KAction * action )
-{
-	kpop->addAction( action );
-	pasteAsSubAction = action;
-}
-
-void CategoryActionsHandler::createNew()
-{
-	ElementList categories;
-	database->loadCategories( &categories );
-	QPointer<CreateCategoryDialog> categoryDialog = new CreateCategoryDialog( \
                parentListView, categories );
-
-	if ( categoryDialog->exec() == QDialog::Accepted ) {
-		QString result = categoryDialog->newCategoryName();
-		int subcategory = categoryDialog->subcategory();
-
-		//check bounds first
-		if ( checkBounds( result ) )
-			database->createNewCategory( result, subcategory ); // Create the new category in \
                the database
-	}
-	delete categoryDialog;
-}
-
-void CategoryActionsHandler::cut()
-{
-	//restore a never used cut
-	if ( clipboard_item ) {
-		if ( clipboard_parent )
-			clipboard_parent->insertItem( clipboard_item );
-		else
-			parentListView->insertItem( clipboard_item );
-		clipboard_item = 0;
-	}
-
-	Q3ListViewItem *item = parentListView->currentItem();
-
-	if ( item ) {
-		clipboard_item = item;
-		clipboard_parent = item->parent();
-
-		if ( item->parent() )
-			item->parent() ->takeItem( item );
-		else
-			parentListView->takeItem( item );
-	}
-}
-
-void CategoryActionsHandler::paste()
-{
-	Q3ListViewItem * item = parentListView->currentItem();
-	if ( item && clipboard_item ) {
-		if ( item->parent() )
-			item->parent() ->insertItem( clipboard_item );
-		else
-			parentListView->insertItem( clipboard_item );
-
-		database->modCategory( clipboard_item->text( 1 ).toInt(), item->parent() ? \
                item->parent() ->text( 1 ).toInt() : -1 );
-		clipboard_item = 0;
-	}
-}
-
-void CategoryActionsHandler::pasteAsSub()
-{
-	Q3ListViewItem * item = parentListView->currentItem();
-
-	if ( item && clipboard_item ) {
-		item->insertItem( clipboard_item );
-		database->modCategory( clipboard_item->text( 1 ).toInt(), item->text( 1 ).toInt() \
                );
-		clipboard_item = 0;
-	}
-}
-
-void CategoryActionsHandler::changeCategoryParent(Q3ListViewItem *item,
-	Q3ListViewItem * /*afterFirst*/, Q3ListViewItem * /*afterNow*/ )
-{
-	int new_parent_id = -1;
-	if ( Q3ListViewItem * parent = item->parent() )
-		new_parent_id = parent->text( 1 ).toInt();
-
-	int cat_id = item->text( 1 ).toInt();
-
-	database->modCategory( cat_id, new_parent_id, false );
-}
-
-void CategoryActionsHandler::remove()
-{
-	Q3ListViewItem * item = parentListView->currentItem();
-
-	if ( item ) {
-		int id = item->text( 1 ).toInt();
-
-		ElementList recipeDependancies;
-		database->findUseOfCategoryInRecipes( &recipeDependancies, id );
-
-		if ( recipeDependancies.isEmpty() ) {
-			switch ( KMessageBox::warningContinueCancel( parentListView,
-			i18n( "Are you sure you want to delete this category and all its subcategories?" \
                ) ) ) {
-				case KMessageBox::Continue:
-					database->removeCategory( id );
-					break;
-			}
-			return;
-		}
-		else { // need warning!
-			ListInfo info;
-			info.list = recipeDependancies;
-			info.name = i18n("Recipes");
-			QPointer<DependanciesDialog> warnDialog = new DependanciesDialog( parentListView, \
                info, false );
-
-			if ( warnDialog->exec() == QDialog::Accepted )
-				database->removeCategory( id );
-
-			delete warnDialog;
-		}
-	}
-}
-
-bool CategoryActionsHandler::checkBounds( const QString &name )
-{
-	if ( name.length() > int(database->maxCategoryNameLength()) ) {
-		KMessageBox::error( parentListView,
-		i18np( "Category name cannot be longer than 1 character.",
-		"Category name cannot be longer than %1 characters." ,
-		database->maxCategoryNameLength() ));
-		return false;
-	}
-
-	return true;
-}
-
-void CategoryActionsHandler::preparePopup()
-{
-	//only enable the paste actions if clipboard_item isn't null
-	pasteAction->setEnabled( clipboard_item );
-	pasteAsSubAction->setEnabled( clipboard_item );
-}
-
-void CategoryActionsHandler::saveElement( Q3ListViewItem* i )
-{
-	CategoryListItem * cat_it = ( CategoryListItem* ) i;
-
-	if ( !checkBounds( cat_it->categoryName() ) ) {
-		parentListView->reload(ForceReload); //reset the changed text
-		return ;
-	}
-
-	int existing_id = database->findExistingCategoryByName( cat_it->categoryName() );
-	int cat_id = cat_it->categoryId();
-	if ( existing_id != -1 && existing_id != cat_id )  //category already exists with \
                this label... merge the two
-	{
-		switch ( KMessageBox::warningContinueCancel( parentListView,
-		i18n( "This category already exists. Continuing will merge these two categories \
                into one. Are you sure?" ) ) )
-		{
-		case KMessageBox::Continue: {
-				database->mergeCategories( existing_id, cat_id );
-				break;
-			}
-		default:
-			parentListView->reload(ForceReload);
-			break;
-		}
-	}
-	else
-		database->modCategory( cat_id, cat_it->categoryName() );
-}
-
-CategoryActionsHandler::~CategoryActionsHandler()
-{
-	delete clipboard_item;
-}
diff --git a/src/actionshandlers/categoryactionshandler.h \
b/src/actionshandlers/categoryactionshandler.h deleted file mode 100644
index 5f0a4f4..0000000
--- a/src/actionshandlers/categoryactionshandler.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/***************************************************************************
-*   Copyright  © 2004 Jason Kivlighn <jkivlighn@gmail.com>                 *
-*   Copyright  © 2004 Unai Garro <ugarro@gmail.com>                        *
-*   Copyright  © 2009 José Manuel Santamaría Lema <panfaust@gmail.com>     *
-*                                                                         *
-*   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 CATEGORYACTIONSHANDLER_H
-#define CATEGORYACTIONSHANDLER_H
-
-#include "actionshandlers/actionshandlerbase.h"
-
-class StdCategoryListView;
-class Q3ListViewItem;
-class KAction;
-
-class CategoryActionsHandler : public ActionsHandlerBase
-{
-	Q_OBJECT
-
-public:
-	CategoryActionsHandler( StdCategoryListView *_parentListView, RecipeDB *db );
-	~CategoryActionsHandler();
-
-	void setCategoryPasteAction( KAction * action );
-	void setPasteAsSubcategoryAction( KAction * action );
-
-public slots:
-	void createNew();
-	void cut();
-	void paste();
-	void pasteAsSub();
-	void changeCategoryParent(Q3ListViewItem *item,
-		Q3ListViewItem * /*afterFirst*/, Q3ListViewItem * /*afterNow*/ );
-	void remove();
-
-private:
-	Q3ListViewItem *clipboard_item;
-	Q3ListViewItem *clipboard_parent;
-	KAction *pasteAction;
-	KAction *pasteAsSubAction;
-	bool checkBounds( const QString &name );	
-
-private slots:
-	void preparePopup();
-	void saveElement( Q3ListViewItem* i );
-};
-
-#endif //CATEGORYACTIONSHANDLER_H
-
diff --git a/src/actionshandlers/headeractionshandler.cpp \
b/src/actionshandlers/headeractionshandler.cpp deleted file mode 100644
index 75d7a96..0000000
--- a/src/actionshandlers/headeractionshandler.cpp
+++ /dev/null
@@ -1,118 +0,0 @@
-/***************************************************************************
-*   Copyright  © 2004 Jason Kivlighn <jkivlighn@gmail.com>                 *
-*   Copyright  © 2004 Unai Garro <ugarro@gmail.com>                        *
-*   Copyright  © 2004 Cyril Bosselut <bosselut@b1project.com>              *
-*   Copyright  © 2009 José Manuel Santamaría Lema <panfaust@gmail.com>     *
-*                                                                         *
-*   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.                                   *
-***************************************************************************/
-
-#include "headeractionshandler.h"
-
-#include <KLocale>
-#include <K3ListView>
-#include <KMenu>
-#include <QPointer>
-#include <KMessageBox>
-class Q3ListViewItem;
-
-#include "datablocks/elementlist.h"
-
-#include "backends/recipedb.h"
-
-#include "widgets/dblistviewbase.h"
-
-#include "dialogs/createelementdialog.h"
-#include "dialogs/dependanciesdialog.h"
-
-
-HeaderActionsHandler::HeaderActionsHandler( DBListViewBase *_parentListView, \
                RecipeDB *db ):
-	ActionsHandlerBase( _parentListView, db )
-{
-}
-
-void HeaderActionsHandler::createNew()
-{
-	QPointer<CreateElementDialog> elementDialog = new CreateElementDialog( \
                parentListView, i18n( "New Header" ) );
-
-	if ( elementDialog->exec() == QDialog::Accepted ) {
-		QString result = elementDialog->newElementName();
-
-		//check bounds first
-		if ( checkBounds( result ) )
-			database->createNewIngGroup( result ); // Create the new header in the database
-	}
-	delete elementDialog;
-}
-
-void HeaderActionsHandler::remove()
-{
-	Q3ListViewItem * item = parentListView->currentItem();
-
-	if ( item ) {
-		int id = item->text( 1 ).toInt();
-
-		ElementList dependingRecipes;
-		database->findUseOfIngGroupInRecipes( &dependingRecipes, id);
-
-		if ( dependingRecipes.isEmpty() )
-			database->removeIngredientGroup( id );
-		else { // Need Warning!
-			ListInfo list;
-			list.list = dependingRecipes;
-			list.name = i18n( "Recipes" );
-
-			QPointer<DependanciesDialog> warnDialog = new DependanciesDialog( parentListView, \
                list, false );
-			if ( warnDialog->exec() == QDialog::Accepted )
-				database->removeIngredientGroup( id );
-			delete warnDialog;
-		}
-	}
-}
-
-bool HeaderActionsHandler::checkBounds( const QString &name )
-{
-	if ( name.length() > int(database->maxIngGroupNameLength()) ) {
-		KMessageBox::error( parentListView,
-		i18np( "Header cannot be longer than 1 character.", "Header cannot be longer than \
                %1 characters.",
-		database->maxIngGroupNameLength() ) );
-		return false;
-	}
-	else if ( name.trimmed().isEmpty() )
-		return false;
-
-	return true;
-
-}
-
-void HeaderActionsHandler::saveElement( Q3ListViewItem* i )
-{
-	if ( !checkBounds( i->text( 0 ) ) ) {
-		parentListView->reload(ForceReload); //reset the changed text
-		return ;
-	}
-
-	int existing_id = database->findExistingIngredientGroupByName( i->text( 0 ) );
-	int id = i->text( 1 ).toInt();
-	if ( existing_id != -1 && existing_id != id )  //already exists with this label... \
                merge the two
-	{
-		switch ( KMessageBox::warningContinueCancel( parentListView,
-		i18n( "This header already exists.  Continuing will merge these two headers into \
                one.  Are you sure?" ) ) )
-		{
-		case KMessageBox::Continue: {
-				database->modIngredientGroup( id, i->text( 0 ) );
-				database->mergeIngredientGroups( id, existing_id );
-				break;
-			}
-		default:
-			parentListView->reload(ForceReload);
-			break;
-		}
-	}
-	else {
-		database->modIngredientGroup( id, i->text( 0 ) );
-	}
-}
diff --git a/src/actionshandlers/headeractionshandler.h \
b/src/actionshandlers/headeractionshandler.h deleted file mode 100644
index b5de9e8..0000000
--- a/src/actionshandlers/headeractionshandler.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/***************************************************************************
-*   Copyright  © 2004 Jason Kivlighn <jkivlighn@gmail.com>                 *
-*   Copyright  © 2004 Unai Garro <ugarro@gmail.com>                        *
-*   Copyright  © 2004 Cyril Bosselut <bosselut@b1project.com>              *
-*   Copyright  © 2009 José Manuel Santamaría Lema <panfaust@gmail.com>     *
-*                                                                         *
-*   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 HEADERACTIONSHANDLER_H
-#define HEADERACTIONSHANDLER_H
-
-#include "actionshandlers/actionshandlerbase.h"
-
-class DBListViewBase;
-class Q3ListViewItem;
-
-class HeaderActionsHandler : public ActionsHandlerBase
-{
-	Q_OBJECT
-
-public:
-	HeaderActionsHandler( DBListViewBase *_parentListView, RecipeDB *db );
-	~HeaderActionsHandler() {}
-
-public slots:
-	void createNew();
-	void remove();
-
-private:
-	bool checkBounds( const QString &name );
-
-private slots:
-	void saveElement( Q3ListViewItem* i );
-};
-
-#endif //HEADERACTIONSHANDLER_H
-
diff --git a/src/actionshandlers/ingredientactionshandler.cpp \
b/src/actionshandlers/ingredientactionshandler.cpp deleted file mode 100644
index b1673da..0000000
--- a/src/actionshandlers/ingredientactionshandler.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-/***************************************************************************
-*   Copyright  © 2004 Jason Kivlighn <jkivlighn@gmail.com>                 *
-*   Copyright  © 2008 Montel Laurent <montel@kde.org>                      *
-*   Copyright  © 2009 José Manuel Santamaría Lema <panfaust@gmail.com>     *
-*                                                                         *
-*   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.                                   *
-***************************************************************************/
-
-#include "ingredientactionshandler.h"
-
-#include <KLocale>
-#include <K3ListView>
-#include <KMenu>
-#include <QPointer>
-#include <KMessageBox>
-class Q3ListViewItem;
-
-#include "datablocks/elementlist.h"
-
-#include "backends/recipedb.h"
-
-#include "widgets/dblistviewbase.h"
-
-#include "dialogs/createelementdialog.h"
-#include "dialogs/dependanciesdialog.h"
-
-
-IngredientActionsHandler::IngredientActionsHandler( DBListViewBase *_parentListView, \
                RecipeDB *db ):
-	ActionsHandlerBase( _parentListView, db )
-{
-}
-
-void IngredientActionsHandler::createNew()
-{
-	QPointer<CreateElementDialog> elementDialog = new CreateElementDialog( \
                parentListView, i18n( "New Ingredient" ) );
-
-	if ( elementDialog->exec() == QDialog::Accepted ) {
-		QString result = elementDialog->newElementName();
-
-		//check bounds first
-		if ( checkBounds( result ) )
-			database->createNewIngredient( result ); // Create the new ingredient in the \
                database
-	}
-	delete elementDialog;
-}
-
-void IngredientActionsHandler::remove()
-{
-	Q3ListViewItem * item = parentListView->currentItem();
-
-	if ( item ) {
-		int id = item->text( 1 ).toInt();
-
-		ElementList dependingRecipes;
-		database->findIngredientDependancies( id, &dependingRecipes );
-
-		if ( dependingRecipes.isEmpty() )
-			database->removeIngredient( id );
-		else { // Need Warning!
-			ListInfo list;
-			list.list = dependingRecipes;
-			list.name = i18n( "Recipes" );
-
-			QPointer<DependanciesDialog> warnDialog = new DependanciesDialog( parentListView, \
                list );
-			warnDialog->setCustomWarning( i18n("You are about to permanently delete recipes \
                from your database.") );
-			if ( warnDialog->exec() == QDialog::Accepted )
-				database->removeIngredient( id );
-			delete warnDialog;
-		}
-	}
-}
-
-bool IngredientActionsHandler::checkBounds( const QString &name )
-{
-	if ( name.length() > int(database->maxIngredientNameLength()) ) {
-		KMessageBox::error( parentListView,
-		i18np( "Ingredient name cannot be longer than 1 character.",
-		"Ingredient name cannot be longer than %1 characters.",
-		database->maxIngredientNameLength() ) );
-		return false;
-	}
-
-	return true;
-
-}
-
-void IngredientActionsHandler::saveElement( Q3ListViewItem* i )
-{
-	if ( !checkBounds( i->text( 0 ) ) ) {
-		parentListView->reload(ForceReload); //reset the changed text
-		return ;
-	}
-
-	int existing_id = database->findExistingIngredientByName( i->text( 0 ) );
-	int ing_id = i->text( 1 ).toInt();
-	if ( existing_id != -1 && existing_id != ing_id )  //ingredient already exists with \
                this label... merge the two
-	{
-		switch ( KMessageBox::warningContinueCancel( parentListView,
-		i18n( "This ingredient already exists. Continuing will merge these two ingredients \
                into one. Are you sure?" ) ) )
-		{
-		case KMessageBox::Continue: {
-				database->mergeIngredients( existing_id, ing_id );
-				break;
-			}
-		default:
-			parentListView->reload(ForceReload);
-			break;
-		}
-	}
-	else {
-		database->modIngredient( ( i->text( 1 ) ).toInt(), i->text( 0 ) );
-	}
-}
diff --git a/src/actionshandlers/ingredientactionshandler.h \
b/src/actionshandlers/ingredientactionshandler.h deleted file mode 100644
index 4adb6bf..0000000
--- a/src/actionshandlers/ingredientactionshandler.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/***************************************************************************
-*   Copyright  © 2004 Jason Kivlighn <jkivlighn@gmail.com>                 *
-*   Copyright  © 2008 Montel Laurent <montel@kde.org>                      *
-*   Copyright  © 2009 José Manuel Santamaría Lema <panfaust@gmail.com>     *
-*                                                                         *
-*   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 INGREDIENTACTIONSHANDLER_H
-#define INGREDIENTACTIONSHANDLER_H
-
-#include "actionshandlers/actionshandlerbase.h"
-
-class DBListViewBase;
-class Q3ListViewItem;
-
-class IngredientActionsHandler : public ActionsHandlerBase
-{
-Q_OBJECT
-
-public:
-	IngredientActionsHandler( DBListViewBase *_parentListView, RecipeDB *db );
-	~IngredientActionsHandler() {}
-
-public slots:
-	void createNew();
-	void remove();
-
-private:
-	bool checkBounds( const QString &name );
-
-private slots:
-	void saveElement( Q3ListViewItem* i );
-};
-
-#endif //INGREDIENTACTIONSHANDLER_H
-
diff --git a/src/actionshandlers/prepmethodactionshandler.cpp \
b/src/actionshandlers/prepmethodactionshandler.cpp deleted file mode 100644
index 560cebe..0000000
--- a/src/actionshandlers/prepmethodactionshandler.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-/***************************************************************************
-*   Copyright  © 2004 Jason Kivlighn <jkivlighn@gmail.com>                 *
-*   Copyright  © 2009 José Manuel Santamaría Lema <panfaust@gmail.com>     *
-*                                                                         *
-*   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.                                   *
-***************************************************************************/
-
-#include "prepmethodactionshandler.h"
-
-#include <KLocale>
-#include <K3ListView>
-#include <KMenu>
-#include <KIcon>
-#include <QPointer>
-#include <KMessageBox>
-class Q3ListViewItem;
-
-#include "datablocks/elementlist.h"
-
-#include "backends/recipedb.h"
-
-#include "widgets/dblistviewbase.h"
-
-#include "dialogs/createelementdialog.h"
-#include "dialogs/dependanciesdialog.h"
-
-
-PrepMethodActionsHandler::PrepMethodActionsHandler( DBListViewBase *_parentListView, \
                RecipeDB *db ):
-	ActionsHandlerBase( _parentListView, db )
-{
-}
-
-void PrepMethodActionsHandler::createNew()
-{
-	QPointer<CreateElementDialog> elementDialog = new CreateElementDialog( \
                parentListView, i18n( "New Preparation Method" ) );
-
-	if ( elementDialog->exec() == QDialog::Accepted ) {
-		QString result = elementDialog->newElementName();
-
-		//check bounds first
-		if ( checkBounds( result ) )
-			database->createNewPrepMethod( result ); // Create the new prepMethod in the \
                database
-	}
-
-	delete elementDialog;
-}
-
-void PrepMethodActionsHandler::remove()
-{
-	Q3ListViewItem * item = parentListView->currentItem();
-
-	if ( item ) {
-		ElementList dependingRecipes;
-		int prepMethodID = item->text( 1 ).toInt();
-		database->findPrepMethodDependancies( prepMethodID, &dependingRecipes );
-		if ( dependingRecipes.isEmpty() )
-			database->removePrepMethod( prepMethodID );
-		else // Need Warning!
-		{
-			ListInfo info;
-			info.list = dependingRecipes;
-			info.name = i18n("Recipes");
-			QPointer<DependanciesDialog> warnDialog = new DependanciesDialog( parentListView, \
                info );
-			warnDialog->setCustomWarning( i18n("You are about to permanently delete recipes \
                from your database.") );
-			if ( warnDialog->exec() == QDialog::Accepted )
-				database->removePrepMethod( prepMethodID );
-			delete warnDialog;
-		}
-	}
-}
-
-bool PrepMethodActionsHandler::checkBounds( const QString &name )
-{
-	if ( name.length() > int(database->maxPrepMethodNameLength()) ) {
-		KMessageBox::error( parentListView,
-		i18np( "Preparation method cannot be longer than 1 character.",
-		"Preparation method cannot be longer than %1 characters." ,
-		database->maxPrepMethodNameLength() ) );
-		return false;
-	}
-
-	return true;
-
-}
-
-void PrepMethodActionsHandler::saveElement( Q3ListViewItem* i )
-{
-	if ( !checkBounds( i->text( 0 ) ) ) {
-		parentListView->reload(ForceReload); //reset the changed text
-		return ;
-	}
-
-	int existing_id = database->findExistingIngredientGroupByName( i->text( 0 ) );
-	int id = i->text( 1 ).toInt();
-	if ( existing_id != -1 && existing_id != id )  //already exists with this label... \
                merge the two
-	{
-		switch ( KMessageBox::warningContinueCancel( parentListView,
-		i18n( "This header already exists.  Continuing will merge these two headers into \
                one.  Are you sure?" ) ) )
-		{
-		case KMessageBox::Continue: {
-				database->modIngredientGroup( id, i->text( 0 ) );
-				database->mergeIngredientGroups( id, existing_id );
-				break;
-			}
-		default:
-			parentListView->reload(ForceReload);
-			break;
-		}
-	}
-	else {
-		database->modIngredientGroup( id, i->text( 0 ) );
-	}
-}
diff --git a/src/actionshandlers/prepmethodactionshandler.h \
b/src/actionshandlers/prepmethodactionshandler.h deleted file mode 100644
index 5afc133..0000000
--- a/src/actionshandlers/prepmethodactionshandler.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/***************************************************************************
-*   Copyright  © 2004 Jason Kivlighn <jkivlighn@gmail.com>                 *
-*   Copyright  © 2009 José Manuel Santamaría Lema <panfaust@gmail.com>     *
-*                                                                         *
-*   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 PREPMETHODACTIONSHANDLER_H
-#define PREPMETHODACTIONSHANDLER_H
-
-#include "actionshandlers/actionshandlerbase.h"
-
-class DBListViewBase;
-class Q3ListViewItem;
-
-class PrepMethodActionsHandler : public ActionsHandlerBase
-{
-	Q_OBJECT
-
-public:
-	PrepMethodActionsHandler( DBListViewBase *_parentListView, RecipeDB *db );
-	~PrepMethodActionsHandler() {}
-
-public slots:
-	void createNew();
-	void remove();
-
-private:
-	bool checkBounds( const QString &name );
-
-private slots:
-	void saveElement( Q3ListViewItem* i );
-};
-
-#endif //PREPMETHODACTIONSHANDLER_H
-
diff --git a/src/actionshandlers/propertyactionshandler.cpp \
b/src/actionshandlers/propertyactionshandler.cpp deleted file mode 100644
index 64dfaf2..0000000
--- a/src/actionshandlers/propertyactionshandler.cpp
+++ /dev/null
@@ -1,106 +0,0 @@
-/***************************************************************************
-*   Copyright  © 2004 Jason Kivlighn <jkivlighn@gmail.com>                 *
-*   Copyright  © 2009 José Manuel Santamaría Lema <panfaust@gmail.com>     *
-*                                                                         *
-*   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.                                   *
-***************************************************************************/
-
-#include "propertyactionshandler.h"
-
-#include <KLocale>
-#include <K3ListView>
-#include <KMenu>
-#include <QPointer>
-#include <KMessageBox>
-class Q3ListViewItem;
-
-#include "datablocks/elementlist.h"
-
-#include "backends/recipedb.h"
-
-#include "widgets/dblistviewbase.h"
-
-#include "dialogs/createpropertydialog.h"
-#include "dialogs/dependanciesdialog.h"
-
-
-PropertyActionsHandler::PropertyActionsHandler( DBListViewBase *_parentListView, \
                RecipeDB *db ):
-	ActionsHandlerBase( _parentListView, db )
-{
-}
-
-void PropertyActionsHandler::createNew()
-{
-	UnitList list;
-	database->loadUnits( &list );
-	QPointer<CreatePropertyDialog> propertyDialog = new CreatePropertyDialog( \
                parentListView, &list );
-
-	if ( propertyDialog->exec() == QDialog::Accepted ) {
-		QString name = propertyDialog->newPropertyName();
-		QString units = propertyDialog->newUnitsName();
-		if ( !( ( name.isEmpty() ) || ( units.isEmpty() ) ) )  // Make sure none of the \
                fields are empty
-		{
-			//check bounds first
-			if ( checkBounds( name ) )
-				database->addProperty( name, units );
-		}
-	}
-	delete propertyDialog;
-}
-
-void PropertyActionsHandler::remove()
-{
-	Q3ListViewItem * item = parentListView->currentItem();
-
-	if ( item ) {
-		switch ( KMessageBox::warningContinueCancel( parentListView,
-			i18n( "Are you sure you want to delete this property?" ) ) ) {
-		case KMessageBox::Continue:
-			database->removeProperty( item->text( 2 ).toInt() );
-			break;
-		default:
-			break;
-		}
-	}
-}
-
-bool PropertyActionsHandler::checkBounds( const QString &name )
-{
-	if ( name.length() > (int)database->maxPropertyNameLength() ) {
-		KMessageBox::error( parentListView,
-			i18np( "Property name cannot be longer than 1 character.",
-			"Property name cannot be longer than %1 characters." ,
-			database->maxPropertyNameLength() ) );
-		return false;
-	}
-	return true;
-}
-
-void PropertyActionsHandler::saveElement( Q3ListViewItem* i )
-{
-	if ( !checkBounds( i->text( 0 ) ) ) {
-		parentListView->reload(); //reset the changed text
-		return ;
-	}
-	int existing_id = database->findExistingPropertyByName( i->text( 0 ) );
-	int prop_id = i->text( 2 ).toInt();
-	if ( existing_id != -1 && existing_id != prop_id )  //already exists with this \
                label... merge the two
-	{
-		switch ( KMessageBox::warningContinueCancel( parentListView,
-		i18n( "This property already exists.  Continuing will merge these two properties \
                into one.  Are you sure?" ) ) )
-		{
-		case KMessageBox::Continue: {
-				database->mergeProperties( existing_id, prop_id );
-				break;
-			}
-		default:
-			parentListView->reload();
-			break;
-		}
-	}
-	else
-		database->modProperty( prop_id, i->text( 0 ) );
-}
diff --git a/src/actionshandlers/propertyactionshandler.h \
b/src/actionshandlers/propertyactionshandler.h deleted file mode 100644
index e24c6c9..0000000
--- a/src/actionshandlers/propertyactionshandler.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/***************************************************************************
-*   Copyright  © 2004 Jason Kivlighn <jkivlighn@gmail.com>                 *
-*   Copyright  © 2009 José Manuel Santamaría Lema <panfaust@gmail.com>     *
-*                                                                         *
-*   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 PROPERTYACTIONSHANDLER_H
-#define PROPERTYACTIONSHANDLER_H
-
-#include "actionshandlers/actionshandlerbase.h"
-
-class DBListViewBase;
-class Q3ListViewItem;
-
-class PropertyActionsHandler : public ActionsHandlerBase
-{
-	Q_OBJECT
-
-public:
-	PropertyActionsHandler( DBListViewBase *_parentListView, RecipeDB *db );
-	~PropertyActionsHandler() {}
-
-public slots:
-	void createNew();
-	void remove();
-
-private:
-	bool checkBounds( const QString &name );
-
-private slots:
-	void saveElement( Q3ListViewItem* i );
-};
-
-#endif //PROPERTYACTIONSHANDLER_H
-
diff --git a/src/actionshandlers/unitactionshandler.cpp \
b/src/actionshandlers/unitactionshandler.cpp deleted file mode 100644
index 77a26fa..0000000
--- a/src/actionshandlers/unitactionshandler.cpp
+++ /dev/null
@@ -1,219 +0,0 @@
-/***************************************************************************
-*   Copyright  © 2004-2006 Jason Kivlighn <jkivlighn@gmail.com>            *
-*   Copyright  © 2004 Unai Garro <ugarro@gmail.com>                        *
-*   Copyright  © 2004 Cyril Bosselut <bosselut@b1project.com>              *
-*   Copyright  © 2009 José Manuel Santamaría Lema <panfaust@gmail.com>     *
-*                                                                         *
-*   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.                                   *
-***************************************************************************/
-
-#include "unitactionshandler.h"
-
-#include <KLocale>
-#include <K3ListView>
-#include <KMenu>
-#include <KIcon>
-#include <QPointer>
-#include <QString>
-#include <KMessageBox>
-class Q3ListViewItem;
-
-#include "datablocks/elementlist.h"
-
-#include "backends/recipedb.h"
-
-#include "widgets/unitlistview.h"
-
-#include "dialogs/createunitdialog.h"
-#include "dialogs/dependanciesdialog.h"
-
-
-UnitActionsHandler::UnitActionsHandler( StdUnitListView *_parentListView, RecipeDB \
                *db ):
-	ActionsHandlerBase( _parentListView, db )
-{
-	connect( parentListView,
-		SIGNAL( itemRenamed( Q3ListViewItem*, const QString &, int ) ),
-		SLOT( saveUnit( Q3ListViewItem*, const QString &, int ) )
-	);
-}
-
-void UnitActionsHandler::createNew()
-{
-	QPointer<CreateUnitDialog> unitDialog = new CreateUnitDialog( parentListView );
-
-	if ( unitDialog->exec() == QDialog::Accepted ) {
-		Unit result = unitDialog->newUnit();
-
-		//check bounds first
-		if ( checkBounds( result )
-		  && database->findExistingUnitByName( result.name() ) == -1
-		  && database->findExistingUnitByName( result.plural() ) == -1
-		) {
-			database->createNewUnit( result );
-		}
-	}
-	delete unitDialog;
-}
-
-void UnitActionsHandler::rename()
-{
-	UnitListViewItem * item = (UnitListViewItem*)parentListView->currentItem();
-
-	if ( item ) {
-		QPointer<CreateUnitDialog> unitDialog = new CreateUnitDialog( 
-			parentListView, item->text(0), item->text(2), item->text(1), item->text(3),
-			item->type(), false );
-		unitDialog->setCaption( i18n("Rename Unit") );
-
-		if ( unitDialog->exec() == QDialog::Accepted ) {
-			UnitListViewItem *unit_item = (UnitListViewItem*)item;
-			Unit origUnit = unit_item->unit();
-			Unit newUnit = unitDialog->newUnit();
-
-			//for each changed entry, save the change individually
-
-			Unit unit = origUnit;
-
-			if ( newUnit.name() != origUnit.name() ) {
-				unit.setName(newUnit.name());
-				unit_item->setUnit( unit );
-				saveUnit( unit_item, newUnit.name(), 0 );
-
-				//saveUnit will call database->modUnit which deletes the list item we were using
-				unit_item = (UnitListViewItem*) parentListView->findItem( \
                QString::number(unit.id()), 5 );
-			}
-
-			if ( newUnit.plural() != origUnit.plural() ) {
-				unit.setPlural(newUnit.plural());
-				unit_item->setUnit( unit );
-				saveUnit( unit_item, newUnit.plural(), 2 );
-				unit_item = (UnitListViewItem*) parentListView->findItem( \
                QString::number(unit.id()), 5 );
-			}
-
-			if ( !newUnit.nameAbbrev().trimmed().isEmpty() && newUnit.nameAbbrev() != \
                origUnit.nameAbbrev() ) {
-				unit.setNameAbbrev(newUnit.nameAbbrev());
-				unit_item->setUnit( unit );
-				saveUnit( unit_item, newUnit.nameAbbrev(), 1 );
-				unit_item = (UnitListViewItem*) parentListView->findItem( \
                QString::number(unit.id()), 5 );
-			}
-			if ( !newUnit.pluralAbbrev().trimmed().isEmpty() && newUnit.pluralAbbrev() != \
                origUnit.pluralAbbrev() ) {
-				unit.setPluralAbbrev(newUnit.pluralAbbrev());
-				unit_item->setUnit( unit );
-				saveUnit( unit_item, newUnit.pluralAbbrev(), 3 );
-				unit_item = (UnitListViewItem*) parentListView->findItem( \
                QString::number(unit.id()), 5 );
-			}
-			if ( newUnit.type() != unit.type() ) {
-				unit.setType(newUnit.type());
-				unit_item->setUnit( unit );
-				saveUnit( unit_item, unit_item->text(4), 5 );
-			}
-		}
-		delete unitDialog;
-	}
-}
-
-void UnitActionsHandler::remove()
-{
-	// Find selected unit item
-	UnitListViewItem* it = (UnitListViewItem*) parentListView->currentItem();
-
-	if ( it ) {
-		int unitID = it->unit().id();
-
-		ElementList recipeDependancies, propertyDependancies, weightDependancies;
-		database->findUnitDependancies( unitID, &propertyDependancies, \
                &recipeDependancies, &weightDependancies );
-
-		QList<ListInfo> lists;
-		if ( !recipeDependancies.isEmpty() ) {
-			ListInfo info;
-			info.list = recipeDependancies;
-			info.name = i18n("Recipes");
-			lists << info;
-		}
-		if ( !propertyDependancies.isEmpty() ) {
-			ListInfo info;
-			info.list = propertyDependancies;
-			info.name = i18n("Properties");
-			lists << info;
-		}
-		if ( !weightDependancies.isEmpty() ) {
-			ListInfo info;
-			info.list = weightDependancies;
-			info.name = i18n("Ingredient Weights");
-			lists << info;
-		}
-
-		if ( lists.isEmpty() )
-			database->removeUnit( unitID );
-		else { // need warning!
-			QPointer<DependanciesDialog> warnDialog = new DependanciesDialog( parentListView, \
                lists );
-			if ( !recipeDependancies.isEmpty() )
-				warnDialog->setCustomWarning( i18n("You are about to permanently delete recipes \
                from your database.") );
-			if ( warnDialog->exec() == QDialog::Accepted )
-				database->removeUnit( unitID );
-			delete warnDialog;
-		}
-	}
-}
-
-bool UnitActionsHandler::checkBounds( const Unit &unit )
-{
-	if ( unit.name().length() > int(database->maxUnitNameLength()) ||
-	unit.plural().length() > int(database->maxUnitNameLength()) ) {
-		KMessageBox::error( parentListView,
-		i18np( "Unit name cannot be longer than 1 character.",
-		"Unit name cannot be longer than %1 characters.",
-		database->maxUnitNameLength() ) );
-		return false;
-	}
-	else if ( unit.name().trimmed().isEmpty() || unit.plural().trimmed().isEmpty() )
-		return false;
-
-	return true;
-}
-
-void UnitActionsHandler::renameElement( Q3ListViewItem* i, const QPoint & /*p*/, int \
                c )
-{
-	if ( i ) {
-		if ( c != 4 )
-			parentListView->rename( i, c );
-		else {
-			((StdUnitListView*)parentListView)->insertTypeComboBox(i);
-		}
-	}
-}
-
-void UnitActionsHandler::saveUnit( Q3ListViewItem* i, const QString &text, int c )
-{
-	//skip abbreviations
-	if ( c == 0 || c == 2 ) {
-		if ( !checkBounds( Unit( text, text ) ) ) {
-			parentListView->reload(ForceReload); //reset the changed text
-			return ;
-		}
-	}
-
-	int existing_id = database->findExistingUnitByName( text );
-
-	UnitListViewItem *unit_it = (UnitListViewItem*)i;
-	int unit_id = unit_it->unit().id();
-	if ( existing_id != -1 && existing_id != unit_id && !text.trimmed().isEmpty() ) { \
                //unit already exists with this label... merge the two
-		switch ( KMessageBox::warningContinueCancel( parentListView,
-		i18n( "This unit already exists.  Continuing will merge these two units into one.  \
                Are you sure?" ) ) ) {
-		case KMessageBox::Continue: {
-				database->modUnit( unit_it->unit() );
-				database->mergeUnits( unit_id, existing_id );
-				break;
-			}
-		default:
-			parentListView->reload(ForceReload);
-			break;
-		}
-	}
-	else {
-		database->modUnit( unit_it->unit() );
-	}
-}
diff --git a/src/actionshandlers/unitactionshandler.h \
b/src/actionshandlers/unitactionshandler.h deleted file mode 100644
index 89b528e..0000000
--- a/src/actionshandlers/unitactionshandler.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/***************************************************************************
-*   Copyright  © 2004-2006 Jason Kivlighn <jkivlighn@gmail.com>            *
-*   Copyright  © 2004 Unai Garro <ugarro@gmail.com>                        *
-*   Copyright  © 2004 Cyril Bosselut <bosselut@b1project.com>              *
-*   Copyright  © 2009 José Manuel Santamaría Lema <panfaust@gmail.com>     *
-*                                                                         *
-*   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 UNITACTIONSHANDLER_H
-#define UNITACTIONSHANDLER_H
-
-#include "actionshandlers/actionshandlerbase.h"
-
-class StdUnitListView;
-class Q3ListViewItem;
-class Unit;
-class QPoint;
-class QString;
-
-class UnitActionsHandler : public ActionsHandlerBase
-{
-	Q_OBJECT
-
-public:
-	UnitActionsHandler( StdUnitListView *_parentListView, RecipeDB *db );
-	~UnitActionsHandler() {}
-
-public slots:
-	void createNew();
-	void rename();
-	void remove();
-
-private:
-	bool checkBounds( const Unit &unit );
-
-private slots:
-	void renameElement( Q3ListViewItem* i, const QPoint &p, int c );
-	void saveElement( Q3ListViewItem* ){}
-	void saveUnit( Q3ListViewItem* i, const QString &text, int c );
-};
-
-#endif //UNITACTIONSHANDLER_H
-
diff --git a/src/dialogs/unitsdialog.cpp b/src/dialogs/unitsdialog.cpp
index 022e22e..6a7a298 100644
--- a/src/dialogs/unitsdialog.cpp
+++ b/src/dialogs/unitsdialog.cpp
@@ -22,7 +22,6 @@
 #include "widgets/kreconversiontable.h"
 #include "widgets/unitlistview.h" //TODO: Remove, deprecated.
 #include "widgets/kreunitlistwidget.h" //TODO: Remove, deprecated.
-#include "actionshandlers/unitactionshandler.h" //TODO: Remove, deprecated.
 #include "actionshandlers/kreunitactionshandler.h"
 
 #include <kapplication.h>
diff --git a/src/dialogs/unitsdialog.h b/src/dialogs/unitsdialog.h
index d19d59e..abefefa 100644
--- a/src/dialogs/unitsdialog.h
+++ b/src/dialogs/unitsdialog.h
@@ -21,7 +21,6 @@
 class RecipeDB;
 class KreConversionTable;
 class KreUnitListWidget;
-class UnitActionsHandler; //TODO: Remove, obsolete.
 class KreUnitActionsHandler;
 class KAction;
 class KPushButton;


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

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