Element editor : a copied/pasted terminal part have a new uuid.

This commit is contained in:
Claveau Joshua
2020-08-12 15:45:48 +02:00
parent 1805ef300e
commit 86766a9090
7 changed files with 178 additions and 106 deletions

View File

@@ -119,79 +119,6 @@ void DeletePartsCommand::redo() {
m_scene -> blockSignals(false);
}
/*** CutPartsCommand ***/
/**
Constructeur
@param view ElementView concernee
@param c Liste des parties collees
@param parent QUndoCommand parent
*/
PastePartsCommand::PastePartsCommand(
ElementView *view,
const ElementContent &c,
QUndoCommand *parent
) :
ElementEditionCommand(view ? view -> scene() : nullptr, view, parent),
content_(c),
uses_offset(false),
first_redo(true)
{
setText(QObject::tr("coller"));
m_scene -> qgiManager().manage(content_);
}
/// Destructeur
PastePartsCommand::~PastePartsCommand() {
m_scene -> qgiManager().release(content_);
}
/// annule le coller
void PastePartsCommand::undo() {
// enleve les parties
m_scene -> blockSignals(true);
foreach(QGraphicsItem *part, content_) {
m_scene -> removeItem(part);
}
m_scene -> blockSignals(false);
if (uses_offset) {
m_view -> offset_paste_count_ = old_offset_paste_count_;
m_view -> start_top_left_corner_ = old_start_top_left_corner_;
}
m_view -> adjustSceneRect();
}
/// refait le coller
void PastePartsCommand::redo() {
if (first_redo) first_redo = false;
else {
// pose les parties
m_scene -> blockSignals(true);
foreach(QGraphicsItem *part, content_) {
m_scene -> addItem(part);
}
m_scene -> blockSignals(false);
if (uses_offset) {
m_view -> offset_paste_count_ = new_offset_paste_count_;
m_view -> start_top_left_corner_ = new_start_top_left_corner_;
}
}
m_scene -> slot_select(content_);
m_view -> adjustSceneRect();
}
/**
Indique a cet objet d'annulation que le c/c a annuler ou refaire etait un
c/c avec decalage ; il faut plus d'informations pour annuler ce type de
collage.
*/
void PastePartsCommand::setOffset(int old_offset_pc, const QPointF &old_start_tlc, int new_offset_pc, const QPointF &new_start_tlc) {
old_offset_paste_count_ = old_offset_pc;
old_start_top_left_corner_ = old_start_tlc;
new_offset_paste_count_ = new_offset_pc;
new_start_top_left_corner_ = new_start_tlc;
uses_offset = true;
}
/*** CutPartsCommand ***/
/**
Constructeur