Merge pull request #9259 from ronnystandtke/multiselect_hide_in_tree
added support for multi selection when toggling visibility in tree view
This commit is contained in:
@@ -409,10 +409,9 @@ TreeWidget::TreeWidget(const char* name, QWidget* parent)
|
||||
connect(this->showHiddenAction, &QAction::triggered,
|
||||
this, &TreeWidget::onShowHidden);
|
||||
|
||||
this->hideInTreeAction = new QAction(this);
|
||||
this->hideInTreeAction->setCheckable(true);
|
||||
connect(this->hideInTreeAction, &QAction::triggered,
|
||||
this, &TreeWidget::onHideInTree);
|
||||
this->toggleVisibilityInTreeAction = new QAction(this);
|
||||
connect(this->toggleVisibilityInTreeAction, &QAction::triggered,
|
||||
this, &TreeWidget::onToggleVisibilityInTree);
|
||||
|
||||
this->createGroupAction = new QAction(this);
|
||||
connect(this->createGroupAction, &QAction::triggered,
|
||||
@@ -843,9 +842,7 @@ void TreeWidget::contextMenuEvent(QContextMenuEvent* e)
|
||||
|
||||
showHiddenAction->setChecked(doc->ShowHidden.getValue());
|
||||
contextMenu.addAction(this->showHiddenAction);
|
||||
|
||||
hideInTreeAction->setChecked(!objitem->object()->showInTree());
|
||||
contextMenu.addAction(this->hideInTreeAction);
|
||||
contextMenu.addAction(this->toggleVisibilityInTreeAction);
|
||||
|
||||
if (!acrossDocuments) { // is only sensible for selections within one document
|
||||
if (objitem->object()->getObject()->isDerivedFrom(App::DocumentObjectGroup::getClassTypeId()))
|
||||
@@ -2774,11 +2771,11 @@ void TreeWidget::setupText()
|
||||
this->headerItem()->setText(1, tr("Description"));
|
||||
this->rootItem->setText(0, tr("Application"));
|
||||
|
||||
this->showHiddenAction->setText(tr("Show hidden items"));
|
||||
this->showHiddenAction->setStatusTip(tr("Show hidden tree view items"));
|
||||
this->showHiddenAction->setText(tr("Show items hidden in tree view"));
|
||||
this->showHiddenAction->setStatusTip(tr("Show items that are marked as 'hidden' in the tree view"));
|
||||
|
||||
this->hideInTreeAction->setText(tr("Hide item"));
|
||||
this->hideInTreeAction->setStatusTip(tr("Hide the item in tree"));
|
||||
this->toggleVisibilityInTreeAction->setText(tr("Toggle visibility in tree view"));
|
||||
this->toggleVisibilityInTreeAction->setStatusTip(tr("Toggles the visibility of selected items in the tree view"));
|
||||
|
||||
this->createGroupAction->setText(tr("Create group..."));
|
||||
this->createGroupAction->setStatusTip(tr("Create a group"));
|
||||
@@ -2837,11 +2834,28 @@ void TreeWidget::onShowHidden()
|
||||
docItem->setShowHidden(showHiddenAction->isChecked());
|
||||
}
|
||||
|
||||
void TreeWidget::onHideInTree()
|
||||
void TreeWidget::onToggleVisibilityInTree()
|
||||
{
|
||||
if (this->contextItem && this->contextItem->type() == ObjectType) {
|
||||
auto item = static_cast<DocumentObjectItem*>(contextItem);
|
||||
item->object()->ShowInTree.setValue(!hideInTreeAction->isChecked());
|
||||
const auto items = selectedItems();
|
||||
for (auto item : items) {
|
||||
if (item->type() == ObjectType) {
|
||||
auto objectItem = static_cast<DocumentObjectItem*>(item);
|
||||
auto object = objectItem->object();
|
||||
|
||||
// toggle value
|
||||
bool showInTree = !object->showInTree();
|
||||
|
||||
// update object
|
||||
object->ShowInTree.setValue(showInTree);
|
||||
|
||||
// update GUI
|
||||
auto ownerDocument = objectItem->getOwnerDocument();
|
||||
bool hidden = !ownerDocument->showHidden() && !showInTree;
|
||||
objectItem->setHidden(hidden);
|
||||
if (hidden) {
|
||||
objectItem->setSelected(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -157,7 +157,7 @@ protected Q_SLOTS:
|
||||
void onPreSelectTimer();
|
||||
void onSelectTimer();
|
||||
void onShowHidden();
|
||||
void onHideInTree();
|
||||
void onToggleVisibilityInTree();
|
||||
void onSearchObjects();
|
||||
|
||||
private Q_SLOTS:
|
||||
@@ -205,7 +205,7 @@ private:
|
||||
QAction* markRecomputeAction;
|
||||
QAction* recomputeObjectAction;
|
||||
QAction* showHiddenAction;
|
||||
QAction* hideInTreeAction;
|
||||
QAction* toggleVisibilityInTreeAction;
|
||||
QAction* reloadDocAction;
|
||||
QAction* closeDocAction;
|
||||
QAction* searchObjectsAction;
|
||||
|
||||
Reference in New Issue
Block a user