Commit d0c35f98 authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[widgets][editor] Add string getter for editor JSON content

parent 73328f6f
......@@ -23,6 +23,8 @@
# #
###############################################################################
import simplejson as json
from PyQt5.QtCore import pyqtSignal
from PyQt5.QtWidgets import QFormLayout
......@@ -64,10 +66,12 @@ class AbstractAssetEditor(QWidget):
def _load_json(self, json_object):
"""To be implemented by subclass to load their specific JSON parts"""
raise NotImplementedError
def _dump_json(self, json_object):
"""To be implemented by subclass to dump their specific JSON parts"""
raise NotImplementedError
def set_dirty(self):
......@@ -117,11 +121,17 @@ class AbstractAssetEditor(QWidget):
def dump_json(self):
"""Returns the json representation of the asset"""
json_data = {"description": self.description_lineedit.text()}
json_data.update(self._dump_json())
return json_data
def dump_as_string(self):
"""Returns the string representation of this editor json"""
return json.dumps(self.dump_json(), sort_keys=True, indent=4)
class PlaceholderEditor(AbstractAssetEditor):
"""Placeholder widget providing the API of an editor"""
......@@ -138,8 +148,10 @@ class PlaceholderEditor(AbstractAssetEditor):
def _load_json(self, json_object):
"""Re-imp. Does nothing"""
pass
def _dump_json(self):
"""Re-imp. Does nothing"""
return {}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment