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:
donovaly
2020-02-16 17:46:34 +01:00
committed by wmayer
parent 606606edec
commit 0283cb09fb
6 changed files with 38 additions and 22 deletions

View File

@@ -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