Gui: [skip ci] add possibility to auto-expand items in property editor
This commit is contained in:
@@ -96,10 +96,12 @@ PropertyView::PropertyView(QWidget *parent)
|
||||
|
||||
propertyEditorView = new Gui::PropertyEditor::PropertyEditor();
|
||||
propertyEditorView->setAutomaticDocumentUpdate(_GetParam()->GetBool("AutoTransactionView", false));
|
||||
propertyEditorView->setAutomaticExpand(_GetParam()->GetBool("AutoExpandView", false));
|
||||
tabs->addTab(propertyEditorView, tr("View"));
|
||||
|
||||
propertyEditorData = new Gui::PropertyEditor::PropertyEditor();
|
||||
propertyEditorData->setAutomaticDocumentUpdate(_GetParam()->GetBool("AutoTransactionData", true));
|
||||
propertyEditorData->setAutomaticExpand(_GetParam()->GetBool("AutoExpandData", false));
|
||||
tabs->addTab(propertyEditorData, tr("Data"));
|
||||
|
||||
int preferredTab = _GetParam()->GetInt("LastTabIndex", 1);
|
||||
|
||||
@@ -51,7 +51,12 @@ FC_LOG_LEVEL_INIT("PropertyView",true,true)
|
||||
using namespace Gui::PropertyEditor;
|
||||
|
||||
PropertyEditor::PropertyEditor(QWidget *parent)
|
||||
: QTreeView(parent), autoupdate(false), committing(false), delaybuild(false), binding(false)
|
||||
: QTreeView(parent)
|
||||
, autoexpand(false)
|
||||
, autoupdate(false)
|
||||
, committing(false)
|
||||
, delaybuild(false)
|
||||
, binding(false)
|
||||
{
|
||||
propertyModel = new PropertyModel(this);
|
||||
setModel(propertyModel);
|
||||
@@ -80,6 +85,16 @@ PropertyEditor::~PropertyEditor()
|
||||
{
|
||||
}
|
||||
|
||||
void PropertyEditor::setAutomaticExpand(bool v)
|
||||
{
|
||||
autoexpand = v;
|
||||
}
|
||||
|
||||
bool PropertyEditor::isAutomaticExpand(bool) const
|
||||
{
|
||||
return autoexpand;
|
||||
}
|
||||
|
||||
void PropertyEditor::setAutomaticDocumentUpdate(bool v)
|
||||
{
|
||||
autoupdate = v;
|
||||
@@ -359,6 +374,9 @@ void PropertyEditor::buildUp(PropertyModel::PropertyList &&props, bool checkDocu
|
||||
propOwners.insert(container);
|
||||
}
|
||||
}
|
||||
|
||||
if (autoexpand)
|
||||
expandAll();
|
||||
}
|
||||
|
||||
void PropertyEditor::updateProperty(const App::Property& prop)
|
||||
@@ -449,6 +467,7 @@ void PropertyEditor::removeProperty(const App::Property& prop)
|
||||
}
|
||||
|
||||
enum MenuAction {
|
||||
MA_AutoExpand,
|
||||
MA_ShowAll,
|
||||
MA_Expression,
|
||||
MA_RemoveProp,
|
||||
@@ -464,6 +483,11 @@ enum MenuAction {
|
||||
|
||||
void PropertyEditor::contextMenuEvent(QContextMenuEvent *) {
|
||||
QMenu menu;
|
||||
QAction *autoExpand = menu.addAction(tr("Auto expand"));
|
||||
autoExpand->setCheckable(true);
|
||||
autoExpand->setChecked(autoexpand);
|
||||
autoExpand->setData(QVariant(MA_AutoExpand));
|
||||
|
||||
QAction *showAll = menu.addAction(tr("Show all"));
|
||||
showAll->setCheckable(true);
|
||||
showAll->setChecked(PropertyView::showAll());
|
||||
@@ -556,6 +580,11 @@ void PropertyEditor::contextMenuEvent(QContextMenuEvent *) {
|
||||
return;
|
||||
|
||||
switch(action->data().toInt()) {
|
||||
case MA_AutoExpand:
|
||||
autoexpand = autoExpand->isChecked();
|
||||
if (autoexpand)
|
||||
expandAll();
|
||||
return;
|
||||
case MA_ShowAll:
|
||||
PropertyView::setShowAll(action->isChecked());
|
||||
return;
|
||||
|
||||
@@ -77,6 +77,8 @@ public:
|
||||
void updateEditorMode(const App::Property&);
|
||||
bool appendProperty(const App::Property&);
|
||||
void removeProperty(const App::Property&);
|
||||
void setAutomaticExpand(bool);
|
||||
bool isAutomaticExpand(bool) const;
|
||||
void setAutomaticDocumentUpdate(bool);
|
||||
bool isAutomaticDocumentUpdate(bool) const;
|
||||
/*! Reset the internal state of the view. */
|
||||
@@ -115,6 +117,7 @@ private:
|
||||
QStringList selectedProperty;
|
||||
PropertyModel::PropertyList propList;
|
||||
std::unordered_set<const App::PropertyContainer*> propOwners;
|
||||
bool autoexpand;
|
||||
bool autoupdate;
|
||||
bool committing;
|
||||
bool delaybuild;
|
||||
|
||||
Reference in New Issue
Block a user