PartDesign: Allow selection of sketch plane by double click in picker dialog

Thanks to @0penBrain for solving a tricky segmentation fault
This commit is contained in:
David Osterberg
2021-01-30 18:24:05 +01:00
committed by wwmayer
parent 09385d9d00
commit c19341b866
2 changed files with 26 additions and 7 deletions

View File

@@ -26,6 +26,7 @@
#ifndef _PreComp_
# include <QListIterator>
# include <QTimer>
# include <QListWidgetItem>
#endif
#include <Gui/Application.h>
@@ -96,6 +97,8 @@ TaskFeaturePick::TaskFeaturePick(std::vector<App::DocumentObject*>& objects,
connect(ui->radioDependent, SIGNAL(toggled(bool)), this, SLOT(onUpdate(bool)));
connect(ui->radioXRef, SIGNAL(toggled(bool)), this, SLOT(onUpdate(bool)));
connect(ui->listWidget, SIGNAL(itemSelectionChanged()), this, SLOT(onItemSelectionChanged()));
connect(ui->listWidget, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(onDoubleClick(QListWidgetItem *)));
enum { axisBit=0, planeBit = 1};
@@ -471,6 +474,18 @@ void TaskFeaturePick::onItemSelectionChanged()
doSelection = false;
}
void TaskFeaturePick::onDoubleClick(QListWidgetItem *item)
{
if (doSelection)
return;
doSelection = true;
QString t = item->data(Qt::UserRole).toString();
Gui::Selection().addSelection(documentName.c_str(), t.toLatin1());
doSelection = false;
QMetaObject::invokeMethod(qobject_cast<Gui::ControlSingleton*>(&Gui::Control()), "accept", Qt::QueuedConnection);
}
void TaskFeaturePick::slotDeletedObject(const Gui::ViewProviderDocumentObject& Obj)
{
std::vector<Gui::ViewProviderOrigin*>::iterator it;
@@ -572,4 +587,5 @@ void TaskDlgFeaturePick::showExternal(bool val)
}
#include "moc_TaskFeaturePick.cpp"

View File

@@ -31,6 +31,7 @@
#include <App/DocumentObject.h>
#include <boost/function.hpp>
#include <QListWidgetItem>
namespace PartDesignGui {
@@ -55,22 +56,23 @@ public:
afterTip
};
TaskFeaturePick(std::vector<App::DocumentObject*> &objects,
TaskFeaturePick(std::vector<App::DocumentObject*> &objects,
const std::vector<featureStatus> &status,
QWidget *parent = 0);
~TaskFeaturePick();
std::vector<App::DocumentObject*> getFeatures();
std::vector<App::DocumentObject*> buildFeatures();
void showExternal(bool val);
static App::DocumentObject* makeCopy(App::DocumentObject* obj, std::string sub, bool independent);
protected Q_SLOTS:
void onUpdate(bool);
void onSelectionChanged(const Gui::SelectionChanges& msg);
void onItemSelectionChanged();
void onDoubleClick(QListWidgetItem *item);
protected:
/** Notifies when the object is about to be removed. */
@@ -117,16 +119,17 @@ public:
virtual bool accept();
/// is called by the framework if the dialog is rejected (Cancel)
virtual bool reject();
/// is called by the framework if the user presses the help button
/// is called by the framework if the user presses the help button
virtual bool isAllowedAlterDocument(void) const
{ return false; }
void showExternal(bool val);
/// returns for Close and Help button
/// returns for Close and Help button
virtual QDialogButtonBox::StandardButtons getStandardButtons(void) const
{ return QDialogButtonBox::Ok|QDialogButtonBox::Cancel; }
protected:
TaskFeaturePick *pick;
bool accepted;