Gui: improve PropertyEditor refresh (#3535)

* Gui: fix PropertyView 'Add property' action

* Gui: fix property view font color for linked property

* Gui: improve PropertyEditor refresh

* Gui: show real property name in property view tool tip

* Gui: improve property view tool tip

* Gui: fix auto recompute in property view

* Gui: remove duplicated PropertyModel signal of dataChanged()

* Gui: fix property view update on property change
Including changes in document properties

* Gui: fix transaction closing on property editor change
On editing row removal and on model reset.

* Gui: fix property view auto expansion of previous selected item

* Gui: improve property editor navigation using tab/shift+tab
This commit is contained in:
Zheng Lei
2022-02-21 19:26:21 +08:00
committed by GitHub
parent 83f0f6c3bb
commit f12ae8a13c
12 changed files with 603 additions and 334 deletions

View File

@@ -95,7 +95,7 @@ Q_DECLARE_METATYPE(Py::Object)
PROPERTYITEM_SOURCE(Gui::PropertyEditor::PropertyItem)
PropertyItem::PropertyItem() : parentItem(0), readonly(false), cleared(false), linked(false)
PropertyItem::PropertyItem() : parentItem(0), readonly(false), linked(false), expanded(false)
{
precision = Base::UnitsApi::getDecimals();
setAutoApply(true);
@@ -255,6 +255,11 @@ void PropertyItem::removeChildren(int from, int to)
}
}
void PropertyItem::moveChild(int from, int to)
{
childItems.move(from, to);
}
/*!
* \brief PropertyItem::takeChild
* Removes the child at index row but doesn't delete it
@@ -305,6 +310,16 @@ bool PropertyItem::isLinked() const
return linked;
}
void PropertyItem::setExpanded(bool enable)
{
expanded = enable;
}
bool PropertyItem::isExpanded() const
{
return expanded;
}
bool PropertyItem::testStatus(App::Property::Status pos) const
{
std::vector<App::Property*>::const_iterator it;
@@ -468,9 +483,15 @@ QString PropertyItem::propertyName() const
return propName;
}
void PropertyItem::setPropertyName(const QString& name)
void PropertyItem::setPropertyName(QString name, QString realName)
{
setObjectName(name);
if(realName.size())
propName = realName;
else
propName = name;
setObjectName(propName);
QString display;
bool upper = false;
for (int i=0; i<name.length(); i++) {
@@ -552,10 +573,10 @@ QVariant PropertyItem::data(int column, int role) const
{
// property name
if (column == 0) {
if (role == Qt::ForegroundRole && linked)
if (role == Qt::TextColorRole && linked)
return QVariant::fromValue(QColor(0x20,0xaa,0x20));
if (role == Qt::BackgroundRole || role == Qt::ForegroundRole) {
if (role == Qt::BackgroundRole || role == Qt::TextColorRole) {
if(PropertyView::showAll()
&& propertyItems.size() == 1
&& propertyItems.front()->testStatus(App::Property::PropDynamic)
@@ -575,11 +596,12 @@ QVariant PropertyItem::data(int column, int role) const
return QVariant();
}
else if (role == Qt::ToolTipRole) {
if(!PropertyView::showAll())
return toolTip(propertyItems[0]);
QString type = QString::fromLatin1("Type: %1").arg(
QString::fromLatin1(propertyItems[0]->getTypeId().getName()));
QString doc = toolTip(propertyItems[0]).toString();
QString type = QString::fromLatin1("Type: %1\nName: %2").arg(
QString::fromLatin1(propertyItems[0]->getTypeId().getName()), objectName());
QString doc = PropertyItem::toolTip(propertyItems[0]).toString();
if(doc.isEmpty())
doc = toolTip(propertyItems[0]).toString();
if(doc.size())
return type + QLatin1String("\n\n") + doc;
return type;
@@ -637,8 +659,6 @@ QVariant PropertyItem::data(int column, int role) const
bool PropertyItem::setData (const QVariant& value)
{
cleared = false;
// This is the basic mechanism to set the value to
// a property and if no property is set for this item
// it delegates it to its parent which sets then the
@@ -4136,6 +4156,9 @@ LinkLabel::LinkLabel (QWidget * parent, const App::Property *prop)
#endif
editButton->setToolTip(tr("Change the linked object"));
layout->addWidget(editButton);
this->setFocusPolicy(Qt::StrongFocus);
this->setFocusProxy(label);
// setLayout(layout);
@@ -4201,7 +4224,7 @@ void LinkLabel::onEditClicked ()
if(!dlg) {
dlg = new DlgPropertyLink(this);
dlg->init(objProp,true);
connect(dlg, SIGNAL(accepted()), this, SLOT(onLinkChanged()));
connect(dlg, SIGNAL(finished(int)), this, SLOT(onLinkChanged()));
} else
dlg->init(objProp,false);
dlg->show();