diff --git a/app/fullscreencontent.cpp b/app/fullscreencontent.cpp --- a/app/fullscreencontent.cpp +++ b/app/fullscreencontent.cpp @@ -457,7 +457,7 @@ // Interval label QString text = formatSlideShowIntervalText(88); - int width = widget->mSlideShowIntervalLabel->fontMetrics().width(text); + int width = widget->mSlideShowIntervalLabel->fontMetrics().boundingRect(text).width(); widget->mSlideShowIntervalLabel->setFixedWidth(width); updateSlideShowIntervalLabel(); diff --git a/app/infocontextmanageritem.cpp b/app/infocontextmanageritem.cpp --- a/app/infocontextmanageritem.cpp +++ b/app/infocontextmanageritem.cpp @@ -158,7 +158,7 @@ void finishAddRows() { - qSort(mRows.begin(), mRows.end(), KeyValueWidget::rowsLessThan); + std::sort(mRows.begin(), mRows.end(), KeyValueWidget::rowsLessThan); updateGeometry(); } diff --git a/app/kipiinterface.cpp b/app/kipiinterface.cpp --- a/app/kipiinterface.cpp +++ b/app/kipiinterface.cpp @@ -334,7 +334,7 @@ if (!info.mActions.isEmpty()) { QMenu* menu = d->mPluginMenu->addMenu(info.mName); menu->setIcon(QIcon::fromTheme(info.mIconName)); - qSort(info.mActions.begin(), info.mActions.end(), actionLessThan); + std::sort(info.mActions.begin(), info.mActions.end(), actionLessThan); Q_FOREACH(QAction * action, info.mActions) { menu->addAction(action); } diff --git a/lib/crop/croptool.cpp b/lib/crop/croptool.cpp --- a/lib/crop/croptool.cpp +++ b/lib/crop/croptool.cpp @@ -272,8 +272,8 @@ static const QColor borderColor = QColor::fromHsvF(0, 0, 1.0); static const QColor fillColor = QColor::fromHsvF(0, 0, 0.75, 0.66); - QRegion outerRegion = QRegion(imageRect) - QRegion(rect); - Q_FOREACH(const QRect & outerRect, outerRegion.rects()) { + const QRegion outerRegion = QRegion(imageRect) - QRegion(rect); + for (const QRect &outerRect : outerRegion) { painter->fillRect(outerRect, outerColor); } diff --git a/lib/crop/cropwidget.cpp b/lib/crop/cropwidget.cpp --- a/lib/crop/cropwidget.cpp +++ b/lib/crop/cropwidget.cpp @@ -200,6 +200,9 @@ addRatioToComboBox(QSizeF(1, 1), i18n("Square")); addRatioToComboBox(ratio(QApplication::desktop()->screenGeometry().size()), i18n("This Screen")); + // The previous string should be changed to + // addRatioToComboBox(ratio(QGuiApplication::screenAt(QCursor::pos())->geometry().size()), i18n("This Screen")); + // after switching to Qt > 5.9 addSectionHeaderToComboBox(i18n("Landscape")); Q_FOREACH(const QSizeF& size, ratioList) { diff --git a/lib/documentview/documentviewcontainer.cpp b/lib/documentview/documentviewcontainer.cpp --- a/lib/documentview/documentviewcontainer.cpp +++ b/lib/documentview/documentviewcontainer.cpp @@ -176,7 +176,7 @@ // and not through scheduleLayoutUpdate() d->mLayoutUpdateTimer->stop(); QList views = (d->mViews | d->mAddedViews).toList(); - qSort(views.begin(), views.end(), viewLessThan); + std::sort(views.begin(), views.end(), viewLessThan); bool animated = GwenviewConfig::animationMethod() != DocumentView::NoAnimation; bool crossFade = d->mAddedViews.count() == 1 && d->mRemovedViews.count() == 1; diff --git a/lib/fullscreenbar.cpp b/lib/fullscreenbar.cpp --- a/lib/fullscreenbar.cpp +++ b/lib/fullscreenbar.cpp @@ -82,6 +82,10 @@ QRect slideInTriggerRect() const { QRect rect = QApplication::desktop()->screenGeometry(QApplication::desktop()->screenNumber(q->parentWidget())); + // The previous string should be changed to + // QRect rect = QGuiApplication::screenAt(QCursor::pos())->geometry(); + // after switching to Qt > 5.9 + // Take parent widget position into account because it may not be at // the top of the screen, for example when the save bar warning is // shown. diff --git a/lib/imagescaler.cpp b/lib/imagescaler.cpp --- a/lib/imagescaler.cpp +++ b/lib/imagescaler.cpp @@ -131,7 +131,7 @@ } LOG("Starting"); - Q_FOREACH(const QRect & rect, d->mRegion.rects()) { + for (const QRect &rect : qAsConst(d->mRegion)) { LOG(rect); scaleRect(rect); } diff --git a/lib/semanticinfo/tagitemdelegate.cpp b/lib/semanticinfo/tagitemdelegate.cpp --- a/lib/semanticinfo/tagitemdelegate.cpp +++ b/lib/semanticinfo/tagitemdelegate.cpp @@ -124,7 +124,7 @@ QSize TagItemDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const { - const int width = option.fontMetrics.width(index.data().toString()); + const int width = option.fontMetrics.boundingRect(index.data().toString()).width(); const int height = qMax(mButtonSize, option.fontMetrics.height()); return QSize(width + 2 * mMargin, height + 2 * mMargin); } diff --git a/lib/slideshow.cpp b/lib/slideshow.cpp --- a/lib/slideshow.cpp +++ b/lib/slideshow.cpp @@ -100,7 +100,7 @@ QUrl findNextOrderedUrl() { - QVector::ConstIterator it = qFind(mUrls.constBegin(), mUrls.constEnd(), mCurrentUrl); + QVector::ConstIterator it = std::find(mUrls.constBegin(), mUrls.constEnd(), mCurrentUrl); GV_RETURN_VALUE_IF_FAIL2(it != mUrls.constEnd(), QUrl(), "Current url not found in list."); ++it; @@ -216,9 +216,9 @@ void SlideShow::start(const QList& urls) { d->mUrls.resize(urls.size()); - qCopy(urls.begin(), urls.end(), d->mUrls.begin()); + std::copy(urls.begin(), urls.end(), d->mUrls.begin()); - d->mStartIt = qFind(d->mUrls.constBegin(), d->mUrls.constEnd(), d->mCurrentUrl); + d->mStartIt = std::find(d->mUrls.constBegin(), d->mUrls.constEnd(), d->mCurrentUrl); if (d->mStartIt == d->mUrls.constEnd()) { qWarning() << "Current url not found in list, aborting.\n"; return; diff --git a/lib/thumbnailview/itemeditor.cpp b/lib/thumbnailview/itemeditor.cpp --- a/lib/thumbnailview/itemeditor.cpp +++ b/lib/thumbnailview/itemeditor.cpp @@ -72,7 +72,7 @@ if (d->mCenter.isNull()) { d->mCenter = geometry().center(); } - int textWidth = fontMetrics().width(" " + text() + " "); + int textWidth = fontMetrics().boundingRect(" " + text() + " ").width(); QRect rect = geometry(); rect.setWidth(textWidth); rect.moveCenter(d->mCenter); diff --git a/lib/thumbnailview/previewitemdelegate.cpp b/lib/thumbnailview/previewitemdelegate.cpp --- a/lib/thumbnailview/previewitemdelegate.cpp +++ b/lib/thumbnailview/previewitemdelegate.cpp @@ -350,7 +350,7 @@ int posX; if (text.length() == fullText.length()) { // Not elided, center text - posX = (rect.width() - fm.width(text)) / 2; + posX = (rect.width() - fm.boundingRect(text).width()) / 2; } else { // Elided, left align posX = 0; @@ -961,7 +961,7 @@ return; } QString text = index.data().toString(); - int textWidth = edit->fontMetrics().width(QStringLiteral(" ") + text + QStringLiteral(" ")); + int textWidth = edit->fontMetrics().boundingRect(QStringLiteral(" ") + text + QStringLiteral(" ")).width(); QRect textRect( option.rect.left() + (option.rect.width() - textWidth) / 2, option.rect.top() + 2 * ITEM_MARGIN + d->mThumbnailSize.height(), diff --git a/lib/zoomwidget.cpp b/lib/zoomwidget.cpp --- a/lib/zoomwidget.cpp +++ b/lib/zoomwidget.cpp @@ -109,7 +109,7 @@ } d->mZoomLabel = new QLabel; - d->mZoomLabel->setFixedWidth(d->mZoomLabel->fontMetrics().width(QStringLiteral(" 1000% "))); + d->mZoomLabel->setFixedWidth(d->mZoomLabel->fontMetrics().boundingRect(QStringLiteral(" 1000% ")).width()); d->mZoomLabel->setAlignment(Qt::AlignCenter); d->mZoomSlider = new ZoomSlider; diff --git a/tests/auto/recursivedirmodeltest.cpp b/tests/auto/recursivedirmodeltest.cpp --- a/tests/auto/recursivedirmodeltest.cpp +++ b/tests/auto/recursivedirmodeltest.cpp @@ -95,7 +95,7 @@ KFileItem item = index.data(KDirModel::FileItemRole).value(); out << item.url(); } - qSort(out); + std::sort(out.begin(), out.end()); return out; } @@ -105,7 +105,7 @@ Q_FOREACH(const QString &name, files) { lst << QUrl::fromLocalFile(dir.absoluteFilePath(name)); } - qSort(lst); + std::sort(lst.begin(), lst.end()); return lst; }