Can edit paths and changes are updated to model.
This commit is contained in:
parent
4953ee7ea9
commit
6963695cd5
16
mesongui.py
16
mesongui.py
|
@ -30,7 +30,11 @@ class PathModel(QAbstractItemModel):
|
|||
'mandir', 'localedir']
|
||||
|
||||
def flags(self, index):
|
||||
return PyQt5.QtCore.Qt.ItemIsSelectable | PyQt5.QtCore.Qt.ItemIsEnabled
|
||||
if index.column() == 1:
|
||||
editable = PyQt5.QtCore.Qt.ItemIsEditable
|
||||
else:
|
||||
editable= 0
|
||||
return PyQt5.QtCore.Qt.ItemIsSelectable | PyQt5.QtCore.Qt.ItemIsEnabled | editable
|
||||
|
||||
def rowCount(self, index):
|
||||
if index.isValid():
|
||||
|
@ -45,6 +49,16 @@ class PathModel(QAbstractItemModel):
|
|||
return QVariant('Path')
|
||||
return QVariant('Type')
|
||||
|
||||
def setData(self, index, value, role):
|
||||
if role != PyQt5.QtCore.Qt.EditRole:
|
||||
return False
|
||||
row = index.row()
|
||||
column = index.column()
|
||||
s = str(value)
|
||||
setattr(self.coredata, self.attr_name[row], s)
|
||||
self.dataChanged.emit(self.createIndex(row, column), self.createIndex(row, column))
|
||||
return True
|
||||
|
||||
def data(self, index, role):
|
||||
if role != PyQt5.QtCore.Qt.DisplayRole:
|
||||
return QVariant()
|
||||
|
|
Loading…
Reference in New Issue