From 625c84e34a86cb2f176bcf9ded0abc408c2de066 Mon Sep 17 00:00:00 2001 From: Uwe Date: Sun, 28 Nov 2021 21:50:33 +0100 Subject: [PATCH] [PD] allow to move sweep sections Now that we have the feature that sweeps can have vertices as end or begin of a sweep, there is the need for the feature to move sections. For example vertices may only be the last section. --- src/Mod/PartDesign/Gui/TaskPipeParameters.cpp | 24 +++++++++++++++++++ src/Mod/PartDesign/Gui/TaskPipeParameters.h | 1 + src/Mod/PartDesign/Gui/TaskPipeScaling.ui | 13 +++++++--- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp b/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp index d7d1796ce0..ba80f2bd9e 100644 --- a/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp @@ -938,6 +938,9 @@ TaskPipeScaling::TaskPipeScaling(ViewProviderPipe* PipeView, bool /*newObj*/, QW ui->listWidgetReferences->setContextMenuPolicy(Qt::ActionsContextMenu); connect(remove, SIGNAL(triggered()), this, SLOT(onDeleteSection())); + connect(ui->listWidgetReferences->model(), + SIGNAL(rowsMoved(QModelIndex, int, int, QModelIndex, int)), this, SLOT(indexesMoved())); + this->groupLayout()->addWidget(proxy); PartDesign::Pipe* pipe = static_cast(PipeView->getObject()); @@ -964,6 +967,27 @@ TaskPipeScaling::~TaskPipeScaling() } } +void TaskPipeScaling::indexesMoved() +{ + QAbstractItemModel* model = qobject_cast(sender()); + if (!model) + return; + + PartDesign::Pipe* pipe = static_cast(vp->getObject()); + auto originals = pipe->Sections.getSubListValues(); + + QByteArray name; + int rows = model->rowCount(); + for (int i = 0; i < rows; i++) { + QModelIndex index = model->index(i, 0); + originals[i] = index.data(Qt::UserRole).value(); + } + + pipe->Sections.setSubListValues(originals); + recomputeFeature(); + updateUI(ui->stackedWidget->currentIndex()); +} + void TaskPipeScaling::clearButtons(const selectionModes notThis) { // TODO: Clear buttons in the other pipe taskboxes as well diff --git a/src/Mod/PartDesign/Gui/TaskPipeParameters.h b/src/Mod/PartDesign/Gui/TaskPipeParameters.h index 8c534f135e..f080561792 100644 --- a/src/Mod/PartDesign/Gui/TaskPipeParameters.h +++ b/src/Mod/PartDesign/Gui/TaskPipeParameters.h @@ -145,6 +145,7 @@ private Q_SLOTS: void onButtonRefRemove(bool checked); void updateUI(int idx); void onDeleteSection(); + void indexesMoved(); protected: enum selectionModes { none, refAdd, refRemove }; diff --git a/src/Mod/PartDesign/Gui/TaskPipeScaling.ui b/src/Mod/PartDesign/Gui/TaskPipeScaling.ui index d06cbe8bc9..c3d535007b 100644 --- a/src/Mod/PartDesign/Gui/TaskPipeScaling.ui +++ b/src/Mod/PartDesign/Gui/TaskPipeScaling.ui @@ -6,8 +6,8 @@ 0 0 - 353 - 407 + 262 + 270 @@ -97,7 +97,14 @@ - + + + List can be reordered by dragging + + + QAbstractItemView::InternalMove + +