From d1949f6e28fab93e05f0dda565c59488ebad285a Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 27 Jan 2018 21:10:01 +0100 Subject: [PATCH] add command to show/hide several constraints at once --- .../Sketcher/Gui/TaskSketcherConstrains.cpp | 24 +++++++++++++++++++ src/Mod/Sketcher/Gui/TaskSketcherConstrains.h | 2 ++ 2 files changed, 26 insertions(+) diff --git a/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp b/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp index c1f65adfae..c5697c2b03 100644 --- a/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp +++ b/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp @@ -419,6 +419,12 @@ void ConstraintView::contextMenuEvent (QContextMenuEvent* event) QAction* driven = menu.addAction(tr("Toggle to/from reference"), this, SLOT(updateDrivingStatus())); driven->setEnabled(isToggleDriving); + menu.addSeparator(); + QAction* show = menu.addAction(tr("Show constraints"), this, SLOT(showConstraints())); + show->setEnabled(!items.isEmpty()); + QAction* hide = menu.addAction(tr("Hide constraints"), this, SLOT(hideConstraints())); + hide->setEnabled(!items.isEmpty()); + menu.addSeparator(); CONTEXT_ITEM("Sketcher_SelectElementsAssociatedWithConstraints","Select Elements","Sketcher_SelectElementsAssociatedWithConstraints",doSelectConstraints,true) @@ -454,6 +460,24 @@ void ConstraintView::updateDrivingStatus() } } +void ConstraintView::showConstraints() +{ + QList items = selectedItems(); + for (auto it : items) { + if (it->checkState() != Qt::Checked) + it->setCheckState(Qt::Checked); + } +} + +void ConstraintView::hideConstraints() +{ + QList items = selectedItems(); + for (auto it : items) { + if (it->checkState() != Qt::Unchecked) + it->setCheckState(Qt::Unchecked); + } +} + void ConstraintView::modifyCurrentItem() { /*emit*/itemActivated(currentItem()); diff --git a/src/Mod/Sketcher/Gui/TaskSketcherConstrains.h b/src/Mod/Sketcher/Gui/TaskSketcherConstrains.h index 3d33f18816..aa079c9ace 100644 --- a/src/Mod/Sketcher/Gui/TaskSketcherConstrains.h +++ b/src/Mod/Sketcher/Gui/TaskSketcherConstrains.h @@ -61,6 +61,8 @@ protected Q_SLOTS: void doSelectConstraints(); void updateDrivingStatus(); void swapNamedOfSelectedItems(); + void showConstraints(); + void hideConstraints(); }; class TaskSketcherConstrains : public Gui::TaskView::TaskBox, public Gui::SelectionObserver