mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 12:40:35 +01:00
Multi paste dialog : add a check box for allows auto connection of the pasted elements.
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@5331 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -999,7 +999,7 @@ bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_inf
|
|||||||
|
|
||||||
// remplissage des listes facultatives
|
// remplissage des listes facultatives
|
||||||
if (content_ptr) {
|
if (content_ptr) {
|
||||||
content_ptr -> m_elements = added_elements.toSet();
|
content_ptr -> m_elements = added_elements;
|
||||||
content_ptr -> m_conductors_to_move = added_conductors.toSet();
|
content_ptr -> m_conductors_to_move = added_conductors.toSet();
|
||||||
content_ptr -> m_text_fields = added_texts.toSet();
|
content_ptr -> m_text_fields = added_texts.toSet();
|
||||||
content_ptr -> m_images = added_images.toSet();
|
content_ptr -> m_images = added_images.toSet();
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ void PasteDiagramCommand::redo()
|
|||||||
first_redo = false;
|
first_redo = false;
|
||||||
|
|
||||||
//this is the first paste, we do some actions for the new element
|
//this is the first paste, we do some actions for the new element
|
||||||
const QList <Element *> elmts_list = content.m_elements.toList();
|
const QList <Element *> elmts_list = content.m_elements;
|
||||||
for (Element *e : elmts_list)
|
for (Element *e : elmts_list)
|
||||||
{
|
{
|
||||||
//make new uuid, because old uuid are the uuid of the copied element
|
//make new uuid, because old uuid are the uuid of the copied element
|
||||||
|
|||||||
@@ -238,10 +238,10 @@ int DiagramContent::removeNonMovableItems()
|
|||||||
{
|
{
|
||||||
int count_ = 0;
|
int count_ = 0;
|
||||||
|
|
||||||
const QSet<Element *> elements_set = m_elements;
|
const QList<Element *> elements_set = m_elements;
|
||||||
for(Element *elmt : elements_set) {
|
for(Element *elmt : elements_set) {
|
||||||
if (!elmt->isMovable()) {
|
if (!elmt->isMovable()) {
|
||||||
m_elements.remove(elmt);
|
m_elements.removeAll(elmt);
|
||||||
++count_;
|
++count_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ class DiagramContent
|
|||||||
SelectedOnly = 512
|
SelectedOnly = 512
|
||||||
};
|
};
|
||||||
|
|
||||||
QSet<Element *> m_elements;
|
QList<Element *> m_elements;
|
||||||
QSet<IndependentTextItem *> m_text_fields;
|
QSet<IndependentTextItem *> m_text_fields;
|
||||||
QSet<DiagramImageItem *> m_images;
|
QSet<DiagramImageItem *> m_images;
|
||||||
QSet<QetShapeItem *> m_shapes;
|
QSet<QetShapeItem *> m_shapes;
|
||||||
|
|||||||
@@ -819,7 +819,7 @@ void DiagramView::editSelectionProperties()
|
|||||||
selection.conductors().first()->editProperty();
|
selection.conductors().first()->editProperty();
|
||||||
// edit element
|
// edit element
|
||||||
else if (selection.m_elements.size())
|
else if (selection.m_elements.size())
|
||||||
selection.m_elements.toList().first() -> editProperty();
|
selection.m_elements.first() -> editProperty();
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ void ElementsMover::endMovement()
|
|||||||
m_moved_content.items(dc::Elements).size() == 1 &&
|
m_moved_content.items(dc::Elements).size() == 1 &&
|
||||||
diagram_ -> project() -> autoConductor())
|
diagram_ -> project() -> autoConductor())
|
||||||
{
|
{
|
||||||
Element *elmt = m_moved_content.m_elements.toList().first();
|
Element *elmt = m_moved_content.m_elements.first();
|
||||||
|
|
||||||
int acc = elmt->AlignedFreeTerminals().size();
|
int acc = elmt->AlignedFreeTerminals().size();
|
||||||
|
|
||||||
|
|||||||
@@ -276,8 +276,8 @@ void QETDiagramEditor::setUpActions()
|
|||||||
m_grey_background -> setCheckable (true);
|
m_grey_background -> setCheckable (true);
|
||||||
connect (m_grey_background, &QAction::triggered, [this](bool checked) {
|
connect (m_grey_background, &QAction::triggered, [this](bool checked) {
|
||||||
Diagram::background_color = checked ? Qt::darkGray : Qt::white;
|
Diagram::background_color = checked ? Qt::darkGray : Qt::white;
|
||||||
if (this->currentDiagram() && this->currentDiagram()->diagram())
|
if (this->currentDiagramView() && this->currentDiagramView()->diagram())
|
||||||
this->currentDiagram()->diagram()->update();
|
this->currentDiagramView()->diagram()->update();
|
||||||
});
|
});
|
||||||
|
|
||||||
m_draw_grid = new QAction ( QET::Icons::Grid, tr("Afficher la grille"), this);
|
m_draw_grid = new QAction ( QET::Icons::Grid, tr("Afficher la grille"), this);
|
||||||
@@ -984,7 +984,7 @@ bool QETDiagramEditor::addProject(QETProject *project, bool update_panel) {
|
|||||||
// met a jour le panel d'elements
|
// met a jour le panel d'elements
|
||||||
if (update_panel) {
|
if (update_panel) {
|
||||||
pa -> elementsPanel().projectWasOpened(project);
|
pa -> elementsPanel().projectWasOpened(project);
|
||||||
if (currentDiagram() != nullptr)
|
if (currentDiagramView() != nullptr)
|
||||||
m_autonumbering_dock->setProject(project, project_view);
|
m_autonumbering_dock->setProject(project, project_view);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1026,7 +1026,7 @@ ProjectView *QETDiagramEditor::currentProjectView() const {
|
|||||||
@return Le schema actuellement edite (= l'onglet ouvert dans le projet
|
@return Le schema actuellement edite (= l'onglet ouvert dans le projet
|
||||||
courant) ou 0 s'il n'y en a pas
|
courant) ou 0 s'il n'y en a pas
|
||||||
*/
|
*/
|
||||||
DiagramView *QETDiagramEditor::currentDiagram() const {
|
DiagramView *QETDiagramEditor::currentDiagramView() const {
|
||||||
if (ProjectView *project_view = currentProjectView()) {
|
if (ProjectView *project_view = currentProjectView()) {
|
||||||
return(project_view -> currentDiagram());
|
return(project_view -> currentDiagram());
|
||||||
}
|
}
|
||||||
@@ -1041,11 +1041,11 @@ DiagramView *QETDiagramEditor::currentDiagram() const {
|
|||||||
*/
|
*/
|
||||||
Element *QETDiagramEditor::currentElement() const
|
Element *QETDiagramEditor::currentElement() const
|
||||||
{
|
{
|
||||||
DiagramView *dv = currentDiagram();
|
DiagramView *dv = currentDiagramView();
|
||||||
if (!dv)
|
if (!dv)
|
||||||
return(nullptr);
|
return(nullptr);
|
||||||
|
|
||||||
QList<Element *> selected_elements = DiagramContent(dv->diagram()).m_elements.toList();
|
QList<Element *> selected_elements = DiagramContent(dv->diagram()).m_elements;
|
||||||
if (selected_elements.count() != 1)
|
if (selected_elements.count() != 1)
|
||||||
return(nullptr);
|
return(nullptr);
|
||||||
|
|
||||||
@@ -1150,27 +1150,27 @@ void QETDiagramEditor::activateWidget(QWidget *widget) {
|
|||||||
Effectue l'action "couper" sur le schema en cours
|
Effectue l'action "couper" sur le schema en cours
|
||||||
*/
|
*/
|
||||||
void QETDiagramEditor::slot_cut() {
|
void QETDiagramEditor::slot_cut() {
|
||||||
if(currentDiagram()) currentDiagram() -> cut();
|
if(currentDiagramView()) currentDiagramView() -> cut();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Effectue l'action "copier" sur le diagram en cours
|
Effectue l'action "copier" sur le diagram en cours
|
||||||
*/
|
*/
|
||||||
void QETDiagramEditor::slot_copy() {
|
void QETDiagramEditor::slot_copy() {
|
||||||
if(currentDiagram()) currentDiagram() -> copy();
|
if(currentDiagramView()) currentDiagramView() -> copy();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Effectue l'action "coller" sur le schema en cours
|
Effectue l'action "coller" sur le schema en cours
|
||||||
*/
|
*/
|
||||||
void QETDiagramEditor::slot_paste() {
|
void QETDiagramEditor::slot_paste() {
|
||||||
if(currentDiagram()) currentDiagram() -> paste();
|
if(currentDiagramView()) currentDiagramView() -> paste();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QETDiagramEditor::zoomGroupTriggered(QAction *action)
|
void QETDiagramEditor::zoomGroupTriggered(QAction *action)
|
||||||
{
|
{
|
||||||
QString value = action->data().toString();
|
QString value = action->data().toString();
|
||||||
DiagramView *dv = currentDiagram();
|
DiagramView *dv = currentDiagramView();
|
||||||
|
|
||||||
if (!dv || value.isEmpty()) return;
|
if (!dv || value.isEmpty()) return;
|
||||||
|
|
||||||
@@ -1194,7 +1194,7 @@ void QETDiagramEditor::zoomGroupTriggered(QAction *action)
|
|||||||
void QETDiagramEditor::selectGroupTriggered(QAction *action)
|
void QETDiagramEditor::selectGroupTriggered(QAction *action)
|
||||||
{
|
{
|
||||||
QString value = action->data().toString();
|
QString value = action->data().toString();
|
||||||
DiagramView *dv = currentDiagram();
|
DiagramView *dv = currentDiagramView();
|
||||||
|
|
||||||
if (!dv || value.isEmpty()) return;
|
if (!dv || value.isEmpty()) return;
|
||||||
|
|
||||||
@@ -1216,9 +1216,9 @@ void QETDiagramEditor::addItemGroupTriggered(QAction *action)
|
|||||||
{
|
{
|
||||||
QString value = action->data().toString();
|
QString value = action->data().toString();
|
||||||
|
|
||||||
if (Q_UNLIKELY (!currentDiagram() || !currentDiagram()->diagram() || value.isEmpty())) return;
|
if (Q_UNLIKELY (!currentDiagramView() || !currentDiagramView()->diagram() || value.isEmpty())) return;
|
||||||
|
|
||||||
Diagram *d = currentDiagram()->diagram();
|
Diagram *d = currentDiagramView()->diagram();
|
||||||
DiagramEventInterface *diagram_event = nullptr;
|
DiagramEventInterface *diagram_event = nullptr;
|
||||||
|
|
||||||
if (value == "line")
|
if (value == "line")
|
||||||
@@ -1259,7 +1259,7 @@ void QETDiagramEditor::addItemGroupTriggered(QAction *action)
|
|||||||
void QETDiagramEditor::selectionGroupTriggered(QAction *action)
|
void QETDiagramEditor::selectionGroupTriggered(QAction *action)
|
||||||
{
|
{
|
||||||
QString value = action->data().toString();
|
QString value = action->data().toString();
|
||||||
DiagramView *dv = currentDiagram();
|
DiagramView *dv = currentDiagramView();
|
||||||
Diagram *diagram = dv->diagram();
|
Diagram *diagram = dv->diagram();
|
||||||
DiagramContent dc(diagram);
|
DiagramContent dc(diagram);
|
||||||
|
|
||||||
@@ -1288,7 +1288,7 @@ void QETDiagramEditor::selectionGroupTriggered(QAction *action)
|
|||||||
void QETDiagramEditor::rowColumnGroupTriggered(QAction *action)
|
void QETDiagramEditor::rowColumnGroupTriggered(QAction *action)
|
||||||
{
|
{
|
||||||
QString value = action->data().toString();
|
QString value = action->data().toString();
|
||||||
DiagramView *dv = currentDiagram();
|
DiagramView *dv = currentDiagramView();
|
||||||
|
|
||||||
if (!dv || value.isEmpty() || dv->diagram()->isReadOnly()) return;
|
if (!dv || value.isEmpty() || dv->diagram()->isReadOnly()) return;
|
||||||
|
|
||||||
@@ -1336,7 +1336,7 @@ void QETDiagramEditor::slot_setVisualisationMode()
|
|||||||
*/
|
*/
|
||||||
void QETDiagramEditor::slot_updateActions()
|
void QETDiagramEditor::slot_updateActions()
|
||||||
{
|
{
|
||||||
DiagramView *dv = currentDiagram();
|
DiagramView *dv = currentDiagramView();
|
||||||
ProjectView *pv = currentProjectView();
|
ProjectView *pv = currentProjectView();
|
||||||
|
|
||||||
bool opened_project = pv;
|
bool opened_project = pv;
|
||||||
@@ -1377,7 +1377,7 @@ void QETDiagramEditor::slot_updateActions()
|
|||||||
void QETDiagramEditor::slot_updateAutoNumDock() {
|
void QETDiagramEditor::slot_updateAutoNumDock() {
|
||||||
if ( workspace.subWindowList().indexOf(workspace.activeSubWindow()) != activeSubWindowIndex) {
|
if ( workspace.subWindowList().indexOf(workspace.activeSubWindow()) != activeSubWindowIndex) {
|
||||||
activeSubWindowIndex = workspace.subWindowList().indexOf(workspace.activeSubWindow());
|
activeSubWindowIndex = workspace.subWindowList().indexOf(workspace.activeSubWindow());
|
||||||
if (currentProjectView() != nullptr && currentDiagram() != nullptr) {
|
if (currentProjectView() != nullptr && currentDiagramView() != nullptr) {
|
||||||
m_autonumbering_dock->setProject(currentProjectView()->project(),currentProjectView());
|
m_autonumbering_dock->setProject(currentProjectView()->project(),currentProjectView());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1400,7 +1400,7 @@ void QETDiagramEditor::slot_updateUndoStack()
|
|||||||
*/
|
*/
|
||||||
void QETDiagramEditor::slot_updateComplexActions()
|
void QETDiagramEditor::slot_updateComplexActions()
|
||||||
{
|
{
|
||||||
DiagramView *dv = currentDiagram();
|
DiagramView *dv = currentDiagramView();
|
||||||
if(!dv)
|
if(!dv)
|
||||||
{
|
{
|
||||||
QList <QAction *> action_list;
|
QList <QAction *> action_list;
|
||||||
@@ -1493,7 +1493,7 @@ void QETDiagramEditor::slot_updateComplexActions()
|
|||||||
*/
|
*/
|
||||||
void QETDiagramEditor::slot_updateModeActions()
|
void QETDiagramEditor::slot_updateModeActions()
|
||||||
{
|
{
|
||||||
DiagramView *dv = currentDiagram();
|
DiagramView *dv = currentDiagramView();
|
||||||
|
|
||||||
if (!dv)
|
if (!dv)
|
||||||
grp_visu_sel -> setEnabled(false);
|
grp_visu_sel -> setEnabled(false);
|
||||||
@@ -1528,7 +1528,7 @@ void QETDiagramEditor::slot_updateModeActions()
|
|||||||
Gere les actions ayant besoin du presse-papier
|
Gere les actions ayant besoin du presse-papier
|
||||||
*/
|
*/
|
||||||
void QETDiagramEditor::slot_updatePasteAction() {
|
void QETDiagramEditor::slot_updatePasteAction() {
|
||||||
DiagramView *dv = currentDiagram();
|
DiagramView *dv = currentDiagramView();
|
||||||
bool editable_diagram = (dv && !dv -> diagram() -> isReadOnly());
|
bool editable_diagram = (dv && !dv -> diagram() -> isReadOnly());
|
||||||
|
|
||||||
// pour coller, il faut un schema ouvert et un schema dans le presse-papier
|
// pour coller, il faut un schema ouvert et un schema dans le presse-papier
|
||||||
@@ -1738,7 +1738,7 @@ void QETDiagramEditor::editDiagramProperties(Diagram *diagram) {
|
|||||||
Edite les proprietes des objets selectionnes
|
Edite les proprietes des objets selectionnes
|
||||||
*/
|
*/
|
||||||
void QETDiagramEditor::editSelectionProperties() {
|
void QETDiagramEditor::editSelectionProperties() {
|
||||||
if (DiagramView *dv = currentDiagram()) {
|
if (DiagramView *dv = currentDiagramView()) {
|
||||||
dv -> editSelectionProperties();
|
dv -> editSelectionProperties();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1747,7 +1747,7 @@ void QETDiagramEditor::editSelectionProperties() {
|
|||||||
Reinitialise les conducteurs selectionnes
|
Reinitialise les conducteurs selectionnes
|
||||||
*/
|
*/
|
||||||
void QETDiagramEditor::slot_resetConductors() {
|
void QETDiagramEditor::slot_resetConductors() {
|
||||||
if (DiagramView *dv = currentDiagram()) {
|
if (DiagramView *dv = currentDiagramView()) {
|
||||||
dv -> resetConductors();
|
dv -> resetConductors();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2179,7 +2179,7 @@ void QETDiagramEditor::selectionChanged()
|
|||||||
{
|
{
|
||||||
slot_updateComplexActions();
|
slot_updateComplexActions();
|
||||||
|
|
||||||
DiagramView *dv = currentDiagram();
|
DiagramView *dv = currentDiagramView();
|
||||||
if (dv && dv->diagram())
|
if (dv && dv->diagram())
|
||||||
m_selection_properties_editor->setDiagram(dv->diagram());
|
m_selection_properties_editor->setDiagram(dv->diagram());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ class QETDiagramEditor : public QETMainWindow {
|
|||||||
private:
|
private:
|
||||||
bool addProject(QETProject *, bool = true);
|
bool addProject(QETProject *, bool = true);
|
||||||
ProjectView *currentProjectView() const;
|
ProjectView *currentProjectView() const;
|
||||||
DiagramView *currentDiagram() const;
|
DiagramView *currentDiagramView() const;
|
||||||
Element *currentElement() const;
|
Element *currentElement() const;
|
||||||
CustomElement * currentCustomElement() const;
|
CustomElement * currentCustomElement() const;
|
||||||
ProjectView *findProject(DiagramView *) const;
|
ProjectView *findProject(DiagramView *) const;
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
#include "ui_multipastedialog.h"
|
#include "ui_multipastedialog.h"
|
||||||
#include "diagram.h"
|
#include "diagram.h"
|
||||||
#include "diagramcommands.h"
|
#include "diagramcommands.h"
|
||||||
|
#include "element.h"
|
||||||
|
#include "conductorautonumerotation.h"
|
||||||
|
|
||||||
MultiPasteDialog::MultiPasteDialog(Diagram *diagram, QWidget *parent) :
|
MultiPasteDialog::MultiPasteDialog(Diagram *diagram, QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
@@ -74,7 +76,32 @@ void MultiPasteDialog::on_m_button_box_accepted()
|
|||||||
if(m_pasted_content.count())
|
if(m_pasted_content.count())
|
||||||
{
|
{
|
||||||
m_diagram->clearSelection();
|
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);
|
||||||
|
|
||||||
|
if(ui->m_auto_connection_cb->isChecked())
|
||||||
|
{
|
||||||
|
for(Element *elmt : m_pasted_content.m_elements)
|
||||||
|
{
|
||||||
|
while (!elmt->AlignedFreeTerminals().isEmpty())
|
||||||
|
{
|
||||||
|
QPair <Terminal *, Terminal *> pair = elmt->AlignedFreeTerminals().takeFirst();
|
||||||
|
|
||||||
|
Conductor *conductor = new Conductor(pair.first, pair.second);
|
||||||
|
new AddItemCommand<Conductor *>(conductor, m_diagram, QPointF(), undo);
|
||||||
|
|
||||||
|
//Autonum the new conductor, the undo command associated for this, have for parent undo_object
|
||||||
|
ConductorAutoNumerotation can (conductor, m_diagram, undo);
|
||||||
|
can.numerate();
|
||||||
|
if (m_diagram->freezeNewConductors() || m_diagram->project()->isFreezeNewConductors()) {
|
||||||
|
conductor->setFreezeLabel(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_diagram->undoStack().push(undo);
|
||||||
m_diagram->adjustSceneRect();
|
m_diagram->adjustSceneRect();
|
||||||
m_accept = true;
|
m_accept = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,6 +87,13 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="m_auto_connection_cb">
|
||||||
|
<property name="text">
|
||||||
|
<string>Auto-connection</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
|||||||
Reference in New Issue
Block a user