summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2011-11-03 19:35:50 +0100
committerTreeki <treeki@gmail.com>2011-11-03 19:35:50 +0100
commitfd78999a93710ba53c915779c126e664323a728f (patch)
tree593fb081b9533dff0731baa2e1731354007f7bea /src
parent7635775ee641395eca839bf135ae29fbc2f64b23 (diff)
downloadkoopatlas-fd78999a93710ba53c915779c126e664323a728f.tar.gz
koopatlas-fd78999a93710ba53c915779c126e664323a728f.zip
added stuff preparing for the layer system
Diffstat (limited to '')
-rw-r--r--src/mapdata.py12
-rw-r--r--src/ui.py48
2 files changed, 51 insertions, 9 deletions
diff --git a/src/mapdata.py b/src/mapdata.py
index b453172..2a19da6 100644
--- a/src/mapdata.py
+++ b/src/mapdata.py
@@ -1,7 +1,7 @@
class KPLayer(object):
def __init__(self):
+ self.name = ''
self.tileset = ''
- self.size = (0,0)
self.objects = []
@@ -39,10 +39,16 @@ class KPDoodad(object):
class KPMap(object):
def __init__(self):
- self.layers = []
+ self.nextLayerNumber = 1
+
+ self.layers = [self.createNewLayer() for x in range(4)]
self.nodes = []
self.paths = []
self.doodads = []
- self.nextLayerNumber = 1
+ def createNewLayer(self):
+ layer = KPLayer()
+ layer.name = "Layer %d" % self.nextLayerNumber
+ self.nextLayerNumber += 1
+ return layer
diff --git a/src/ui.py b/src/ui.py
index fdb83f2..95ced0c 100644
--- a/src/ui.py
+++ b/src/ui.py
@@ -4,7 +4,6 @@ from editorui import *
class KPLayerList(QtGui.QWidget):
class LayerModel(QtCore.QAbstractListModel):
-
def headerData(self, section, orientation, role = Qt.DisplayRole):
return 'Layer'
@@ -13,29 +12,66 @@ class KPLayerList(QtGui.QWidget):
def data(self, index, role = Qt.DisplayRole):
try:
- if role == Qt.DisplayRole and index.isValid():
+ if (role == Qt.DisplayRole or role == Qt.EditRole) and index.isValid():
return KP.map.layers[index.row()].name
except IndexError:
pass
- return QVariant()
+ return QtCore.QVariant()
+
+ def flags(self, index):
+ if not index.isValid():
+ return Qt.ItemIsEnabled
+
+ return Qt.ItemIsEditable \
+ | 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:
+ KP.map.layers[index.row()].name = value
+ self.dataChanged.emit(index, index)
+ return True
+
+ return False
def __init__(self):
QtGui.QWidget.__init__(self)
self.layout = QtGui.QVBoxLayout()
+ self.layout.setSpacing(0)
self.model = KPLayerList.LayerModel()
- self.listWidget = QtGui.QListView()
- self.listWidget.setModel(self.model)
- self.layout.addWidget(self.listWidget)
+ self.listView = QtGui.QListView()
+ self.listView.setModel(self.model)
+ self.layout.addWidget(self.listView)
self.toolbar = QtGui.QToolBar()
self.layout.addWidget(self.toolbar)
+ self.setupToolbar(self.toolbar)
+
self.setLayout(self.layout)
+
+
+ def setupToolbar(self, tb):
+ tb.addAction(QtGui.QIcon(), 'Add', self.addLayer)
+ tb.addAction(QtGui.QIcon(), 'Remove', self.removeLayer)
+ tb.addAction(QtGui.QIcon(), 'Move Up', self.moveUp)
+ tb.addAction(QtGui.QIcon(), 'Move Down', self.moveDown)
+
+
+ def addLayer(self):
+ pass
+ def removeLayer(self):
+ pass
+ def moveUp(self):
+ pass
+ def moveDown(self):
+ pass
class KPMainWindow(QtGui.QMainWindow):