mirror of
https://invent.kde.org/frameworks/kimageformats.git
synced 2025-05-28 00:30:23 -04:00
compile without foreach
Summary: compile without foreach Reviewers: dfaure, apol Reviewed By: apol Subscribers: apol, kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D19317
This commit is contained in:
parent
156bac5e54
commit
f1c6c15b06
@ -45,7 +45,7 @@ set_package_properties(OpenEXR PROPERTIES
|
|||||||
TYPE OPTIONAL
|
TYPE OPTIONAL
|
||||||
PURPOSE "Required for the QImage plugin for OpenEXR images"
|
PURPOSE "Required for the QImage plugin for OpenEXR images"
|
||||||
)
|
)
|
||||||
|
add_definitions(-DQT_NO_FOREACH)
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
if (BUILD_TESTING)
|
if (BUILD_TESTING)
|
||||||
add_subdirectory(autotests)
|
add_subdirectory(autotests)
|
||||||
|
@ -127,7 +127,8 @@ int main(int argc, char ** argv)
|
|||||||
<< "Starting basic read tests for "
|
<< "Starting basic read tests for "
|
||||||
<< suffix << " images *********\n";
|
<< suffix << " images *********\n";
|
||||||
|
|
||||||
foreach (QFileInfo fi, imgdir.entryInfoList()) {
|
const QFileInfoList lstImgDir = imgdir.entryInfoList();
|
||||||
|
for (const QFileInfo &fi : lstImgDir) {
|
||||||
int suffixPos = fi.filePath().count() - suffix.count();
|
int suffixPos = fi.filePath().count() - suffix.count();
|
||||||
QString inputfile = fi.filePath();
|
QString inputfile = fi.filePath();
|
||||||
QString expfile = fi.filePath().replace(suffixPos, suffix.count(), QStringLiteral("png"));
|
QString expfile = fi.filePath().replace(suffixPos, suffix.count(), QStringLiteral("png"));
|
||||||
|
@ -73,8 +73,8 @@ int main(int argc, char ** argv)
|
|||||||
QTextStream(stdout) << "********* "
|
QTextStream(stdout) << "********* "
|
||||||
<< "Starting basic write tests for "
|
<< "Starting basic write tests for "
|
||||||
<< suffix << " images *********\n";
|
<< suffix << " images *********\n";
|
||||||
|
const QFileInfoList lstImgDir = imgdir.entryInfoList();
|
||||||
foreach (QFileInfo fi, imgdir.entryInfoList()) {
|
for (const QFileInfo &fi : lstImgDir) {
|
||||||
int suffixPos = fi.filePath().count() - suffix.count();
|
int suffixPos = fi.filePath().count() - suffix.count();
|
||||||
QString pngfile = fi.filePath().replace(suffixPos, suffix.count(), QStringLiteral("png"));
|
QString pngfile = fi.filePath().replace(suffixPos, suffix.count(), QStringLiteral("png"));
|
||||||
QString pngfilename = QFileInfo(pngfile).fileName();
|
QString pngfilename = QFileInfo(pngfile).fileName();
|
||||||
|
@ -173,9 +173,9 @@ static QDataStream &operator<< (QDataStream &s, const QList<PicChannel> &channel
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool readRow(QDataStream &stream, QRgb *row, quint16 width, QList<PicChannel> channels)
|
static bool readRow(QDataStream &stream, QRgb *row, quint16 width, const QList<PicChannel> &channels)
|
||||||
{
|
{
|
||||||
Q_FOREACH(const PicChannel &channel, channels) {
|
for(const PicChannel &channel : channels) {
|
||||||
auto readPixel = [&] (QDataStream &str) -> QRgb {
|
auto readPixel = [&] (QDataStream &str) -> QRgb {
|
||||||
quint8 red = 0;
|
quint8 red = 0;
|
||||||
if (channel.code & RED) {
|
if (channel.code & RED) {
|
||||||
@ -242,7 +242,7 @@ bool SoftimagePICHandler::read(QImage *image)
|
|||||||
}
|
}
|
||||||
|
|
||||||
QImage::Format fmt = QImage::Format_RGB32;
|
QImage::Format fmt = QImage::Format_RGB32;
|
||||||
Q_FOREACH(const PicChannel &channel, m_channels) {
|
for (const PicChannel &channel : qAsConst(m_channels)) {
|
||||||
if (channel.size != 8) {
|
if (channel.size != 8) {
|
||||||
// we cannot read images that do not come in bytes
|
// we cannot read images that do not come in bytes
|
||||||
qDebug() << "Channel size was" << channel.size;
|
qDebug() << "Channel size was" << channel.size;
|
||||||
@ -388,8 +388,8 @@ void SoftimagePICHandler::setOption(ImageOption option, const QVariant &value)
|
|||||||
break;
|
break;
|
||||||
case Description: {
|
case Description: {
|
||||||
m_description.clear();
|
m_description.clear();
|
||||||
QStringList entries = value.toString().split(QStringLiteral("\n\n"));
|
const QStringList entries = value.toString().split(QStringLiteral("\n\n"));
|
||||||
Q_FOREACH(const QString entry, entries) {
|
for (const QString &entry : entries) {
|
||||||
if (entry.startsWith(QStringLiteral("Description: "))) {
|
if (entry.startsWith(QStringLiteral("Description: "))) {
|
||||||
m_description = entry.mid(13).simplified().toUtf8();
|
m_description = entry.mid(13).simplified().toUtf8();
|
||||||
}
|
}
|
||||||
@ -425,7 +425,7 @@ QVariant SoftimagePICHandler::option(ImageOption option) const
|
|||||||
return QString();
|
return QString();
|
||||||
case ImageFormat:
|
case ImageFormat:
|
||||||
if (const_cast<SoftimagePICHandler*>(this)->readChannels()) {
|
if (const_cast<SoftimagePICHandler*>(this)->readChannels()) {
|
||||||
Q_FOREACH (const PicChannel &channel, m_channels) {
|
for (const PicChannel &channel : qAsConst(m_channels)) {
|
||||||
if (channel.code & ALPHA) {
|
if (channel.code & ALPHA) {
|
||||||
return QImage::Format_ARGB32;
|
return QImage::Format_ARGB32;
|
||||||
}
|
}
|
||||||
|
@ -64,11 +64,13 @@ int main(int argc, char **argv)
|
|||||||
if (parser.isSet(listformats)) {
|
if (parser.isSet(listformats)) {
|
||||||
QTextStream out(stdout);
|
QTextStream out(stdout);
|
||||||
out << "Input formats:\n";
|
out << "Input formats:\n";
|
||||||
foreach (const QByteArray &fmt, QImageReader::supportedImageFormats()) {
|
const auto lstReaderSupportedFormats = QImageReader::supportedImageFormats();
|
||||||
|
for (const QByteArray &fmt : lstReaderSupportedFormats) {
|
||||||
out << " " << fmt << '\n';
|
out << " " << fmt << '\n';
|
||||||
}
|
}
|
||||||
out << "Output formats:\n";
|
out << "Output formats:\n";
|
||||||
foreach (const QByteArray &fmt, QImageWriter::supportedImageFormats()) {
|
const auto lstWriterSupportedFormats = QImageWriter::supportedImageFormats();
|
||||||
|
for (const QByteArray &fmt : lstWriterSupportedFormats) {
|
||||||
out << " " << fmt << '\n';
|
out << " " << fmt << '\n';
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -72,7 +72,8 @@ int main(int argc, char **argv)
|
|||||||
if (parser.isSet(listformats)) {
|
if (parser.isSet(listformats)) {
|
||||||
QTextStream out(stdout);
|
QTextStream out(stdout);
|
||||||
out << "File formats:\n";
|
out << "File formats:\n";
|
||||||
foreach (const QByteArray &fmt, QImageReader::supportedImageFormats()) {
|
const QList<QByteArray> lstSupportedFormats = QImageReader::supportedImageFormats();
|
||||||
|
for (const QByteArray &fmt : lstSupportedFormats) {
|
||||||
out << " " << fmt << '\n';
|
out << " " << fmt << '\n';
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user