improve fillet dialog logic
- now also the case of only one item in the list is handled properly (single-click will highlight it, double-click will show the final fillet)
This commit is contained in:
@@ -101,7 +101,7 @@ TaskChamferParameters::TaskChamferParameters(ViewProviderDressUp *DressUpView, Q
|
||||
connect(action, SIGNAL(triggered()), this, SLOT(onRefDeleted()));
|
||||
ui->listWidgetReferences->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
|
||||
connect(ui->listWidgetReferences, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)),
|
||||
connect(ui->listWidgetReferences, SIGNAL(itemClicked(QListWidgetItem*)),
|
||||
this, SLOT(setSelection(QListWidgetItem*)));
|
||||
connect(ui->listWidgetReferences, SIGNAL(itemDoubleClicked(QListWidgetItem*)),
|
||||
this, SLOT(doubleClicked(QListWidgetItem*)));
|
||||
|
||||
@@ -115,7 +115,7 @@ TaskDraftParameters::TaskDraftParameters(ViewProviderDressUp *DressUpView, QWidg
|
||||
connect(action, SIGNAL(triggered()), this, SLOT(onRefDeleted()));
|
||||
ui->listWidgetReferences->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
|
||||
connect(ui->listWidgetReferences, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)),
|
||||
connect(ui->listWidgetReferences, SIGNAL(itemClicked(QListWidgetItem*)),
|
||||
this, SLOT(setSelection(QListWidgetItem*)));
|
||||
connect(ui->listWidgetReferences, SIGNAL(itemDoubleClicked(QListWidgetItem*)),
|
||||
this, SLOT(doubleClicked(QListWidgetItem*)));
|
||||
|
||||
@@ -156,10 +156,11 @@ void TaskDressUpParameters::onButtonRefRemove(const bool checked)
|
||||
}
|
||||
|
||||
void TaskDressUpParameters::doubleClicked(QListWidgetItem* item) {
|
||||
// executed when the user selected a new item in the list
|
||||
// executed when the user double-clicks on any item in the list
|
||||
// shows the fillets as they are -> useful to switch out of selection mode
|
||||
|
||||
Q_UNUSED(item)
|
||||
wasDoubleClicked = true;
|
||||
|
||||
// assure we are not in selection mode
|
||||
exitSelectionMode();
|
||||
@@ -170,29 +171,42 @@ void TaskDressUpParameters::doubleClicked(QListWidgetItem* item) {
|
||||
// remove any highlights andd selections
|
||||
DressUpView->highlightReferences(false);
|
||||
Gui::Selection().clearSelection();
|
||||
|
||||
// enable next possible single-click event after double-click time passed
|
||||
QTimer::singleShot(QApplication::doubleClickInterval(), this, SLOT(itemClickedTimeout()));
|
||||
}
|
||||
|
||||
void TaskDressUpParameters::setSelection(QListWidgetItem* current) {
|
||||
// executed when the user selected a new item in the list
|
||||
// executed when the user selected an item in the list (but double-clicked it)
|
||||
// highlights the currently selected item
|
||||
|
||||
// name of the item
|
||||
std::string subName = current->text().toStdString();
|
||||
// get the document name
|
||||
std::string docName = DressUpView->getObject()->getDocument()->getName();
|
||||
// get the name of the body we are in
|
||||
Part::BodyBase* body = PartDesign::Body::findBodyOf(DressUpView->getObject());
|
||||
std::string objName = body->getNameInDocument();
|
||||
if (!wasDoubleClicked) {
|
||||
// we treat it as single-click event once the QApplication double-click time is passed
|
||||
QTimer::singleShot(QApplication::doubleClickInterval(), this, SLOT(itemClickedTimeout()));
|
||||
|
||||
// hide fillet to see the original edge
|
||||
// (a fillet creates new edges so that the original one is not available)
|
||||
hideObject();
|
||||
// highlight all objects in the list
|
||||
DressUpView->highlightReferences(true);
|
||||
// clear existing selections
|
||||
Gui::Selection().clearSelection();
|
||||
// highligh the selected item
|
||||
Gui::Selection().addSelection(docName.c_str(), objName.c_str(), subName.c_str(), 0, 0, 0);
|
||||
// name of the item
|
||||
std::string subName = current->text().toStdString();
|
||||
// get the document name
|
||||
std::string docName = DressUpView->getObject()->getDocument()->getName();
|
||||
// get the name of the body we are in
|
||||
Part::BodyBase* body = PartDesign::Body::findBodyOf(DressUpView->getObject());
|
||||
std::string objName = body->getNameInDocument();
|
||||
|
||||
// hide fillet to see the original edge
|
||||
// (a fillet creates new edges so that the original one is not available)
|
||||
hideObject();
|
||||
// highlight all objects in the list
|
||||
DressUpView->highlightReferences(true);
|
||||
// clear existing selections
|
||||
Gui::Selection().clearSelection();
|
||||
// highligh the selected item
|
||||
Gui::Selection().addSelection(docName.c_str(), objName.c_str(), subName.c_str(), 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void TaskDressUpParameters::itemClickedTimeout() {
|
||||
// executed after double-click time passed
|
||||
wasDoubleClicked = false;
|
||||
}
|
||||
|
||||
const std::vector<std::string> TaskDressUpParameters::getReferences() const
|
||||
|
||||
@@ -63,11 +63,13 @@ protected Q_SLOTS:
|
||||
void onButtonRefRemove(const bool checked);
|
||||
void doubleClicked(QListWidgetItem* item);
|
||||
void setSelection(QListWidgetItem* current);
|
||||
void itemClickedTimeout();
|
||||
virtual void onRefDeleted(void) = 0;
|
||||
|
||||
protected:
|
||||
void exitSelectionMode();
|
||||
bool referenceSelected(const Gui::SelectionChanges& msg);
|
||||
bool wasDoubleClicked = false;
|
||||
|
||||
protected:
|
||||
enum selectionModes { none, refAdd, refRemove, plane, line };
|
||||
|
||||
@@ -102,7 +102,7 @@ TaskFilletParameters::TaskFilletParameters(ViewProviderDressUp *DressUpView, QWi
|
||||
connect(deleteAction, SIGNAL(triggered()), this, SLOT(onRefDeleted()));
|
||||
ui->listWidgetReferences->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
|
||||
connect(ui->listWidgetReferences, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)),
|
||||
connect(ui->listWidgetReferences, SIGNAL(itemClicked(QListWidgetItem*)),
|
||||
this, SLOT(setSelection(QListWidgetItem*)));
|
||||
connect(ui->listWidgetReferences, SIGNAL(itemDoubleClicked(QListWidgetItem*)),
|
||||
this, SLOT(doubleClicked(QListWidgetItem*)));
|
||||
|
||||
@@ -117,7 +117,7 @@ TaskThicknessParameters::TaskThicknessParameters(ViewProviderDressUp *DressUpVie
|
||||
connect(action, SIGNAL(triggered()), this, SLOT(onRefDeleted()));
|
||||
ui->listWidgetReferences->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
|
||||
connect(ui->listWidgetReferences, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)),
|
||||
connect(ui->listWidgetReferences, SIGNAL(itemClicked(QListWidgetItem*)),
|
||||
this, SLOT(setSelection(QListWidgetItem*)));
|
||||
connect(ui->listWidgetReferences, SIGNAL(itemDoubleClicked(QListWidgetItem*)),
|
||||
this, SLOT(doubleClicked(QListWidgetItem*)));
|
||||
|
||||
Reference in New Issue
Block a user