|
@@ -33,15 +33,15 @@ namespace qtprotobuf {
|
|
|
|
|
|
static const char *PreambleTemplate = "/* This file is autogenerated. DO NOT CHANGE. All changes will be lost */\n\n"
|
|
|
"#pragma once\n\n"
|
|
|
- "#include <QObject>\n";
|
|
|
+ "#include <QObject>\n"
|
|
|
+ "#include <unordered_map>\n\n";
|
|
|
|
|
|
static const char *InternalIncludeTemplate = "#include \"$type_lower$.h\"\n";
|
|
|
static const char *ExternalIncludeTemplate = "#include <$type$>\n";
|
|
|
static const char *ListModelsIncludeTemplate = "\n#include \"listmodels.h\"\n";
|
|
|
static const char *UniversalListModelIncludeTemplate = "\n#include <universallistmodel.h>\n";
|
|
|
|
|
|
-static const char *NamespaceTemplate = "\nnamespace $namespace$\n"
|
|
|
- "{\n";
|
|
|
+static const char *NamespaceTemplate = "\nnamespace $namespace$ {\n";
|
|
|
|
|
|
static const char *ClassDefinitionTemplate = "\nclass $classname$ : public QObject\n"
|
|
|
"{\n"
|
|
@@ -53,10 +53,11 @@ static const char *PublicBlockTemplate = "\npublic:\n";
|
|
|
static const char *EnumDefinitionTemplate = "enum $enum$ {\n";
|
|
|
static const char *EnumFieldTemplate = "$enumvalue$ = $value$,\n";
|
|
|
static const char *ConstructorTemplate = "$classname$(QObject *parent = nullptr) : QObject(parent)\n";
|
|
|
-static const char *CopyConstructorTemplate = "$classname$(const $classname$ &other) {\n";
|
|
|
-static const char *MoveConstructorTemplate = "$classname$(const $classname$ &&other) {\n";
|
|
|
+static const char *CopyConstructorTemplate = "$classname$(const $classname$ &other) : QObject() {\n";
|
|
|
+static const char *MoveConstructorTemplate = "$classname$(const $classname$ &&other) : QObject() {\n";
|
|
|
static const char *CopyFieldTemplate = "m_$property_name$ = other.m_$property_name$;\n";
|
|
|
static const char *AssignmentOperatorTemplate = "$classname$ &operator =(const $classname$ &other) {\n";
|
|
|
+static const char *AssignmentOperatorReturnTemplate = "return *this;\n";
|
|
|
static const char *MoveAssignmentOperatorTemplate = "$classname$ &operator =(const $classname$ &&other) {\n";
|
|
|
static const char *EqualOperatorTemplate = "bool operator ==(const $type$ &other) {\n"
|
|
|
" return ";
|
|
@@ -83,6 +84,11 @@ static const char *SetterTemplateComplexType = "void set$property_name_cap$(cons
|
|
|
static const char *SignalsBlockTemplate = "\nsignals:\n";
|
|
|
static const char *SignalTemplate = "void $property_name$Changed();\n";
|
|
|
|
|
|
+static const char *FieldsOrderingDefinitionContainerTemplate = "static const std::unordered_map<int/*field number*/, int/*property number*/> propertyOrdering;\n";
|
|
|
+
|
|
|
+static const char *FieldsOrderingContainerTemplate = "const std::unordered_map<int, int> $type$::propertyOrdering = {";
|
|
|
+static const char *FieldOrderTemplate = "{$field_number$,$property_number$}";
|
|
|
+
|
|
|
static const char *EnumTemplate = "$type$";
|
|
|
static const char *ModelClassTemplate = "using $type$Model = UniversalListModel<$type$>;\n";
|
|
|
|
|
@@ -101,10 +107,10 @@ static const std::unordered_map<::google::protobuf::FieldDescriptor::Type, std::
|
|
|
{::google::protobuf::FieldDescriptor::TYPE_BOOL, "bool"},
|
|
|
{::google::protobuf::FieldDescriptor::TYPE_STRING, "QString"},
|
|
|
{::google::protobuf::FieldDescriptor::TYPE_GROUP, ""},//Not supported and deprecated in protobuf
|
|
|
-// {FieldDescriptor::TYPE_MESSAGE, ""},//Custom typename
|
|
|
+ // {FieldDescriptor::TYPE_MESSAGE, ""},//Custom typename
|
|
|
{::google::protobuf::FieldDescriptor::TYPE_BYTES, "QByteArray"},
|
|
|
{::google::protobuf::FieldDescriptor::TYPE_UINT32, "int"},//Limited usage see https://doc.qt.io/qt-5/qtqml-typesystem-basictypes.html
|
|
|
-// {FieldDescriptor::TYPE_ENUM, ""},//Custom typename
|
|
|
+ // {FieldDescriptor::TYPE_ENUM, ""},//Custom typename
|
|
|
{::google::protobuf::FieldDescriptor::TYPE_SFIXED32, "int"},
|
|
|
// {FieldDescriptor::TYPE_SFIXED64, "int"},//Not supported see https://doc.qt.io/qt-5/qtqml-typesystem-basictypes.html
|
|
|
{::google::protobuf::FieldDescriptor::TYPE_SINT32, "int"},
|