tools/configcollector.py

changeset 1206
743dc95e0be6
parent 1204
1d25231dd7c9
--- a/tools/configcollector.py	Wed Mar 08 22:09:48 2017 +0200
+++ b/tools/configcollector.py	Wed Mar 08 22:48:43 2017 +0200
@@ -136,7 +136,7 @@
 		write('public:')
 		write('\tvoid initDefaults() override;')
 		for declaration in self.declarations.values():
-			write('\t{type} {readgate}() const;'.format(**declaration))
+			write('\t{type} {readgate}();'.format(**declaration))
 		for declaration in self.declarations.values():
 			write('\tvoid {writegate}({typereference} value);'.format(**declaration))
 		for declaration in filter(lambda declaration: declaration['type'] == 'bool', self.declarations.values()):
@@ -145,34 +145,25 @@
 		write('')
 	
 	def writeSource(self, device, headername):
-		for qttype in self.qtTypes:
+		for qttype in sorted(self.qtTypes):
 			device.write('#include <%s>\n' % qttype)
 		device.write('#include "configuration.h"\n')
 		device.write('void Configuration::initDefaults()\n')
 		device.write('{\n')
 		device.write('\tBaseConfiguration::initDefaults();\n')
 		for declaration in self.declarations.values():
-			device.write('\tm_defaults["{name}"] = QVariant::fromValue<{type}>({default});\n'.format(**declaration))
+			device.write('\tregisterConfigurationEntry("{name}", QVariant::fromValue<{type}>({default}));\n'.format(**declaration))
 		device.write('}\n')
 		for declaration in self.declarations.values():
-			device.write('{type} Configuration::{readgate}() const\n'.format(**declaration))
+			device.write('{type} Configuration::{readgate}()\n'.format(**declaration))
 			device.write('{\n')
-			device.write('\tstatic const QVariant defaultvalue = QVariant::fromValue<{type}>({default});\n'.format(**declaration))
-			device.write('\treturn m_settings->value("{name}", defaultvalue).value<{type}>();\n'.format(**declaration))
+			device.write('\treturn value("{name}").value<{type}>();\n'.format(**declaration))
 			device.write('}\n')
 			device.write('\n')
 		for declaration in self.declarations.values():
 			device.write('void Configuration::{writegate}({typereference} value)\n'.format(**declaration))
 			device.write('{\n')
-			device.write('\tif (value != {readgate}())\n'.format(**declaration))
-			device.write('\t{\n')
-			device.write('\t\tQVariant oldValue = {readgate}();\n'.format(**declaration))
-			device.write('\t\tif(value != {default})\n'.format(**declaration))
-			device.write('\t\t\tm_settings->setValue("{name}", QVariant::fromValue<{type}>(value));\n'.format(**declaration))
-			device.write('\t\telse\n')
-			device.write('\t\t\tm_settings->remove("{name}");\n'.format(**declaration))
-			device.write('\t\temit configurationChanged("{name}", oldValue, value);\n'.format(**declaration))
-			device.write('\t}\n')
+			device.write('\tsetValue("{name}", QVariant::fromValue(value));\n'.format(**declaration))
 			device.write('}\n')
 			device.write('\n')
 		for declaration in filter(lambda declaration: declaration['type'] == 'bool', self.declarations.values()):

mercurial