diff --git a/sources/elementscategoryeditor.h b/sources/elementscategoryeditor.h index 2294f4c84..9bc6f3fec 100644 --- a/sources/elementscategoryeditor.h +++ b/sources/elementscategoryeditor.h @@ -21,7 +21,6 @@ #include #include "elementslocation.h" -class ElementsCategory; class NamesListWidget; class QFileNameEdit; class QDialogButtonBox; @@ -43,7 +42,6 @@ class ElementsCategoryEditor : public QDialog ElementsCategoryEditor(const ElementsCategoryEditor &); private: - ElementsCategory *category; QDialogButtonBox *m_buttons; NamesListWidget *m_names_list; QLabel *m_file_name; diff --git a/sources/elementspanel.cpp b/sources/elementspanel.cpp index 02dee748f..d9bbf5d72 100644 --- a/sources/elementspanel.cpp +++ b/sources/elementspanel.cpp @@ -201,48 +201,6 @@ void ElementsPanel::dragMoveEvent(QDragMoveEvent *e) /// @todo mettre en valeur le lieu de depot } -/** - Gere le depot lors d'un drag'n drop - @param e QDropEvent decrivant le depot -*/ -void ElementsPanel::dropEvent(QDropEvent *e) -{ - // recupere la categorie cible pour le deplacement / la copie - ElementsCategory *target_category = categoryForPos(e -> pos()); - if (!target_category) { - e -> ignore(); - return; - } - - // recupere la source (categorie ou element) pour le deplacement / la copie - ElementsLocation dropped_location = ElementsLocation(e -> mimeData() -> text()); - ElementsCollectionItem *source_item = QETApp::collectionItem(dropped_location, false); - if (!source_item) { - e -> ignore(); - return; - } - -#ifdef ENABLE_PANEL_DND_CHECKS - // ne prend pas en consideration le drop d'un item sur lui-meme ou une categorie imbriquee - if ( - source_item -> location() == target_category -> location() ||\ - target_category -> isChildOf(source_item) - ) { - e -> ignore(); - return; - } - - // s'assure que la categorie cible est accessible en ecriture - if (!target_category -> isWritable()) { - e -> ignore(); - return; - } -#endif - - e -> accept(); - emit(requestForMoveElements(source_item, target_category, e -> pos())); -} - /** Gere le debut des drag'n drop @param supportedActions Les actions supportees diff --git a/sources/elementspanel.h b/sources/elementspanel.h index 1758cdea8..848c9a87d 100644 --- a/sources/elementspanel.h +++ b/sources/elementspanel.h @@ -68,7 +68,6 @@ class ElementsPanel : public GenericPanel { void requestForProject(QETProject *); void requestForDiagram(Diagram *); void requestForCollectionItem(const ElementsLocation &); - void requestForMoveElements(ElementsCollectionItem *, ElementsCollectionItem *, QPoint); void requestForTitleBlockTemplate(const TitleBlockTemplateLocation &); void readingAboutToBegin(); void readingFinished(); @@ -90,7 +89,6 @@ class ElementsPanel : public GenericPanel { protected: void dragEnterEvent(QDragEnterEvent *); void dragMoveEvent(QDragMoveEvent *); - void dropEvent(QDropEvent *); void startDrag(Qt::DropActions); void startElementDrag(const ElementsLocation &); void startTitleBlockTemplateDrag(const TitleBlockTemplateLocation &); diff --git a/sources/elementspanelwidget.cpp b/sources/elementspanelwidget.cpp index ed8d577e9..b47d32c1b 100644 --- a/sources/elementspanelwidget.cpp +++ b/sources/elementspanelwidget.cpp @@ -24,7 +24,6 @@ #include "elementscategoryeditor.h" #include "elementscategorydeleter.h" #include "qetapp.h" -#include "interactivemoveelementshandler.h" #include "qetproject.h" #include "diagram.h" #include "qeticons.h" @@ -78,9 +77,6 @@ ElementsPanelWidget::ElementsPanelWidget(QWidget *parent) : QWidget(parent) { tbt_add = new QAction(QET::Icons::TitleBlock, tr("Nouveau modèle"), this); tbt_edit = new QAction(QET::Icons::TitleBlock, tr("Éditer ce modèle"), this); tbt_remove = new QAction(QET::Icons::TitleBlock, tr("Supprimer ce modèle"), this); - move_elements_ = new QAction(QET::Icons::IC_MoveFile, tr("Déplacer dans cette catégorie"), this); - copy_elements_ = new QAction(QET::Icons::IC_CopyFile, tr("Copier dans cette catégorie"), this); - cancel_elements_ = new QAction(QET::Icons::Cancel, tr("Annuler"), this); reload -> setShortcut(Qt::Key_F5); @@ -125,8 +121,6 @@ ElementsPanelWidget::ElementsPanelWidget(QWidget *parent) : QWidget(parent) { connect(tbt_add, SIGNAL(triggered()), this, SLOT(addTitleBlockTemplate())); connect(tbt_edit, SIGNAL(triggered()), this, SLOT(editTitleBlockTemplate())); connect(tbt_remove, SIGNAL(triggered()), this, SLOT(removeTitleBlockTemplate())); - connect(move_elements_, SIGNAL(triggered()), this, SLOT(moveElements())); - connect(copy_elements_, SIGNAL(triggered()), this, SLOT(copyElements())); connect(filter_textfield, SIGNAL(textChanged(const QString &)), this, SLOT(filterEdited(const QString &))); @@ -134,13 +128,6 @@ ElementsPanelWidget::ElementsPanelWidget(QWidget *parent) : QWidget(parent) { connect(elements_panel, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(handleContextMenu(const QPoint &))); connect(elements_panel, SIGNAL(requestForDiagram(Diagram*)), this, SIGNAL(requestForDiagram(Diagram*))); connect(elements_panel, SIGNAL(requestForCollectionItem(const ElementsLocation &)), this, SLOT(handleCollectionRequest(const ElementsLocation &))); - connect( - elements_panel, - SIGNAL(requestForMoveElements(ElementsCollectionItem *, ElementsCollectionItem *, QPoint)), - this, - SLOT(handleMoveElementsRequest(ElementsCollectionItem *, ElementsCollectionItem *, const QPoint &)), - Qt::QueuedConnection - ); connect( elements_panel, SIGNAL(requestForTitleBlockTemplate(const TitleBlockTemplateLocation &)), @@ -591,71 +578,6 @@ void ElementsPanelWidget::handleCollectionRequest(const ElementsLocation &item_l // expand/collapse them } -/** - Gere le drop d'un collectionItem sur un autre. - Elle memorise dans les attributs de cette classe l'item source et l'item - destination du drag'n drop. - Un menu est ensuite affiche pour demander a l'utilisateur ce qu'il - souhaite faire (deplacer, copier ou annuler). - @param src Item source - @param dst Item cible - @param pos Position ou le menu contextuel a ete demande -*/ -void ElementsPanelWidget::handleMoveElementsRequest(ElementsCollectionItem *src, ElementsCollectionItem *dst, const QPoint &pos) { - if (!src || !dst || !dst -> isCategory()) return; - - // memorise les items source et cible du drag'n drop - dnd_item_src_ = src; - dnd_item_dst_ = dst; - -#ifdef ENABLE_PANEL_WIDGET_DND_CHECKS - // active ou desactive les actions selon la source et la cible - copy_elements_ -> setEnabled(src -> isReadable() && dst -> isWritable()); - move_elements_ -> setEnabled(!src -> isRootCategory() && src -> isWritable() && dst -> isWritable()); -#endif - - // affiche un menu contextuel pour que l'utilisateur indique s'il souhaite - // effectuer un deplacement ou une copie - context_menu -> clear(); - context_menu -> addAction(copy_elements_); - context_menu -> addAction(move_elements_); - context_menu -> addSeparator(); - context_menu -> addAction(cancel_elements_); - - context_menu -> popup(mapToGlobal(elements_panel -> mapTo(this, pos + QPoint(2, 2)))); -} - -/** - Cette classe memorise l'item source et l'item destination du dernier drag'n - drop. Cette methode effectue le deplacement de l'item source memorise dans - l'item destination memorise. - @see handleMoveElementsRequest -*/ -void ElementsPanelWidget::moveElements() { - moveElements(dnd_item_src_, dnd_item_dst_); -} - -/** - Deplace l'item src dans l'item dst -*/ -void ElementsPanelWidget::moveElements(ElementsCollectionItem *src, ElementsCollectionItem *dst) { - InteractiveMoveElementsHandler *interactive_handler = new InteractiveMoveElementsHandler(); - src -> move(dst -> toCategory(), interactive_handler); - delete interactive_handler; - elements_panel -> reload(true); -} - -/** - Cette classe memorise l'item source et l'item destination du dernier drag'n - drop. Cette methode effectue la copie de l'item source memorise dans l'item - destination memorise. - @see handleMoveElementsRequest -*/ -void ElementsPanelWidget::copyElements() { - copyElements(dnd_item_src_, dnd_item_dst_); - elements_panel -> reload(true); -} - /** Reflects the fact that collections are being read (i.e from filesystem) in the progress bar. @@ -717,15 +639,6 @@ void ElementsPanelWidget::filterEdited(const QString &next_text) { previous_filter_ = next_text; } -/** - Copie l'item src dans l'item dst -*/ -void ElementsPanelWidget::copyElements(ElementsCollectionItem *src, ElementsCollectionItem *dst) { - InteractiveMoveElementsHandler *interactive_handler = new InteractiveMoveElementsHandler(); - src -> copy(dst -> toCategory(), interactive_handler, true); - delete interactive_handler; -} - /** Edite la categorie selectionnee */ diff --git a/sources/elementspanelwidget.h b/sources/elementspanelwidget.h index 046ba17c9..e538d41dd 100644 --- a/sources/elementspanelwidget.h +++ b/sources/elementspanelwidget.h @@ -17,8 +17,9 @@ */ #ifndef ELEMENTS_PANEL_WIDGET_H #define ELEMENTS_PANEL_WIDGET_H -#include + #include "elementspanel.h" + /** This class embeds an elements panel under a toolbar providing various actions to manage elements. @@ -46,10 +47,8 @@ class ElementsPanelWidget : public QWidget { 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; - QAction *copy_elements_, *move_elements_, *cancel_elements_; QMenu *context_menu; QLineEdit *filter_textfield; - ElementsCollectionItem *dnd_item_src_, *dnd_item_dst_; QProgressBar *progress_bar_; // methods @@ -100,11 +99,6 @@ class ElementsPanelWidget : public QWidget { int launchCategoriesManager(); void handleContextMenu(const QPoint &); void handleCollectionRequest(const ElementsLocation &); - void handleMoveElementsRequest(ElementsCollectionItem *, ElementsCollectionItem *, const QPoint & = QPoint()); - void moveElements(); - void moveElements(ElementsCollectionItem *, ElementsCollectionItem *); - void copyElements(); - void copyElements(ElementsCollectionItem *, ElementsCollectionItem *); void collectionsRead(); void collectionsReadFinished(); void updateProgressBar(int, int); diff --git a/sources/interactivemoveelementshandler.cpp b/sources/interactivemoveelementshandler.cpp deleted file mode 100644 index 5e375510c..000000000 --- a/sources/interactivemoveelementshandler.cpp +++ /dev/null @@ -1,389 +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 . -*/ -#include "interactivemoveelementshandler.h" -#include -#include "elementscategory.h" -#include "elementdefinition.h" -#include "qfilenameedit.h" -#include "qetmessagebox.h" - -/** - Constructeur - @param parent QWidget parent a utiliser pour l'affichage des dialogues lors - des interactions avec l'utilisateur -*/ -InteractiveMoveElementsHandler::InteractiveMoveElementsHandler(QWidget *parent) : - BasicMoveElementsHandler(parent), - parent_widget_(parent), - rename_(""), - always_erase_(false), - always_skip_(false), - aborted_(false), - conflict_dialog_(0) -{ -} - -/** - Destructeur -*/ -InteractiveMoveElementsHandler::~InteractiveMoveElementsHandler() { -} - -/** - @param src Categorie source - @param dst Categorie cible / destination - @return l'action a effectuer si la categorie cible existe deja -*/ -QET::Action InteractiveMoveElementsHandler::categoryAlreadyExists(ElementsCategory *src, ElementsCategory *dst) { - // verifie si la reponse n'est pas systematique - if (aborted_) return(QET::Abort); - if (always_erase_) return(QET::Erase); - if (always_skip_) return(QET::Ignore); - - // a ce stade, l'action a effectuer pour gerer le conflit doit etre - // demandee a l'utilisateur via un dialogue - initConflictDialog(); - - QString src_location(src -> location().toString()); - QString dst_location(dst -> location().toString()); - - // prepare le dialogue - QString dialog_title(QString(tr("Copie de %1 vers %2", "dialog title")).arg(src_location).arg(dst_location)); - - QLabel *question_label = new QLabel( - QString( - tr( - "La catégorie « %1 » (%2) existe déjà. " - "Que souhaitez-vous faire ?", - "dialog content" - ) - ) - .arg(dst -> name()) - .arg(dst_location) - ); - question_label -> setWordWrap(true); - - setConflictDialogTitle(dialog_title); - setConflictDialogMainWidget(question_label); - - // execute le dialogue - conflict_dialog_ -> exec(); - - // enleve et detruit le widget principal - setConflictDialogMainWidget(0); - delete question_label; - - // renvoie la reponse obtenue via le dialogue - return(conflict_result_); -} - -/** - @param src Element source - @param dst Element cible / destination - @return l'action a effectuer si l'element cible existe deja -*/ -QET::Action InteractiveMoveElementsHandler::elementAlreadyExists(ElementDefinition *src, ElementDefinition *dst) { - // verifie si la reponse n'est pas systematique - if (aborted_) return(QET::Abort); - if (always_erase_) return(QET::Erase); - if (always_skip_) return(QET::Ignore); - - // a ce stade, l'action a effectuer pour gerer le conflit doit etre - // demandee a l'utilisateur via un dialogue - initConflictDialog(); - - QString src_location(src -> location().toString()); - QString dst_location(dst -> location().toString()); - - // prepare le dialogue - QString dialog_title(QString(tr("Copie de %1 vers %2", "dialog title")).arg(src_location).arg(dst_location)); - - QLabel *question_label = new QLabel( - QString( - tr( - "L'élément « %1 » existe déjà. " - "Que souhaitez-vous faire ?", - "dialog content" - ) - ) - .arg(dst_location) - ); - question_label -> setWordWrap(true); - - setConflictDialogTitle(dialog_title); - setConflictDialogMainWidget(question_label); - - // execute le dialogue - conflict_dialog_ -> exec(); - - // enleve et detruit le widget principal - setConflictDialogMainWidget(0); - delete question_label; - - if (conflict_result_ == QET::Rename) { - if (!rename_.endsWith(".elmt")) rename_ += ".elmt"; - } - - // renvoie la reponse obtenue via le dialogue - return(conflict_result_); -} - -/** - Cette methode permet de savoir comment agir lorsqu'une categorie n'est pas lisible - @param category La categorie qui n'est pas lisible - @return QET::Retry, QET::Ignore ou QET::Abort -*/ -QET::Action InteractiveMoveElementsHandler::categoryIsNotReadable(ElementsCategory *category) { - QString message = QString(tr("La catégorie %1 n'est pas accessible en lecture.", "message box content")).arg(category -> location().toString()); - return(retryErrorMessage(message)); -} - -/** - Cette methode permet de savoir comment agir lorsqu'un element n'est pas lisible - @param element L'element qui n'est pas lisible - @return QET::Retry, QET::Ignore ou QET::Abort -*/ -QET::Action InteractiveMoveElementsHandler::elementIsNotReadable(ElementDefinition *element) { - QString message = QString(tr("L'élément %1 n'est pas accessible en lecture.", "message box content")).arg(element -> location().toString()); - return(retryErrorMessage(message)); -} - -/** - Cette methode permet de savoir comment agir lorsqu'une categorie n'est pas accessible en ecriture - @param category La categorie qui n'est pas lisible - @return QET::Retry, QET::Ignore ou QET::Abort -*/ -QET::Action InteractiveMoveElementsHandler::categoryIsNotWritable(ElementsCategory *category) { - QString message = QString(tr("La catégorie %1 n'est pas accessible en écriture.", "message box content")).arg(category -> location().toString()); - return(retryErrorMessage(message)); -} - -/** - Cette methode permet de savoir comment agir lorsqu'un element n'est pas accessible en ecriture - @param element L'element qui n'est pas lisible - @return QET::Retry, QET::Ignore ou QET::Abort -*/ -QET::Action InteractiveMoveElementsHandler::elementIsNotWritable(ElementDefinition *element) { - QString message = QString(tr("L'élément %1 n'est pas accessible en écriture.", "message box content")).arg(element -> location().toString()); - return(retryErrorMessage(message)); -} - -/** - Affiche un message d'erreur relatif a une categorie - @param category La categorie concernee par l'erreur - @param message Le message d'erreur a afficher - @return toujours QET::Ignore -*/ -QET::Action InteractiveMoveElementsHandler::errorWithACategory(ElementsCategory *category, const QString &message) { - QString category_location = category -> location().toString(); - QString error_message = QString("Une erreur s'est produite avec la catégorie %1 : %2").arg(category_location).arg(message); - simpleErrorMessage(error_message); - return(QET::Ignore); -} - -/** - Affiche un message d'erreur relatif a un element - @param element L'element concerne par l'erreur - @param message Le message d'erreur a afficher - @return toujours QET::Ignore -*/ -QET::Action InteractiveMoveElementsHandler::errorWithAnElement(ElementDefinition *element, const QString &message) { - QString element_location = element -> location().toString(); - QString error_message = QString("Une erreur s'est produite avec l'élément %1 : %2").arg(element_location).arg(message); - simpleErrorMessage(error_message); - return(QET::Ignore); -} - -/** - @return le nom a utiliser pour le renommage si une methode de cet objet - a precedemment renvoye QET::Rename. -*/ -QString InteractiveMoveElementsHandler::nameForRenamingOperation() { - return(rename_); -} - -/** - Initialise le dialogue qui sera utilise pour les conflits - elements / categories. -*/ -void InteractiveMoveElementsHandler::initConflictDialog() { - // n'agit qu'une seule fois - if (conflict_dialog_) return; - - conflict_dialog_ = new QDialog(parent_widget_); - conflict_dialog_ -> setMaximumSize(600, 200); - - // initialisation du champ de texte - rename_label_ = new QLabel(tr("Nouveau nom :")); - rename_textfield_ = new QFileNameEdit(); - connect( - rename_textfield_, - SIGNAL(textEdited(const QString &)), - this, - SLOT(conflictDialogFileNameFieldChanged()) - ); - - // initialisation des boutons - rename_button_ = new QPushButton(tr("Renommer")); - erase_button_ = new QPushButton(tr("Écraser")); - erase_all_button_ = new QPushButton(tr("Écraser tout")); - ignore_button_ = new QPushButton(tr("Ignorer")); - ignore_all_button_ = new QPushButton(tr("Ignorer tout")); - abort_button_ = new QPushButton(tr("Annuler")); - - conflict_buttons_ = new QDialogButtonBox(); - conflict_buttons_ -> addButton(rename_button_, QDialogButtonBox::ActionRole); - conflict_buttons_ -> addButton(erase_button_, QDialogButtonBox::AcceptRole); - conflict_buttons_ -> addButton(erase_all_button_, QDialogButtonBox::AcceptRole); - conflict_buttons_ -> addButton(ignore_button_, QDialogButtonBox::AcceptRole); - conflict_buttons_ -> addButton(ignore_all_button_, QDialogButtonBox::AcceptRole); - conflict_buttons_ -> addButton(abort_button_, QDialogButtonBox::AcceptRole); - - rename_button_ -> setEnabled(false); - connect( - conflict_buttons_, - SIGNAL(clicked(QAbstractButton *)), - this, - SLOT(conflictDialogButtonClicked(QAbstractButton *)) - ); - - // layout - conflict_layout1_ = new QHBoxLayout(); - conflict_layout1_ -> addWidget(rename_label_); - conflict_layout1_ -> addWidget(rename_textfield_); - - conflict_layout0_ = new QVBoxLayout(conflict_dialog_); - conflict_layout0_ -> insertLayout(1, conflict_layout1_); - conflict_layout0_ -> insertWidget(2, conflict_buttons_); -} - -/** - Slot appele lorsque l'utilisateur modifie le contenu du champ -*/ -void InteractiveMoveElementsHandler::conflictDialogFileNameFieldChanged() { - if (rename_textfield_ -> isValid()) { - /// @todo verifier que le nom n'est pas deja pris - rename_button_ -> setEnabled(true); - } else { - rename_button_ -> setEnabled(false); - } -} - -/** - Slot appele lorsque l'utilisateur presse un des boutons du dialogue de - conflit. - @param button Bouton presse par l'utilisateur -*/ -void InteractiveMoveElementsHandler::conflictDialogButtonClicked(QAbstractButton *button) { - conflict_dialog_ -> accept(); - // change la valeur de l'attribut - if (button == rename_button_) { - rename_ = rename_textfield_ -> text(); - conflict_result_= QET::Rename; - } else if (button == erase_button_) { - conflict_result_= QET::Erase; - } else if (button == erase_all_button_) { - always_erase_ = true; - conflict_result_= QET::Erase; - } else if (button == ignore_button_) { - conflict_result_= QET::Ignore; - } else if (button == ignore_all_button_) { - always_skip_ = true; - conflict_result_= QET::Ignore; - } else if (button == abort_button_) { - aborted_ = true; - conflict_result_= QET::Abort; - } -} - -/** - Change le titre du dialogue de conflit - @param new_title Nouveau titre pour le dialogue de conflit -*/ -void InteractiveMoveElementsHandler::setConflictDialogTitle(const QString &new_title) { - conflict_dialog_ -> setWindowTitle(new_title); -} - -/** - @return le titre du dialogue de conflit -*/ -QString InteractiveMoveElementsHandler::conflictDialogTitle() const { - return(conflict_dialog_ -> windowTitle()); -} - -/** - Change le widget affiche au centre du dialogue de conflit - @param widget Widget a inserer dans le dialogue de conflit - Si widget vaut 0, le widget central est retire. -*/ -void InteractiveMoveElementsHandler::setConflictDialogMainWidget(QWidget *widget) { - // gere l'enlevement du widget principal - if (!widget) { - if (conflict_layout0_ -> count() != 3) return; - conflict_layout0_ -> removeItem(conflict_layout0_ -> itemAt(0)); - } else { - conflict_layout0_ -> insertWidget(0, widget); - } -} - -/** - @return le widget insere dans le dialogue de conflit, ou 0 s'il n'y en a - aucun. -*/ -QWidget *InteractiveMoveElementsHandler::conflictDialogMainWidget() const { - if (conflict_layout0_ -> count() != 3) return(0); - return(conflict_layout0_ -> itemAt(0) -> widget()); -} - -/** - Affiche un message d'erreur en donnant la possibilite d'ignorer l'item en cours, - d'annuler tout le mouvement ou de le reessayer. - @param message Message d'erreur a afficher - @return L'action choisie par l'utilisateur -*/ -QET::Action InteractiveMoveElementsHandler::retryErrorMessage(const QString &message) const { - int todo = QET::QetMessageBox::critical( - parent_widget_, - tr("Erreur", "message box title"), - message, - QMessageBox::Abort | QMessageBox::Retry | QMessageBox::Ignore, - QMessageBox::Ignore - ); - - if (todo == QMessageBox::Abort) { - return(QET::Abort); - } else if (todo == QMessageBox::Retry) { - return(QET::Retry); - } else { - return(QET::Ignore); - } -} - -/** - Affiche un simple message d'erreur - @param message Message d'erreur a afficher -*/ -void InteractiveMoveElementsHandler::simpleErrorMessage(const QString &message) const { - QET::QetMessageBox::critical( - parent_widget_, - tr("Erreur", "message box title"), - message, - QMessageBox::Ok, - QMessageBox::Ok - ); -} diff --git a/sources/interactivemoveelementshandler.h b/sources/interactivemoveelementshandler.h deleted file mode 100644 index e60264c0f..000000000 --- a/sources/interactivemoveelementshandler.h +++ /dev/null @@ -1,96 +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 . -*/ -#ifndef INTERACTIVE_MOVE_ELEMENTS_HANDLER_H -#define INTERACTIVE_MOVE_ELEMENTS_HANDLER_H -#include "basicmoveelementshandler.h" -class QDialog; -class QDialogButtonBox; -class QAbstractButton; -class QPushButton; -class QFileNameEdit; -class QHBoxLayout; -class QVBoxLayout; -class QLabel; -/** - This class implements the MoveElementsHandler Strategy class by asking - users how to handle the various expected problems through interactive - dialogs. -*/ -class InteractiveMoveElementsHandler : public BasicMoveElementsHandler { - Q_OBJECT - - // constructors, destructor - public: - InteractiveMoveElementsHandler(QWidget * = 0); - virtual ~InteractiveMoveElementsHandler(); - private: - InteractiveMoveElementsHandler(const InteractiveMoveElementsHandler &); - - // methods - public: - virtual QET::Action categoryAlreadyExists(ElementsCategory *, ElementsCategory *); - virtual QET::Action elementAlreadyExists(ElementDefinition *, ElementDefinition *); - 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(); - - private slots: - void conflictDialogFileNameFieldChanged(); - void conflictDialogButtonClicked(QAbstractButton *); - - private: - void initConflictDialog(); - void setConflictDialogTitle(const QString &); - QString conflictDialogTitle() const; - void setConflictDialogMainWidget(QWidget *); - QWidget *conflictDialogMainWidget() const; - QET::Action retryErrorMessage(const QString &) const; - void simpleErrorMessage(const QString &) const; - - - // attributes - private: - QWidget *parent_widget_; ///< Widget to be used as parent when displaying dialogs - QString rename_; ///< Name to be used when renaming an item - bool always_erase_; ///< Whether to systematically erase conflicting targets without bothering users - bool always_skip_; ///< Whether to systematically ignore conflicting targets without bothering users - bool aborted_; ///< Whether the movement has been cancelled - - // attributes related to the dialog displayed for already existing elements and - // categories (= i.e. conflict dialog) - QET::Action conflict_result_; - QDialog *conflict_dialog_; - QVBoxLayout *conflict_layout0_; - QHBoxLayout *conflict_layout1_; - QLabel *rename_label_; - QFileNameEdit *rename_textfield_; - - /// Buttons for the conflict dialog - QDialogButtonBox *conflict_buttons_; - QPushButton *rename_button_; - QPushButton *erase_button_; - QPushButton *erase_all_button_; - QPushButton *ignore_button_; - QPushButton *ignore_all_button_; - QPushButton *abort_button_; -}; -#endif diff --git a/sources/projectview.cpp b/sources/projectview.cpp index d3b0f1d2b..b1aecb774 100644 --- a/sources/projectview.cpp +++ b/sources/projectview.cpp @@ -23,7 +23,6 @@ #include "exportdialog.h" #include "qetapp.h" #include "qetelementeditor.h" -#include "interactivemoveelementshandler.h" #include "borderpropertieswidget.h" #include "titleblockpropertieswidget.h" #include "conductorpropertieswidget.h" diff --git a/sources/qetproject.cpp b/sources/qetproject.cpp index 4384358ac..aafe7518a 100644 --- a/sources/qetproject.cpp +++ b/sources/qetproject.cpp @@ -18,13 +18,9 @@ #include "qetproject.h" #include "diagram.h" #include "diagramfoliolist.h" -#include "elementdefinition.h" -#include "xmlelementscollection.h" -#include "elementscategory.h" #include "qetapp.h" #include "qetresult.h" #include "movetemplateshandler.h" -#include "basicmoveelementshandler.h" #include "qetmessagebox.h" #include "titleblocktemplate.h" #include "ui/dialogwaiting.h" @@ -38,8 +34,6 @@ #include -QString QETProject::integration_category_name = "import"; - /** Constructeur par defaut - cree un schema contenant une collection d'elements vide et un schema vide. @@ -48,7 +42,6 @@ QString QETProject::integration_category_name = "import"; */ QETProject::QETProject(int diagrams, QObject *parent) : QObject (parent), - collection_ (0 ), project_qet_version_ (-1 ), modified_ (false ), read_only_ (false ), @@ -64,12 +57,6 @@ QETProject::QETProject(int diagrams, QObject *parent) : addNewDiagram(); } - // une collection d'elements vide - collection_ = new XmlElementsCollection(); - collection_ -> setProtocol("embed"); - collection_ -> setProject(this); - connect(collection_, SIGNAL(written()), this, SLOT(componentWritten())); - m_elements_collection = new XmlElementCollection(this); setupTitleBlockTemplatesCollection(); @@ -86,7 +73,6 @@ QETProject::QETProject(int diagrams, QObject *parent) : */ QETProject::QETProject(const QString &path, QObject *parent) : QObject (parent), - collection_ (0 ), project_qet_version_ (-1 ), modified_ (false ), read_only_ (false ), @@ -134,7 +120,6 @@ QETProject::QETProject(const QString &path, QObject *parent) : */ QETProject::~QETProject() { - if (collection_) delete collection_; qDeleteAll(diagrams_); delete undo_stack_; } @@ -1129,21 +1114,14 @@ void QETProject::readElementsCollectionXml(QDomDocument &xml_project) //Only the first found collection is take collection_root = collection_roots.at(0).toElement(); } - - if (collection_root.isNull()) //Make an empty collection - { - collection_ = new XmlElementsCollection(); + //Make an empty collection + if (collection_root.isNull()) { m_elements_collection = new XmlElementCollection(this); } - else //Read the collection - { - collection_ = new XmlElementsCollection(collection_root); + //Read the collection + else { m_elements_collection = new XmlElementCollection(collection_root, this); } - - collection_ -> setProtocol("embed"); - collection_ -> setProject(this); - connect(collection_, SIGNAL(written()), this, SLOT(componentWritten())); } /** @@ -1474,23 +1452,3 @@ void QETProject::removeDiagramsTitleBlockTemplate(TitleBlockTemplatesCollection void QETProject::usedTitleBlockTemplateChanged(const QString &template_name) { emit(diagramUsedTemplate(embeddedTitleBlockTemplatesCollection(), template_name)); } - -/** - Copie l'element integ_elmt dans la categorie target_cat en utilisant le - gestionnaire handler ; en cas d'erreur, error_message est rempli. - @return l'emplacement de l'element cree -*/ -ElementsLocation QETProject::copyElementWithHandler( - ElementDefinition *integ_elmt, - ElementsCategory *target_cat, - MoveElementsHandler *handler, - QString &error_message -) { - ElementsCollectionItem *result_item = integ_elmt -> copy(target_cat, handler); - ElementDefinition *result_elmt = result_item ? result_item -> toElement() : 0; - if (!result_item || !result_elmt) { - error_message = QString(tr("Un problème s'est produit pendant la copie de l'élément %1")).arg(integ_elmt -> location().toString()); - return(ElementsLocation()); - } - return(result_elmt -> location()); -} diff --git a/sources/qetproject.h b/sources/qetproject.h index 72a6debc5..cfc4c64ac 100644 --- a/sources/qetproject.h +++ b/sources/qetproject.h @@ -27,14 +27,10 @@ #include "properties/xrefproperties.h" class Diagram; -class ElementsCollection; -class ElementsCategory; -class ElementDefinition; class ElementsLocation; class QETResult; class TitleBlockTemplate; class XmlElementsCollection; -class MoveElementsHandler; class MoveTitleBlockTemplatesHandler; class NumerotationContext; class QUndoStack; @@ -185,7 +181,6 @@ class QETProject : public QObject void writeDefaultPropertiesXml(QDomElement &); void addDiagram(Diagram *); NamesList namesListForIntegrationCategory(); - ElementsLocation copyElementWithHandler(ElementDefinition *, ElementsCategory *, MoveElementsHandler *, QString &); // attributes private: @@ -195,8 +190,6 @@ class QETProject : public QObject ProjectState state_; /// Diagrams carried by the project QList diagrams_; - /// Embedded elements collection - XmlElementsCollection *collection_; /// Project title QString project_title_; /// QElectroTech version declared in the XML document at opening time @@ -207,8 +200,6 @@ class QETProject : public QObject bool read_only_; /// Filepath for which this project is considered read only QString read_only_file_path_; - /// Name of the category used when automatically integrating elements within the embedded collection - static QString integration_category_name; /// Default dimensions and properties for new diagrams created within the project BorderProperties default_border_properties_; /// Default conductor properties for new diagrams created within the project