Expand/Collapse Property Editor
This commit is contained in:
@@ -52,6 +52,7 @@ using namespace Gui::PropertyEditor;
|
||||
|
||||
PropertyEditor::PropertyEditor(QWidget* parent)
|
||||
: QTreeView(parent)
|
||||
, autocollapse(false)
|
||||
, autoexpand(false)
|
||||
, autoupdate(false)
|
||||
, committing(false)
|
||||
@@ -118,6 +119,14 @@ PropertyEditor::~PropertyEditor()
|
||||
delete f;
|
||||
}
|
||||
|
||||
void PropertyEditor::setAutomaticCollapse(bool v) {
|
||||
autocollapse = v;
|
||||
}
|
||||
|
||||
bool PropertyEditor::isAutomaticCollapse(bool) const {
|
||||
return autocollapse;
|
||||
}
|
||||
|
||||
void PropertyEditor::setAutomaticExpand(bool v)
|
||||
{
|
||||
autoexpand = v;
|
||||
@@ -715,6 +724,10 @@ void PropertyEditor::buildUp(PropertyModel::PropertyList&& props, bool _checkDoc
|
||||
if (autoexpand) {
|
||||
expandAll();
|
||||
}
|
||||
|
||||
if (autocollapse) {
|
||||
collapseAll();
|
||||
}
|
||||
}
|
||||
|
||||
void PropertyEditor::updateProperty(const App::Property& prop)
|
||||
@@ -769,7 +782,10 @@ void PropertyEditor::renameProperty(const App::Property& prop)
|
||||
|
||||
enum MenuAction
|
||||
{
|
||||
MA_AutoCollapse,
|
||||
MA_AutoExpand,
|
||||
MA_CollapseAll,
|
||||
MA_ExpandAll,
|
||||
MA_ShowHidden,
|
||||
MA_Expression,
|
||||
MA_RemoveProp,
|
||||
@@ -841,6 +857,7 @@ void PropertyEditor::contextMenuEvent(QContextMenuEvent*)
|
||||
{
|
||||
QMenu menu;
|
||||
QAction* autoExpand = nullptr;
|
||||
QAction* autoCollapse = nullptr;
|
||||
|
||||
auto contextIndex = currentIndex();
|
||||
|
||||
@@ -904,12 +921,26 @@ void PropertyEditor::contextMenuEvent(QContextMenuEvent*)
|
||||
showHidden->setChecked(PropertyView::showAll());
|
||||
showHidden->setData(QVariant(MA_ShowHidden));
|
||||
|
||||
// auto collapse
|
||||
autoCollapse = menu.addAction(tr("Auto collapse"));
|
||||
autoCollapse->setCheckable(true);
|
||||
autoCollapse->setChecked(autocollapse);
|
||||
autoCollapse->setData(QVariant(MA_AutoCollapse));
|
||||
|
||||
// auto expand
|
||||
autoExpand = menu.addAction(tr("Auto-Expand"));
|
||||
autoExpand->setCheckable(true);
|
||||
autoExpand->setChecked(autoexpand);
|
||||
autoExpand->setData(QVariant(MA_AutoExpand));
|
||||
|
||||
QAction* collapseall = menu.addAction(tr("Collapse all"));
|
||||
collapseall->setData(QVariant(MA_CollapseAll));
|
||||
|
||||
QAction* expandall = menu.addAction(tr("Expand all"));
|
||||
expandall->setData(QVariant(MA_ExpandAll));
|
||||
|
||||
menu.addSeparator();
|
||||
|
||||
// expression
|
||||
if (props.size() == 1) {
|
||||
auto item = static_cast<PropertyItem*>(contextIndex.internalPointer());
|
||||
@@ -969,17 +1000,43 @@ void PropertyEditor::contextMenuEvent(QContextMenuEvent*)
|
||||
}
|
||||
|
||||
switch (action->data().toInt()) {
|
||||
case MA_AutoCollapse:
|
||||
if (autoCollapse) {
|
||||
autocollapse = autoCollapse->isChecked();
|
||||
|
||||
// uncheck auto expand
|
||||
if (autoExpand->isChecked()) {
|
||||
autoexpand = false;
|
||||
}
|
||||
|
||||
if (autocollapse) {
|
||||
collapseAll();
|
||||
}
|
||||
}
|
||||
return;
|
||||
case MA_AutoExpand:
|
||||
if (autoExpand) {
|
||||
// Variable autoExpand should not be null when we arrive here, but
|
||||
// since we explicitly initialize the variable to nullptr, a check
|
||||
// nonetheless.
|
||||
autoexpand = autoExpand->isChecked();
|
||||
|
||||
// uncheck auto collapse
|
||||
if (autoCollapse->isChecked()) {
|
||||
autocollapse = false;
|
||||
}
|
||||
|
||||
if (autoexpand) {
|
||||
expandAll();
|
||||
}
|
||||
}
|
||||
return;
|
||||
case MA_CollapseAll:
|
||||
collapseAll();
|
||||
return;
|
||||
case MA_ExpandAll:
|
||||
expandAll();
|
||||
return;
|
||||
case MA_ShowHidden:
|
||||
PropertyView::setShowAll(action->isChecked());
|
||||
return;
|
||||
|
||||
@@ -79,6 +79,8 @@ public:
|
||||
void updateProperty(const App::Property&);
|
||||
void removeProperty(const App::Property&);
|
||||
void renameProperty(const App::Property&);
|
||||
void setAutomaticCollapse(bool);
|
||||
bool isAutomaticCollapse(bool) const;
|
||||
void setAutomaticExpand(bool);
|
||||
bool isAutomaticExpand(bool) const;
|
||||
void setAutomaticDocumentUpdate(bool);
|
||||
@@ -148,6 +150,7 @@ private:
|
||||
QStringList selectedProperty;
|
||||
PropertyModel::PropertyList propList;
|
||||
std::unordered_set<const App::PropertyContainer*> propOwners;
|
||||
bool autocollapse;
|
||||
bool autoexpand;
|
||||
bool autoupdate;
|
||||
bool committing;
|
||||
|
||||
Reference in New Issue
Block a user