diff --git a/src/Mod/PartDesign/Gui/TaskLoftParameters.cpp b/src/Mod/PartDesign/Gui/TaskLoftParameters.cpp index 3197efb07f..32bd20803f 100644 --- a/src/Mod/PartDesign/Gui/TaskLoftParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskLoftParameters.cpp @@ -77,12 +77,20 @@ TaskLoftParameters::TaskLoftParameters(ViewProviderLoft *LoftView,bool /*newObj* connect(ui->checkBoxUpdateView, SIGNAL(toggled(bool)), this, SLOT(onUpdateView(bool))); + // Create context menu QAction* remove = new QAction(tr("Remove"), this); - remove->setShortcut(QString::fromLatin1("Del")); + remove->setShortcut(QKeySequence::Delete); +#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) + // display shortcut behind the context menu entry + remove->setShortcutVisibleInContextMenu(true); +#endif ui->listWidgetReferences->addAction(remove); 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); // Temporarily prevent unnecessary feature recomputes @@ -109,6 +117,10 @@ TaskLoftParameters::TaskLoftParameters(ViewProviderLoft *LoftView,bool /*newObj* ui->listWidgetReferences->addItem(item); } + // get options + ui->checkBoxRuled->setChecked(loft->Ruled.getValue()); + ui->checkBoxClosed->setChecked(loft->Closed.getValue()); + if (!loft->Sections.getValues().empty()) { LoftView->makeTemporaryVisible(true); } @@ -250,6 +262,27 @@ void TaskLoftParameters::onDeleteSection() } } +void TaskLoftParameters::indexesMoved() +{ + QAbstractItemModel* model = qobject_cast(sender()); + if (!model) + return; + + PartDesign::Loft* loft = static_cast(vp->getObject()); + std::vector originals = loft->Sections.getValues(); + + QByteArray name; + int rows = model->rowCount(); + for (int i = 0; i < rows; i++) { + QModelIndex index = model->index(i, 0); + name = index.data(Qt::UserRole).toByteArray().constData(); + originals[i] = loft->getDocument()->getObject(name.constData()); + } + + loft->Sections.setValues(originals); + recomputeFeature(); +} + void TaskLoftParameters::clearButtons() { ui->buttonRefAdd->setChecked(false); diff --git a/src/Mod/PartDesign/Gui/TaskLoftParameters.h b/src/Mod/PartDesign/Gui/TaskLoftParameters.h index c856e4b436..4e5d276c49 100644 --- a/src/Mod/PartDesign/Gui/TaskLoftParameters.h +++ b/src/Mod/PartDesign/Gui/TaskLoftParameters.h @@ -60,6 +60,7 @@ private Q_SLOTS: void onClosed(bool); void onRuled(bool); void onDeleteSection(); + void indexesMoved(); protected: void changeEvent(QEvent *e); diff --git a/src/Mod/PartDesign/Gui/TaskLoftParameters.ui b/src/Mod/PartDesign/Gui/TaskLoftParameters.ui index 7ffc60cb16..8e0d0b3fa6 100644 --- a/src/Mod/PartDesign/Gui/TaskLoftParameters.ui +++ b/src/Mod/PartDesign/Gui/TaskLoftParameters.ui @@ -98,7 +98,14 @@ - + + + List can be reordered by dragging + + + QAbstractItemView::InternalMove + + diff --git a/src/Mod/PartDesign/Gui/TaskMirroredParameters.ui b/src/Mod/PartDesign/Gui/TaskMirroredParameters.ui index bf4f9e41b5..f37573dda2 100644 --- a/src/Mod/PartDesign/Gui/TaskMirroredParameters.ui +++ b/src/Mod/PartDesign/Gui/TaskMirroredParameters.ui @@ -40,6 +40,9 @@ + + List can be reordered by dragging + QAbstractItemView::InternalMove