From 870cf5ad6f121e3a0f69c7f1645dad59eded416b Mon Sep 17 00:00:00 2001 From: Treeki Date: Thu, 3 Nov 2011 05:16:37 +0100 Subject: current broken progress --- src/common.py | 8 ++++++++ src/editorui.py | 3 ++- src/main.py | 27 +++++++++++++++------------ src/mapdata.py | 6 ++++-- src/ui.py | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- 5 files changed, 76 insertions(+), 17 deletions(-) create mode 100644 src/common.py (limited to 'src') diff --git a/src/common.py b/src/common.py new file mode 100644 index 0000000..b106ab5 --- /dev/null +++ b/src/common.py @@ -0,0 +1,8 @@ +import sys +from PyQt4 import QtCore, QtGui +from PyQt4.QtCore import Qt + +from mapdata import * + +from main import KP + diff --git a/src/editorui.py b/src/editorui.py index d53deb7..5055f69 100644 --- a/src/editorui.py +++ b/src/editorui.py @@ -1,4 +1,5 @@ -from PyQt4 import QtCore, QtGui +from common import * + class KPEditorWidget(QtGui.QGraphicsView): pass diff --git a/src/main.py b/src/main.py index ba1ff2c..927c970 100644 --- a/src/main.py +++ b/src/main.py @@ -1,16 +1,19 @@ -from PyQt4 import QtCore, QtGui -import sys - +from common import * from ui import KPMainWindow -def run_koopatlas(): - global Koopatlas - Koopatlas = KPApplication(sys.argv) - Koopatlas.run() +class KP: + @staticmethod + def newMap(): + KP.map = KPMap() + + @staticmethod + def run(): + KP.app = QtGui.QApplication(sys.argv) + + KP.newMap() + + KP.mainWindow = KPMainWindow() + KP.mainWindow.show() -class KPApplication(QtGui.QApplication): - def run(self): - self.mainWindow = KPMainWindow() - self.mainWindow.show() - self.exec_() + KP.app.exec_() diff --git a/src/mapdata.py b/src/mapdata.py index 8ecb33c..b453172 100644 --- a/src/mapdata.py +++ b/src/mapdata.py @@ -25,8 +25,8 @@ class KPPathSegment(object): class KPPath(object): def __init__(self): - self.start_node = None - self.end_node = None + self.startNode = None + self.endNode = None self.segments = [] @@ -44,3 +44,5 @@ class KPMap(object): self.paths = [] self.doodads = [] + self.nextLayerNumber = 1 + diff --git a/src/ui.py b/src/ui.py index 9b5f705..8fafd3b 100644 --- a/src/ui.py +++ b/src/ui.py @@ -1,8 +1,43 @@ -from PyQt4 import QtCore, QtGui - +from common import * from editorui import * +class KPLayerList(QtGui.QWidget): + class LayerModel(QtCore.QAbstractListModel): + def headerData(self, section, orientation, role = Qt.DisplayRole): + return 'Layer' + + def rowCount(self, parent): + print globals().keys() + return len(KP.map.layers) + + def data(self, index, role = Qt.DisplayRole): + try: + if role == Qt.DisplayRole and index.isValid(): + return KP.map.layers[index.row()].name + except IndexError: + pass + + return QVariant() + + + def __init__(self): + QtGui.QWidget.__init__(self) + + self.layout = QtGui.QVBoxLayout() + + self.model = KPLayerList.LayerModel() + + self.listWidget = QtGui.QListView() + self.listWidget.setModel(self.model) + self.layout.addWidget(self.listWidget) + + self.toolbar = QtGui.QToolBar() + self.layout.addWidget(self.toolbar) + + self.setLayout(self.layout) + + class KPMainWindow(QtGui.QMainWindow): def __init__(self): QtGui.QMainWindow.__init__(self) @@ -11,6 +46,8 @@ class KPMainWindow(QtGui.QMainWindow): self.setCentralWidget(self.editor) self.setupMenuBar() + + self.setupDocks() def setupMenuBar(self): @@ -18,6 +55,14 @@ class KPMainWindow(QtGui.QMainWindow): m = mb.addMenu('&File') # ... + + + def setupDocks(self): + self.layerList = KPLayerList() + self.layerListDock = QtGui.QDockWidget('Layers') + self.layerListDock.setWidget(self.layerList) + + self.addDockWidget(Qt.RightDockWidgetArea, self.layerListDock) -- cgit v1.2.3