Skip to content

Commit

Permalink
Double click on property name brings up property modify editor.
Browse files Browse the repository at this point in the history
  • Loading branch information
mlampert committed Jan 27, 2021
1 parent eee8d12 commit a405691
Showing 1 changed file with 27 additions and 20 deletions.
47 changes: 27 additions & 20 deletions src/Mod/Path/PathScripts/PathPropertyBagGui.py
Expand Up @@ -268,6 +268,7 @@ def setupUi(self):
self.form.add.clicked.connect(self.propertyAdd)
self.form.remove.clicked.connect(self.propertyRemove)
self.form.modify.clicked.connect(self.propertyModify)
self.form.table.doubleClicked.connect(self.propertyModifyIndex)
self.propertySelected([])

def accept(self):
Expand Down Expand Up @@ -326,6 +327,31 @@ def propertyAdd(self):
if not more:
break

def propertyModifyIndex(self, index):
PathLog.track(index.row(), index.column())
row = index.row()

obj = self.model.item(row, self.ColumnVal).data(Delegate.RoleObject)
nam = self.model.item(row, self.ColumnVal).data(Delegate.RoleProperty)
grp = obj.getGroupOfProperty(nam)
typ = obj.getTypeIdOfProperty(nam)

dialog = PropertyCreate(self.obj, grp, typ, False)
if dialog.exec_(nam):
val = getattr(obj, nam)
obj.removeProperty(nam)
name, info = self.addCustomProperty(self.obj, dialog)
try:
setattr(obj, nam, val)
except:
# this can happen if the old enumeration value doesn't exist anymore
pass
newVal = PathUtil.getPropertyValueString(obj, nam)
self.model.setData(self.model.index(row, self.ColumnVal), newVal, QtCore.Qt.DisplayRole)

#self.model.setData(self.model.index(row, self.ColumnType), info, QtCore.Qt.ToolTipRole)
self.model.setData(self.model.index(row, self.ColumnVal), info, QtCore.Qt.ToolTipRole)

def propertyModify(self):
PathLog.track()
rows = []
Expand All @@ -335,26 +361,7 @@ def propertyModify(self):
continue
rows.append(row)

obj = self.model.item(row, self.ColumnVal).data(Delegate.RoleObject)
nam = self.model.item(row, self.ColumnVal).data(Delegate.RoleProperty)
grp = obj.getGroupOfProperty(nam)
typ = obj.getTypeIdOfProperty(nam)

dialog = PropertyCreate(self.obj, grp, typ, False)
if dialog.exec_(nam):
val = getattr(obj, nam)
obj.removeProperty(nam)
name, info = self.addCustomProperty(self.obj, dialog)
try:
setattr(obj, nam, val)
except:
# this can happen if the old enumeration value doesn't exist anymore
pass
newVal = PathUtil.getPropertyValueString(obj, nam)
self.model.setData(self.model.index(row, self.ColumnVal), newVal, QtCore.Qt.DisplayRole)

#self.model.setData(self.model.index(row, self.ColumnType), info, QtCore.Qt.ToolTipRole)
self.model.setData(self.model.index(row, self.ColumnVal), info, QtCore.Qt.ToolTipRole)
self.propertyModifyIndex(index)


def propertyRemove(self):
Expand Down

0 comments on commit a405691

Please sign in to comment.