Permalink
Browse files

Fixed:

 Invalid status on first-time selection;
 Indent and EOL for the output image data;

Merge branch 'develop'
  • Loading branch information...
riuson committed Mar 13, 2013
2 parents b1e5f17 + 24c602a commit 559bd5a29c5725863955aa5f974598aef8dff630
@@ -79,7 +79,10 @@ QString Parser::convert(IDocument *document, Tags &tags) const
}
tags.setTagValue(Tags::TemplateFilename, file.fileName());

tags.setTagValue(Tags::OutputDataIndent, this->imageIndent(templateString));
QString prefix, suffix;
this->imageParticles(templateString, &prefix, &suffix);
tags.setTagValue(Tags::OutputDataIndent, prefix);
tags.setTagValue(Tags::OutputDataEOL, suffix);

this->addMatrixInfo(tags);

@@ -220,7 +223,7 @@ QString Parser::parseImage(const QImage *image, Tags &tags) const
tags.setTagValue(Tags::OutputBlocksCount, QString("%1").arg(compressedData.size()));

QString dataString = ConverterHelper::dataToString(this->mPreset, &compressedData, compressedWidth, compressedHeight, "0x");
dataString.replace("\n", "\n" + tags.tagValue(Tags::OutputDataIndent));
dataString.replace("\n", tags.tagValue(Tags::OutputDataEOL) + tags.tagValue(Tags::OutputDataIndent));

// end of conversion

@@ -422,21 +425,49 @@ void Parser::addImagesInfo(Tags &tags, IDocument *doc) const
tags.setTagValue(Tags::OutputImagesMaxHeight, QString("%1").arg(maxHeight));
}
//-----------------------------------------------------------------------------
QString Parser::imageIndent(const QString &templateString) const
void Parser::imageParticles(const QString &templateString, QString *prefix, QString *suffix) const
{
QRegExp regIndent = QRegExp("([\\t\\ ]+)(\\@|\\$\\()imageData(\\@|\\))");
regIndent.setMinimal(true);
if (regIndent.indexIn(templateString) >= 0)
{
QString result = regIndent.cap(1);
if (result.isEmpty())
result = " ";
QString templateOutImageData;

return result;
// extract 'out_image_data' line
QRegExp regOutImageData = QRegExp("[^\\n\\r]*out_image_data[^\\n\\r]*[\\n\\r]*");
if (regOutImageData.indexIn(templateString) >= 0)
{
templateOutImageData = regOutImageData.cap();
}
else
{
return " ";
regOutImageData.setPattern("[^\\n\\r]*imageData[^\\n\\r]*[\\n\\r]*");
if (regOutImageData.indexIn(templateString) >= 0)
{
templateOutImageData = regOutImageData.cap();
}
}

*prefix = QString(" ");
*suffix = QString("\r\n");

if (!templateOutImageData.isEmpty())
{
QRegExp regIndent = QRegExp("^[\\t\\ ]*");
if (regIndent.indexIn(templateOutImageData) >= 0)
{
QString result = regIndent.cap();
if (!result.isEmpty())
{
*prefix = result;
}
}

QRegExp regEOL = QRegExp("[\\r\\n]*$");
if (regEOL.indexIn(templateOutImageData) >= 0)
{
QString result = regEOL.cap();
if (!result.isEmpty())
{
*suffix = result;
}
}
}
}
//-----------------------------------------------------------------------------
@@ -60,7 +60,7 @@ class Parser : public QObject
void addImagesInfo(Tags &tags, IDocument *doc) const;

bool findNextTag(int startIndex, int *resultIndex, Tags);
QString imageIndent(const QString &templateString) const;
void imageParticles(const QString &templateString, QString *prefix, QString *suffix) const;
};
//-----------------------------------------------------------------------------
#endif // PARSER_H
@@ -75,6 +75,7 @@ class Tags
OutputImagesCount,
OutputComma,
OutputDataIndent,
OutputDataEOL,
OutputImageWidth,
OutputImageHeight,
OutputImagesMaxWidth,
@@ -237,6 +237,10 @@ void EditorTabFont::currentChanged(const QModelIndex &current, const QModelIndex
const QImage *image = this->mContainer->image(key);
this->mEditor->setImage(image);

// update selection for currentKey() method, called by updateStatus()
QItemSelectionModel *selectionModel = this->ui->tableViewCharacters->selectionModel();
selectionModel->setCurrentIndex(current, QItemSelectionModel::SelectCurrent);

this->updateStatus();
}
}
@@ -6,7 +6,22 @@
<date>current</date>
</commit>
<description>Fixed:
Invalid status on first-time selection;
Indent and EOL for the output image data.</description>
</record>
<record>
<commit>
<sha1>b1e5f171a1b6ecd5593003a2aa35191022537dd9</sha1>
<date>2013-03-05 23:31:02</date>
</commit>
<description>Fixed:
Character's filter in resize dialog.</description>
<downloads>
<item>
<name>Application for Windows (7.7 MB)</name>
<url>http://code.google.com/p/lcd-image-converter/downloads/detail?name=lcd-image-converter-20130305-b1e5f171a1b6.zip</url>
</item>
</downloads>
</record>
<record>
<commit>

0 comments on commit 559bd5a

Please sign in to comment.