[qet] [4527] Element panel widget : remove all action used for interact with elements collection

[ Thread Index | Date Index | More lists.tuxfamily.org/qet Archives ]


Revision: 4527
Author:   blacksun
Date:     2016-05-26 19:12:12 +0200 (Thu, 26 May 2016)
Log Message:
-----------
Element panel widget : remove all action used for interact with elements collection
Remove all classes become unused

Modified Paths:
--------------
    trunk/sources/elementspanelwidget.cpp
    trunk/sources/elementspanelwidget.h

Removed Paths:
-------------
    trunk/sources/basicmoveelementshandler.cpp
    trunk/sources/basicmoveelementshandler.h
    trunk/sources/elementdeleter.cpp
    trunk/sources/elementdeleter.h
    trunk/sources/elementscategorieslist.cpp
    trunk/sources/elementscategorieslist.h

Deleted: trunk/sources/basicmoveelementshandler.cpp
===================================================================
--- trunk/sources/basicmoveelementshandler.cpp	2016-05-26 09:00:05 UTC (rev 4526)
+++ trunk/sources/basicmoveelementshandler.cpp	2016-05-26 17:12:12 UTC (rev 4527)
@@ -1,143 +0,0 @@
-/*
-	Copyright 2006-2016 The QElectroTech Team
-	This file is part of QElectroTech.
-	
-	QElectroTech 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.
-	
-	QElectroTech is distributed in the hope that it will be useful,
-	but WITHOUT ANY WARRANTY; without even the implied warranty of
-	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-	GNU General Public License for more details.
-	
-	You should have received a copy of the GNU General Public License
-	along with QElectroTech.  If not, see <http://www.gnu.org/licenses/>.
-*/
-#include "basicmoveelementshandler.h"
-
-/**
-	Constructeur
-	@param parent QObject parent
-*/
-BasicMoveElementsHandler::BasicMoveElementsHandler(QObject *parent) :
-	MoveElementsHandler(parent),
-	already_exists_(QET::Erase),
-	not_readable_(QET::Ignore),
-	not_writable_(QET::Ignore),
-	error_(QET::Ignore),
-	rename_("renamed")
-{
-}
-
-/**
-	Destructeur
-*/
-BasicMoveElementsHandler::~BasicMoveElementsHandler() {
-}
-
-/**
-	@param action Action return if an item already exists
-*/
-void BasicMoveElementsHandler::setActionIfItemAlreadyExists(QET::Action action) {
-	already_exists_ = action;
-}
-
-/**
-	@param action Action return if an item is not readable
-*/
-void BasicMoveElementsHandler::setActionIfItemIsNotReadable(QET::Action action) {
-	not_readable_ = action;
-}
-
-/**
-	@param action Action return if an item is not writable
-*/
-void BasicMoveElementsHandler::setActionIfItemIsNotWritable(QET::Action action) {
-	not_writable_ = action;
-}
-
-/**
-	@param action Action if a return item causes an error
-*/
-void BasicMoveElementsHandler::setActionIfItemTriggersAnError(QET::Action action) {
-	error_ = action;
-}
-
-/**
-	@param name Name refer to a possible renaming operation
-	However, it is not recommended to proceed to a systematic renaming, as
-	this property is invariable.
-*/
-void BasicMoveElementsHandler::setNameForRenamingOperation(const QString &name) {
-	rename_ = name;
-}
-
-/**
-	@return the action to be performed if the target category already exists
-*/
-QET::Action BasicMoveElementsHandler::categoryAlreadyExists(ElementsCategory *, ElementsCategory  *) {
-	return(already_exists_);
-}
-
-/**
-	@return the action performed if the target element already exists
-*/
-QET::Action BasicMoveElementsHandler::elementAlreadyExists(ElementDefinition *, ElementDefinition *) {
-	return(already_exists_);
-}
-
-/**
-	@return the action to take if the category already exists
-*/
-QET::Action BasicMoveElementsHandler::categoryIsNotReadable(ElementsCategory *) {
-	return(not_readable_);
-}
-
-/**
-	@return the action to take if the element already exists
-*/
-QET::Action BasicMoveElementsHandler::elementIsNotReadable(ElementDefinition *) {
-	return(not_readable_);
-}
-
-/**
-	@return the action to be performed if the target category is not accessible
-	in writing
-*/
-QET::Action BasicMoveElementsHandler::categoryIsNotWritable(ElementsCategory *) {
-	return(not_writable_);
-}
-
-/**
-	@return the action performed if the target element is not accessible
-	in writing
-*/
-QET::Action BasicMoveElementsHandler::elementIsNotWritable(ElementDefinition *) {
-	return(not_writable_);
-}
-
-/**
-	@return the action to be performed when the error described in the QString
-	occurred with dieters category
-*/
-QET::Action BasicMoveElementsHandler::errorWithACategory(ElementsCategory *, const QString &) {
-	return(error_);
-}
-
-/**
-	@return the action to be performed when the error described in the QString
-	occurred with the element indicates
-*/
-QET::Action BasicMoveElementsHandler::errorWithAnElement(ElementDefinition *, const QString &) {
-	return(error_);
-}
-
-/**
-	@return the name to use for renaming if a method of this object
-	has previously sent back QET::Rename.
-*/
-QString BasicMoveElementsHandler::nameForRenamingOperation() {
-	return(rename_);
-}

Deleted: trunk/sources/basicmoveelementshandler.h
===================================================================
--- trunk/sources/basicmoveelementshandler.h	2016-05-26 09:00:05 UTC (rev 4526)
+++ trunk/sources/basicmoveelementshandler.h	2016-05-26 17:12:12 UTC (rev 4527)
@@ -1,62 +0,0 @@
-/*
-	Copyright 2006-2016 The QElectroTech Team
-	This file is part of QElectroTech.
-	
-	QElectroTech 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.
-	
-	QElectroTech is distributed in the hope that it will be useful,
-	but WITHOUT ANY WARRANTY; without even the implied warranty of
-	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-	GNU General Public License for more details.
-	
-	You should have received a copy of the GNU General Public License
-	along with QElectroTech.  If not, see <http://www.gnu.org/licenses/>.
-*/
-#ifndef BASIC_MOVE_ELEMENTS_HANDLER
-#define BASIC_MOVE_ELEMENTS_HANDLER
-#include "moveelementshandler.h"
-/**
-	This class implements the MoveElementsHandler Strategy class in a baasic way.
-	It always returns the same (configurable) action or value for a particular
-	question.
-*/
-class BasicMoveElementsHandler : public MoveElementsHandler {
-	Q_OBJECT
-	
-	// constructors, destructor
-	public:
-	BasicMoveElementsHandler(QObject * = 0);
-	virtual ~BasicMoveElementsHandler();
-	private:
-	BasicMoveElementsHandler(const BasicMoveElementsHandler &);
-	
-	// methods
-	public:
-	virtual void setActionIfItemAlreadyExists(QET::Action);
-	virtual void setActionIfItemIsNotReadable(QET::Action);
-	virtual void setActionIfItemIsNotWritable(QET::Action);
-	virtual void setActionIfItemTriggersAnError(QET::Action);
-	virtual void setNameForRenamingOperation(const QString &);
-	
-	virtual QET::Action categoryAlreadyExists(ElementsCategory *src, ElementsCategory  *dst);
-	virtual QET::Action elementAlreadyExists(ElementDefinition *src, ElementDefinition *dst);
-	virtual QET::Action categoryIsNotReadable(ElementsCategory *);
-	virtual QET::Action elementIsNotReadable(ElementDefinition *);
-	virtual QET::Action categoryIsNotWritable(ElementsCategory *);
-	virtual QET::Action elementIsNotWritable(ElementDefinition *);
-	virtual QET::Action errorWithACategory(ElementsCategory *, const QString &);
-	virtual QET::Action errorWithAnElement(ElementDefinition *, const QString &);
-	virtual QString nameForRenamingOperation();
-	
-	// attributes
-	private:
-	QET::Action already_exists_;
-	QET::Action not_readable_;
-	QET::Action not_writable_;
-	QET::Action error_;
-	QString rename_;
-};
-#endif

Deleted: trunk/sources/elementdeleter.cpp
===================================================================
--- trunk/sources/elementdeleter.cpp	2016-05-26 09:00:05 UTC (rev 4526)
+++ trunk/sources/elementdeleter.cpp	2016-05-26 17:12:12 UTC (rev 4527)
@@ -1,76 +0,0 @@
-/*
-	Copyright 2006-2016 The QElectroTech Team
-	This file is part of QElectroTech.
-	
-	QElectroTech 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.
-	
-	QElectroTech is distributed in the hope that it will be useful,
-	but WITHOUT ANY WARRANTY; without even the implied warranty of
-	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-	GNU General Public License for more details.
-	
-	You should have received a copy of the GNU General Public License
-	along with QElectroTech.  If not, see <http://www.gnu.org/licenses/>.
-*/
-#include "elementdeleter.h"
-#include "qetapp.h"
-#include "qetmessagebox.h"
-
-/**
-	Constructeur
-	@param elmt_path Chemin virtuel du fichier representant l'element a supprimer
-	@param parent QWidget parent
-*/
-ElementDeleter::ElementDeleter(const ElementsLocation &elmt_path, QWidget *parent) :
-	QWidget(parent),
-	element(0)
-{
-	// recupere l'element a supprimer
-	ElementsCollectionItem *element_item = QETApp::collectionItem(elmt_path);
-	if (!element_item) return;
-	
-	// on exige un element
-	if (!element_item -> isElement()) return;
-	
-	element = element_item;
-}
-
-/// Destructeur
-ElementDeleter::~ElementDeleter() {
-}
-
-/**
-	Supprime l'element : verifie l'existence du fichier, demande confirmation a
-	l'utilisateur et avertit ce dernier si la suppression a echoue.
-*/
-bool ElementDeleter::exec() {
-	// verifie l'existence de l'element
-	if (!element || !element -> isElement()) return(false);
-	
-	// confirmation #1
-	QMessageBox::StandardButton answer_1 = QET::QetMessageBox::question(
-		this,
-		tr("Supprimer l'élément ?", "message box title"),
-		tr("Êtes-vous sûr  de vouloir supprimer cet élément ?\n", "message box content"),
-		QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel
-	);
-	if (answer_1 != QMessageBox::Yes) return(false);
-	
-	/**
-		@todo Regression : rafficher le chemin de l'element
-	*/
-	
-	// supprime l'element
-	if (!element -> remove()) {
-		QET::QetMessageBox::warning(
-			this,
-			tr("Suppression de l'élément", "message box title"),
-			tr("La suppression de l'élément a échoué.", "message box content")
-		);
-		return(false);
-	}
-	return(true);
-}

Deleted: trunk/sources/elementdeleter.h
===================================================================
--- trunk/sources/elementdeleter.h	2016-05-26 09:00:05 UTC (rev 4526)
+++ trunk/sources/elementdeleter.h	2016-05-26 17:12:12 UTC (rev 4527)
@@ -1,44 +0,0 @@
-/*
-	Copyright 2006-2016 The QElectroTech Team
-	This file is part of QElectroTech.
-	
-	QElectroTech 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.
-	
-	QElectroTech is distributed in the hope that it will be useful,
-	but WITHOUT ANY WARRANTY; without even the implied warranty of
-	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-	GNU General Public License for more details.
-	
-	You should have received a copy of the GNU General Public License
-	along with QElectroTech.  If not, see <http://www.gnu.org/licenses/>.
-*/
-#ifndef ELEMENT_DELETER_H
-#define ELEMENT_DELETER_H
-#include "elementscategory.h"
-#include "elementslocation.h"
-#include <QtWidgets>
-/**
-	This class provides an abstract way to delete an element from its parent
-	collection. Especially, it requires a confirmation from users.
-*/
-class ElementDeleter : public QWidget {
-	Q_OBJECT
-	// constructors, destructor
-	public:
-	ElementDeleter(const ElementsLocation &, QWidget * = 0);
-	virtual ~ElementDeleter();
-	private:
-	ElementDeleter(const ElementsCategory &);
-	
-	// methods
-	public slots:
-	bool exec();
-	
-	// attributes
-	private:
-	ElementsCollectionItem *element;
-};
-#endif

Deleted: trunk/sources/elementscategorieslist.cpp
===================================================================
--- trunk/sources/elementscategorieslist.cpp	2016-05-26 09:00:05 UTC (rev 4526)
+++ trunk/sources/elementscategorieslist.cpp	2016-05-26 17:12:12 UTC (rev 4527)
@@ -1,141 +0,0 @@
-/*
-	Copyright 2006-2016 The QElectroTech Team
-	This file is part of QElectroTech.
-	
-	QElectroTech 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.
-	
-	QElectroTech is distributed in the hope that it will be useful,
-	but WITHOUT ANY WARRANTY; without even the implied warranty of
-	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-	GNU General Public License for more details.
-	
-	You should have received a copy of the GNU General Public License
-	along with QElectroTech.  If not, see <http://www.gnu.org/licenses/>.
-*/
-#include "elementscategorieslist.h"
-#include "qetapp.h"
-#include "qetgraphicsitem/customelement.h"
-#include "elementscollection.h"
-#include "elementscategory.h"
-#include "elementdefinition.h"
-#include "qeticons.h"
-
-/**
-	Constructeur
-	@param display_elements true pour afficher les elements, false sinon
-	@param selectables Types selectionnables
-	@see QET::ItemType
-	@param parent QWidget parent de ce widget
-*/
-ElementsCategoriesList::ElementsCategoriesList(bool display_elements, uint selectables, QWidget *parent) :
-	GenericPanel(parent),
-	display_elements_(display_elements),
-	selectables_(selectables),
-	first_load(true)
-{
-	// selection unique
-	setSelectionMode(QAbstractItemView::SingleSelection);
-	setColumnCount(1);
-	
-	// charge les categories
-	setElementsCache(QETApp::collectionCache());
-	reload();
-	
-	connect(
-		this, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
-		this, SLOT(selectionChanged(QTreeWidgetItem *, QTreeWidgetItem *))
-	);
-}
-
-/**
-	Destructeur
-*/
-ElementsCategoriesList::~ElementsCategoriesList() {
-}
-
-/**
-	Recharge l'arbre des categories
-*/
-void ElementsCategoriesList::reload() {
-	GenericPanel::PanelOptions  options = display_elements_ ? GenericPanel::AddAllChildElements : GenericPanel::AddChildElementsContainers;
-	options |= GenericPanel::DisplayElementsPreview;
-	
-	foreach(ElementsCollection *collection, QETApp::availableCollections()) {
-		if (collection == QETApp::commonElementsCollection()) continue;
-		if (collection == QETApp::customElementsCollection()) continue;
-		addElementsCollection(collection, invisibleRootItem(), options) -> setExpanded(true);
-	}
-	
-	// chargement des elements de la collection commune si droits d'ecriture
-	if (QETApp::commonElementsCollection() -> isWritable()) {
-		addElementsCollection(
-			QETApp::commonElementsCollection(),
-			invisibleRootItem(),
-			options
-		) -> setExpanded(true);
-	}
-	
-	// chargement des elements de la collection utilisateur
-	addElementsCollection(
-		QETApp::customElementsCollection(),
-		invisibleRootItem(),
-		options
-	) -> setExpanded(true);
-	
-	if (first_load) first_load = false;
-}
-
-/**
-	Create a QTreeWidgetItem
-	@param type Item type (e.g QET::Diagram, QET::Project, ...)
-	@param parent Parent for the created item
-	@param label Label for the created item
-	@param icon Icon for the created item
-	@return the create QTreeWidgetItem
-*/
-QTreeWidgetItem *ElementsCategoriesList::makeItem(QET::ItemType type, QTreeWidgetItem *parent, const QString &label, const QIcon &icon) {
-	QTreeWidgetItem *item = GenericPanel::makeItem(type, parent, label, icon);
-	Qt::ItemFlags flags = Qt::ItemIsEnabled;
-	if (selectables_ & item -> type()) flags |= Qt::ItemIsSelectable;
-	item -> setFlags(flags);
-	return(item);
-}
-
-/**
-	@return l'emplacement correspondant au QTreeWidgetItem selectionne
-*/
-ElementsLocation ElementsCategoriesList::selectedLocation() const {
-	QTreeWidgetItem *current_qtwi = currentItem();
-	if (!current_qtwi) return(ElementsLocation());
-	return(valueForItem<ElementsLocation>(current_qtwi));
-}
-
-/**
-	Selectionne un element dans la liste a partir de son emplacement
-	@see ElementsLocation
-	@param location Emplacement a selectionner
-	@return true si la selection a pu etre effectuee, false sinon
-*/
-bool ElementsCategoriesList::selectLocation(const ElementsLocation &location) {
-	QTreeWidgetItem *qtwi = itemForElementsLocation(location);
-	if (qtwi) setCurrentItem(qtwi);
-	return(qtwi);
-}
-
-/**
-	Recupere le chemin virtuel de l'element selectionne et emet le signal
-	virtualPathChanged.
-	@param current  QTreeWidgetItem selectionne
-	@param previous QTreeWidgetItem precedemment selectionne
-*/
-void ElementsCategoriesList::selectionChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous) {
-	Q_UNUSED(previous);
-	ElementsLocation emited_location;
-	if (current) {
-		emited_location = valueForItem<ElementsLocation>(current);
-	}
-	emit(locationChanged(emited_location));
-}

Deleted: trunk/sources/elementscategorieslist.h
===================================================================
--- trunk/sources/elementscategorieslist.h	2016-05-26 09:00:05 UTC (rev 4526)
+++ trunk/sources/elementscategorieslist.h	2016-05-26 17:12:12 UTC (rev 4527)
@@ -1,65 +0,0 @@
-/*
-	Copyright 2006-2016 The QElectroTech Team
-	This file is part of QElectroTech.
-	
-	QElectroTech 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.
-	
-	QElectroTech is distributed in the hope that it will be useful,
-	but WITHOUT ANY WARRANTY; without even the implied warranty of
-	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-	GNU General Public License for more details.
-	
-	You should have received a copy of the GNU General Public License
-	along with QElectroTech.  If not, see <http://www.gnu.org/licenses/>.
-*/
-#ifndef ELEMENTS_CATEGORIES_LIST_H
-#define ELEMENTS_CATEGORIES_LIST_H
-#include <QtWidgets>
-#include "qet.h"
-#include "elementslocation.h"
-#include "genericpanel.h"
-class ElementsCollection;
-class ElementsCategory;
-class ElementDefinition;
-/**
-	This class provides a visual listing of available elements categories.
-*/
-class ElementsCategoriesList : public GenericPanel {
-	Q_OBJECT
-	
-	// Constructors, destructor
-	public:
-	ElementsCategoriesList(bool = false, uint = QET::All, QWidget * = 0);
-	virtual ~ElementsCategoriesList();
-	
-	private:
-	ElementsCategoriesList(const ElementsCategoriesList &);
-	
-	// methods
-	public:
-	ElementsLocation selectedLocation() const;
-	bool selectLocation(const ElementsLocation &);
-	
-	private:
-	QString categoryName(QDir &);
-	QTreeWidgetItem *makeItem(QET::ItemType, QTreeWidgetItem *, const QString &, const QIcon &);
-	
-	public slots:
-	void reload();
-	
-	private slots:
-	void selectionChanged(QTreeWidgetItem *, QTreeWidgetItem *);
-	
-	signals:
-	void locationChanged(const ElementsLocation &);
-	
-	// attributes
-	private:
-	bool display_elements_;
-	int selectables_;
-	bool first_load;
-};
-#endif

Modified: trunk/sources/elementspanelwidget.cpp
===================================================================
--- trunk/sources/elementspanelwidget.cpp	2016-05-26 09:00:05 UTC (rev 4526)
+++ trunk/sources/elementspanelwidget.cpp	2016-05-26 17:12:12 UTC (rev 4527)
@@ -16,12 +16,9 @@
 	along with QElectroTech.  If not, see <http://www.gnu.org/licenses/>.
 */
 #include "elementspanelwidget.h"
-#include "newelementwizard.h"
 #include "elementscollectionitem.h"
 #include "qetelementeditor.h"
-#include "elementdeleter.h"
 #include "elementscategoryeditor.h"
-#include "elementscategorydeleter.h"
 #include "qetapp.h"
 #include "qetproject.h"
 #include "diagram.h"
@@ -54,14 +51,6 @@
 	open_directory        = new QAction(QET::Icons::DocumentOpen,              tr("Ouvrir le dossier correspondant"),     this);
 	copy_path             = new QAction(QET::Icons::IC_CopyFile,                  tr("Copier le chemin"),                    this);
 	reload                = new QAction(QET::Icons::ViewRefresh,               tr("Recharger les collections"),           this);
-	new_category          = new QAction(QET::Icons::FolderNew,                 tr("Nouvelle catégorie"),               this);
-	edit_category         = new QAction(QET::Icons::FolderEdit,                tr("Éditer la catégorie"),           this);
-	delete_category       = new QAction(QET::Icons::FolderDelete,              tr("Supprimer la catégorie"),           this);
-	delete_collection     = new QAction(QET::Icons::FolderDelete,              tr("Vider la collection"),                 this);
-	new_element           = new QAction(QET::Icons::ElementNew,                tr("Nouvel élément"),                this);
-	edit_element          = new QAction(QET::Icons::ElementEdit,               tr("Éditer l'élément"),           this);
-	delete_element        = new QAction(QET::Icons::ElementDelete,             tr("Supprimer l'élément"),           this);
-	open_element          = new QAction(QET::Icons::DocumentImport,            tr("Ouvrir un fichier élément"),     this);
 	prj_activate          = new QAction(QET::Icons::ProjectFile,               tr("Basculer vers ce projet"),             this);
 	prj_close             = new QAction(QET::Icons::DocumentClose,             tr("Fermer ce projet"),                    this);
 	prj_edit_prop         = new QAction(QET::Icons::DialogInformation,         tr("Propriétés du projet"),          this);
@@ -98,14 +87,6 @@
 	connect(open_directory,        SIGNAL(triggered()), this,           SLOT(openDirectoryForSelectedItem()));
 	connect(copy_path,             SIGNAL(triggered()), this,           SLOT(copyPathForSelectedItem()));
 	connect(reload,                SIGNAL(triggered()), this,           SLOT(reloadAndFilter()));
-	connect(new_category,          SIGNAL(triggered()), this,           SLOT(newCategory()));
-	connect(edit_category,         SIGNAL(triggered()), this,           SLOT(editCategory()));
-	connect(delete_category,       SIGNAL(triggered()), this,           SLOT(deleteCategory()));
-	connect(delete_collection,     SIGNAL(triggered()), this,           SLOT(deleteCategory()));
-	connect(new_element,           SIGNAL(triggered()), this,           SLOT(newElement()));
-	connect(edit_element,          SIGNAL(triggered()), this,           SLOT(editElement()));
-	connect(delete_element,        SIGNAL(triggered()), this,           SLOT(deleteElement()));
-	connect(open_element,          SIGNAL(triggered()), this,           SLOT(openElementFromFile()));
 	connect(prj_activate,          SIGNAL(triggered()), this,           SLOT(activateProject()));
 	connect(prj_close,             SIGNAL(triggered()), this,           SLOT(closeProject()));
 	connect(prj_edit_prop,         SIGNAL(triggered()), this,           SLOT(editProjectProperties()));
@@ -138,26 +119,10 @@
 	connect(elements_panel, SIGNAL(readingFinished()),            this, SLOT(collectionsReadFinished()));
 	connect(elements_panel, SIGNAL(loadingFinished()),            this, SLOT(loadingFinished()));
 	
-	// initialise la barre d'outils
-	toolbar = new QToolBar(this);
-	toolbar -> setMovable(false);
-	toolbar -> addAction(reload);
-	toolbar -> addSeparator();
-	toolbar -> addAction(new_category);
-	toolbar -> addAction(edit_category);
-	toolbar -> addAction(delete_category);
-	toolbar -> addSeparator();
-	toolbar -> addAction(new_element);
-	toolbar -> addAction(edit_element);
-	toolbar -> addAction(delete_element);
-	toolbar -> addSeparator();
-	toolbar -> addAction(open_element);
-	
 	// disposition verticale
 	QVBoxLayout *vlayout = new QVBoxLayout(this);
 	vlayout -> setMargin(0);
 	vlayout -> setSpacing(0);
-	vlayout -> addWidget(toolbar);
 	vlayout -> addWidget(filter_textfield);
 	vlayout -> addWidget(elements_panel);
 	vlayout -> addWidget(progress_bar_);
@@ -360,67 +325,15 @@
 }
 
 /**
-	Appelle l'assistant de creation de nouvel element
-*/
-void ElementsPanelWidget::newElement() {	
-	NewElementWizard new_element_wizard(this);
-	new_element_wizard.exec();
-}
-
-/**
-	Open an element from a file freely chosen by the user.
-*/
-void ElementsPanelWidget::openElementFromFile() {
-	QString fileName = QETElementEditor::getOpenElementFileName(this);
-	
-	// Ouverture de l'element dans l'editeur pour pouvoir ensuite l'enregistrer dans la categorie voulue
-	if (!fileName.isEmpty()) {
-		QETApp::instance() -> openElementFiles(QStringList() << fileName);
-	}
-}
-
-/**
-	Si une categorie accessible en ecriture est selectionnee, cette methode
-	affiche directement un formulaire de creation de categorie en utilisant la
-	selection comme categorie parente.
-	Sinon, elle affiche un gestionnaire de categories, permettant ainsi a
-	l'utilisateur de choisir une categorie parente.
-*/
-void ElementsPanelWidget::newCategory() {
-	ElementsCategory *selected_category = writableSelectedCategory();
-	
-	if (selected_category) {
-		ElementsCategoryEditor new_category_dialog(selected_category -> location(), false, this);
-		if (new_category_dialog.exec() == QDialog::Accepted) {
-			elements_panel -> reload();
-		}
-	}
-}
-
-/**
 	Met a jour les boutons afin d'assurer la coherence de l'interface
 */
 void ElementsPanelWidget::updateButtons() {
 	QTreeWidgetItem *current_item = elements_panel -> currentItem();
 	int current_type = elements_panel -> currentItemType();
 	
-	bool collection_selected = current_type == QET::ElementsCollection;
-	bool category_selected   = current_type & QET::ElementsContainer;
-	bool element_selected    = current_type == QET::Element;
-	
-	if (collection_selected || category_selected || element_selected) {
-		bool element_writable = elements_panel -> selectedItemIsWritable();
-		delete_collection -> setEnabled(collection_selected && element_writable);
-		new_category      -> setEnabled(category_selected && element_writable);
-		edit_category     -> setEnabled(category_selected && !collection_selected);
-		delete_category   -> setEnabled(category_selected && element_writable);
-		new_element       -> setEnabled(category_selected && element_writable);
-		edit_element      -> setEnabled(element_selected);
-		delete_element    -> setEnabled(element_selected && element_writable);
-	} else if (current_type == QET::Project) {
+	if (current_type == QET::Project) {
 		bool is_writable = !(elements_panel -> selectedProject() -> isReadOnly());
 		prj_add_diagram -> setEnabled(is_writable);
-		setElementsActionEnabled(false);
 	} else if (current_type == QET::Diagram) {
 		Diagram    *selected_diagram         = elements_panel -> selectedDiagram();
 		QETProject *selected_diagram_project = selected_diagram -> project();
@@ -435,13 +348,11 @@
 		prj_move_diagram_top   -> setEnabled(is_writable && diagram_position > 0);
 		prj_move_diagram_upx10   -> setEnabled(is_writable && diagram_position > 10);
 		prj_move_diagram_downx10 -> setEnabled(is_writable && diagram_position < project_diagrams_count - 10);
-		setElementsActionEnabled(false);
 	} else if (current_type == QET::TitleBlockTemplatesCollection) {
 		TitleBlockTemplateLocation location = elements_panel -> templateLocationForItem(current_item);
 		tbt_add    -> setEnabled(!location.isReadOnly());
 		tbt_edit   -> setEnabled(false); // would not make sense
 		tbt_remove -> setEnabled(false); // would not make sense
-		setElementsActionEnabled(false);
 	} else if (current_type == QET::TitleBlockTemplate) {
 		QTreeWidgetItem *item = elements_panel -> currentItem();
 		TitleBlockTemplateLocation location = elements_panel -> templateLocationForItem(item);
@@ -449,26 +360,10 @@
 		tbt_edit   -> setEnabled(true); // the tbt editor has a read-only mode
 		// deleting a tbt requires its parent collection to be writable
 		tbt_remove -> setEnabled(location.parentCollection() && !(location.parentCollection() -> isReadOnly()));
-		setElementsActionEnabled(false);
 	}
 }
 
 /**
-	Enable or disable elements-related actions (i.e. new/edit/delete
-	categories/elements).
-	@param bool true to enable actions, false to disable them
-*/
-void ElementsPanelWidget::setElementsActionEnabled(bool enable) {
-	delete_collection -> setEnabled(enable);
-	new_category      -> setEnabled(enable);
-	edit_category     -> setEnabled(enable);
-	delete_category   -> setEnabled(enable);
-	new_element       -> setEnabled(enable);
-	edit_element      -> setEnabled(enable);
-	delete_element    -> setEnabled(enable);
-}
-
-/**
 	Gere le menu contextuel du panel d'elements
 	@param pos Position ou le menu contextuel a ete demande
 */
@@ -479,6 +374,7 @@
 	
 	updateButtons();
 	context_menu -> clear();
+	context_menu->addAction(reload);
 	
 	QString dir_path = elements_panel -> dirPathForItem(item);
 	if (!dir_path.isEmpty()) {
@@ -488,21 +384,6 @@
 	}
 	
 	switch(item -> type()) {
-		case QET::ElementsCategory:
-			context_menu -> addAction(new_category);
-			context_menu -> addAction(edit_category);
-			context_menu -> addAction(delete_category);
-			context_menu -> addAction(new_element);
-			break;
-		case QET::Element:
-			context_menu -> addAction(edit_element);
-			context_menu -> addAction(delete_element);
-			break;
-		case QET::ElementsCollection:
-			context_menu -> addAction(new_category);
-			context_menu -> addAction(delete_collection);
-			context_menu -> addAction(new_element);
-			break;
 		case QET::Project:
 			context_menu -> addAction(prj_activate);
 			context_menu -> addAction(prj_edit_prop);
@@ -611,52 +492,6 @@
 }
 
 /**
-	Edite la categorie selectionnee
-*/
-void ElementsPanelWidget::editCategory() {
-	if (ElementsCollectionItem *selected_item = elements_panel -> selectedItem()) {
-		if (selected_item -> isCategory()) {
-			launchCategoryEditor(selected_item -> location());
-		}
-	}
-}
-
-/**
-	Edite l'element selectionne
-*/
-void ElementsPanelWidget::editElement() {
-	if (ElementsCollectionItem *selected_item = elements_panel -> selectedItem()) {
-		if (selected_item -> isElement()) {
-			launchElementEditor(selected_item -> location());
-		}
-	}
-}
-
-/**
-	Supprime la categorie selectionnee
-*/
-void ElementsPanelWidget::deleteCategory() {
-	if (ElementsCollectionItem *selected_item = elements_panel -> selectedItem()) {
-		if (selected_item -> isCategory() || selected_item -> isCollection()) {
-			ElementsCategoryDeleter cat_deleter(selected_item -> location(), this);
-			if (cat_deleter.exec()) elements_panel -> reload(true);
-		}
-	}
-}
-
-/**
-	Supprime l'element selectionne
-*/
-void ElementsPanelWidget::deleteElement() {
-	if (ElementsCollectionItem *selected_item = elements_panel -> selectedItem()) {
-		if (selected_item -> isElement()) {
-			ElementDeleter elmt_deleter(selected_item -> location(), this);
-			if (elmt_deleter.exec()) elements_panel -> reload(true);
-		}
-	}
-}
-
-/**
 	Treat key press event inside elements panel widget
 */
 void ElementsPanelWidget::keyPressEvent   (QKeyEvent *e) {
@@ -687,26 +522,3 @@
 		elements_panel -> reload();
 	}
 }
-
-/**
-	@return la categorie selectionnee s'il y en a une et que celle-ci est
-	accessible en ecriture ; sinon retourne 0
-	@see ElementsPanel::categoryForItem(QTreeWidgetItem *)
-*/
-ElementsCategory *ElementsPanelWidget::writableSelectedCategory() {
-	// recupere l'element selectionne
-	QTreeWidgetItem *selected_qtwi = elements_panel -> currentItem();
-	if (!selected_qtwi) return(0);
-	
-	// l'element selectionne doit pouvoir correspondre a une categorie
-	if (!(selected_qtwi -> type() & QET::ElementsContainer)) return(0);
-	ElementsLocation category_location = elements_panel -> elementLocationForItem(selected_qtwi);
-	ElementsCollectionItem *category = QETApp::collectionItem(category_location, false);
-	ElementsCategory *selected_category = category -> toCategory();
-	if (!selected_category) return(0);
-	
-	// la categorie doit etre accessible en ecriture
-	if (!selected_category -> isWritable()) return(0);
-	
-	return(selected_category);
-}

Modified: trunk/sources/elementspanelwidget.h
===================================================================
--- trunk/sources/elementspanelwidget.h	2016-05-26 09:00:05 UTC (rev 4526)
+++ trunk/sources/elementspanelwidget.h	2016-05-26 17:12:12 UTC (rev 4527)
@@ -39,12 +39,8 @@
 	// attributes
 	private:
 	ElementsPanel *elements_panel;
-	QToolBar *toolbar;
 	QAction *open_directory, *copy_path;
 	QAction *reload;
-	QAction *new_category, *edit_category, *delete_category;
-	QAction *delete_collection;
-	QAction *new_element, *edit_element, *delete_element, *open_element;
 	QAction *prj_activate, *prj_close, *prj_edit_prop, *prj_prop_diagram, *prj_add_diagram, *prj_del_diagram, *prj_move_diagram_up, *prj_move_diagram_top, *prj_move_diagram_down, *prj_move_diagram_upx10, *prj_move_diagram_downx10;
 	QAction *tbt_add, *tbt_edit, *tbt_remove;
 	QMenu *context_menu;
@@ -87,15 +83,7 @@
 	void addTitleBlockTemplate();
 	void editTitleBlockTemplate();
 	void removeTitleBlockTemplate();
-	void newCategory();
-	void newElement();
-	void openElementFromFile();
-	void editCategory();
-	void editElement();
-	void deleteCategory();
-	void deleteElement();
 	void updateButtons();
-	void setElementsActionEnabled(bool);
 	void handleContextMenu(const QPoint &);
 	void handleCollectionRequest(const ElementsLocation &);
 	void collectionsRead();
@@ -110,7 +98,6 @@
 	private:
 	void launchElementEditor(const ElementsLocation &);
 	void launchCategoryEditor(const ElementsLocation &);
-	ElementsCategory *writableSelectedCategory();
 	QString previous_filter_;
 };
 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/