Commit 9b4540d6 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

use std::as_const

parent 98300b9e
......@@ -31,7 +31,7 @@ void FileFetchJob::start()
void FileFetchJob::doStart()
{
for (const QString &filePath : qAsConst(m_urls)) {
for (const QString &filePath : std::as_const(m_urls)) {
bool extractorRunning = false;
KFileMetaData::PropertyMap fileProperties;
......
......@@ -235,7 +235,7 @@ void FileMetaDataProvider::insertFilesListBasicData()
// If all directories
Q_ASSERT(m_fileItems.count() > 1);
bool allDirectories = true;
for (const KFileItem &item : qAsConst(m_fileItems)) {
for (const KFileItem &item : std::as_const(m_fileItems)) {
allDirectories &= item.isDir();
if (!allDirectories) {
break;
......@@ -246,7 +246,7 @@ void FileMetaDataProvider::insertFilesListBasicData()
int count = 0;
int hiddenCount = 0;
bool isSizeKnown = true;
for (const KFileItem &item : qAsConst(m_fileItems)) {
for (const KFileItem &item : std::as_const(m_fileItems)) {
isSizeKnown = item.isLocalFile() && !item.isSlow();
if (!isSizeKnown) {
return;
......@@ -271,7 +271,7 @@ void FileMetaDataProvider::insertFilesListBasicData()
} else {
// Calculate the size of all items
quint64 totalSize = 0;
for (const KFileItem &item : qAsConst(m_fileItems)) {
for (const KFileItem &item : std::as_const(m_fileItems)) {
if (!item.isDir() && !item.isLink()) {
totalSize += item.size();
}
......@@ -314,8 +314,8 @@ void FileMetaDataProvider::insertCommonData(const QList<QVariantMap> &files)
totalPropertyAndInsert(QStringLiteral("wordCount"), propertyList, allProperties);
totalPropertyAndInsert(QStringLiteral("lineCount"), propertyList, allProperties);
for (const QString &propUri : qAsConst(allProperties)) {
for (const QVariantMap &map : qAsConst(propertyList)) {
for (const QString &propUri : std::as_const(allProperties)) {
for (const QVariantMap &map : std::as_const(propertyList)) {
QVariantMap::const_iterator it = map.find(propUri);
if (it == map.constEnd()) {
m_data.remove(propUri);
......@@ -393,7 +393,7 @@ void FileMetaDataProvider::setFileItems()
urls.reserve(m_fileItems.size());
// Only extract data from indexed files,
// it would be too expensive otherwise.
for (const KFileItem &item : qAsConst(m_fileItems)) {
for (const KFileItem &item : std::as_const(m_fileItems)) {
const QUrl url = item.targetUrl();
if (url.isLocalFile() && !item.isSlow()) {
urls << url.toLocalFile();
......
......@@ -92,7 +92,7 @@ FileMetaDataWidgetPrivate::~FileMetaDataWidgetPrivate() = default;
void FileMetaDataWidgetPrivate::deleteRows()
{
for (const Row &row : qAsConst(m_rows)) {
for (const Row &row : std::as_const(m_rows)) {
delete row.label;
row.value->deleteLater();
if (row.checkBox) {
......@@ -316,7 +316,7 @@ QSize FileMetaDataWidget::sizeHint() const
int leftWidthMax = 0;
int rightWidthMax = 0;
int rightWidthAverage = 0;
for (const FileMetaDataWidgetPrivate::Row &row : qAsConst(d->m_rows)) {
for (const FileMetaDataWidgetPrivate::Row &row : std::as_const(d->m_rows)) {
const QWidget *valueWidget = row.value;
const int rightWidth = valueWidget->sizeHint().width();
rightWidthAverage += rightWidth;
......@@ -342,7 +342,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);
for (const FileMetaDataWidgetPrivate::Row &row : qAsConst(d->m_rows)) {
for (const FileMetaDataWidgetPrivate::Row &row : std::as_const(d->m_rows)) {
const QWidget *valueWidget = row.value;
const int rowHeight = qMax(row.label->heightForWidth(leftWidthMax), valueWidget->heightForWidth(rightWidthMax));
height += rowHeight;
......
......@@ -154,7 +154,7 @@ QSize KBlockLayout::sizeHint() const
{
// TODO: try to get the items into a square
QSize size;
for (QLayoutItem *item : qAsConst(d->itemList)) {
for (QLayoutItem *item : std::as_const(d->itemList)) {
const QSize itemSize = item->minimumSize();
size.rwidth() += itemSize.width();
if (itemSize.height() > size.height()) {
......@@ -170,7 +170,7 @@ QSize KBlockLayout::sizeHint() const
QSize KBlockLayout::minimumSize() const
{
QSize size;
for (QLayoutItem *item : qAsConst(d->itemList)) {
for (QLayoutItem *item : std::as_const(d->itemList)) {
size = size.expandedTo(item->minimumSize());
}
......@@ -227,14 +227,14 @@ int KBlockLayout::doLayout(const QRect &rect, bool testOnly) const
// 2. place the items
y = rect.y();
for (const Row &row : qAsConst(rows)) {
for (const Row &row : std::as_const(rows)) {
x = rect.x();
if (alignment() & Qt::AlignRight)
x += (rect.width() - row.width);
else if (alignment() & Qt::AlignHCenter)
x += (rect.width() - row.width) / 2;
for (QLayoutItem *item : qAsConst(row.items)) {
for (QLayoutItem *item : std::as_const(row.items)) {
int yy = y;
if (alignment() & Qt::AlignBottom)
yy += (row.height - item->sizeHint().height());
......
......@@ -94,7 +94,7 @@ void KEditTagsDialog::slotAcceptedButtonClicked()
{
m_tags.clear();
for (const QTreeWidgetItem *item : qAsConst(m_allTagTreeItems)) {
for (const QTreeWidgetItem *item : std::as_const(m_allTagTreeItems)) {
if (item->checkState(0) == Qt::Checked) {
m_tags << qvariant_cast<QString>(item->data(0, Qt::UserRole));
}
......@@ -163,11 +163,11 @@ void KEditTagsDialog::slotTextEdited(const QString &text)
void KEditTagsDialog::loadTagWidget()
{
for (const QString &tag : qAsConst(m_tags)) {
for (const QString &tag : std::as_const(m_tags)) {
modifyTagWidget(tag);
}
for (const QString &tag : qAsConst(m_allTags)) {
for (const QString &tag : std::as_const(m_allTags)) {
modifyTagWidget(tag);
}
......
......@@ -42,7 +42,7 @@ TagsFileItemAction::TagsFileItemAction(QObject *parent, const QVariantList &)
allTags.sort(Qt::CaseInsensitive);
allTags.removeDuplicates();
for (const QString &name : qAsConst(allTags)) {
for (const QString &name : std::as_const(allTags)) {
QAction *action = m_menu->addAction(QIcon::fromTheme(QStringLiteral("tag")), name);
action->setCheckable(true);
action->setChecked(fileTags.contains(name));
......
......@@ -227,7 +227,7 @@ QLabel *WidgetFactory::createValueWidget(QWidget *parent)
void WidgetFactory::slotCommentChanged(const QString &comment)
{
for (const KFileItem &item : qAsConst(m_items)) {
for (const KFileItem &item : std::as_const(m_items)) {
QUrl url = item.targetUrl();
if (!url.isLocalFile()) {
continue;
......@@ -241,7 +241,7 @@ void WidgetFactory::slotCommentChanged(const QString &comment)
void WidgetFactory::slotRatingChanged(int rating)
{
for (const KFileItem &item : qAsConst(m_items)) {
for (const KFileItem &item : std::as_const(m_items)) {
QUrl url = item.targetUrl();
if (!url.isLocalFile()) {
continue;
......@@ -256,7 +256,7 @@ void WidgetFactory::slotRatingChanged(int rating)
void WidgetFactory::slotTagsChanged(const QStringList &tags)
{
if (m_tagWidget) {
for (const KFileItem &item : qAsConst(m_items)) {
for (const KFileItem &item : std::as_const(m_items)) {
QUrl url = item.targetUrl();
if (!url.isLocalFile()) {
continue;
......@@ -268,7 +268,7 @@ void WidgetFactory::slotTagsChanged(const QStringList &tags)
QStringList newTags = md.tags() + tags;
newTags.removeDuplicates();
for (const QString &tag : qAsConst(m_prevTags)) {
for (const QString &tag : std::as_const(m_prevTags)) {
if (!tags.contains(tag)) {
newTags.removeAll(tag);
}
......
Supports Markdown
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