summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/tileset.py58
1 files changed, 20 insertions, 38 deletions
diff --git a/src/tileset.py b/src/tileset.py
index 8f7c437..b0cb88c 100644
--- a/src/tileset.py
+++ b/src/tileset.py
@@ -187,7 +187,7 @@ class KPGroupModel(QtCore.QAbstractListModel):
return self.container.objectCount()
- def data(self, index, role=QtCore.Qt.DisplayRole):
+ def data(self, index, role=Qt.DisplayRole):
# Should return the contents of a row when asked for the index
#
# Can be optimized by only dealing with the roles we need prior
@@ -196,11 +196,11 @@ class KPGroupModel(QtCore.QAbstractListModel):
if ((role > 1) and (role < 6)):
return None
- elif (role == QtCore.Qt.ForegroundRole):
- return QtGui.QBrush(QtCore.Qt.black)
+ elif (role == Qt.ForegroundRole):
+ return QtGui.QBrush(Qt.black)
- elif role == QtCore.Qt.TextAlignmentRole:
- return QtCore.Qt.AlignCenter
+ elif role == Qt.TextAlignmentRole:
+ return Qt.AlignCenter
if not index.isValid(): return None
@@ -209,24 +209,21 @@ class KPGroupModel(QtCore.QAbstractListModel):
if n < 0: return None
if n >= self.container.objectCount(): return None
- itemTuple = self.container.getItem(n)
- item = itemTuple[0]
- depth = itemTuple[1]
+ item, depth = self.container.getItem(n)
-
- if role == QtCore.Qt.DecorationRole:
+ if role == Qt.DecorationRole:
if isinstance(item, KPTileObject):
return item.icon
- elif role == QtCore.Qt.DisplayRole:
+ elif role == Qt.DisplayRole:
if isinstance(item, KPGroupItem):
return item.name
- elif (role == QtCore.Qt.SizeHintRole):
+ elif (role == Qt.SizeHintRole):
if isinstance(item, KPGroupItem):
return QtCore.QSize(self.view.viewport().width(), (28 - (depth * 2)))
- elif role == QtCore.Qt.BackgroundRole:
+ elif role == Qt.BackgroundRole:
if isinstance(item, KPGroupItem):
colour = 165 + (depth * 15)
@@ -234,11 +231,11 @@ class KPGroupModel(QtCore.QAbstractListModel):
if colour > 255:
colour = 255
- brush = QtGui.QBrush(QtGui.QColor(colour, colour, colour), QtCore.Qt.Dense4Pattern)
+ brush = QtGui.QBrush(QtGui.QColor(colour, colour, colour), Qt.Dense4Pattern)
return brush
- elif (role == QtCore.Qt.FontRole):
+ elif (role == Qt.FontRole):
font = QtGui.QFont()
font.setPixelSize(20 - (depth * 2))
font.setBold(True)
@@ -261,7 +258,7 @@ class KPGroupItem(object):
self.endIndex = 0
self.name = name
- self.alignment = QtCore.Qt.AlignCenter
+ self.alignment = Qt.AlignCenter
def objectCount(self):
@@ -280,48 +277,33 @@ class KPGroupItem(object):
def getItem(self, index, depth=0):
''' Retrieves an item of a specific index. The index is already checked for validity '''
- # print "{1} looking for item {0}".format(index, self.name)
-
if index == self.startIndex:
- # print "Olook, that's me!"
return self, depth
if (index <= self.startIndex + len(self.objects)):
- # print "Heyho, that's one of my objects!"
- # print len(self.objects)
return self.objects[index - self.startIndex - 1], depth
else:
- # print "I don't have it."
- # print self.groups
-
depth += 1
for group in self.groups:
- # print "Checking {0} - {1}, {2}".format(group.name, group.startIndex, group.endIndex)
if (group.startIndex <= index) and (index <= group.endIndex):
- # print "Looks like it's in {0}".format(group.name)
return group.getItem(index, depth)
- def calculateIndices(self, index):
- print "{0} open[ ".format(self.name)
+ def calculateIndices(self, index):
self.startIndex = index
-
self.endIndex = self.objectCount() + index
- print "\t{0} - {1}".format(self.startIndex, self.endIndex)
- indexAdd = 1
+ start = self.startIndex + len(self.objects) + 1
for group in self.groups:
- print "\t{0}".format(indexAdd)
- group.calculateIndices(self.startIndex + len(self.objects) + indexAdd)
+ group.calculateIndices(start)
+
+ start = group.endIndex + 1
- indexAdd = group.endIndex
- print indexAdd
- print "{0} Close] ".format(self.name)
class KPTileset(object):
@@ -411,7 +393,7 @@ class KPTileset(object):
@staticmethod
def RGB4A3Decode(tex):
dest = QtGui.QImage(1024,512,QtGui.QImage.Format_ARGB32)
- dest.fill(QtCore.Qt.transparent)
+ dest.fill(Qt.transparent)
i = 0
for ytile in xrange(0, 512, 4):
@@ -462,7 +444,7 @@ class KPTileset(object):
row = 0
tex = QtGui.QPixmap(entry[1] * 24, entry[2] * 24)
- tex.fill(QtCore.Qt.transparent)
+ tex.fill(Qt.transparent)
painter = QtGui.QPainter(tex)