summaryrefslogtreecommitdiff
path: root/src/mapfile.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/mapfile.py')
-rw-r--r--src/mapfile.py27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/mapfile.py b/src/mapfile.py
index eb05a4a..16d57db 100644
--- a/src/mapfile.py
+++ b/src/mapfile.py
@@ -7,7 +7,7 @@ DUMPABLE_CLASS_NAMES = {}
DUMPABLE_PROXIES = {}
LOADABLE_PROXIES = {}
-def dumpClassAs(cls, name):
+def dumpClassAs(cls, name=None):
def __add_it(function):
DUMPABLE_PROXIES[cls] = (name, function)
return function
@@ -39,7 +39,8 @@ def dump(rootObj):
return piece
dest = dumpFunc(piece)
- dest['_t'] = dumpName
+ if dumpName is not None:
+ dest['_t'] = dumpName
return dest
@@ -94,3 +95,25 @@ def load(string):
return root
+
+
+
+@dumpClassAs(QtGui.QPixmap, 'pixmap')
+def dumpPixmap(pm):
+ buf = QtCore.QBuffer()
+ buf.open(buf.WriteOnly)
+ pm.save(buf, 'PNG')
+ data = str(buf.data())
+ buf.close()
+ return {'png': base64.b64encode(data)}
+
+@loadClassFrom('pixmap')
+def loadPixmap(source):
+ pm = QtGui.QPixmap()
+ pm.loadFromData(base64.b64decode(source['png']), 'PNG')
+ return pm
+
+@dumpClassAs(QtCore.QString)
+def dumpQString(string):
+ return str(string)
+