diff options
author | Treeki <treeki@gmail.com> | 2011-11-04 00:18:33 +0100 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2011-11-04 00:18:33 +0100 |
commit | e86dd60fb52a68ef96930bfa4f2632265bf629fa (patch) | |
tree | 91a153c9ca45f716193671b4adf26b98574de970 /src | |
parent | 2015541472eb19b8039e98bfeec3aa5678dd0b75 (diff) | |
download | koopatlas-e86dd60fb52a68ef96930bfa4f2632265bf629fa.tar.gz koopatlas-e86dd60fb52a68ef96930bfa4f2632265bf629fa.zip |
added checks for layer visibility (though they do nothing so far)
Diffstat (limited to '')
-rw-r--r-- | src/mapdata.py | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/src/mapdata.py b/src/mapdata.py index c82021b..5e65599 100644 --- a/src/mapdata.py +++ b/src/mapdata.py @@ -8,6 +8,7 @@ class KPLayer(object): self.name = '' self.tileset = '' self.objects = [] + self.visible = True class KPNodeAction(object): @@ -68,8 +69,14 @@ class KPMap(object): def data(self, index, role = Qt.DisplayRole): try: - if (role == Qt.DisplayRole or role == Qt.EditRole) and index.isValid(): - return self.list[index.row()].name + if index.isValid(): + layer = self.list[index.row()] + + if (role == Qt.DisplayRole or role == Qt.EditRole): + return layer.name + elif role == Qt.CheckStateRole: + return (Qt.Checked if layer.visible else Qt.Unchecked) + except IndexError: pass @@ -79,14 +86,22 @@ class KPMap(object): if not index.isValid(): return Qt.ItemIsEnabled - return Qt.ItemIsEditable \ + return Qt.ItemIsEditable | Qt.ItemIsUserCheckable \ | QtCore.QAbstractListModel.flags(self, index) def setData(self, index, value, role = Qt.EditRole): - if index.isValid() and role == Qt.EditRole: - value = str(value.toString()) - if len(value) > 0: - self.list[index.row()].name = value + if index.isValid(): + layer = self.list[index.row()] + + if role == Qt.EditRole: + value = str(value.toString()) + if len(value) > 0: + layer.name = value + self.dataChanged.emit(index, index) + return True + + elif role == Qt.CheckStateRole: + layer.visible = value.toBool() self.dataChanged.emit(index, index) return True |