mirror of
https://invent.kde.org/frameworks/kimageformats.git
synced 2025-06-03 17:08:08 -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
|
||||
PURPOSE "Required for the QImage plugin for OpenEXR images"
|
||||
)
|
||||
|
||||
add_definitions(-DQT_NO_FOREACH)
|
||||
add_subdirectory(src)
|
||||
if (BUILD_TESTING)
|
||||
add_subdirectory(autotests)
|
||||
|
@ -127,7 +127,8 @@ int main(int argc, char ** argv)
|
||||
<< "Starting basic read tests for "
|
||||
<< 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();
|
||||
QString inputfile = fi.filePath();
|
||||
QString expfile = fi.filePath().replace(suffixPos, suffix.count(), QStringLiteral("png"));
|
||||
|
@ -73,8 +73,8 @@ int main(int argc, char ** argv)
|
||||
QTextStream(stdout) << "********* "
|
||||
<< "Starting basic write tests for "
|
||||
<< 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();
|
||||
QString pngfile = fi.filePath().replace(suffixPos, suffix.count(), QStringLiteral("png"));
|
||||
QString pngfilename = QFileInfo(pngfile).fileName();
|
||||
|
@ -173,9 +173,9 @@ static QDataStream &operator<< (QDataStream &s, const QList<PicChannel> &channel
|
||||
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 {
|
||||
quint8 red = 0;
|
||||
if (channel.code & RED) {
|
||||
@ -242,7 +242,7 @@ bool SoftimagePICHandler::read(QImage *image)
|
||||
}
|
||||
|
||||
QImage::Format fmt = QImage::Format_RGB32;
|
||||
Q_FOREACH(const PicChannel &channel, m_channels) {
|
||||
for (const PicChannel &channel : qAsConst(m_channels)) {
|
||||
if (channel.size != 8) {
|
||||
// we cannot read images that do not come in bytes
|
||||
qDebug() << "Channel size was" << channel.size;
|
||||
@ -388,8 +388,8 @@ void SoftimagePICHandler::setOption(ImageOption option, const QVariant &value)
|
||||
break;
|
||||
case Description: {
|
||||
m_description.clear();
|
||||
QStringList entries = value.toString().split(QStringLiteral("\n\n"));
|
||||
Q_FOREACH(const QString entry, entries) {
|
||||
const QStringList entries = value.toString().split(QStringLiteral("\n\n"));
|
||||
for (const QString &entry : entries) {
|
||||
if (entry.startsWith(QStringLiteral("Description: "))) {
|
||||
m_description = entry.mid(13).simplified().toUtf8();
|
||||
}
|
||||
@ -425,7 +425,7 @@ QVariant SoftimagePICHandler::option(ImageOption option) const
|
||||
return QString();
|
||||
case ImageFormat:
|
||||
if (const_cast<SoftimagePICHandler*>(this)->readChannels()) {
|
||||
Q_FOREACH (const PicChannel &channel, m_channels) {
|
||||
for (const PicChannel &channel : qAsConst(m_channels)) {
|
||||
if (channel.code & ALPHA) {
|
||||
return QImage::Format_ARGB32;
|
||||
}
|
||||
|
@ -64,11 +64,13 @@ int main(int argc, char **argv)
|
||||
if (parser.isSet(listformats)) {
|
||||
QTextStream out(stdout);
|
||||
out << "Input formats:\n";
|
||||
foreach (const QByteArray &fmt, QImageReader::supportedImageFormats()) {
|
||||
const auto lstReaderSupportedFormats = QImageReader::supportedImageFormats();
|
||||
for (const QByteArray &fmt : lstReaderSupportedFormats) {
|
||||
out << " " << fmt << '\n';
|
||||
}
|
||||
out << "Output formats:\n";
|
||||
foreach (const QByteArray &fmt, QImageWriter::supportedImageFormats()) {
|
||||
const auto lstWriterSupportedFormats = QImageWriter::supportedImageFormats();
|
||||
for (const QByteArray &fmt : lstWriterSupportedFormats) {
|
||||
out << " " << fmt << '\n';
|
||||
}
|
||||
return 0;
|
||||
|
@ -72,7 +72,8 @@ int main(int argc, char **argv)
|
||||
if (parser.isSet(listformats)) {
|
||||
QTextStream out(stdout);
|
||||
out << "File formats:\n";
|
||||
foreach (const QByteArray &fmt, QImageReader::supportedImageFormats()) {
|
||||
const QList<QByteArray> lstSupportedFormats = QImageReader::supportedImageFormats();
|
||||
for (const QByteArray &fmt : lstSupportedFormats) {
|
||||
out << " " << fmt << '\n';
|
||||
}
|
||||
return 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user