From 5da75dba065df3a16d2c58fcd89027750b34f12f Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 29 Jul 2014 22:02:56 -0700 Subject: [PATCH] Replace the PMF to certain QString members with a regular function Qt 5.4 is adding ref-qualified overloads to toUpper, toLower, trimmed and some others, so the cast becomes ambiguous or just plain wrong. Change-Id: Idff0b3e100f075b9b995aeb84d88575afecb2d6f Reviewed-by: hjk --- src/plugins/qtsupport/exampleslistmodel.cpp | 2 +- src/plugins/texteditor/basetexteditor.cpp | 20 +++++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/plugins/qtsupport/exampleslistmodel.cpp b/src/plugins/qtsupport/exampleslistmodel.cpp index a06bfd9cd45..7e3f465f1b9 100644 --- a/src/plugins/qtsupport/exampleslistmodel.cpp +++ b/src/plugins/qtsupport/exampleslistmodel.cpp @@ -264,7 +264,7 @@ static QString fixStringForTags(const QString &string) static QStringList trimStringList(const QStringList &stringlist) { - return Utils::transform(stringlist, &QString::trimmed); + return Utils::transform(stringlist, [](const QString &str) { return str.trimmed(); }); } static QString relativeOrInstallPath(const QString &path, const QString &manifestPath, diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index 9f54e841a59..0903b10605a 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -133,7 +133,17 @@ using namespace Utils; namespace TextEditor { namespace Internal { -typedef QString (QString::*TransformationMethod)() const; +typedef QString (TransformationMethod)(const QString &); + +static QString QString_toUpper(const QString &str) +{ + return str.toUpper(); +} + +static QString QString_toLower(const QString &str) +{ + return str.toLower(); +} class BaseTextEditorAnimator : public QObject { @@ -1252,12 +1262,12 @@ void BaseTextEditorWidget::moveLineDown() void BaseTextEditorWidget::uppercaseSelection() { - d->transformSelection(&QString::toUpper); + d->transformSelection(&QString_toUpper); } void BaseTextEditorWidget::lowercaseSelection() { - d->transformSelection(&QString::toLower); + d->transformSelection(&QString_toLower); } void BaseTextEditorWidget::indent() @@ -6833,7 +6843,7 @@ void BaseTextEditorWidgetPrivate::transformSelection(TransformationMethod method } QString text = cursor.selectedText(); - QString transformedText = (text.*method)(); + QString transformedText = method(text); if (transformedText == text) { // if the transformation does not do anything to the selection, do no create an undo step @@ -6878,7 +6888,7 @@ void BaseTextEditorWidgetPrivate::transformBlockSelection(TransformationMethod m if (startPos < endPos) { cursor.setPosition(startPos); cursor.setPosition(endPos, QTextCursor::KeepAnchor); - const QString &transformedText = (m_document->textAt(startPos, endPos - startPos).*method)(); + const QString &transformedText = method(m_document->textAt(startPos, endPos - startPos)); if (transformedText != cursor.selectedText()) cursor.insertText(transformedText); }