Commit c65f5d9c authored by Alexander Stippich's avatar Alexander Stippich

remove foreach

Reviewers: bruns

Reviewed By: bruns

Subscribers: #baloo

Tags: #baloo

Differential Revision: https://phabricator.kde.org/D22192
parent 36c29550
......@@ -28,6 +28,8 @@ include(ECMGenerateHeaders)
include(ECMAddTests)
include(CMakePackageConfigHelpers)
add_definitions(-DQT_NO_FOREACH)
ecm_setup_version(PROJECT
VARIABLE_PREFIX BALOO_WIDGETS
SOVERSION 5
......
......@@ -110,7 +110,7 @@ void FileMetaDataProvider::totalPropertyAndInsert(const QString& prop,
{
if (allProperties.contains(prop)) {
int total = 0;
foreach (const QVariantMap& map, resources) {
for (const QVariantMap& map : resources) {
QVariantMap::const_iterator it = map.constFind(prop);
if (it == map.constEnd()) {
total = 0;
......@@ -244,7 +244,7 @@ void FileMetaDataProvider::insertCommonData(const QList<QVariantMap>& files)
//
QSet<QString> allProperties;
QList<QVariantMap> propertyList;
foreach (const QVariantMap& fileData, files) {
for (const QVariantMap& fileData : files) {
propertyList << fileData;
allProperties.unite(fileData.uniqueKeys().toSet());
}
......@@ -255,8 +255,8 @@ void FileMetaDataProvider::insertCommonData(const QList<QVariantMap>& files)
totalPropertyAndInsert(QStringLiteral("wordCount"), propertyList, allProperties);
totalPropertyAndInsert(QStringLiteral("lineCount"), propertyList, allProperties);
foreach (const QString& propUri, allProperties) {
foreach (const QVariantMap& map, propertyList) {
for (const QString& propUri : qAsConst(allProperties)) {
for (const QVariantMap& map : qAsConst(propertyList)) {
QVariantMap::const_iterator it = map.find(propUri);
if (it == map.constEnd()) {
m_data.remove(propUri);
......
......@@ -107,7 +107,7 @@ FileMetaDataWidget::Private::~Private()
void FileMetaDataWidget::Private::deleteRows()
{
foreach (const Row& row, m_rows) {
for (const Row& row : qAsConst(m_rows)) {
delete row.label;
row.value->deleteLater();
if (row.checkBox) {
......@@ -335,7 +335,7 @@ QSize FileMetaDataWidget::sizeHint() const
int leftWidthMax = 0;
int rightWidthMax = 0;
int rightWidthAverage = 0;
foreach (const Private::Row& row, d->m_rows) {
for (const Private::Row& row : qAsConst(d->m_rows)) {
const QWidget* valueWidget = row.value;
const int rightWidth = valueWidget->sizeHint().width();
rightWidthAverage += rightWidth;
......@@ -361,7 +361,7 @@ QSize FileMetaDataWidget::sizeHint() const
// Based on the available width calculate the required height
int height = d->m_gridLayout->margin() * 2 + d->m_gridLayout->spacing() * (d->m_rows.count() - 1);
foreach (const Private::Row& row, d->m_rows) {
for (const Private::Row& row : qAsConst(d->m_rows)) {
const QWidget* valueWidget = row.value;
const int rowHeight = qMax(row.label->heightForWidth(leftWidthMax),
valueWidget->heightForWidth(rightWidthMax));
......
......@@ -172,8 +172,7 @@ QSize KBlockLayout::sizeHint() const
{
// TODO: try to get the items into a square
QSize size;
QLayoutItem *item;
foreach (item, d->itemList) {
for (QLayoutItem* item : qAsConst(d->itemList)) {
const QSize itemSize = item->minimumSize();
size.rwidth() += itemSize.width();
if (itemSize.height() > size.height()) {
......@@ -189,8 +188,7 @@ QSize KBlockLayout::sizeHint() const
QSize KBlockLayout::minimumSize() const
{
QSize size;
QLayoutItem *item;
foreach (item, d->itemList) {
for (QLayoutItem* item : qAsConst(d->itemList)) {
size = size.expandedTo(item->minimumSize());
}
......@@ -244,14 +242,14 @@ int KBlockLayout::doLayout( const QRect& rect, bool testOnly ) const
// 2. place the items
y = rect.y();
foreach( const Row &row, rows ) {
for (const Row& row : qAsConst(rows)) {
x = rect.x();
if( alignment() & Qt::AlignRight )
x += (rect.width() - row.width);
else if( alignment() & Qt::AlignHCenter )
x += (rect.width() - row.width)/2;
foreach( QLayoutItem* item, row.items ) {
for (QLayoutItem* item : qAsConst(row.items)) {
int yy = y;
if( alignment() & Qt::AlignBottom )
yy += (row.height - item->sizeHint().height());
......
......@@ -61,7 +61,7 @@ void TagWidgetPrivate::buildTagHash(const QStringList& tags)
qDeleteAll(m_checkBoxHash);
m_checkBoxHash.clear();
foreach (const QString& tag, tags) {
for (const QString& tag : tags) {
getTagCheckBox(tag);
}
......
......@@ -54,9 +54,9 @@ FileMetadataWidgetTest::FileMetadataWidgetTest(QWidget* parent, Qt::WindowFlags
void FileMetadataWidgetTest::slotChooseFiles()
{
QList<QUrl> urlList = QFileDialog::getOpenFileUrls();
const QList<QUrl> urlList = QFileDialog::getOpenFileUrls();
KFileItemList list;
foreach(const QUrl& url, urlList)
for (const QUrl& url : urlList)
list << KFileItem( url, QString(), mode_t() );
m_metadataWidget->setItems( list );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment