mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-09-14 20:33:05 +02:00
Old element panel doesn't manage the embedded collection of project anymore.
Remove unused classes (become unused since the old panel doesn't manage embedded collection) git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4523 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
parent
8aa79b165a
commit
0b1fdb1564
@ -21,7 +21,6 @@
|
|||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include "elementslocation.h"
|
#include "elementslocation.h"
|
||||||
|
|
||||||
class ElementsCategory;
|
|
||||||
class NamesListWidget;
|
class NamesListWidget;
|
||||||
class QFileNameEdit;
|
class QFileNameEdit;
|
||||||
class QDialogButtonBox;
|
class QDialogButtonBox;
|
||||||
@ -43,7 +42,6 @@ class ElementsCategoryEditor : public QDialog
|
|||||||
ElementsCategoryEditor(const ElementsCategoryEditor &);
|
ElementsCategoryEditor(const ElementsCategoryEditor &);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ElementsCategory *category;
|
|
||||||
QDialogButtonBox *m_buttons;
|
QDialogButtonBox *m_buttons;
|
||||||
NamesListWidget *m_names_list;
|
NamesListWidget *m_names_list;
|
||||||
QLabel *m_file_name;
|
QLabel *m_file_name;
|
||||||
|
@ -201,48 +201,6 @@ void ElementsPanel::dragMoveEvent(QDragMoveEvent *e)
|
|||||||
/// @todo mettre en valeur le lieu de depot
|
/// @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
|
Gere le debut des drag'n drop
|
||||||
@param supportedActions Les actions supportees
|
@param supportedActions Les actions supportees
|
||||||
|
@ -68,7 +68,6 @@ class ElementsPanel : public GenericPanel {
|
|||||||
void requestForProject(QETProject *);
|
void requestForProject(QETProject *);
|
||||||
void requestForDiagram(Diagram *);
|
void requestForDiagram(Diagram *);
|
||||||
void requestForCollectionItem(const ElementsLocation &);
|
void requestForCollectionItem(const ElementsLocation &);
|
||||||
void requestForMoveElements(ElementsCollectionItem *, ElementsCollectionItem *, QPoint);
|
|
||||||
void requestForTitleBlockTemplate(const TitleBlockTemplateLocation &);
|
void requestForTitleBlockTemplate(const TitleBlockTemplateLocation &);
|
||||||
void readingAboutToBegin();
|
void readingAboutToBegin();
|
||||||
void readingFinished();
|
void readingFinished();
|
||||||
@ -90,7 +89,6 @@ class ElementsPanel : public GenericPanel {
|
|||||||
protected:
|
protected:
|
||||||
void dragEnterEvent(QDragEnterEvent *);
|
void dragEnterEvent(QDragEnterEvent *);
|
||||||
void dragMoveEvent(QDragMoveEvent *);
|
void dragMoveEvent(QDragMoveEvent *);
|
||||||
void dropEvent(QDropEvent *);
|
|
||||||
void startDrag(Qt::DropActions);
|
void startDrag(Qt::DropActions);
|
||||||
void startElementDrag(const ElementsLocation &);
|
void startElementDrag(const ElementsLocation &);
|
||||||
void startTitleBlockTemplateDrag(const TitleBlockTemplateLocation &);
|
void startTitleBlockTemplateDrag(const TitleBlockTemplateLocation &);
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
#include "elementscategoryeditor.h"
|
#include "elementscategoryeditor.h"
|
||||||
#include "elementscategorydeleter.h"
|
#include "elementscategorydeleter.h"
|
||||||
#include "qetapp.h"
|
#include "qetapp.h"
|
||||||
#include "interactivemoveelementshandler.h"
|
|
||||||
#include "qetproject.h"
|
#include "qetproject.h"
|
||||||
#include "diagram.h"
|
#include "diagram.h"
|
||||||
#include "qeticons.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_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_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);
|
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);
|
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_add, SIGNAL(triggered()), this, SLOT(addTitleBlockTemplate()));
|
||||||
connect(tbt_edit, SIGNAL(triggered()), this, SLOT(editTitleBlockTemplate()));
|
connect(tbt_edit, SIGNAL(triggered()), this, SLOT(editTitleBlockTemplate()));
|
||||||
connect(tbt_remove, SIGNAL(triggered()), this, SLOT(removeTitleBlockTemplate()));
|
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 &)));
|
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(customContextMenuRequested(const QPoint &)), this, SLOT(handleContextMenu(const QPoint &)));
|
||||||
connect(elements_panel, SIGNAL(requestForDiagram(Diagram*)), this, SIGNAL(requestForDiagram(Diagram*)));
|
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(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(
|
connect(
|
||||||
elements_panel,
|
elements_panel,
|
||||||
SIGNAL(requestForTitleBlockTemplate(const TitleBlockTemplateLocation &)),
|
SIGNAL(requestForTitleBlockTemplate(const TitleBlockTemplateLocation &)),
|
||||||
@ -591,71 +578,6 @@ void ElementsPanelWidget::handleCollectionRequest(const ElementsLocation &item_l
|
|||||||
// expand/collapse them
|
// 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
|
Reflects the fact that collections are being read (i.e from filesystem) in
|
||||||
the progress bar.
|
the progress bar.
|
||||||
@ -717,15 +639,6 @@ void ElementsPanelWidget::filterEdited(const QString &next_text) {
|
|||||||
previous_filter_ = 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
|
Edite la categorie selectionnee
|
||||||
*/
|
*/
|
||||||
|
@ -17,8 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
#ifndef ELEMENTS_PANEL_WIDGET_H
|
#ifndef ELEMENTS_PANEL_WIDGET_H
|
||||||
#define ELEMENTS_PANEL_WIDGET_H
|
#define ELEMENTS_PANEL_WIDGET_H
|
||||||
#include <QtWidgets>
|
|
||||||
#include "elementspanel.h"
|
#include "elementspanel.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This class embeds an elements panel under a toolbar providing various actions
|
This class embeds an elements panel under a toolbar providing various actions
|
||||||
to manage elements.
|
to manage elements.
|
||||||
@ -46,10 +47,8 @@ class ElementsPanelWidget : public QWidget {
|
|||||||
QAction *new_element, *edit_element, *delete_element, *open_element;
|
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 *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 *tbt_add, *tbt_edit, *tbt_remove;
|
||||||
QAction *copy_elements_, *move_elements_, *cancel_elements_;
|
|
||||||
QMenu *context_menu;
|
QMenu *context_menu;
|
||||||
QLineEdit *filter_textfield;
|
QLineEdit *filter_textfield;
|
||||||
ElementsCollectionItem *dnd_item_src_, *dnd_item_dst_;
|
|
||||||
QProgressBar *progress_bar_;
|
QProgressBar *progress_bar_;
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
@ -100,11 +99,6 @@ class ElementsPanelWidget : public QWidget {
|
|||||||
int launchCategoriesManager();
|
int launchCategoriesManager();
|
||||||
void handleContextMenu(const QPoint &);
|
void handleContextMenu(const QPoint &);
|
||||||
void handleCollectionRequest(const ElementsLocation &);
|
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 collectionsRead();
|
||||||
void collectionsReadFinished();
|
void collectionsReadFinished();
|
||||||
void updateProgressBar(int, int);
|
void updateProgressBar(int, int);
|
||||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
#include "interactivemoveelementshandler.h"
|
|
||||||
#include <QtWidgets>
|
|
||||||
#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
|
|
||||||
);
|
|
||||||
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
#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
|
|
@ -23,7 +23,6 @@
|
|||||||
#include "exportdialog.h"
|
#include "exportdialog.h"
|
||||||
#include "qetapp.h"
|
#include "qetapp.h"
|
||||||
#include "qetelementeditor.h"
|
#include "qetelementeditor.h"
|
||||||
#include "interactivemoveelementshandler.h"
|
|
||||||
#include "borderpropertieswidget.h"
|
#include "borderpropertieswidget.h"
|
||||||
#include "titleblockpropertieswidget.h"
|
#include "titleblockpropertieswidget.h"
|
||||||
#include "conductorpropertieswidget.h"
|
#include "conductorpropertieswidget.h"
|
||||||
|
@ -18,13 +18,9 @@
|
|||||||
#include "qetproject.h"
|
#include "qetproject.h"
|
||||||
#include "diagram.h"
|
#include "diagram.h"
|
||||||
#include "diagramfoliolist.h"
|
#include "diagramfoliolist.h"
|
||||||
#include "elementdefinition.h"
|
|
||||||
#include "xmlelementscollection.h"
|
|
||||||
#include "elementscategory.h"
|
|
||||||
#include "qetapp.h"
|
#include "qetapp.h"
|
||||||
#include "qetresult.h"
|
#include "qetresult.h"
|
||||||
#include "movetemplateshandler.h"
|
#include "movetemplateshandler.h"
|
||||||
#include "basicmoveelementshandler.h"
|
|
||||||
#include "qetmessagebox.h"
|
#include "qetmessagebox.h"
|
||||||
#include "titleblocktemplate.h"
|
#include "titleblocktemplate.h"
|
||||||
#include "ui/dialogwaiting.h"
|
#include "ui/dialogwaiting.h"
|
||||||
@ -38,8 +34,6 @@
|
|||||||
|
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
|
|
||||||
QString QETProject::integration_category_name = "import";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructeur par defaut - cree un schema contenant une collection
|
Constructeur par defaut - cree un schema contenant une collection
|
||||||
d'elements vide et un schema vide.
|
d'elements vide et un schema vide.
|
||||||
@ -48,7 +42,6 @@ QString QETProject::integration_category_name = "import";
|
|||||||
*/
|
*/
|
||||||
QETProject::QETProject(int diagrams, QObject *parent) :
|
QETProject::QETProject(int diagrams, QObject *parent) :
|
||||||
QObject (parent),
|
QObject (parent),
|
||||||
collection_ (0 ),
|
|
||||||
project_qet_version_ (-1 ),
|
project_qet_version_ (-1 ),
|
||||||
modified_ (false ),
|
modified_ (false ),
|
||||||
read_only_ (false ),
|
read_only_ (false ),
|
||||||
@ -64,12 +57,6 @@ QETProject::QETProject(int diagrams, QObject *parent) :
|
|||||||
addNewDiagram();
|
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);
|
m_elements_collection = new XmlElementCollection(this);
|
||||||
|
|
||||||
setupTitleBlockTemplatesCollection();
|
setupTitleBlockTemplatesCollection();
|
||||||
@ -86,7 +73,6 @@ QETProject::QETProject(int diagrams, QObject *parent) :
|
|||||||
*/
|
*/
|
||||||
QETProject::QETProject(const QString &path, QObject *parent) :
|
QETProject::QETProject(const QString &path, QObject *parent) :
|
||||||
QObject (parent),
|
QObject (parent),
|
||||||
collection_ (0 ),
|
|
||||||
project_qet_version_ (-1 ),
|
project_qet_version_ (-1 ),
|
||||||
modified_ (false ),
|
modified_ (false ),
|
||||||
read_only_ (false ),
|
read_only_ (false ),
|
||||||
@ -134,7 +120,6 @@ QETProject::QETProject(const QString &path, QObject *parent) :
|
|||||||
*/
|
*/
|
||||||
QETProject::~QETProject()
|
QETProject::~QETProject()
|
||||||
{
|
{
|
||||||
if (collection_) delete collection_;
|
|
||||||
qDeleteAll(diagrams_);
|
qDeleteAll(diagrams_);
|
||||||
delete undo_stack_;
|
delete undo_stack_;
|
||||||
}
|
}
|
||||||
@ -1129,21 +1114,14 @@ void QETProject::readElementsCollectionXml(QDomDocument &xml_project)
|
|||||||
//Only the first found collection is take
|
//Only the first found collection is take
|
||||||
collection_root = collection_roots.at(0).toElement();
|
collection_root = collection_roots.at(0).toElement();
|
||||||
}
|
}
|
||||||
|
//Make an empty collection
|
||||||
if (collection_root.isNull()) //Make an empty collection
|
if (collection_root.isNull()) {
|
||||||
{
|
|
||||||
collection_ = new XmlElementsCollection();
|
|
||||||
m_elements_collection = new XmlElementCollection(this);
|
m_elements_collection = new XmlElementCollection(this);
|
||||||
}
|
}
|
||||||
else //Read the collection
|
//Read the collection
|
||||||
{
|
else {
|
||||||
collection_ = new XmlElementsCollection(collection_root);
|
|
||||||
m_elements_collection = new XmlElementCollection(collection_root, this);
|
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) {
|
void QETProject::usedTitleBlockTemplateChanged(const QString &template_name) {
|
||||||
emit(diagramUsedTemplate(embeddedTitleBlockTemplatesCollection(), 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());
|
|
||||||
}
|
|
||||||
|
@ -27,14 +27,10 @@
|
|||||||
#include "properties/xrefproperties.h"
|
#include "properties/xrefproperties.h"
|
||||||
|
|
||||||
class Diagram;
|
class Diagram;
|
||||||
class ElementsCollection;
|
|
||||||
class ElementsCategory;
|
|
||||||
class ElementDefinition;
|
|
||||||
class ElementsLocation;
|
class ElementsLocation;
|
||||||
class QETResult;
|
class QETResult;
|
||||||
class TitleBlockTemplate;
|
class TitleBlockTemplate;
|
||||||
class XmlElementsCollection;
|
class XmlElementsCollection;
|
||||||
class MoveElementsHandler;
|
|
||||||
class MoveTitleBlockTemplatesHandler;
|
class MoveTitleBlockTemplatesHandler;
|
||||||
class NumerotationContext;
|
class NumerotationContext;
|
||||||
class QUndoStack;
|
class QUndoStack;
|
||||||
@ -185,7 +181,6 @@ class QETProject : public QObject
|
|||||||
void writeDefaultPropertiesXml(QDomElement &);
|
void writeDefaultPropertiesXml(QDomElement &);
|
||||||
void addDiagram(Diagram *);
|
void addDiagram(Diagram *);
|
||||||
NamesList namesListForIntegrationCategory();
|
NamesList namesListForIntegrationCategory();
|
||||||
ElementsLocation copyElementWithHandler(ElementDefinition *, ElementsCategory *, MoveElementsHandler *, QString &);
|
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
private:
|
private:
|
||||||
@ -195,8 +190,6 @@ class QETProject : public QObject
|
|||||||
ProjectState state_;
|
ProjectState state_;
|
||||||
/// Diagrams carried by the project
|
/// Diagrams carried by the project
|
||||||
QList<Diagram *> diagrams_;
|
QList<Diagram *> diagrams_;
|
||||||
/// Embedded elements collection
|
|
||||||
XmlElementsCollection *collection_;
|
|
||||||
/// Project title
|
/// Project title
|
||||||
QString project_title_;
|
QString project_title_;
|
||||||
/// QElectroTech version declared in the XML document at opening time
|
/// QElectroTech version declared in the XML document at opening time
|
||||||
@ -207,8 +200,6 @@ class QETProject : public QObject
|
|||||||
bool read_only_;
|
bool read_only_;
|
||||||
/// Filepath for which this project is considered read only
|
/// Filepath for which this project is considered read only
|
||||||
QString read_only_file_path_;
|
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
|
/// Default dimensions and properties for new diagrams created within the project
|
||||||
BorderProperties default_border_properties_;
|
BorderProperties default_border_properties_;
|
||||||
/// Default conductor properties for new diagrams created within the project
|
/// Default conductor properties for new diagrams created within the project
|
||||||
|
Loading…
x
Reference in New Issue
Block a user