diff --git a/src/Mod/Fem/Gui/TaskFemConstraint.cpp b/src/Mod/Fem/Gui/TaskFemConstraint.cpp index 0e6136224a..6bb940a3f0 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraint.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraint.cpp @@ -27,7 +27,9 @@ #ifndef _PreComp_ # include +# include # include +# include # include # include # include @@ -183,6 +185,45 @@ const QString TaskFemConstraint::makeRefText(const App::DocumentObject* obj, con return QString::fromUtf8((std::string(obj->getNameInDocument()) + ":" + subName).c_str()); } +void TaskFemConstraint::createDeleteAction(QListWidget* parentList) +{ + // creates a context menu, a shortcutt for it and connects it to e slot function + + deleteAction = new QAction(tr("Delete"), this); + deleteAction->setShortcut(QKeySequence::Delete); +#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) + // display shortcut behind the context menu entry + deleteAction->setShortcutVisibleInContextMenu(true); +#endif + parentList->addAction(deleteAction); + parentList->setContextMenuPolicy(Qt::ActionsContextMenu); +} + +bool TaskFemConstraint::KeyEvent(QEvent *e) +{ + // in case another instance takes key events, accept the overridden key even + if (e && e->type() == QEvent::ShortcutOverride) { + QKeyEvent * kevent = static_cast(e); + if (kevent->modifiers() == Qt::NoModifier) { + if (kevent->key() == Qt::Key_Delete) { + kevent->accept(); + return true; + } + } + } + // if we have a Del key, trigger the deleteAction + else if (e && e->type() == QEvent::KeyPress) { + QKeyEvent * kevent = static_cast(e); + if (kevent->key() == Qt::Key_Delete) { + if (deleteAction->isEnabled()) + deleteAction->trigger(); + return true; + } + } + + return TaskFemConstraint::event(e); +} + //************************************************************************** //************************************************************************** // TaskDialog diff --git a/src/Mod/Fem/Gui/TaskFemConstraint.h b/src/Mod/Fem/Gui/TaskFemConstraint.h index 936c397600..f761e2e59b 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraint.h +++ b/src/Mod/Fem/Gui/TaskFemConstraint.h @@ -31,6 +31,9 @@ #include "ViewProviderFemConstraint.h" +class QAction; +class QListWidget; + namespace FemGui { class TaskFemConstraint : public Gui::TaskView::TaskBox, public Gui::SelectionObserver @@ -56,12 +59,15 @@ protected: virtual void changeEvent(QEvent *e) { TaskBox::changeEvent(e); } const QString makeRefText(const App::DocumentObject* obj, const std::string& subName) const; virtual void keyPressEvent(QKeyEvent * ke); + void createDeleteAction(QListWidget* parentList); + bool KeyEvent(QEvent *e); private: virtual void onSelectionChanged(const Gui::SelectionChanges&) {} protected: QWidget* proxy; + QAction* deleteAction; ViewProviderFemConstraint *ConstraintView; enum {seldir, selref, selloc, selnone} selectionMode; diff --git a/src/Mod/Fem/Gui/TaskFemConstraintBearing.cpp b/src/Mod/Fem/Gui/TaskFemConstraintBearing.cpp index ca432c7d04..61b4bf5c50 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintBearing.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintBearing.cpp @@ -27,10 +27,11 @@ #ifndef _PreComp_ # include +# include +# include +# include # include # include -# include -# include # include # include @@ -76,12 +77,9 @@ TaskFemConstraintBearing::TaskFemConstraintBearing(ViewProviderFemConstraint *Co ui->setupUi(proxy); QMetaObject::connectSlotsByName(this); - // Create a context menu for the listview of the references - QAction* action = new QAction(tr("Delete"), ui->listReferences); - action->connect(action, SIGNAL(triggered()), - this, SLOT(onReferenceDeleted())); - ui->listReferences->addAction(action); - ui->listReferences->setContextMenuPolicy(Qt::ActionsContextMenu); + // create a context menu for the listview of the references + createDeleteAction(ui->listReferences); + deleteAction->connect(deleteAction, SIGNAL(triggered()), this, SLOT(onReferenceDeleted())); connect(ui->spinDistance, SIGNAL(valueChanged(double)), this, SLOT(onDistanceChanged(double))); @@ -302,6 +300,11 @@ TaskFemConstraintBearing::~TaskFemConstraintBearing() delete ui; } +bool TaskFemConstraintBearing::event(QEvent *e) +{ + return TaskFemConstraint::KeyEvent(e); +} + void TaskFemConstraintBearing::changeEvent(QEvent *e) { TaskBox::changeEvent(e); diff --git a/src/Mod/Fem/Gui/TaskFemConstraintBearing.h b/src/Mod/Fem/Gui/TaskFemConstraintBearing.h index 5f0b7b4f36..fff4b3833b 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintBearing.h +++ b/src/Mod/Fem/Gui/TaskFemConstraintBearing.h @@ -32,6 +32,8 @@ #include "TaskFemConstraint.h" #include "ViewProviderFemConstraintBearing.h" +#include + class Ui_TaskFemConstraintBearing; namespace App { @@ -66,6 +68,7 @@ private Q_SLOTS: void onCheckAxial(bool); protected: + bool event(QEvent *e); virtual void changeEvent(QEvent *e); virtual void onSelectionChanged(const Gui::SelectionChanges& msg); diff --git a/src/Mod/Fem/Gui/TaskFemConstraintDisplacement.cpp b/src/Mod/Fem/Gui/TaskFemConstraintDisplacement.cpp index cfb16d9d81..d70e510b6e 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintDisplacement.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintDisplacement.cpp @@ -31,10 +31,13 @@ # include # include # include -# include + # include +# include +# include # include # include + # include # include # include @@ -67,10 +70,9 @@ TaskFemConstraintDisplacement::TaskFemConstraintDisplacement(ViewProviderFemCons ui->setupUi(proxy); QMetaObject::connectSlotsByName(this); - QAction* action = new QAction(tr("Delete"), ui->lw_references); - action->connect(action, SIGNAL(triggered()), this, SLOT(onReferenceDeleted())); - ui->lw_references->addAction(action); - ui->lw_references->setContextMenuPolicy(Qt::ActionsContextMenu); + // create a context menu for the listview of the references + createDeleteAction(ui->lw_references); + deleteAction->connect(deleteAction, SIGNAL(triggered()), this, SLOT(onReferenceDeleted())); connect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(setSelection(QListWidgetItem*))); @@ -575,6 +577,11 @@ bool TaskFemConstraintDisplacement::get_rotyfree() const{return ui->rotyfree->is bool TaskFemConstraintDisplacement::get_rotzfix() const{return ui->rotzfix->isChecked();} bool TaskFemConstraintDisplacement::get_rotzfree() const{return ui->rotzfree->isChecked();} +bool TaskFemConstraintDisplacement::event(QEvent *e) +{ + return TaskFemConstraint::KeyEvent(e); +} + void TaskFemConstraintDisplacement::changeEvent(QEvent *) { // TaskBox::changeEvent(e); diff --git a/src/Mod/Fem/Gui/TaskFemConstraintDisplacement.h b/src/Mod/Fem/Gui/TaskFemConstraintDisplacement.h index 48f7eb2577..6794ca9d88 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintDisplacement.h +++ b/src/Mod/Fem/Gui/TaskFemConstraintDisplacement.h @@ -38,6 +38,7 @@ #include #include #include +#include #include class Ui_TaskFemConstraintDisplacement; @@ -48,7 +49,7 @@ class TaskFemConstraintDisplacement : public TaskFemConstraint Q_OBJECT public: - TaskFemConstraintDisplacement(ViewProviderFemConstraintDisplacement *ConstraintView,QWidget *parent = 0); + TaskFemConstraintDisplacement(ViewProviderFemConstraintDisplacement *ConstraintView, QWidget *parent = 0); ~TaskFemConstraintDisplacement(); const std::string getReferences() const; double get_spinxDisplacement()const; @@ -96,10 +97,10 @@ private Q_SLOTS: void setSelection(QListWidgetItem* item); protected: + bool event(QEvent *e); void changeEvent(QEvent *e); private: - //void onSelectionChanged(const Gui::SelectionChanges& msg); void updateUI(); Ui_TaskFemConstraintDisplacement* ui; diff --git a/src/Mod/Fem/Gui/TaskFemConstraintFixed.cpp b/src/Mod/Fem/Gui/TaskFemConstraintFixed.cpp index e18d84f6ce..1cf997236f 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintFixed.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintFixed.cpp @@ -29,10 +29,13 @@ # include # include # include -# include + # include +# include +# include # include # include + # include # include # include @@ -45,9 +48,6 @@ #include "ui_TaskFemConstraintFixed.h" #include #include - - - #include #include @@ -65,10 +65,9 @@ TaskFemConstraintFixed::TaskFemConstraintFixed(ViewProviderFemConstraintFixed *C ui->setupUi(proxy); QMetaObject::connectSlotsByName(this); - QAction* action = new QAction(tr("Delete"), ui->lw_references); - action->connect(action, SIGNAL(triggered()), this, SLOT(onReferenceDeleted())); - ui->lw_references->addAction(action); - ui->lw_references->setContextMenuPolicy(Qt::ActionsContextMenu); + // create a context menu for the listview of the references + createDeleteAction(ui->lw_references); + deleteAction->connect(deleteAction, SIGNAL(triggered()), this, SLOT(onReferenceDeleted())); connect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(setSelection(QListWidgetItem*))); @@ -261,6 +260,10 @@ const std::string TaskFemConstraintFixed::getReferences() const return TaskFemConstraint::getReferences(items); } +bool TaskFemConstraintFixed::event(QEvent *e) +{ + return TaskFemConstraint::KeyEvent(e); +} void TaskFemConstraintFixed::changeEvent(QEvent *) { diff --git a/src/Mod/Fem/Gui/TaskFemConstraintFixed.h b/src/Mod/Fem/Gui/TaskFemConstraintFixed.h index 5e1a696090..705e20cc6a 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintFixed.h +++ b/src/Mod/Fem/Gui/TaskFemConstraintFixed.h @@ -58,10 +58,10 @@ private Q_SLOTS: void setSelection(QListWidgetItem* item); protected: + bool event(QEvent *e); void changeEvent(QEvent *e); private: - //void onSelectionChanged(const Gui::SelectionChanges& msg); void updateUI(); Ui_TaskFemConstraintFixed* ui; diff --git a/src/Mod/Fem/Gui/TaskFemConstraintFluidBoundary.cpp b/src/Mod/Fem/Gui/TaskFemConstraintFluidBoundary.cpp index c895f05724..2c7b64a141 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintFluidBoundary.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintFluidBoundary.cpp @@ -28,10 +28,11 @@ #ifndef _PreComp_ # include +# include +# include +# include # include # include -# include -# include # include # include @@ -139,12 +140,9 @@ TaskFemConstraintFluidBoundary::TaskFemConstraintFluidBoundary(ViewProviderFemCo ui->setupUi(proxy); QMetaObject::connectSlotsByName(this); - // Create a context menu for the listview of the references - QAction* action = new QAction(tr("Delete"), ui->listReferences); - action->connect(action, SIGNAL(triggered()), - this, SLOT(onReferenceDeleted())); - ui->listReferences->addAction(action); - ui->listReferences->setContextMenuPolicy(Qt::ActionsContextMenu); + // create a context menu for the listview of the references + createDeleteAction(ui->listReferences); + deleteAction->connect(deleteAction, SIGNAL(triggered()), this, SLOT(onReferenceDeleted())); connect(ui->comboBoundaryType, SIGNAL(currentIndexChanged(int)), this, SLOT(onBoundaryTypeChanged(void))); @@ -800,6 +798,11 @@ TaskFemConstraintFluidBoundary::~TaskFemConstraintFluidBoundary() delete ui; } +bool TaskFemConstraintFluidBoundary::event(QEvent *e) +{ + return TaskFemConstraint::KeyEvent(e); +} + void TaskFemConstraintFluidBoundary::changeEvent(QEvent *e) { TaskBox::changeEvent(e); diff --git a/src/Mod/Fem/Gui/TaskFemConstraintFluidBoundary.h b/src/Mod/Fem/Gui/TaskFemConstraintFluidBoundary.h index 033e5f082d..54cc9ebf2e 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintFluidBoundary.h +++ b/src/Mod/Fem/Gui/TaskFemConstraintFluidBoundary.h @@ -33,6 +33,8 @@ #include "TaskFemConstraint.h" #include "ViewProviderFemConstraintFluidBoundary.h" +#include + class Ui_TaskFemConstraintFluidBoundary; namespace App { @@ -86,6 +88,7 @@ private Q_SLOTS: void onCheckReverse(bool); // consider removing this slot as the UI is hidden protected: + bool event(QEvent *e); virtual void changeEvent(QEvent *e); private: diff --git a/src/Mod/Fem/Gui/TaskFemConstraintForce.cpp b/src/Mod/Fem/Gui/TaskFemConstraintForce.cpp index 6a640bcc78..de12d638ca 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintForce.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintForce.cpp @@ -27,10 +27,11 @@ #ifndef _PreComp_ # include +# include +# include +# include # include # include -# include -# include # include # include @@ -75,12 +76,9 @@ TaskFemConstraintForce::TaskFemConstraintForce(ViewProviderFemConstraintForce *C ui->setupUi(proxy); QMetaObject::connectSlotsByName(this); - // Create a context menu for the listview of the references - QAction* action = new QAction(tr("Delete"), ui->listReferences); - action->connect(action, SIGNAL(triggered()), - this, SLOT(onReferenceDeleted())); - ui->listReferences->addAction(action); - ui->listReferences->setContextMenuPolicy(Qt::ActionsContextMenu); + // create a context menu for the listview of the references + createDeleteAction(ui->listReferences); + deleteAction->connect(deleteAction, SIGNAL(triggered()), this, SLOT(onReferenceDeleted())); connect(ui->spinForce, SIGNAL(valueChanged(double)), this, SLOT(onForceChanged(double))); @@ -314,6 +312,11 @@ TaskFemConstraintForce::~TaskFemConstraintForce() delete ui; } +bool TaskFemConstraintForce::event(QEvent *e) +{ + return TaskFemConstraint::KeyEvent(e); +} + void TaskFemConstraintForce::changeEvent(QEvent *e) { TaskBox::changeEvent(e); diff --git a/src/Mod/Fem/Gui/TaskFemConstraintForce.h b/src/Mod/Fem/Gui/TaskFemConstraintForce.h index 8c741b150b..42ac2fd52f 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintForce.h +++ b/src/Mod/Fem/Gui/TaskFemConstraintForce.h @@ -32,6 +32,8 @@ #include "TaskFemConstraint.h" #include "ViewProviderFemConstraintForce.h" +#include + class Ui_TaskFemConstraintForce; namespace App { @@ -65,6 +67,7 @@ private Q_SLOTS: void onCheckReverse(bool); protected: + bool event(QEvent *e); virtual void changeEvent(QEvent *e); private: diff --git a/src/Mod/Fem/Gui/TaskFemConstraintHeatflux.cpp b/src/Mod/Fem/Gui/TaskFemConstraintHeatflux.cpp index f3fbf37ee6..cf30e2b5d8 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintHeatflux.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintHeatflux.cpp @@ -36,8 +36,9 @@ # include # include -# include # include +# include +# include # include # include @@ -63,10 +64,9 @@ TaskFemConstraintHeatflux::TaskFemConstraintHeatflux(ViewProviderFemConstraintHe ui->setupUi(proxy); QMetaObject::connectSlotsByName(this); - QAction* action = new QAction(tr("Delete"), ui->lw_references); - action->connect(action, SIGNAL(triggered()), this, SLOT(onReferenceDeleted())); - ui->lw_references->addAction(action); - ui->lw_references->setContextMenuPolicy(Qt::ActionsContextMenu); + // create a context menu for the listview of the references + createDeleteAction(ui->lw_references); + deleteAction->connect(deleteAction, SIGNAL(triggered()), this, SLOT(onReferenceDeleted())); connect(ui->rb_convection, SIGNAL(clicked(bool)), this, SLOT(Conv())); connect(ui->rb_dflux, SIGNAL(clicked(bool)), this, SLOT(Flux())); @@ -388,6 +388,11 @@ std::string TaskFemConstraintHeatflux::get_constraint_type(void) const { return type; } +bool TaskFemConstraintHeatflux::event(QEvent *e) +{ + return TaskFemConstraint::KeyEvent(e); +} + void TaskFemConstraintHeatflux::changeEvent(QEvent *e) { TaskBox::changeEvent(e); diff --git a/src/Mod/Fem/Gui/TaskFemConstraintHeatflux.h b/src/Mod/Fem/Gui/TaskFemConstraintHeatflux.h index 4d0e0d46a1..2cf62cf802 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintHeatflux.h +++ b/src/Mod/Fem/Gui/TaskFemConstraintHeatflux.h @@ -38,6 +38,7 @@ #include #include #include +#include #include class Ui_TaskFemConstraintHeatflux; @@ -69,10 +70,10 @@ private Q_SLOTS: void setSelection(QListWidgetItem* item); protected: + bool event(QEvent *e); virtual void changeEvent(QEvent *e); private: - //void onSelectionChanged(const Gui::SelectionChanges& msg); void updateUI(); Ui_TaskFemConstraintHeatflux* ui; }; diff --git a/src/Mod/Fem/Gui/TaskFemConstraintPlaneRotation.cpp b/src/Mod/Fem/Gui/TaskFemConstraintPlaneRotation.cpp index de30cd75fc..aab8837566 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintPlaneRotation.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintPlaneRotation.cpp @@ -28,10 +28,11 @@ #ifndef _PreComp_ # include +# include +# include +# include # include # include -# include -# include # include # include @@ -76,10 +77,9 @@ TaskFemConstraintPlaneRotation::TaskFemConstraintPlaneRotation(ViewProviderFemCo ui->setupUi(proxy); QMetaObject::connectSlotsByName(this); - QAction* action = new QAction(tr("Delete"), ui->lw_references); - action->connect(action, SIGNAL(triggered()), this, SLOT(onReferenceDeleted())); - ui->lw_references->addAction(action); - ui->lw_references->setContextMenuPolicy(Qt::ActionsContextMenu); + // create a context menu for the listview of the references + createDeleteAction(ui->lw_references); + deleteAction->connect(deleteAction, SIGNAL(triggered()), this, SLOT(onReferenceDeleted())); connect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(setSelection(QListWidgetItem*))); @@ -283,6 +283,10 @@ const std::string TaskFemConstraintPlaneRotation::getReferences() const return TaskFemConstraint::getReferences(items); } +bool TaskFemConstraintPlaneRotation::event(QEvent *e) +{ + return TaskFemConstraint::KeyEvent(e); +} void TaskFemConstraintPlaneRotation::changeEvent(QEvent *) { diff --git a/src/Mod/Fem/Gui/TaskFemConstraintPlaneRotation.h b/src/Mod/Fem/Gui/TaskFemConstraintPlaneRotation.h index 4f259822ef..106df6a511 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintPlaneRotation.h +++ b/src/Mod/Fem/Gui/TaskFemConstraintPlaneRotation.h @@ -38,6 +38,7 @@ #include #include #include +#include #include class Ui_TaskFemConstraintPlaneRotation; @@ -60,10 +61,10 @@ private Q_SLOTS: void setSelection(QListWidgetItem* item); protected: + bool event(QEvent *e); void changeEvent(QEvent *e); private: - //void onSelectionChanged(const Gui::SelectionChanges& msg); void updateUI(); Ui_TaskFemConstraintPlaneRotation* ui; diff --git a/src/Mod/Fem/Gui/TaskFemConstraintPressure.cpp b/src/Mod/Fem/Gui/TaskFemConstraintPressure.cpp index 864d8f56f6..49e98ab26f 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintPressure.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintPressure.cpp @@ -33,9 +33,9 @@ # include # include # include - -# include # include +# include +# include # include # include @@ -67,10 +67,9 @@ TaskFemConstraintPressure::TaskFemConstraintPressure(ViewProviderFemConstraintPr ui->setupUi(proxy); QMetaObject::connectSlotsByName(this); - QAction* action = new QAction(tr("Delete"), ui->lw_references); - action->connect(action, SIGNAL(triggered()), this, SLOT(onReferenceDeleted())); - ui->lw_references->addAction(action); - ui->lw_references->setContextMenuPolicy(Qt::ActionsContextMenu); + // create a context menu for the listview of the references + createDeleteAction(ui->lw_references); + deleteAction->connect(deleteAction, SIGNAL(triggered()), this, SLOT(onReferenceDeleted())); connect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(setSelection(QListWidgetItem*))); @@ -281,7 +280,11 @@ bool TaskFemConstraintPressure::get_Reverse() const { return ui->checkBoxReverse->isChecked(); } -/* */ + +bool TaskFemConstraintPressure::event(QEvent *e) +{ + return TaskFemConstraint::KeyEvent(e); +} void TaskFemConstraintPressure::changeEvent(QEvent *) { diff --git a/src/Mod/Fem/Gui/TaskFemConstraintPressure.h b/src/Mod/Fem/Gui/TaskFemConstraintPressure.h index 0856154509..0793ca74c4 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintPressure.h +++ b/src/Mod/Fem/Gui/TaskFemConstraintPressure.h @@ -38,6 +38,7 @@ #include #include #include +#include #include class Ui_TaskFemConstraintPressure; @@ -63,10 +64,10 @@ private Q_SLOTS: void setSelection(QListWidgetItem* item); protected: + bool event(QEvent *e); void changeEvent(QEvent *e); private: - //void onSelectionChanged(const Gui::SelectionChanges& msg); void updateUI(); Ui_TaskFemConstraintPressure* ui; diff --git a/src/Mod/Fem/Gui/TaskFemConstraintTemperature.cpp b/src/Mod/Fem/Gui/TaskFemConstraintTemperature.cpp index 2cca083da8..838411b639 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintTemperature.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintTemperature.cpp @@ -37,9 +37,9 @@ # include # include - -# include # include +# include +# include # include # include #endif @@ -69,10 +69,9 @@ TaskFemConstraintTemperature::TaskFemConstraintTemperature(ViewProviderFemConstr ui->setupUi(proxy); QMetaObject::connectSlotsByName(this); - QAction* action = new QAction(tr("Delete"), ui->lw_references); - action->connect(action, SIGNAL(triggered()), this, SLOT(onReferenceDeleted())); - ui->lw_references->addAction(action); - ui->lw_references->setContextMenuPolicy(Qt::ActionsContextMenu); + // create a context menu for the listview of the references + createDeleteAction(ui->lw_references); + deleteAction->connect(deleteAction, SIGNAL(triggered()), this, SLOT(onReferenceDeleted())); connect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(setSelection(QListWidgetItem*))); @@ -330,6 +329,11 @@ std::string TaskFemConstraintTemperature::get_constraint_type(void) const { return type; } +bool TaskFemConstraintTemperature::event(QEvent *e) +{ + return TaskFemConstraint::KeyEvent(e); +} + void TaskFemConstraintTemperature::changeEvent(QEvent *) { // TaskBox::changeEvent(e); diff --git a/src/Mod/Fem/Gui/TaskFemConstraintTemperature.h b/src/Mod/Fem/Gui/TaskFemConstraintTemperature.h index f7aa7e47a3..14cd10dc90 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintTemperature.h +++ b/src/Mod/Fem/Gui/TaskFemConstraintTemperature.h @@ -38,6 +38,7 @@ #include #include #include +#include #include class Ui_TaskFemConstraintTemperature; @@ -65,10 +66,10 @@ private Q_SLOTS: void setSelection(QListWidgetItem* item); protected: + bool event(QEvent *e); void changeEvent(QEvent *e); private: - //void onSelectionChanged(const Gui::SelectionChanges& msg); void updateUI(); Ui_TaskFemConstraintTemperature* ui; diff --git a/src/Mod/Fem/Gui/TaskFemConstraintTransform.cpp b/src/Mod/Fem/Gui/TaskFemConstraintTransform.cpp index fc5d41f9df..e3d2da22ba 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintTransform.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintTransform.cpp @@ -36,9 +36,9 @@ # include # include # include - -# include # include +# include +# include # include # include @@ -73,10 +73,9 @@ TaskFemConstraintTransform::TaskFemConstraintTransform(ViewProviderFemConstraint ui->setupUi(proxy); QMetaObject::connectSlotsByName(this); - QAction* actionRect = new QAction(tr("Delete"), ui->lw_Rect); - actionRect->connect(actionRect, SIGNAL(triggered()), this, SLOT(onReferenceDeleted())); - ui->lw_Rect->addAction(actionRect); - ui->lw_Rect->setContextMenuPolicy(Qt::ActionsContextMenu); + // create a context menu for the listview of the references + createDeleteAction(ui->lw_Rect); + deleteAction->connect(deleteAction, SIGNAL(triggered()), this, SLOT(onReferenceDeleted())); connect(ui->lw_Rect, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(setSelection(QListWidgetItem*))); @@ -483,6 +482,11 @@ std::string TaskFemConstraintTransform::get_transform_type(void) const { return transform; } +bool TaskFemConstraintTransform::event(QEvent *e) +{ + return TaskFemConstraint::KeyEvent(e); +} + void TaskFemConstraintTransform::changeEvent(QEvent *){ } diff --git a/src/Mod/Fem/Gui/TaskFemConstraintTransform.h b/src/Mod/Fem/Gui/TaskFemConstraintTransform.h index 83ef193148..31d0340e91 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintTransform.h +++ b/src/Mod/Fem/Gui/TaskFemConstraintTransform.h @@ -38,6 +38,7 @@ #include #include #include +#include #include class Ui_TaskFemConstraintTransform; @@ -69,11 +70,11 @@ private Q_SLOTS: void z_Changed(int z); protected: + bool event(QEvent *e); void changeEvent(QEvent *e); const QString makeText(const App::DocumentObject* obj) const; private: - //void onSelectionChanged(const Gui::SelectionChanges& msg); void updateUI(); Ui_TaskFemConstraintTransform* ui; };