From 6963695cd5fe5feb207b957deaf2135376be6bb9 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Wed, 18 Sep 2013 23:17:05 +0300 Subject: [PATCH] Can edit paths and changes are updated to model. --- mesongui.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/mesongui.py b/mesongui.py index b5a97d6e5..ee3858348 100755 --- a/mesongui.py +++ b/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()