From 58397adbf19eb20d1359fa591a147ec7117821e6 Mon Sep 17 00:00:00 2001 From: Colin Noga Date: Wed, 9 Nov 2011 19:00:49 -0600 Subject: KPObjectSelector and everything it needs is all setup. Emits objects as required, and can return an object with currentSelectedObject(). --- src/tileset.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'src/tileset.py') diff --git a/src/tileset.py b/src/tileset.py index b0cb88c..c060f07 100644 --- a/src/tileset.py +++ b/src/tileset.py @@ -187,6 +187,25 @@ class KPGroupModel(QtCore.QAbstractListModel): return self.container.objectCount() + def groupItem(self): + """Returns the group item""" + + return self.container + + + def flags(self, index): + # item = QtCore.QAbstractItemModel.flags(self, index) + + item, depth = self.container.getItem(index.row()) + + if isinstance(item, KPGroupItem): + return Qt.ItemFlags(32) + else: + return Qt.ItemFlags(33) + + return Qt.ItemFlags(33) + + def data(self, index, role=Qt.DisplayRole): # Should return the contents of a row when asked for the index # @@ -261,6 +280,19 @@ class KPGroupItem(object): self.alignment = Qt.AlignCenter + def getGroupList(self, returnList=[], depth=0): + """Gets a list of group names and indices for the sorter menu""" + + returnList.append(((' ' * depth) + self.name, self.startIndex, self.endIndex)) + + depth += 1 + + for group in self.groups: + group.getGroupList(returnList, depth) + + return returnList + + def objectCount(self): ''' Retrieves the total number of items in this group and all it's children ''' @@ -352,6 +384,9 @@ class KPTileset(object): getObjectIcon(KPTileObject, (width, height)) # Returns a render map for the Object at the given size + getModel() + # Returns the tileset's groupModel, which handles groups + overrideTile(Tile Index, QPixmap) # Takes a 24x24 QPixmap and a tile index -- cgit v1.2.3