enable selection in the dialog item list
now the user can use the Ctrl and/or Shift key to select multiple items to be deleted
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
#ifndef _PreComp_
|
||||
# include <QAction>
|
||||
# include <QKeyEvent>
|
||||
# include <QListWidget>
|
||||
#endif
|
||||
|
||||
#include "ui_TaskFilletParameters.h"
|
||||
@@ -110,6 +111,9 @@ TaskFilletParameters::TaskFilletParameters(ViewProviderDressUp *DressUpView, QWi
|
||||
|
||||
void TaskFilletParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||
{
|
||||
// executed when the user selected something in the CAD object
|
||||
// adds/deletes the selection accordingly
|
||||
|
||||
if (selectionMode == none)
|
||||
return;
|
||||
|
||||
@@ -155,21 +159,40 @@ void TaskFilletParameters::clearButtons(const selectionModes notThis)
|
||||
|
||||
void TaskFilletParameters::onRefDeleted(void)
|
||||
{
|
||||
// get vector of selected objects of active document to assure we have a valid selection
|
||||
std::vector<Gui::SelectionObject> selection = Gui::Selection().getSelectionEx();
|
||||
if (selection.size() == 0) {
|
||||
QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!"));
|
||||
return;
|
||||
}
|
||||
// assure we we are not in selection mode
|
||||
exitSelectionMode();
|
||||
clearButtons(none);
|
||||
// delete any selections since the reference might be highlighted
|
||||
// delete any selections since the reference(s) might be highlighted
|
||||
Gui::Selection().clearSelection();
|
||||
DressUpView->highlightReferences(false);
|
||||
|
||||
PartDesign::Fillet* pcFillet = static_cast<PartDesign::Fillet*>(DressUpView->getObject());
|
||||
App::DocumentObject* base = pcFillet->Base.getValue();
|
||||
std::vector<std::string> refs = pcFillet->Base.getSubValues();
|
||||
refs.erase(refs.begin() + ui->listWidgetReferences->currentRow());
|
||||
setupTransaction();
|
||||
pcFillet->Base.setValue(base, refs);
|
||||
ui->listWidgetReferences->model()->removeRow(ui->listWidgetReferences->currentRow());
|
||||
pcFillet->getDocument()->recomputeFeature(pcFillet);
|
||||
// get the list of items to be deleted
|
||||
QList<QListWidgetItem*> selectedList = ui->listWidgetReferences->selectedItems();
|
||||
|
||||
// delete the selection backwards to assure the list index keeps valid for the deletion
|
||||
for (int i = selectedList.count()-1; i > -1; i--) {
|
||||
//QMessageBox::warning(this, tr("i"), QString::number(i));
|
||||
QListWidgetItem* item = selectedList.at(i);
|
||||
// get the fillet object
|
||||
PartDesign::Fillet* pcFillet = static_cast<PartDesign::Fillet*>(DressUpView->getObject());
|
||||
App::DocumentObject* base = pcFillet->Base.getValue();
|
||||
// get all fillet references
|
||||
std::vector<std::string> refs = pcFillet->Base.getSubValues();
|
||||
// the ref index is the same as the listWidgetReferences index
|
||||
// so we can erase using the row number of the element to be deleted
|
||||
int rowNumber = ui->listWidgetReferences->row(selectedList.at(i));
|
||||
refs.erase(refs.begin() + rowNumber);
|
||||
setupTransaction();
|
||||
pcFillet->Base.setValue(base, refs);
|
||||
ui->listWidgetReferences->model()->removeRow(rowNumber);
|
||||
pcFillet->getDocument()->recomputeFeature(pcFillet);
|
||||
}
|
||||
|
||||
// if there is only one item left, it cannot be deleted
|
||||
if (ui->listWidgetReferences->count() == 1) {
|
||||
|
||||
Reference in New Issue
Block a user