diff --git a/classes/data/fontdocument.cpp b/classes/data/fontdocument.cpp index 9987925..5a60fe1 100644 --- a/classes/data/fontdocument.cpp +++ b/classes/data/fontdocument.cpp @@ -31,7 +31,7 @@ #include #include #include "datacontainer.h" -#include "tags.h" +#include "tagslist.h" #include "parser.h" #include "dialogfontchanged.h" #include "fonteditoroptions.h" @@ -398,30 +398,30 @@ DataContainer *FontDocument::dataContainer() const QString FontDocument::convert(Preset *preset) { - Parsing::Tags tags; + Parsing::TagsList tags; if (!this->documentFilename().isEmpty()) { - tags.setTagValue(Parsing::Tags::DocumentFilename, this->documentFilename()); + tags.setTagValue(Parsing::TagsList::Tag::DocumentFilename, this->documentFilename()); } else { - tags.setTagValue(Parsing::Tags::DocumentFilename, "unsaved"); + tags.setTagValue(Parsing::TagsList::Tag::DocumentFilename, "unsaved"); } - tags.setTagValue(Parsing::Tags::DocumentName, this->documentName()); - tags.setTagValue(Parsing::Tags::DocumentNameWithoutSpaces, this->documentName().remove(QRegExp("\\W", Qt::CaseInsensitive))); + tags.setTagValue(Parsing::TagsList::Tag::DocumentName, this->documentName()); + tags.setTagValue(Parsing::TagsList::Tag::DocumentNameWithoutSpaces, this->documentName().remove(QRegExp("\\W", Qt::CaseInsensitive))); QString chars; FontParameters parameters; this->fontCharacters(&chars, ¶meters); - tags.setTagValue(Parsing::Tags::DocumentDataType, "font"); - tags.setTagValue(Parsing::Tags::FontFamily, parameters.family); - tags.setTagValue(Parsing::Tags::FontSize, QString("%1").arg(parameters.size)); - tags.setTagValue(Parsing::Tags::FontStyle, parameters.style); - tags.setTagValue(Parsing::Tags::FontString, Parsing::Conversion::FontHelper::escapeControlChars(chars)); - tags.setTagValue(Parsing::Tags::FontAntiAliasing, parameters.antiAliasing ? "yes" : "no"); - tags.setTagValue(Parsing::Tags::FontWidthType, parameters.monospaced ? "monospaced" : "proportional"); - tags.setTagValue(Parsing::Tags::FontAscent, QString("%1").arg(parameters.ascent)); - tags.setTagValue(Parsing::Tags::FontDescent, QString("%1").arg(parameters.descent)); + tags.setTagValue(Parsing::TagsList::Tag::DocumentDataType, "font"); + tags.setTagValue(Parsing::TagsList::Tag::FontFamily, parameters.family); + tags.setTagValue(Parsing::TagsList::Tag::FontSize, QString("%1").arg(parameters.size)); + tags.setTagValue(Parsing::TagsList::Tag::FontStyle, parameters.style); + tags.setTagValue(Parsing::TagsList::Tag::FontString, Parsing::Conversion::FontHelper::escapeControlChars(chars)); + tags.setTagValue(Parsing::TagsList::Tag::FontAntiAliasing, parameters.antiAliasing ? "yes" : "no"); + tags.setTagValue(Parsing::TagsList::Tag::FontWidthType, parameters.monospaced ? "monospaced" : "proportional"); + tags.setTagValue(Parsing::TagsList::Tag::FontAscent, QString("%1").arg(parameters.ascent)); + tags.setTagValue(Parsing::TagsList::Tag::FontDescent, QString("%1").arg(parameters.descent)); const QStringList orderedKeys = this->sortKeysWithEncoding(this->dataContainer()->keys(), preset); @@ -722,7 +722,7 @@ void FontDocument::setDescent(int value) this->mContainer->setCommonInfo("descent", value); } -void FontDocument::prepareImages(Preset *preset, const QStringList &orderedKeys, QMap *images, const Parsing::Tags &tags) const +void FontDocument::prepareImages(Preset *preset, const QStringList &orderedKeys, QMap *images, const Parsing::TagsList &tags) const { DataContainer *data = this->dataContainer(); @@ -755,8 +755,8 @@ void FontDocument::prepareImages(Preset *preset, const QStringList &orderedKeys, if (imageData != nullptr) { QString charCode = this->hexCode(key, encoding, useBom); - imageData->tags()->setTagValue(Parsing::Tags::OutputCharacterCode, charCode); - imageData->tags()->setTagValue(Parsing::Tags::OutputCharacterText, Parsing::Conversion::FontHelper::escapeControlChars(key)); + imageData->tags()->setTagValue(Parsing::TagsList::Tag::OutputCharacterCode, charCode); + imageData->tags()->setTagValue(Parsing::TagsList::Tag::OutputCharacterText, Parsing::Conversion::FontHelper::escapeControlChars(key)); } } } @@ -779,14 +779,14 @@ void FontDocument::prepareImages(Preset *preset, const QStringList &orderedKeys, Parsing::ParsedImageData *similarImageData = similarMap.value(imageData->hash(), nullptr); if (similarImageData != nullptr) { - QString similarCode = similarImageData->tags()->tagValue(Parsing::Tags::OutputCharacterCode); - QString similarText = similarImageData->tags()->tagValue(Parsing::Tags::OutputCharacterText); - imageData->tags()->setTagValue(Parsing::Tags::OutputCharacterCodeSimilar, similarCode); - imageData->tags()->setTagValue(Parsing::Tags::OutputCharacterTextSimilar, similarText); + QString similarCode = similarImageData->tags()->tagValue(Parsing::TagsList::Tag::OutputCharacterCode); + QString similarText = similarImageData->tags()->tagValue(Parsing::TagsList::Tag::OutputCharacterText); + imageData->tags()->setTagValue(Parsing::TagsList::Tag::OutputCharacterCodeSimilar, similarCode); + imageData->tags()->setTagValue(Parsing::TagsList::Tag::OutputCharacterTextSimilar, similarText); } else { similarMap.insert(imageData->hash(), imageData); - imageData->tags()->setTagValue(Parsing::Tags::OutputCharacterCodeSimilar, QString()); - imageData->tags()->setTagValue(Parsing::Tags::OutputCharacterTextSimilar, QString()); + imageData->tags()->setTagValue(Parsing::TagsList::Tag::OutputCharacterCodeSimilar, QString()); + imageData->tags()->setTagValue(Parsing::TagsList::Tag::OutputCharacterTextSimilar, QString()); } } } diff --git a/classes/data/fontdocument.h b/classes/data/fontdocument.h index dffa27e..6812bb4 100644 --- a/classes/data/fontdocument.h +++ b/classes/data/fontdocument.h @@ -31,7 +31,7 @@ class Preset; namespace Parsing { class ParsedImageData; -class Tags; +class TagsList; } namespace Data @@ -103,7 +103,7 @@ private: int descent() const; void setDescent(int value); - void prepareImages(Preset *preset, const QStringList &orderedKeys, QMap *images, const Parsing::Tags &tags) const; + void prepareImages(Preset *preset, const QStringList &orderedKeys, QMap *images, const Parsing::TagsList &tags) const; QString hexCode(const QString &key, const QString &encoding, bool bom) const; const QStringList sortKeysWithEncoding(const QStringList &keys, Preset *preset) const; diff --git a/classes/data/imagedocument.cpp b/classes/data/imagedocument.cpp index 5ed960b..0498663 100644 --- a/classes/data/imagedocument.cpp +++ b/classes/data/imagedocument.cpp @@ -28,7 +28,7 @@ #include #include "datacontainer.h" #include "parser.h" -#include "tags.h" +#include "tagslist.h" #include "statusdata.h" #include "preset.h" #include "parsedimagedata.h" @@ -217,18 +217,18 @@ DataContainer *ImageDocument::dataContainer() const QString ImageDocument::convert(Preset *preset) { - Parsing::Tags tags; + Parsing::TagsList tags; if (!this->documentFilename().isEmpty()) { - tags.setTagValue(Parsing::Tags::DocumentFilename, this->documentFilename()); + tags.setTagValue(Parsing::TagsList::Tag::DocumentFilename, this->documentFilename()); } else { - tags.setTagValue(Parsing::Tags::DocumentFilename, "unsaved"); + tags.setTagValue(Parsing::TagsList::Tag::DocumentFilename, "unsaved"); } - tags.setTagValue(Parsing::Tags::DocumentName, this->documentName()); - tags.setTagValue(Parsing::Tags::DocumentNameWithoutSpaces, this->documentName().remove(QRegExp("\\W", Qt::CaseInsensitive))); + tags.setTagValue(Parsing::TagsList::Tag::DocumentName, this->documentName()); + tags.setTagValue(Parsing::TagsList::Tag::DocumentNameWithoutSpaces, this->documentName().remove(QRegExp("\\W", Qt::CaseInsensitive))); - tags.setTagValue(Parsing::Tags::DocumentDataType, "image"); + tags.setTagValue(Parsing::TagsList::Tag::DocumentDataType, "image"); QMap images; this->prepareImages(preset, &images, tags); @@ -298,7 +298,7 @@ void ImageDocument::setDocumentFilename(const QString &value) } } -void ImageDocument::prepareImages(Preset *preset, QMap *images, const Parsing::Tags &tags) const +void ImageDocument::prepareImages(Preset *preset, QMap *images, const Parsing::TagsList &tags) const { DataContainer *data = this->dataContainer(); diff --git a/classes/data/imagedocument.h b/classes/data/imagedocument.h index ab19384..4bdfd33 100644 --- a/classes/data/imagedocument.h +++ b/classes/data/imagedocument.h @@ -28,7 +28,7 @@ class Preset; namespace Parsing { -class Tags; +class TagsList; class ParsedImageData; } @@ -72,7 +72,7 @@ private: void setDocumentFilename(const QString &value); - void prepareImages(Preset *preset, QMap *images, const Parsing::Tags &tags) const; + void prepareImages(Preset *preset, QMap *images, const Parsing::TagsList &tags) const; private slots: void mon_container_dataChanged(bool historyStateMoved); diff --git a/classes/parser/parsedimagedata.cpp b/classes/parser/parsedimagedata.cpp index 71bdc2a..5bb636c 100644 --- a/classes/parser/parsedimagedata.cpp +++ b/classes/parser/parsedimagedata.cpp @@ -24,7 +24,7 @@ #include #include -#include "tags.h" +#include "tagslist.h" #include "converterhelper.h" #include "preset.h" #include "imageoptions.h" @@ -32,17 +32,17 @@ namespace Parsing { -ParsedImageData::ParsedImageData(Preset *preset, const QImage *image, const Tags &tags, QObject *parent) : +ParsedImageData::ParsedImageData(Preset *preset, const QImage *image, const TagsList &tags, QObject *parent) : QObject(parent) { - this->mTags = new Tags(); + this->mTags = new TagsList(); // width and height must be written before image changes - this->mTags->setTagValue(Tags::OutputImageWidth, QString("%1").arg(image->width())); - this->mTags->setTagValue(Tags::OutputImageHeight, QString("%1").arg(image->height())); + this->mTags->setTagValue(TagsList::Tag::OutputImageWidth, QString("%1").arg(image->width())); + this->mTags->setTagValue(TagsList::Tag::OutputImageHeight, QString("%1").arg(image->height())); // parameters from external code - this->mTags->setTagValue(Tags::OutputDataEOL, tags.tagValue(Tags::OutputDataEOL)); - this->mTags->setTagValue(Tags::OutputDataIndent, tags.tagValue(Tags::OutputDataIndent)); + this->mTags->setTagValue(TagsList::Tag::OutputDataEOL, tags.tagValue(TagsList::Tag::OutputDataEOL)); + this->mTags->setTagValue(TagsList::Tag::OutputDataIndent, tags.tagValue(TagsList::Tag::OutputDataIndent)); QImage imagePrepared; Parsing::Conversion::ConverterHelper::prepareImage(preset, image, &imagePrepared); @@ -87,7 +87,7 @@ ParsedImageData::ParsedImageData(Preset *preset, const QImage *image, const Tags &compressedWidth, &compressedHeight); - this->mTags->setTagValue(Tags::OutputBlocksCount, QString("%1").arg(compressedData.size())); + this->mTags->setTagValue(TagsList::Tag::OutputBlocksCount, QString("%1").arg(compressedData.size())); this->mPreparedOutputImageData = Parsing::Conversion::ConverterHelper::dataToString( preset, @@ -127,10 +127,10 @@ ParsedImageData::ParsedImageData(Preset *preset, const QImage *image, const Tags preset, &previewData, previewWidth, previewHeight); } else { - this->mTags->setTagValue(Tags::OutputImageWidth, QString("0")); - this->mTags->setTagValue(Tags::OutputImageHeight, QString("0")); + this->mTags->setTagValue(TagsList::Tag::OutputImageWidth, QString("0")); + this->mTags->setTagValue(TagsList::Tag::OutputImageHeight, QString("0")); - this->mTags->setTagValue(Tags::OutputBlocksCount, QString("0")); + this->mTags->setTagValue(TagsList::Tag::OutputBlocksCount, QString("0")); this->mPreparedOutputImageData = QString(); // get hash @@ -144,7 +144,7 @@ ParsedImageData::~ParsedImageData() delete this->mTags; } -Tags *ParsedImageData::tags() const +TagsList *ParsedImageData::tags() const { return this->mTags; } @@ -154,17 +154,17 @@ uint ParsedImageData::hash() const return this->mHash; } -const QString ParsedImageData::outputImageDataWithEOL(const Tags &tags) const +const QString ParsedImageData::outputImageDataWithEOL(const TagsList &tags) const { QString result = this->mPreparedOutputImageData; - result.replace("\n", tags.tagValue(Tags::OutputDataEOL) + tags.tagValue(Tags::OutputDataIndent)); + result.replace("\n", tags.tagValue(TagsList::Tag::OutputDataEOL) + tags.tagValue(TagsList::Tag::OutputDataIndent)); return result; } -const QString ParsedImageData::outputImagePreviewWithEOL(const Tags &tags) const +const QString ParsedImageData::outputImagePreviewWithEOL(const TagsList &tags) const { QString result = this->mPreparedOutputImagePreview; - result.replace("\n", tags.tagValue(Tags::OutputPreviewEOL) + tags.tagValue(Tags::OutputPreviewIndent)); + result.replace("\n", tags.tagValue(TagsList::Tag::OutputPreviewEOL) + tags.tagValue(TagsList::Tag::OutputPreviewIndent)); return result; } diff --git a/classes/parser/parsedimagedata.h b/classes/parser/parsedimagedata.h index 5968d62..d02f084 100644 --- a/classes/parser/parsedimagedata.h +++ b/classes/parser/parsedimagedata.h @@ -27,23 +27,23 @@ class Preset; namespace Parsing { -class Tags; +class TagsList; class ParsedImageData : public QObject { Q_OBJECT public: - explicit ParsedImageData(Preset *preset, const QImage *image, const Tags &tags, QObject *parent = 0); + explicit ParsedImageData(Preset *preset, const QImage *image, const TagsList &tags, QObject *parent = 0); virtual ~ParsedImageData(); - Tags *tags() const; + TagsList *tags() const; uint hash() const; - const QString outputImageDataWithEOL(const Tags &tags) const; - const QString outputImagePreviewWithEOL(const Tags &tags) const; + const QString outputImageDataWithEOL(const TagsList &tags) const; + const QString outputImagePreviewWithEOL(const TagsList &tags) const; private: - Tags *mTags; + TagsList *mTags; uint mHash; QString mPreparedOutputImageData; QString mPreparedOutputImagePreview; diff --git a/classes/parser/parser.cpp b/classes/parser/parser.cpp index 986c5a0..9a41ee7 100644 --- a/classes/parser/parser.cpp +++ b/classes/parser/parser.cpp @@ -34,7 +34,7 @@ #include "imageoptions.h" #include "fontoptions.h" #include "templateoptions.h" -#include "tags.h" +#include "tagslist.h" #include "parsedimagedata.h" #include "revisioninfo.h" @@ -123,7 +123,7 @@ Parser::~Parser() { } -QString Parser::convert(Data::Containers::IDocument *document, const QStringList &orderedKeys, QMap *images, Tags &tags) const +QString Parser::convert(Data::Containers::IDocument *document, const QStringList &orderedKeys, QMap *images, TagsList &tags) const { QString result; @@ -141,16 +141,16 @@ QString Parser::convert(Data::Containers::IDocument *document, const QStringList file.close(); } - tags.setTagValue(Tags::TemplateFilename, file.fileName()); + tags.setTagValue(TagsList::Tag::TemplateFilename, file.fileName()); QString prefix, suffix; this->imageDataParticles(templateString, &prefix, &suffix); - tags.setTagValue(Tags::OutputDataIndent, prefix); - tags.setTagValue(Tags::OutputDataEOL, suffix); + tags.setTagValue(TagsList::Tag::OutputDataIndent, prefix); + tags.setTagValue(TagsList::Tag::OutputDataEOL, suffix); this->imagePreviewParticles(templateString, &prefix, &suffix); - tags.setTagValue(Tags::OutputPreviewIndent, prefix); - tags.setTagValue(Tags::OutputPreviewEOL, suffix); + tags.setTagValue(TagsList::Tag::OutputPreviewIndent, prefix); + tags.setTagValue(TagsList::Tag::OutputPreviewEOL, suffix); this->addCommonInfo(tags); this->addMatrixInfo(tags); @@ -162,14 +162,14 @@ QString Parser::convert(Data::Containers::IDocument *document, const QStringList } QString Parser::parse(const QString &templateString, - Tags &tags, + TagsList &tags, Data::Containers::IDocument *doc, const QStringList &orderedKeys, QMap *images) const { QString result; - Tags::TagsEnum tagKey = Tags::Unknown; + TagsList::Tag tagKey = TagsList::Tag::Unknown; int lastIndex = 0, foundIndex = 0, nextIndex = 0; QString content; @@ -179,14 +179,14 @@ QString Parser::parse(const QString &templateString, } switch (tagKey) { - case Tags::BlocksHeaderStart: - case Tags::BlocksFontDefinitionStart: { + case TagsList::Tag::BlocksHeaderStart: + case TagsList::Tag::BlocksFontDefinitionStart: { QString temp = this->parse(content, tags, doc, orderedKeys, images); result.append(temp); break; } - case Tags::BlocksImagesTableStart: { + case TagsList::Tag::BlocksImagesTableStart: { QString temp = this->parseImagesTable(content, tags, doc, orderedKeys, images); result.append(temp); break; @@ -209,7 +209,7 @@ QString Parser::parse(const QString &templateString, } QString Parser::parseImagesTable(const QString &templateString, - Tags &tags, + TagsList &tags, Data::Containers::IDocument *doc, const QStringList &orderedKeys, QMap *images) const @@ -228,9 +228,9 @@ QString Parser::parseImagesTable(const QString &templateString, tags.importValues(data->tags()); if (it.hasNext()) { - tags.setTagValue(Tags::OutputComma, ","); + tags.setTagValue(TagsList::Tag::OutputComma, ","); } else { - tags.setTagValue(Tags::OutputComma, ""); + tags.setTagValue(TagsList::Tag::OutputComma, ""); } QString imageString = this->parse(templateString, tags, doc, orderedKeys, images); @@ -297,99 +297,99 @@ QString Parser::hexCode(const QString &key, const QString &encoding, bool bom) c return result; } -void Parser::addMatrixInfo(Tags &tags) const +void Parser::addMatrixInfo(TagsList &tags) const { // byte order if (this->mPreset->image()->bytesOrder() == Parsing::Conversion::Options::BytesOrder::LittleEndian) { - tags.setTagValue(Tags::ImageByteOrder, "little-endian"); + tags.setTagValue(TagsList::Tag::ImageByteOrder, "little-endian"); } else { - tags.setTagValue(Tags::ImageByteOrder, "big-endian"); + tags.setTagValue(TagsList::Tag::ImageByteOrder, "big-endian"); } // data block size int dataBlockSize = (static_cast(this->mPreset->image()->blockSize()) + 1) * 8; - tags.setTagValue(Tags::ImageBlockSize, QString("%1").arg(dataBlockSize)); + tags.setTagValue(TagsList::Tag::ImageBlockSize, QString("%1").arg(dataBlockSize)); // scan main direction switch (this->mPreset->prepare()->scanMain()) { case Parsing::Conversion::Options::ScanMainDirection::TopToBottom: - tags.setTagValue(Tags::PrepareScanMain, "top_to_bottom"); + tags.setTagValue(TagsList::Tag::PrepareScanMain, "top_to_bottom"); break; case Parsing::Conversion::Options::ScanMainDirection::BottomToTop: - tags.setTagValue(Tags::PrepareScanMain, "bottom_to_top"); + tags.setTagValue(TagsList::Tag::PrepareScanMain, "bottom_to_top"); break; case Parsing::Conversion::Options::ScanMainDirection::LeftToRight: - tags.setTagValue(Tags::PrepareScanMain, "left_to_right"); + tags.setTagValue(TagsList::Tag::PrepareScanMain, "left_to_right"); break; case Parsing::Conversion::Options::ScanMainDirection::RightToLeft: - tags.setTagValue(Tags::PrepareScanMain, "right_to_left"); + tags.setTagValue(TagsList::Tag::PrepareScanMain, "right_to_left"); break; } // scan sub direction if (this->mPreset->prepare()->scanSub() == Parsing::Conversion::Options::ScanSubDirection::Forward) { - tags.setTagValue(Tags::PrepareScanSub, "forward"); + tags.setTagValue(TagsList::Tag::PrepareScanSub, "forward"); } else { - tags.setTagValue(Tags::PrepareScanSub, "backward"); + tags.setTagValue(TagsList::Tag::PrepareScanSub, "backward"); } // bands if (this->mPreset->prepare()->bandScanning()) { - tags.setTagValue(Tags::PrepareUseBands, "yes"); + tags.setTagValue(TagsList::Tag::PrepareUseBands, "yes"); } else { - tags.setTagValue(Tags::PrepareUseBands, "no"); + tags.setTagValue(TagsList::Tag::PrepareUseBands, "no"); } int bandWidth = this->mPreset->prepare()->bandWidth(); - tags.setTagValue(Tags::PrepareBandWidth, QString("%1").arg(bandWidth)); + tags.setTagValue(TagsList::Tag::PrepareBandWidth, QString("%1").arg(bandWidth)); // inversion if (this->mPreset->prepare()->inverse()) { - tags.setTagValue(Tags::PrepareInverse, "yes"); + tags.setTagValue(TagsList::Tag::PrepareInverse, "yes"); } else { - tags.setTagValue(Tags::PrepareInverse, "no"); + tags.setTagValue(TagsList::Tag::PrepareInverse, "no"); } // bom if (this->mPreset->font()->bom()) { - tags.setTagValue(Tags::FontUseBom, "yes"); + tags.setTagValue(TagsList::Tag::FontUseBom, "yes"); } else { - tags.setTagValue(Tags::FontUseBom, "no"); + tags.setTagValue(TagsList::Tag::FontUseBom, "no"); } // encoding - tags.setTagValue(Tags::FontEncoding, this->mPreset->font()->encoding()); + tags.setTagValue(TagsList::Tag::FontEncoding, this->mPreset->font()->encoding()); // split to rows if (this->mPreset->image()->splitToRows()) { - tags.setTagValue(Tags::ImageSplitToRows, "yes"); + tags.setTagValue(TagsList::Tag::ImageSplitToRows, "yes"); } else { - tags.setTagValue(Tags::ImageSplitToRows, "no"); + tags.setTagValue(TagsList::Tag::ImageSplitToRows, "no"); } // compression if (this->mPreset->image()->compressionRle()) { - tags.setTagValue(Tags::ImageRleCompression, "yes"); + tags.setTagValue(TagsList::Tag::ImageRleCompression, "yes"); } else { - tags.setTagValue(Tags::ImageRleCompression, "no"); + tags.setTagValue(TagsList::Tag::ImageRleCompression, "no"); } // preset name - tags.setTagValue(Tags::OutputPresetName, this->mPreset->name()); + tags.setTagValue(TagsList::Tag::OutputPresetName, this->mPreset->name()); // conversion type - tags.setTagValue(Tags::PrepareConversionType, this->mPreset->prepare()->convTypeName()); + tags.setTagValue(TagsList::Tag::PrepareConversionType, this->mPreset->prepare()->convTypeName()); // monochrome type if (this->mPreset->prepare()->convType() == Parsing::Conversion::Options::ConversionType::Monochrome) { - tags.setTagValue(Tags::PrepareMonoType, this->mPreset->prepare()->monoTypeName()); - tags.setTagValue(Tags::PrepareMonoEdge, QString("%1").arg(this->mPreset->prepare()->edge())); + tags.setTagValue(TagsList::Tag::PrepareMonoType, this->mPreset->prepare()->monoTypeName()); + tags.setTagValue(TagsList::Tag::PrepareMonoEdge, QString("%1").arg(this->mPreset->prepare()->edge())); } else { - tags.setTagValue(Tags::PrepareMonoType, "not_used"); - tags.setTagValue(Tags::PrepareMonoEdge, "not_used"); + tags.setTagValue(TagsList::Tag::PrepareMonoType, "not_used"); + tags.setTagValue(TagsList::Tag::PrepareMonoEdge, "not_used"); } // bits per pixel @@ -404,10 +404,10 @@ void Parser::addMatrixInfo(Tags &tags) const maskUsed = maskUsed >> 1; } - tags.setTagValue(Tags::OutputBitsPerPixel, QString("%1").arg(bitsPerPixel)); + tags.setTagValue(TagsList::Tag::OutputBitsPerPixel, QString("%1").arg(bitsPerPixel)); } -void Parser::addImagesInfo(Tags &tags, QMap *images) const +void Parser::addImagesInfo(TagsList &tags, QMap *images) const { QListIterator it(images->keys()); it.toFront(); @@ -420,13 +420,13 @@ void Parser::addImagesInfo(Tags &tags, QMap *images) if (data != nullptr) { bool ok; - int width = data->tags()->tagValue(Tags::OutputImageWidth).toInt(&ok); + int width = data->tags()->tagValue(TagsList::Tag::OutputImageWidth).toInt(&ok); if (ok) { - int height = data->tags()->tagValue(Tags::OutputImageHeight).toInt(&ok); + int height = data->tags()->tagValue(TagsList::Tag::OutputImageHeight).toInt(&ok); if (ok) { - int blocksCount = data->tags()->tagValue(Tags::OutputBlocksCount).toInt(&ok); + int blocksCount = data->tags()->tagValue(TagsList::Tag::OutputBlocksCount).toInt(&ok); if (ok) { if (width > maxWidth) { @@ -445,21 +445,21 @@ void Parser::addImagesInfo(Tags &tags, QMap *images) } // apply imageParticles to outputImageData - data->tags()->setTagValue(Tags::OutputImageData, data->outputImageDataWithEOL(tags)); - data->tags()->setTagValue(Tags::OutputImagePreview, data->outputImagePreviewWithEOL(tags)); + data->tags()->setTagValue(TagsList::Tag::OutputImageData, data->outputImageDataWithEOL(tags)); + data->tags()->setTagValue(TagsList::Tag::OutputImagePreview, data->outputImagePreviewWithEOL(tags)); } } - tags.setTagValue(Tags::OutputImagesCount, QString("%1").arg(images->count())); - tags.setTagValue(Tags::OutputImagesMaxWidth, QString("%1").arg(maxWidth)); - tags.setTagValue(Tags::OutputImagesMaxHeight, QString("%1").arg(maxHeight)); - tags.setTagValue(Tags::OutputImagesMaxBlocksCount, QString("%1").arg(maxBlocksCount)); + tags.setTagValue(TagsList::Tag::OutputImagesCount, QString("%1").arg(images->count())); + tags.setTagValue(TagsList::Tag::OutputImagesMaxWidth, QString("%1").arg(maxWidth)); + tags.setTagValue(TagsList::Tag::OutputImagesMaxHeight, QString("%1").arg(maxHeight)); + tags.setTagValue(TagsList::Tag::OutputImagesMaxBlocksCount, QString("%1").arg(maxBlocksCount)); } -void Parser::addCommonInfo(Tags &tags) const +void Parser::addCommonInfo(TagsList &tags) const { - tags.setTagValue(Tags::ApplicationDate, QString("%1").arg(VersionControl::RevisionInfo::date())); - tags.setTagValue(Tags::ApplicationRevision, QString("%1").arg(VersionControl::RevisionInfo::hash_abbr())); + tags.setTagValue(TagsList::Tag::ApplicationDate, QString("%1").arg(VersionControl::RevisionInfo::date())); + tags.setTagValue(TagsList::Tag::ApplicationRevision, QString("%1").arg(VersionControl::RevisionInfo::hash_abbr())); } void Parser::imageDataParticles(const QString &templateString, QString *prefix, QString *suffix) const diff --git a/classes/parser/parser.h b/classes/parser/parser.h index 48a0aef..2983d73 100644 --- a/classes/parser/parser.h +++ b/classes/parser/parser.h @@ -40,7 +40,7 @@ class QImage; namespace Parsing { -class Tags; +class TagsList; class ParsedImageData; class Parser : public QObject @@ -57,20 +57,20 @@ public: QString name(); - QString convert(Data::Containers::IDocument *document, const QStringList &orderedKeys, QMap *images, Tags &tags) const; + QString convert(Data::Containers::IDocument *document, const QStringList &orderedKeys, QMap *images, TagsList &tags) const; private: Preset *mPreset; QString mTemplateFileName; - QString parse(const QString &templateString, Tags &tags, Data::Containers::IDocument *doc, const QStringList &orderedKeys, QMap *images) const; - QString parseImagesTable(const QString &templateString, Tags &tags, Data::Containers::IDocument *doc, const QStringList &orderedKeys, QMap *images) const; + QString parse(const QString &templateString, TagsList &tags, Data::Containers::IDocument *doc, const QStringList &orderedKeys, QMap *images) const; + QString parseImagesTable(const QString &templateString, TagsList &tags, Data::Containers::IDocument *doc, const QStringList &orderedKeys, QMap *images) const; QString hexCode(const QString &key, const QString &encoding, bool bom) const; - void addMatrixInfo(Tags &tags) const; - void addImagesInfo(Tags &tags, QMap *images) const; - void addCommonInfo(Tags &tags) const; + void addMatrixInfo(TagsList &tags) const; + void addImagesInfo(TagsList &tags, QMap *images) const; + void addCommonInfo(TagsList &tags) const; - bool findNextTag(int startIndex, int *resultIndex, Tags); + bool findNextTag(int startIndex, int *resultIndex, TagsList); void imageDataParticles(const QString &templateString, QString *prefix, QString *suffix) const; void imagePreviewParticles(const QString &templateString, QString *prefix, QString *suffix) const; }; diff --git a/classes/parser/tags.cpp b/classes/parser/tags.cpp deleted file mode 100644 index 7a2ad7d..0000000 --- a/classes/parser/tags.cpp +++ /dev/null @@ -1,219 +0,0 @@ -/* - * LCD Image Converter. Converts images and fonts for embedded applications. - * Copyright (C) 2013 riuson - * mailto: riuson@gmail.com - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see -#include -#include - -namespace Parsing -{ - -Tags::Tags() -{ - this->initTagsMap(); - this->mTagValues = new QMap(); -} - -Tags::~Tags() -{ - this->mTagNameMap->clear(); - this->mTagNameMap->clear(); - - delete this->mTagNameMap; - delete this->mTagValues; -} - -Tags::TagsEnum Tags::parseTag(const QString &key) const -{ - return this->mTagNameMap->value(key, Unknown); -} - -const QString Tags::tagValue(Tags::TagsEnum key) const -{ - //return this->mTagValues->value(key, QString("")); - QString res = this->mTagValues->value(key, QString("")); - - if (res.contains("defined")) { - - } - - return res; -} - -void Tags::setTagValue(Tags::TagsEnum key, const QString &value) -{ - this->mTagValues->insert(key, value); -} - -void Tags::importValues(const Tags *other) -{ - QListIterator it(other->mTagValues->keys()); - it.toFront(); - - while (it.hasNext()) { - TagsEnum tag = it.next(); - this->setTagValue(tag, other->tagValue(tag)); - } -} - -bool Tags::find(const QString &text, int startIndex, int *resultIndex, int *nextIndex, TagsEnum *key, QString *content) -{ - *resultIndex = -1; - *nextIndex = -1; - *key = Unknown; - *content = QString(); - - QRegExp reg("(\\@|\\$\\()(.+)(\\@|\\))"); - reg.setMinimal(true); - - int pos = reg.indexIn(text, startIndex); - - if (pos >= 0) { - QString tagText = reg.cap(2); - *key = this->parseTag(tagText); - *resultIndex = pos; - - if (*key == BlocksHeaderStart || - *key == BlocksImagesTableStart || - *key == BlocksFontDefinitionStart) { - QString blockName = tagText.remove(0, 12); - QRegExp regContent = QRegExp("(\\@|\\$\\()start_block_" + blockName + "(\\@|\\))(.+)(\\@|\\$\\()end_block_" + blockName + "(\\@|\\))"); - regContent.setMinimal(true); - - if (regContent.indexIn(text, pos) >= 0) { - QString contentText = regContent.cap(3); - *content = contentText;//.trimmed(); - *nextIndex = pos + regContent.cap().length(); - } - } else { - *content = tagText; - *nextIndex = pos + reg.cap().length(); - } - - return true; - } - - return false; -} - -void Tags::initTagsMap() -{ - this->mTagNameMap = new QHash(); - - this->mTagNameMap->insert("doc_data_type", DocumentDataType); - this->mTagNameMap->insert("dataType", DocumentDataType); - this->mTagNameMap->insert("doc_name", DocumentName); - this->mTagNameMap->insert("documentName", DocumentName); - this->mTagNameMap->insert("doc_name_ws", DocumentNameWithoutSpaces); - this->mTagNameMap->insert("documentName_ws", DocumentNameWithoutSpaces); - this->mTagNameMap->insert("doc_filename", DocumentFilename); - this->mTagNameMap->insert("fileName", DocumentFilename); - - this->mTagNameMap->insert("pre_conv_type", PrepareConversionType); - this->mTagNameMap->insert("convType", PrepareConversionType); - this->mTagNameMap->insert("pre_mono_type", PrepareMonoType); - this->mTagNameMap->insert("monoType", PrepareMonoType); - this->mTagNameMap->insert("pre_mono_edge", PrepareMonoEdge); - this->mTagNameMap->insert("edge", PrepareMonoEdge); - this->mTagNameMap->insert("pre_scan_main", PrepareScanMain); - this->mTagNameMap->insert("scanMain", PrepareScanMain); - this->mTagNameMap->insert("pre_scan_sub", PrepareScanSub); - this->mTagNameMap->insert("scanSub", PrepareScanSub); - this->mTagNameMap->insert("pre_inverse", PrepareInverse); - this->mTagNameMap->insert("inverse", PrepareInverse); - this->mTagNameMap->insert("pre_use_bands", PrepareUseBands); - this->mTagNameMap->insert("bands", PrepareUseBands); - this->mTagNameMap->insert("pre_band_width", PrepareBandWidth); - this->mTagNameMap->insert("bandWidth", PrepareBandWidth); - - this->mTagNameMap->insert("img_split_to_rows", ImageSplitToRows); - this->mTagNameMap->insert("splitToRows", ImageSplitToRows); - this->mTagNameMap->insert("img_data_block_size", ImageBlockSize); - this->mTagNameMap->insert("dataBlockSize", ImageBlockSize); - this->mTagNameMap->insert("img_rle", ImageRleCompression); - this->mTagNameMap->insert("rle", ImageRleCompression); - this->mTagNameMap->insert("img_byte_order", ImageByteOrder); - this->mTagNameMap->insert("bytesOrder", ImageByteOrder); - - this->mTagNameMap->insert("fnt_use_bom", FontUseBom); - this->mTagNameMap->insert("bom", FontUseBom); - this->mTagNameMap->insert("fnt_encoding", FontEncoding); - this->mTagNameMap->insert("encoding", FontEncoding); - - this->mTagNameMap->insert("fnt_family", FontFamily); - this->mTagNameMap->insert("fontFamily", FontFamily); - this->mTagNameMap->insert("fnt_size", FontSize); - this->mTagNameMap->insert("fontSize", FontSize); - this->mTagNameMap->insert("fnt_style", FontStyle); - this->mTagNameMap->insert("fontStyle", FontStyle); - this->mTagNameMap->insert("fnt_string", FontString); - this->mTagNameMap->insert("string", FontString); - this->mTagNameMap->insert("fnt_width_type", FontWidthType); - this->mTagNameMap->insert("fontWidthType", FontWidthType); - this->mTagNameMap->insert("fnt_antialiasing", FontAntiAliasing); - this->mTagNameMap->insert("fontAntialiasing", FontAntiAliasing); - this->mTagNameMap->insert("fnt_ascent", FontAscent); - this->mTagNameMap->insert("fnt_descent", FontDescent); - - this->mTagNameMap->insert("tmpl_filename", TemplateFilename); - this->mTagNameMap->insert("templateFile", TemplateFilename); - - this->mTagNameMap->insert("out_preset_name", OutputPresetName); - this->mTagNameMap->insert("preset", OutputPresetName); - this->mTagNameMap->insert("out_blocks_count", OutputBlocksCount); - this->mTagNameMap->insert("blocksCount", OutputBlocksCount); - this->mTagNameMap->insert("out_bpp", OutputBitsPerPixel); - this->mTagNameMap->insert("bpp", OutputBitsPerPixel); - this->mTagNameMap->insert("out_char_code", OutputCharacterCode); - this->mTagNameMap->insert("charCode", OutputCharacterCode); - this->mTagNameMap->insert("out_char_code_sim", OutputCharacterCodeSimilar); - this->mTagNameMap->insert("out_char_text", OutputCharacterText); - this->mTagNameMap->insert("charText", OutputCharacterText); - this->mTagNameMap->insert("out_char_text_sim", OutputCharacterTextSimilar); - this->mTagNameMap->insert("out_image_data", OutputImageData); - this->mTagNameMap->insert("imageData", OutputImageData); - this->mTagNameMap->insert("out_image_preview", OutputImagePreview); - this->mTagNameMap->insert("out_images_count", OutputImagesCount); - this->mTagNameMap->insert("imagesCount", OutputImagesCount); - this->mTagNameMap->insert("out_comma", OutputComma); - this->mTagNameMap->insert("comma", OutputComma); - this->mTagNameMap->insert("out_data_indent", OutputDataIndent); - this->mTagNameMap->insert("imageDataIndent", OutputDataIndent); - this->mTagNameMap->insert("out_image_width", OutputImageWidth); - this->mTagNameMap->insert("width", OutputImageWidth); - this->mTagNameMap->insert("out_image_height", OutputImageHeight); - this->mTagNameMap->insert("height", OutputImageHeight); - this->mTagNameMap->insert("out_images_max_width", OutputImagesMaxWidth); - this->mTagNameMap->insert("out_images_max_height", OutputImagesMaxHeight); - this->mTagNameMap->insert("out_images_max_blocks_count", OutputImagesMaxBlocksCount); - - this->mTagNameMap->insert("app_date", ApplicationDate); - this->mTagNameMap->insert("app_rev", ApplicationRevision); - - this->mTagNameMap->insert("start_block_header", BlocksHeaderStart); - this->mTagNameMap->insert("end_block_header", BlocksHeaderEnd); - this->mTagNameMap->insert("start_block_images_table", BlocksImagesTableStart); - this->mTagNameMap->insert("end_block_images_table", BlocksImagesTableEnd); - this->mTagNameMap->insert("start_block_font_def", BlocksFontDefinitionStart); - this->mTagNameMap->insert("end_block_font_def", BlocksFontDefinitionEnd); -} - -} // namespace Parsing diff --git a/classes/parser/tagslist.cpp b/classes/parser/tagslist.cpp new file mode 100644 index 0000000..a04afa8 --- /dev/null +++ b/classes/parser/tagslist.cpp @@ -0,0 +1,219 @@ +/* + * LCD Image Converter. Converts images and fonts for embedded applications. + * Copyright (C) 2013 riuson + * mailto: riuson@gmail.com + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see +#include +#include + +namespace Parsing +{ + +TagsList::TagsList() +{ + this->initTagsMap(); + this->mTagValues = new QMap(); +} + +TagsList::~TagsList() +{ + this->mTagNameMap->clear(); + this->mTagNameMap->clear(); + + delete this->mTagNameMap; + delete this->mTagValues; +} + +TagsList::Tag TagsList::parseTag(const QString &key) const +{ + return this->mTagNameMap->value(key, Tag::Unknown); +} + +const QString TagsList::tagValue(TagsList::Tag key) const +{ + //return this->mTagValues->value(key, QString("")); + QString res = this->mTagValues->value(key, QString("")); + + if (res.contains("defined")) { + + } + + return res; +} + +void TagsList::setTagValue(TagsList::Tag key, const QString &value) +{ + this->mTagValues->insert(key, value); +} + +void TagsList::importValues(const TagsList *other) +{ + QListIterator it(other->mTagValues->keys()); + it.toFront(); + + while (it.hasNext()) { + Tag tag = it.next(); + this->setTagValue(tag, other->tagValue(tag)); + } +} + +bool TagsList::find(const QString &text, int startIndex, int *resultIndex, int *nextIndex, Tag *key, QString *content) +{ + *resultIndex = -1; + *nextIndex = -1; + *key = Tag::Unknown; + *content = QString(); + + QRegExp reg("(\\@|\\$\\()(.+)(\\@|\\))"); + reg.setMinimal(true); + + int pos = reg.indexIn(text, startIndex); + + if (pos >= 0) { + QString tagText = reg.cap(2); + *key = this->parseTag(tagText); + *resultIndex = pos; + + if (*key == Tag::BlocksHeaderStart || + *key == Tag::BlocksImagesTableStart || + *key == Tag::BlocksFontDefinitionStart) { + QString blockName = tagText.remove(0, 12); + QRegExp regContent = QRegExp("(\\@|\\$\\()start_block_" + blockName + "(\\@|\\))(.+)(\\@|\\$\\()end_block_" + blockName + "(\\@|\\))"); + regContent.setMinimal(true); + + if (regContent.indexIn(text, pos) >= 0) { + QString contentText = regContent.cap(3); + *content = contentText;//.trimmed(); + *nextIndex = pos + regContent.cap().length(); + } + } else { + *content = tagText; + *nextIndex = pos + reg.cap().length(); + } + + return true; + } + + return false; +} + +void TagsList::initTagsMap() +{ + this->mTagNameMap = new QHash(); + + this->mTagNameMap->insert("doc_data_type", Tag::DocumentDataType); + this->mTagNameMap->insert("dataType", Tag::DocumentDataType); + this->mTagNameMap->insert("doc_name", Tag::DocumentName); + this->mTagNameMap->insert("documentName", Tag::DocumentName); + this->mTagNameMap->insert("doc_name_ws", Tag::DocumentNameWithoutSpaces); + this->mTagNameMap->insert("documentName_ws", Tag::DocumentNameWithoutSpaces); + this->mTagNameMap->insert("doc_filename", Tag::DocumentFilename); + this->mTagNameMap->insert("fileName", Tag::DocumentFilename); + + this->mTagNameMap->insert("pre_conv_type", Tag::PrepareConversionType); + this->mTagNameMap->insert("convType", Tag::PrepareConversionType); + this->mTagNameMap->insert("pre_mono_type", Tag::PrepareMonoType); + this->mTagNameMap->insert("monoType", Tag::PrepareMonoType); + this->mTagNameMap->insert("pre_mono_edge", Tag::PrepareMonoEdge); + this->mTagNameMap->insert("edge", Tag::PrepareMonoEdge); + this->mTagNameMap->insert("pre_scan_main", Tag::PrepareScanMain); + this->mTagNameMap->insert("scanMain", Tag::PrepareScanMain); + this->mTagNameMap->insert("pre_scan_sub", Tag::PrepareScanSub); + this->mTagNameMap->insert("scanSub", Tag::PrepareScanSub); + this->mTagNameMap->insert("pre_inverse", Tag::PrepareInverse); + this->mTagNameMap->insert("inverse", Tag::PrepareInverse); + this->mTagNameMap->insert("pre_use_bands", Tag::PrepareUseBands); + this->mTagNameMap->insert("bands", Tag::PrepareUseBands); + this->mTagNameMap->insert("pre_band_width", Tag::PrepareBandWidth); + this->mTagNameMap->insert("bandWidth", Tag::PrepareBandWidth); + + this->mTagNameMap->insert("img_split_to_rows", Tag::ImageSplitToRows); + this->mTagNameMap->insert("splitToRows", Tag::ImageSplitToRows); + this->mTagNameMap->insert("img_data_block_size", Tag::ImageBlockSize); + this->mTagNameMap->insert("dataBlockSize", Tag::ImageBlockSize); + this->mTagNameMap->insert("img_rle", Tag::ImageRleCompression); + this->mTagNameMap->insert("rle", Tag::ImageRleCompression); + this->mTagNameMap->insert("img_byte_order", Tag::ImageByteOrder); + this->mTagNameMap->insert("bytesOrder", Tag::ImageByteOrder); + + this->mTagNameMap->insert("fnt_use_bom", Tag::FontUseBom); + this->mTagNameMap->insert("bom", Tag::FontUseBom); + this->mTagNameMap->insert("fnt_encoding", Tag::FontEncoding); + this->mTagNameMap->insert("encoding", Tag::FontEncoding); + + this->mTagNameMap->insert("fnt_family", Tag::FontFamily); + this->mTagNameMap->insert("fontFamily", Tag::FontFamily); + this->mTagNameMap->insert("fnt_size", Tag::FontSize); + this->mTagNameMap->insert("fontSize", Tag::FontSize); + this->mTagNameMap->insert("fnt_style", Tag::FontStyle); + this->mTagNameMap->insert("fontStyle", Tag::FontStyle); + this->mTagNameMap->insert("fnt_string", Tag::FontString); + this->mTagNameMap->insert("string", Tag::FontString); + this->mTagNameMap->insert("fnt_width_type", Tag::FontWidthType); + this->mTagNameMap->insert("fontWidthType", Tag::FontWidthType); + this->mTagNameMap->insert("fnt_antialiasing", Tag::FontAntiAliasing); + this->mTagNameMap->insert("fontAntialiasing", Tag::FontAntiAliasing); + this->mTagNameMap->insert("fnt_ascent", Tag::FontAscent); + this->mTagNameMap->insert("fnt_descent", Tag::FontDescent); + + this->mTagNameMap->insert("tmpl_filename", Tag::TemplateFilename); + this->mTagNameMap->insert("templateFile", Tag::TemplateFilename); + + this->mTagNameMap->insert("out_preset_name", Tag::OutputPresetName); + this->mTagNameMap->insert("preset", Tag::OutputPresetName); + this->mTagNameMap->insert("out_blocks_count", Tag::OutputBlocksCount); + this->mTagNameMap->insert("blocksCount", Tag::OutputBlocksCount); + this->mTagNameMap->insert("out_bpp", Tag::OutputBitsPerPixel); + this->mTagNameMap->insert("bpp", Tag::OutputBitsPerPixel); + this->mTagNameMap->insert("out_char_code", Tag::OutputCharacterCode); + this->mTagNameMap->insert("charCode", Tag::OutputCharacterCode); + this->mTagNameMap->insert("out_char_code_sim", Tag::OutputCharacterCodeSimilar); + this->mTagNameMap->insert("out_char_text", Tag::OutputCharacterText); + this->mTagNameMap->insert("charText", Tag::OutputCharacterText); + this->mTagNameMap->insert("out_char_text_sim", Tag::OutputCharacterTextSimilar); + this->mTagNameMap->insert("out_image_data", Tag::OutputImageData); + this->mTagNameMap->insert("imageData", Tag::OutputImageData); + this->mTagNameMap->insert("out_image_preview", Tag::OutputImagePreview); + this->mTagNameMap->insert("out_images_count", Tag::OutputImagesCount); + this->mTagNameMap->insert("imagesCount", Tag::OutputImagesCount); + this->mTagNameMap->insert("out_comma", Tag::OutputComma); + this->mTagNameMap->insert("comma", Tag::OutputComma); + this->mTagNameMap->insert("out_data_indent", Tag::OutputDataIndent); + this->mTagNameMap->insert("imageDataIndent", Tag::OutputDataIndent); + this->mTagNameMap->insert("out_image_width", Tag::OutputImageWidth); + this->mTagNameMap->insert("width", Tag::OutputImageWidth); + this->mTagNameMap->insert("out_image_height", Tag::OutputImageHeight); + this->mTagNameMap->insert("height", Tag::OutputImageHeight); + this->mTagNameMap->insert("out_images_max_width", Tag::OutputImagesMaxWidth); + this->mTagNameMap->insert("out_images_max_height", Tag::OutputImagesMaxHeight); + this->mTagNameMap->insert("out_images_max_blocks_count", Tag::OutputImagesMaxBlocksCount); + + this->mTagNameMap->insert("app_date", Tag::ApplicationDate); + this->mTagNameMap->insert("app_rev", Tag::ApplicationRevision); + + this->mTagNameMap->insert("start_block_header", Tag::BlocksHeaderStart); + this->mTagNameMap->insert("end_block_header", Tag::BlocksHeaderEnd); + this->mTagNameMap->insert("start_block_images_table", Tag::BlocksImagesTableStart); + this->mTagNameMap->insert("end_block_images_table", Tag::BlocksImagesTableEnd); + this->mTagNameMap->insert("start_block_font_def", Tag::BlocksFontDefinitionStart); + this->mTagNameMap->insert("end_block_font_def", Tag::BlocksFontDefinitionEnd); +} + +} // namespace Parsing diff --git a/classes/parser/tags.h b/classes/parser/tagslist.h similarity index 86% rename from classes/parser/tags.h rename to classes/parser/tagslist.h index 421f755..2c0ce12 100644 --- a/classes/parser/tags.h +++ b/classes/parser/tagslist.h @@ -28,13 +28,13 @@ template class QHash; namespace Parsing { -class Tags +class TagsList { public: - Tags(); - virtual ~Tags(); + TagsList(); + virtual ~TagsList(); - enum TagsEnum { + enum class Tag { Unknown = 0, DocumentDataType, @@ -102,17 +102,17 @@ public: BlocksFontDefinitionEnd }; - TagsEnum parseTag(const QString &key) const; + Tag parseTag(const QString &key) const; - const QString tagValue(TagsEnum key) const; - void setTagValue(TagsEnum key, const QString &value); - void importValues(const Tags *other); + const QString tagValue(Tag key) const; + void setTagValue(Tag key, const QString &value); + void importValues(const TagsList *other); - bool find(const QString &text, int startIndex, int *resultIndex, int *nextIndex, TagsEnum *key, QString *content); + bool find(const QString &text, int startIndex, int *resultIndex, int *nextIndex, Tag *key, QString *content); private: - QHash *mTagNameMap; - QMap *mTagValues; + QHash *mTagNameMap; + QMap *mTagValues; void initTagsMap(); }; diff --git a/controls/fonts/font-editor/editortabfont.cpp b/controls/fonts/font-editor/editortabfont.cpp index a9a996c..876fe8f 100644 --- a/controls/fonts/font-editor/editortabfont.cpp +++ b/controls/fonts/font-editor/editortabfont.cpp @@ -38,7 +38,7 @@ #include "imagesscaledproxy.h" #include "parser.h" #include "dialogfontchanged.h" -#include "tags.h" +#include "tagslist.h" #include "statusdata.h" #include "fonteditoroptions.h" #include "fontdocument.h" diff --git a/controls/images/editortabimage.cpp b/controls/images/editortabimage.cpp index 92a00aa..c3c8ddc 100644 --- a/controls/images/editortabimage.cpp +++ b/controls/images/editortabimage.cpp @@ -30,7 +30,7 @@ #include "datacontainer.h" #include "parser.h" -#include "tags.h" +#include "tagslist.h" #include "statusdata.h" #include "imagedocument.h" #include "editor.h" diff --git a/lcd-image-converter.pro b/lcd-image-converter.pro index 47de72b..3d2e8ab 100644 --- a/lcd-image-converter.pro +++ b/lcd-image-converter.pro @@ -103,7 +103,7 @@ SOURCES += main.cpp \ classes/parser/convert/fonthelper.cpp \ classes/parser/parsedimagedata.cpp \ classes/parser/parser.cpp \ - classes/parser/tags.cpp \ + classes/parser/tagslist.cpp \ classes/settings/appsettings.cpp \ classes/settings/conversionpreviewoptions.cpp \ classes/settings/externaltooloptions.cpp \ @@ -224,7 +224,7 @@ HEADERS += \ classes/parser/convert/fonthelper.h \ classes/parser/parsedimagedata.h \ classes/parser/parser.h \ - classes/parser/tags.h \ + classes/parser/tagslist.h \ classes/settings/appsettings.h \ classes/settings/conversionpreviewoptions.h \ classes/settings/externaltooloptions.h \