From 5ffad0a4c57e6838da57eb492d1a63eb444d9634 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Wed, 4 Aug 2021 12:21:43 +0200 Subject: Fix build with Qt 6 - setContentsMargins - QStringView instead of QStringRef Change-Id: I2cd4df9b68f5f2fbf4c5d918b0bf238734518037 Reviewed-by: Christian Stenger Reviewed-by: Eike Ziller --- plugins/haskell/haskellbuildconfiguration.cpp | 4 ++-- plugins/haskell/haskellhighlighter.cpp | 4 ++-- plugins/haskell/haskelltokenizer.cpp | 18 +++++++++--------- plugins/haskell/haskelltokenizer.h | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/plugins/haskell/haskellbuildconfiguration.cpp b/plugins/haskell/haskellbuildconfiguration.cpp index 160e2d1..e523572 100644 --- a/plugins/haskell/haskellbuildconfiguration.cpp +++ b/plugins/haskell/haskellbuildconfiguration.cpp @@ -100,14 +100,14 @@ HaskellBuildConfigurationWidget::HaskellBuildConfigurationWidget(HaskellBuildCon , m_buildConfiguration(bc) { setLayout(new QVBoxLayout); - layout()->setMargin(0); + layout()->setContentsMargins(0, 0, 0, 0); auto box = new Utils::DetailsWidget; box->setState(Utils::DetailsWidget::NoSummary); layout()->addWidget(box); auto details = new QWidget; box->setWidget(details); details->setLayout(new QHBoxLayout); - details->layout()->setMargin(0); + details->layout()->setContentsMargins(0, 0, 0, 0); details->layout()->addWidget(new QLabel(tr("Build directory:"))); auto buildDirectoryInput = new Utils::PathChooser; diff --git a/plugins/haskell/haskellhighlighter.cpp b/plugins/haskell/haskellhighlighter.cpp index 9899cc4..8a5b6ca 100644 --- a/plugins/haskell/haskellhighlighter.cpp +++ b/plugins/haskell/haskellhighlighter.cpp @@ -80,10 +80,10 @@ void HaskellHighlighter::highlightBlock(const QString &text) setTokenFormat(token, C_VISUAL_WHITESPACE); break; case TokenType::Keyword: - if (token.text == "::" && firstNonWS && !secondNonWS) { // toplevel declaration + if (token.text == QLatin1String("::") && firstNonWS && !secondNonWS) { // toplevel declaration setFormat(firstNonWS->startCol, firstNonWS->length, m_toplevelDeclFormat); inType = true; - } else if (token.text == "import") { + } else if (token.text == QLatin1String("import")) { inImport = true; } setTokenFormat(token, C_KEYWORD); diff --git a/plugins/haskell/haskelltokenizer.cpp b/plugins/haskell/haskelltokenizer.cpp index b59b48b..6f2556d 100644 --- a/plugins/haskell/haskelltokenizer.cpp +++ b/plugins/haskell/haskelltokenizer.cpp @@ -142,7 +142,7 @@ namespace Internal { Token token(TokenType type, std::shared_ptr line, int start, int end) { - return {type, start, end - start, line->midRef(start, end - start), line}; + return {type, start, end - start, QStringView(*line).mid(start, end - start), line}; } Tokens::Tokens(std::shared_ptr source) @@ -251,7 +251,7 @@ static QVector getSpace(std::shared_ptr line, int start) ++current; const int length = int(std::distance(tokenStart, current)); if (current > tokenStart) - return {{TokenType::Whitespace, start, length, line->midRef(start, length), line}}; + return {{TokenType::Whitespace, start, length, QStringView(*line).mid(start, length), line}}; return {}; } @@ -405,7 +405,7 @@ static int getEscape(const QString &line, int start) return 0; return count + 1; } - const QStringRef s = line.midRef(start); + const QStringView s = QStringView(line).mid(start); for (const QString &esc : *ASCII_ESCAPES) { if (s.startsWith(esc)) return esc.length(); @@ -481,7 +481,7 @@ static QVector getString(std::shared_ptr line, int start, bool * lastRef.type = TokenType::StringError; } else { --lastRef.length; - lastRef.text = line->midRef(lastRef.startCol, lastRef.length); + lastRef.text = QStringView(*line).mid(lastRef.startCol, lastRef.length); result.append(token(TokenType::StringError, line, current - 1, current)); } } @@ -496,11 +496,11 @@ static QVector getMultiLineComment(std::shared_ptr line, int sta const int length = line->length(); int current = start; do { - const QStringRef test = line->midRef(current, 2); - if (test == "{-") { + const QStringView test = QStringView(*line).mid(current, 2); + if (test == QLatin1String("{-")) { ++(*commentLevel); current += 2; - } else if (test == "-}" && *commentLevel > 0) { + } else if (test == QLatin1String("-}") && *commentLevel > 0) { --(*commentLevel); current += 2; } else if (*commentLevel > 0) { @@ -587,7 +587,7 @@ static QVector getChar(std::shared_ptr line, int start) static QVector getSpecial(std::shared_ptr line, int start) { if (SPECIAL->contains(line->at(start))) - return {{TokenType::Special, start, 1, line->midRef(start, 1), line}}; + return {{TokenType::Special, start, 1, QStringView(*line).mid(start, 1), line}}; return {}; } @@ -620,7 +620,7 @@ Tokens HaskellTokenizer::tokenize(const QString &line, int startState) tokens = {{TokenType::Unknown, currentStart, 1, - result.source->midRef(currentStart, 1), + QStringView(*result.source).mid(currentStart, 1), result.source}}; result.append(tokens); } diff --git a/plugins/haskell/haskelltokenizer.h b/plugins/haskell/haskelltokenizer.h index 29b10df..63d82d9 100644 --- a/plugins/haskell/haskelltokenizer.h +++ b/plugins/haskell/haskelltokenizer.h @@ -61,7 +61,7 @@ public: TokenType type = TokenType::Unknown; int startCol = -1; int length = -1; - QStringRef text; + QStringView text; std::shared_ptr source; // keep the string ref alive }; -- cgit v1.2.3