Skip to content

Commit

Permalink
Get ready for QRegion and QFont
Browse files Browse the repository at this point in the history
  • Loading branch information
beckdave committed Apr 23, 2024
1 parent 4538064 commit 0db3f31
Show file tree
Hide file tree
Showing 6 changed files with 181 additions and 48 deletions.
2 changes: 1 addition & 1 deletion inc/finalmq/Qt/qt.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,10 @@ class QtTypeHelper
m_typesToField.emplace("QBitArray", MetaField{MetaTypeId::TYPE_ARRAY_BOOL, "", "", "", 0, {}});
m_typesToField.emplace("QDate", MetaField{MetaTypeId::TYPE_INT64, "", "", "", 0, {}});
m_typesToField.emplace("QTime", MetaField{MetaTypeId::TYPE_UINT32, "", "", "", 0, {}});
// m_typesToField.emplace("QDateTime", MetaField{ MetaTypeId::TYPE_STRUCT, "", "", "", 0, {} });
m_typesToField.emplace("QUrl", MetaField{MetaTypeId::TYPE_BYTES, "", "", "", 0, {"qttype:QUrl,qtcode:bytes"}});
m_typesToField.emplace("QLocale", MetaField{MetaTypeId::TYPE_STRING, "", "", "", 0, {}});
m_typesToField.emplace("QPixmap", MetaField{ MetaTypeId::TYPE_BYTES, "", "", "", 0, {"png:true"} });
m_typesToField.emplace("QSizePolicy", MetaField{ MetaTypeId::TYPE_UINT32, "", "", "", 0, {} });

static const std::string KEY_QTTYPE = "qttype";

Expand Down
81 changes: 80 additions & 1 deletion inc/finalmq/Qt/qtdata.fmq
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,63 @@
{"type":"FmqQIconState","attrs":[],"desc":"","entries":[
{"name":"On", "id":0, "desc":""},
{"name":"Off", "id":1, "desc":""}
]},
{"type":"FmqQtWindowModality","attrs":["qttype:Qt::WindowModality"],"desc":"","entries":[
{"name":"NonModal", "id":0, "desc":""},
{"name":"WindowModal", "id":1, "desc":""},
{"name":"ApplicationModal", "id":2, "desc":""}
]},
{"type":"FmqQFontStyleHint","attrs":["enumbits:8"],"desc":"","entries":[
{"name":"Helvetica", "id":0, "desc":""},
{"name":"Times", "id":1, "desc":""},
{"name":"Courier", "id":2, "desc":""},
{"name":"OldEnglish", "id":3, "desc":""},
{"name":"System", "id":4, "desc":""},
{"name":"AnyStyle", "id":5, "desc":""},
{"name":"Cursive", "id":6, "desc":""},
{"name":"Monospace", "id":7, "desc":""},
{"name":"Fantasy", "id":8, "desc":""}
]},
{"type":"FmqQFontStyleStrategy","attrs":["enumbits:16"],"desc":"","entries":[
{"name":"None", "id":0, "desc":""},
{"name":"PreferDefault", "id":1, "desc":""},
{"name":"PreferBitmap", "id":2, "desc":""},
{"name":"PreferDevice", "id":4, "desc":""},
{"name":"PreferOutline", "id":8, "desc":""},
{"name":"ForceOutline", "id":16, "desc":""},
{"name":"PreferMatch", "id":32, "desc":""},
{"name":"PreferQuality", "id":64, "desc":""},
{"name":"PreferAntialias", "id":128, "desc":""},
{"name":"NoAntialias", "id":256, "desc":""},
{"name":"OpenGLCompatible", "id":512, "desc":""},
{"name":"ForceIntegerMetrics", "id":1024, "desc":""},
{"name":"NoSubpixelAntialias", "id":2048, "desc":""},
{"name":"PreferNoShaping", "id":4096, "desc":""},
{"name":"NoFontMerging", "id":32768, "desc":""}
]},
{"type":"FmqQFontFontBits","attrs":["enumbits:8"],"desc":"","entries":[
{"name":"None", "id":0, "desc":""},
{"name":"Style", "id":1, "desc":""},
{"name":"Underline", "id":2, "desc":""},
{"name":"Overline", "id":64, "desc":""},
{"name":"StrikeOut", "id":4, "desc":""},
{"name":"FixedPitch", "id":8, "desc":""},
{"name":"Kerning", "id":16, "desc":""},
{"name":"StyleOblique", "id":128, "desc":""}
]},
{"type":"FmqQFontExtendedFontBits","attrs":["enumbits:8"],"desc":"","entries":[
{"name":"None", "id":0, "desc":""},
{"name":"IgnorePitch", "id":1, "desc":""},
{"name":"LetterSpacingIsAbsolute", "id":2, "desc":""}
]},
{"type":"FmqQFontHintingPreference","attrs":["enumbits:8"],"desc":"","entries":[
{"name":"PreferDefaultHinting", "id":0, "desc":""},
{"name":"PreferNoHinting", "id":1, "desc":""},
{"name":"PreferVerticalHinting", "id":2, "desc":""},
{"name":"PreferFullHinting", "id":3, "desc":""}
]}


],

"structs":[
Expand Down Expand Up @@ -317,8 +372,32 @@
{"tid":"string", "name":"iconEngineKey", "attrs":["indexmode:mapping,:0,QPixmapIconEngine:1"], "desc":"","flags":["METAFLAG_INDEX"]},
{"tid":"int8[]", "name":"valueNone", "desc":"desc","attrs":["fixedarray:0"],"flags":[]},
{"tid":"struct[]", "type":"FmqQPixmapIconEngine", "name":"qPixmapIconEngine", "desc":"","flags":[]}
]}
]},

{"type":"FmqQRegion","attrs":["qttype:QRegion"],"desc":"","fields":[
{"tid":"int32", "name":"sizeBytes", "attrs":["structabort:0"], "desc":"When you change FmqQRegion, you always have to set this value to [8+16*rects.size()} or to 0, if rects.size() is 0.","flags":[]},
{"tid":"int32", "name":"command", "desc":"When you change FmqQRegion, you have to set this value to 10","flags":[]},
{"tid":"struct[]", "type":"FmqQRect", "name":"rects", "desc":"","flags":[]}
]},

{"type":"FmqQFont","attrs":["qttype:QFont"],"desc":"","fields":[
{"tid":"string", "name":"family", "desc":"","flags":[]},
{"tid":"string", "name":"style", "desc":"","flags":[]},
{"tid":"double", "name":"pointSize", "desc":"","flags":[]},
{"tid":"int32", "name":"pixelSize", "desc":"","flags":[]},
{"tid":"enum", "type":"FmqQFontStyleHint", "name":"styleHint", "desc":"","flags":[]},
{"tid":"uint16", "name":"styleStrategy", "desc":"","flags":[]},
{"tid":"uint8", "name":"dummy", "desc":"","flags":[]},
{"tid":"uint8", "name":"weight", "desc":"","flags":[]},
{"tid":"uint8", "name":"fontBits", "desc":"","flags":[]},
{"tid":"uint16", "name":"stretch", "desc":"","flags":[]},
{"tid":"uint8", "name":"extendedFontBits", "desc":"","flags":[]},
{"tid":"int32", "name":"letterSpacing", "desc":"","flags":[]},
{"tid":"int32", "name":"wordSpacing", "desc":"","flags":[]},
{"tid":"enum", "type":"FmqQFontHintingPreference", "name":"hintingPreference", "desc":"","flags":[]},
{"tid":"uint8", "name":"capital", "desc":"","flags":[]},
{"tid":"string[]", "name":"families", "desc":"","flags":[]}
]}


]
Expand Down
12 changes: 7 additions & 5 deletions inc/finalmq/serialize/ParserAbortAndIndex.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,6 @@ class SYMBOLEXP ParserAbortAndIndex : public IParserVisitor
virtual void enterArrayEnumMove(const MetaField& field, std::vector<std::string>&& value) override;
virtual void enterArrayEnum(const MetaField& field, const std::vector<std::string>& value) override;

void checkIndex(const MetaField& field, std::int64_t value);
void checkIndex(const MetaField& field, const std::string& value);

IParserVisitor* m_visitor;

enum IndexStatus
{
INDEX_NOT_AVAILABLE = -1,
Expand All @@ -125,6 +120,13 @@ class SYMBOLEXP ParserAbortAndIndex : public IParserVisitor
std::int64_t index{ INDEX_NOT_AVAILABLE };
};

void checkIndex(const MetaField& field, std::int64_t value);
void checkIndex(const MetaField& field, const std::string& value);
void checkAbortAndIndex(const MetaField& field, const std::string& value, LevelState& levelState);
void checkAbortAndIndex(const MetaField& field, std::int64_t value, LevelState& levelState);

IParserVisitor* m_visitor;

std::deque<LevelState> m_levelState{};
};

Expand Down
2 changes: 2 additions & 0 deletions inc/finalmq/serializeqt/ParserQt.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ namespace finalmq {
bool parseQVariantHeader(const MetaField& field);
void checkIndex(const MetaField& field, std::int64_t value, std::int64_t& index, std::int64_t& indexOffset);
void checkIndex(const MetaField& field, const std::string& value, std::int64_t& index, std::int64_t& indexOffset);
void checkAbortAndIndex(const MetaField& field, const std::string& value, std::int64_t& index, std::int64_t& indexOffset, bool& abortStruct);
void checkAbortAndIndex(const MetaField& field, std::int64_t value, std::int64_t& index, std::int64_t& indexOffset, bool& abortStruct);
bool getPngSize(std::uint32_t& size);

bool parseSize(const MetaField& field, std::uint32_t& value);
Expand Down
70 changes: 48 additions & 22 deletions src/serialize/ParserAbortAndIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ void ParserAbortAndIndex::enterInt8(const MetaField& field, std::int8_t value)
}

m_visitor->enterInt8(field, value);
checkIndex(field, value);
checkAbortAndIndex(field, value, levelState);
}
void ParserAbortAndIndex::enterUInt8(const MetaField& field, std::uint8_t value)
{
Expand All @@ -202,7 +202,7 @@ void ParserAbortAndIndex::enterUInt8(const MetaField& field, std::uint8_t value)
return;
}
m_visitor->enterUInt8(field, value);
checkIndex(field, value);
checkAbortAndIndex(field, value, levelState);
}
void ParserAbortAndIndex::enterInt16(const MetaField& field, std::int16_t value)
{
Expand All @@ -214,7 +214,7 @@ void ParserAbortAndIndex::enterInt16(const MetaField& field, std::int16_t value)
}

m_visitor->enterInt16(field, value);
checkIndex(field, value);
checkAbortAndIndex(field, value, levelState);
}
void ParserAbortAndIndex::enterUInt16(const MetaField& field, std::uint16_t value)
{
Expand All @@ -226,7 +226,7 @@ void ParserAbortAndIndex::enterUInt16(const MetaField& field, std::uint16_t valu
}

m_visitor->enterUInt16(field, value);
checkIndex(field, value);
checkAbortAndIndex(field, value, levelState);
}
void ParserAbortAndIndex::enterInt32(const MetaField& field, std::int32_t value)
{
Expand All @@ -238,7 +238,7 @@ void ParserAbortAndIndex::enterInt32(const MetaField& field, std::int32_t value)
}

m_visitor->enterInt32(field, value);
checkIndex(field, value);
checkAbortAndIndex(field, value, levelState);
}
void ParserAbortAndIndex::enterUInt32(const MetaField& field, std::uint32_t value)
{
Expand All @@ -250,7 +250,7 @@ void ParserAbortAndIndex::enterUInt32(const MetaField& field, std::uint32_t valu
}

m_visitor->enterUInt32(field, value);
checkIndex(field, value);
checkAbortAndIndex(field, value, levelState);
}
void ParserAbortAndIndex::enterInt64(const MetaField& field, std::int64_t value)
{
Expand All @@ -262,7 +262,7 @@ void ParserAbortAndIndex::enterInt64(const MetaField& field, std::int64_t value)
}

m_visitor->enterInt64(field, value);
checkIndex(field, value);
checkAbortAndIndex(field, value, levelState);
}
void ParserAbortAndIndex::enterUInt64(const MetaField& field, std::uint64_t value)
{
Expand All @@ -274,7 +274,7 @@ void ParserAbortAndIndex::enterUInt64(const MetaField& field, std::uint64_t valu
}

m_visitor->enterUInt64(field, value);
checkIndex(field, value);
checkAbortAndIndex(field, value, levelState);
}
void ParserAbortAndIndex::enterFloat(const MetaField& field, float value)
{
Expand Down Expand Up @@ -319,20 +319,7 @@ void ParserAbortAndIndex::enterString(const MetaField& field, const char* value,
{
strValue = std::string(value, &value[size]);
}
const std::string& valueAbort = field.getProperty(ABORTSTRUCT);
if (!valueAbort.empty())
{
std::vector<std::string> valuesAbort;
Utils::split(valueAbort, 0, valueAbort.size(), '|', valuesAbort);
if (std::find(valuesAbort.begin(), valuesAbort.end(), strValue) != valuesAbort.end())
{
levelState.abortStruct = ABORT_FIELD;
}
}
else
{
checkIndex(field, strValue);
}
checkAbortAndIndex(field, strValue, levelState);
}
void ParserAbortAndIndex::enterBytes(const MetaField& field, Bytes&& value)
{
Expand Down Expand Up @@ -851,6 +838,45 @@ void ParserAbortAndIndex::checkIndex(const MetaField& field, const std::string&
}
}

void ParserAbortAndIndex::checkAbortAndIndex(const MetaField& field, const std::string& value, LevelState& levelState)
{
// check abort
const std::string& valueAbort = field.getProperty(ABORTSTRUCT);
if (!valueAbort.empty())
{
std::vector<std::string> valuesAbort;
Utils::split(valueAbort, 0, valueAbort.size(), '|', valuesAbort);
if (std::find(valuesAbort.begin(), valuesAbort.end(), value) != valuesAbort.end())
{
levelState.abortStruct = ABORT_FIELD;
}
}
else
{
checkIndex(field, value);
}
}

void ParserAbortAndIndex::checkAbortAndIndex(const MetaField& field, std::int64_t value, LevelState& levelState)
{
// check abort
std::string strValue;
const std::string& valueAbort = field.getProperty(ABORTSTRUCT);
if (!valueAbort.empty())
{
const std::string strValue = std::to_string(value);
std::vector<std::string> valuesAbort;
Utils::split(valueAbort, 0, valueAbort.size(), '|', valuesAbort);
if (std::find(valuesAbort.begin(), valuesAbort.end(), strValue) != valuesAbort.end())
{
levelState.abortStruct = ABORT_FIELD;
}
}
else
{
checkIndex(field, value);
}
}


} // namespace finalmq
Loading

0 comments on commit 0db3f31

Please sign in to comment.