[qet] qet/qet: [5339] Multipaste dialog : add 'autonum pasted conductors' check box |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 5339
Author: blacksun
Date: 2018-04-23 15:50:36 +0200 (Mon, 23 Apr 2018)
Log Message:
-----------
Multipaste dialog : add 'autonum pasted conductors' check box
Modified Paths:
--------------
trunk/sources/diagram.cpp
trunk/sources/diagramcommands.cpp
trunk/sources/diagramcontent.cpp
trunk/sources/diagramcontent.h
trunk/sources/elementsmover.cpp
trunk/sources/ui/multipastedialog.cpp
trunk/sources/ui/multipastedialog.h
trunk/sources/ui/multipastedialog.ui
Modified: trunk/sources/diagram.cpp
===================================================================
--- trunk/sources/diagram.cpp 2018-04-22 12:23:53 UTC (rev 5338)
+++ trunk/sources/diagram.cpp 2018-04-23 13:50:36 UTC (rev 5339)
@@ -1000,7 +1000,7 @@
// remplissage des listes facultatives
if (content_ptr) {
content_ptr -> m_elements = added_elements;
- content_ptr -> m_conductors_to_move = added_conductors.toSet();
+ content_ptr -> m_conductors_to_move = added_conductors;
content_ptr -> m_text_fields = added_texts.toSet();
content_ptr -> m_images = added_images.toSet();
content_ptr -> m_shapes = added_shapes.toSet();
Modified: trunk/sources/diagramcommands.cpp
===================================================================
--- trunk/sources/diagramcommands.cpp 2018-04-22 12:23:53 UTC (rev 5338)
+++ trunk/sources/diagramcommands.cpp 2018-04-23 13:50:36 UTC (rev 5339)
@@ -109,7 +109,7 @@
e -> rElementInformations().addValue("location", "");
//Reset the text of conductors
- const QList <Conductor *> conductors_list = content.m_conductors_to_move.toList();
+ const QList <Conductor *> conductors_list = content.m_conductors_to_move;
for (Conductor *c : conductors_list)
{
ConductorProperties cp = c -> properties();
Modified: trunk/sources/diagramcontent.cpp
===================================================================
--- trunk/sources/diagramcontent.cpp 2018-04-22 12:23:53 UTC (rev 5338)
+++ trunk/sources/diagramcontent.cpp 2018-04-23 13:50:36 UTC (rev 5339)
@@ -81,9 +81,9 @@
other_terminal = conductor->terminal1;
//If the two elements of conductor are movable
- if (m_elements.contains(other_terminal -> parentElement()))
+ if (m_elements.contains(other_terminal -> parentElement()) && !m_conductors_to_move.contains(conductor))
m_conductors_to_move << conductor;
- else
+ else if (!m_conductors_to_update.contains(conductor))
m_conductors_to_update << conductor;
}
}
@@ -160,16 +160,18 @@
*/
QList<Conductor *> DiagramContent::conductors(int filter) const
{
- QSet<Conductor *> result;
+ QList<Conductor *> result;
if (filter & ConductorsToMove) result += m_conductors_to_move;
if (filter & ConductorsToUpdate) result += m_conductors_to_update;
if (filter & OtherConductors) result += m_other_conductors;
if (filter & SelectedOnly) {
- for(Conductor *conductor : result) {
- if (!conductor->isSelected()) result.remove(conductor);
+ for(Conductor *conductor : result)
+ {
+ if (!conductor->isSelected())
+ result.removeAll(conductor);
}
}
- return(result.toList());
+ return(result);
}
/**
Modified: trunk/sources/diagramcontent.h
===================================================================
--- trunk/sources/diagramcontent.h 2018-04-22 12:23:53 UTC (rev 5338)
+++ trunk/sources/diagramcontent.h 2018-04-23 13:50:36 UTC (rev 5339)
@@ -68,9 +68,9 @@
QSet<IndependentTextItem *> m_text_fields;
QSet<DiagramImageItem *> m_images;
QSet<QetShapeItem *> m_shapes;
- QSet<Conductor *> m_conductors_to_update;
- QSet<Conductor *> m_conductors_to_move;
- QSet<Conductor *> m_other_conductors;
+ QList<Conductor *> m_conductors_to_update;
+ QList<Conductor *> m_conductors_to_move;
+ QList<Conductor *> m_other_conductors;
QSet<DynamicElementTextItem *> m_element_texts;
QSet<ElementTextItemGroup *> m_texts_groups;
QList<QGraphicsItem *> m_selected_items;
Modified: trunk/sources/elementsmover.cpp
===================================================================
--- trunk/sources/elementsmover.cpp 2018-04-22 12:23:53 UTC (rev 5338)
+++ trunk/sources/elementsmover.cpp 2018-04-23 13:50:36 UTC (rev 5339)
@@ -194,4 +194,5 @@
// There is no movement in progress now
movement_running_ = false;
+ m_moved_content.clear();
}
Modified: trunk/sources/ui/multipastedialog.cpp
===================================================================
--- trunk/sources/ui/multipastedialog.cpp 2018-04-22 12:23:53 UTC (rev 5338)
+++ trunk/sources/ui/multipastedialog.cpp 2018-04-23 13:50:36 UTC (rev 5339)
@@ -1,3 +1,20 @@
+/*
+ Copyright 2006-2018 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 "multipastedialog.h"
#include "ui_multipastedialog.h"
#include "diagram.h"
@@ -76,6 +93,8 @@
{
if(m_pasted_content.count())
{
+ m_diagram->undoStack().beginMacro(tr("Multi-collage"));
+
QSettings settings;
bool erase_label = settings.value("diagramcommands/erase-label-on-copy", true).toBool();
//Ensure when 'auto_num' is checked, the settings 'save_label' is to true.
@@ -88,10 +107,8 @@
m_diagram->clearSelection();
+ m_diagram->undoStack().push(new PasteDiagramCommand(m_diagram, m_pasted_content));
- QUndoCommand *undo = new QUndoCommand(tr("Multi-collage"));
- new PasteDiagramCommand(m_diagram, m_pasted_content, undo);
-
//Auto-connection
if(ui->m_auto_connection_cb->isChecked())
{
@@ -102,10 +119,10 @@
QPair <Terminal *, Terminal *> pair = elmt->AlignedFreeTerminals().takeFirst();
Conductor *conductor = new Conductor(pair.first, pair.second);
- new AddItemCommand<Conductor *>(conductor, m_diagram, QPointF(), undo);
+ m_diagram->undoStack().push(new AddItemCommand<Conductor *>(conductor, m_diagram, QPointF()));
//Autonum the new conductor, the undo command associated for this, have for parent undo_object
- ConductorAutoNumerotation can (conductor, m_diagram, undo);
+ ConductorAutoNumerotation can (conductor, m_diagram);
can.numerate();
if (m_diagram->freezeNewConductors() || m_diagram->project()->isFreezeNewConductors()) {
conductor->setFreezeLabel(true);
@@ -114,8 +131,6 @@
}
}
- m_diagram->undoStack().push(undo);
-
//Set up the label of element
//Instead of use the current autonum of project,
//we try to fetch the same formula of the pasted element, in the several autonum of the project
@@ -142,8 +157,39 @@
}
}
}
+ //Like elements, we compare formula of pasted conductor with the autonums available in the project.
+ if(ui->m_auto_num_cond_cb->isChecked())
+ {
+ for(Conductor *c : m_pasted_content.conductors())
+ {
+ QString formula = c->properties().m_formula;
+ if(!formula.isEmpty())
+ {
+ QHash <QString, NumerotationContext> autonums = m_diagram->project()->conductorAutoNum();
+ QHashIterator <QString, NumerotationContext> hash_iterator(autonums);
+
+ while (hash_iterator.hasNext())
+ {
+ hash_iterator.next();
+ if(autonum::numerotationContextToFormula(hash_iterator.value()) == formula)
+ {
+ m_diagram->project()->setCurrentConductorAutoNum(hash_iterator.key());
+ c->rSequenceNum().clear();
+ ConductorAutoNumerotation can(c, m_diagram);
+ can.numerate();
+ if (m_diagram->freezeNewConductors() || m_diagram->project()->isFreezeNewConductors())
+ {
+ c->setFreezeLabel(true);
+ }
+ }
+ }
+ }
+ }
+ }
+
m_diagram->adjustSceneRect();
m_accept = true;
settings.setValue("diagramcommands/erase-label-on-copy", erase_label);
+ m_diagram->undoStack().endMacro();
}
}
Modified: trunk/sources/ui/multipastedialog.h
===================================================================
--- trunk/sources/ui/multipastedialog.h 2018-04-22 12:23:53 UTC (rev 5338)
+++ trunk/sources/ui/multipastedialog.h 2018-04-23 13:50:36 UTC (rev 5339)
@@ -1,3 +1,20 @@
+/*
+ Copyright 2006-2018 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 MULTIPASTEDIALOG_H
#define MULTIPASTEDIALOG_H
@@ -16,14 +33,14 @@
Q_OBJECT
public:
- explicit MultiPasteDialog(Diagram *diagram, QWidget *parent = 0);
+ explicit MultiPasteDialog(Diagram *diagram, QWidget *parent = nullptr);
~MultiPasteDialog();
void updatePreview();
- private slots:
+ private slots:
void on_m_button_box_accepted();
- private:
+ private:
Ui::MultiPasteDialog *ui;
Diagram *m_diagram = nullptr;
DiagramContent m_pasted_content;
Modified: trunk/sources/ui/multipastedialog.ui
===================================================================
--- trunk/sources/ui/multipastedialog.ui 2018-04-22 12:23:53 UTC (rev 5338)
+++ trunk/sources/ui/multipastedialog.ui 2018-04-23 13:50:36 UTC (rev 5339)
@@ -102,6 +102,13 @@
</widget>
</item>
<item>
+ <widget class="QCheckBox" name="m_auto_num_cond_cb">
+ <property name="text">
+ <string>Auto-numérotation des conducteurs</string>
+ </property>
+ </widget>
+ </item>
+ <item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>