From e20a0ed580d2f69b80fca34ed58b90c69d830cae Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 11 Feb 2019 11:13:07 +0100 Subject: [PATCH 1/9] buildsteplist.cpp: Fix compile error for Qt < 5.13 QList::swapItemsAt() was added in Qt 5.13 (without \since). Amends 963dc84cc5d1e412344e3a0fbf4a476541da2d19. Change-Id: I40e4a5eda3540ae4a3212ea44413ed8a6cf17ce4 Reviewed-by: Eike Ziller --- src/plugins/projectexplorer/buildsteplist.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/plugins/projectexplorer/buildsteplist.cpp b/src/plugins/projectexplorer/buildsteplist.cpp index 2734f4139d7..3b4ce596a48 100644 --- a/src/plugins/projectexplorer/buildsteplist.cpp +++ b/src/plugins/projectexplorer/buildsteplist.cpp @@ -185,7 +185,11 @@ bool BuildStepList::removeStep(int position) void BuildStepList::moveStepUp(int position) { +#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0) m_steps.swapItemsAt(position - 1, position); +#else + m_steps.swap(position - 1, position); +#endif emit stepMoved(position, position - 1); } From f8dd6b35ec6855583b28f4f81e39192c94d0b73b Mon Sep 17 00:00:00 2001 From: Ivan Donchevskii Date: Fri, 8 Feb 2019 08:59:06 +0100 Subject: [PATCH 2/9] ClangFormat: Do not create extra operations to undo on save If formatting is applied on save do not create a new replacement for each replacement action. Instead join the last edit block to make it possible to undo the formatting in one go. Change-Id: Ie0cb66eb5e76998e5045c1183f5f796e5a718659 Reviewed-by: Marco Bubke --- src/plugins/cppeditor/cppeditordocument.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/plugins/cppeditor/cppeditordocument.cpp b/src/plugins/cppeditor/cppeditordocument.cpp index c1577424570..d058adac9ee 100644 --- a/src/plugins/cppeditor/cppeditordocument.cpp +++ b/src/plugins/cppeditor/cppeditordocument.cpp @@ -462,6 +462,8 @@ static int formatRange(QTextDocument *doc, bool CppEditorDocument::save(QString *errorString, const QString &fileName, bool autoSave) { if (indenter()->formatOnSave()) { + QTextCursor cursor(document()); + cursor.joinPreviousEditBlock(); auto *layout = qobject_cast(document()->documentLayout()); const int documentRevision = layout->lastSaveRevision; @@ -483,6 +485,7 @@ bool CppEditorDocument::save(QString *errorString, const QString &fileName, bool } if (editedRange.first != -1) formatRange(document(), indenter(), editedRange, tabSettings()); + cursor.endEditBlock(); } return TextEditor::TextDocument::save(errorString, fileName, autoSave); From 1740fcc0084b112bd3eff98ea64176cd0429f04a Mon Sep 17 00:00:00 2001 From: Ivan Donchevskii Date: Fri, 8 Feb 2019 09:48:49 +0100 Subject: [PATCH 3/9] ClangFormat: Take line context into account when formatting In some cases indenting/formatting after special characters can break the code. Let's try to avoid such corner cases. Change-Id: I8918bc460af31d696e49f60e0ea85f34e9ff5664 Fixes: QTCREATORBUG-21474 Reviewed-by: Marco Bubke --- .../clangformat/clangformatbaseindenter.cpp | 41 ++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/src/plugins/clangformat/clangformatbaseindenter.cpp b/src/plugins/clangformat/clangformatbaseindenter.cpp index f5bc876020a..e8c6b5e9026 100644 --- a/src/plugins/clangformat/clangformatbaseindenter.cpp +++ b/src/plugins/clangformat/clangformatbaseindenter.cpp @@ -408,6 +408,36 @@ int ClangFormatBaseIndenter::indentBeforeCursor(const QTextBlock &block, return cursorPositionInEditor; } +static bool doNotIndentInContext(QTextDocument *doc, int pos) +{ + const QChar character = doc->characterAt(pos); + const QTextBlock currentBlock = doc->findBlock(pos); + const QString text = currentBlock.text().left(pos - currentBlock.position()); + switch (character.toLatin1()) { + default: + break; + case ':': + // Do not indent when it's the first ':' and it's not the 'case' line. + if (text.contains(QLatin1String("case")) || text.contains(QLatin1String("default")) + || text.contains(QLatin1String("public")) || text.contains(QLatin1String("private")) + || text.contains(QLatin1String("protected")) || text.contains(QLatin1String("signals")) + || text.contains(QLatin1String("Q_SIGNALS"))) { + return false; + } + if (pos > 0 && doc->characterAt(pos - 1) != ':') + return true; + break; + case '<': + case '>': + // "<<" and ">>" could be problematic + if (pos > 0 && doc->characterAt(pos - 1) == character) + return true; + break; + } + + return false; +} + void ClangFormatBaseIndenter::indentBlock(const QTextBlock &block, const QChar &typedChar, int cursorPositionInEditor) @@ -416,12 +446,21 @@ void ClangFormatBaseIndenter::indentBlock(const QTextBlock &block, const int blockPosition = currentBlock.position(); trimFirstNonEmptyBlock(currentBlock); + if (typedChar != QChar::Null && cursorPositionInEditor > 0 + && m_doc->characterAt(cursorPositionInEditor - 1) == typedChar + && doNotIndentInContext(m_doc, cursorPositionInEditor - 1)) { + return; + } + if (formatWhileTyping() - && (cursorPositionInEditor == -1 || cursorPositionInEditor >= blockPosition)) { + && (cursorPositionInEditor == -1 || cursorPositionInEditor >= blockPosition) + && (typedChar == QChar::Null || typedChar == ';' || typedChar == '}')) { // Format before current position only in case the cursor is inside the indented block. // So if cursor position is less then the block position then the current line is before // the indented block - don't trigger extra formatting in this case. // cursorPositionInEditor == -1 means the consition matches automatically. + + // Format only before newline or complete statement not to break code. if (cursorPositionInEditor >= 0) cursorPositionInEditor += currentBlock.position() - blockPosition; else From f6dcc90a6f00672221898a191ccdd30f4d19ac15 Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar Date: Thu, 7 Feb 2019 12:44:25 +0100 Subject: [PATCH 4/9] ClangCodeModel: Modernize Change-Id: Ie001a2d8ed9c82ac5fedf8e59bd56d7bbdddf919 Reviewed-by: Orgad Shaneh --- src/plugins/clangcodemodel/clangbackendreceiver.cpp | 2 +- .../clangcodemodel/clangcompletioncontextanalyzer.h | 3 +-- .../clangcodemodel/clangdiagnosticmanager.cpp | 2 +- .../clangcodemodel/clangeditordocumentprocessor.cpp | 12 ++++++------ src/plugins/clangcodemodel/clangfollowsymbol.cpp | 4 +++- .../clanghighlightingresultreporter.cpp | 5 +---- src/plugins/clangcodemodel/clangoverviewmodel.cpp | 4 ++-- 7 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/plugins/clangcodemodel/clangbackendreceiver.cpp b/src/plugins/clangcodemodel/clangbackendreceiver.cpp index 39c7415a840..34e31368301 100644 --- a/src/plugins/clangcodemodel/clangbackendreceiver.cpp +++ b/src/plugins/clangcodemodel/clangbackendreceiver.cpp @@ -221,7 +221,7 @@ CppTools::CursorInfo::Range toCursorInfoRange(const SourceRangeContainer &source const SourceLocationContainer &end = sourceRange.end; const unsigned length = end.column - start.column; - return CppTools::CursorInfo::Range(start.line, start.column, length); + return {start.line, start.column, length}; } static diff --git a/src/plugins/clangcodemodel/clangcompletioncontextanalyzer.h b/src/plugins/clangcodemodel/clangcompletioncontextanalyzer.h index b51029492f9..08574e50186 100644 --- a/src/plugins/clangcodemodel/clangcompletioncontextanalyzer.h +++ b/src/plugins/clangcodemodel/clangcompletioncontextanalyzer.h @@ -39,6 +39,7 @@ class ClangCompletionAssistInterface; class ClangCompletionContextAnalyzer { public: + ClangCompletionContextAnalyzer() = delete; ClangCompletionContextAnalyzer(const ClangCompletionAssistInterface *assistInterface, CPlusPlus::LanguageFeatures languageFeatures); void analyze(); @@ -61,8 +62,6 @@ public: bool addSnippets() const { return m_addSnippets; } private: - ClangCompletionContextAnalyzer(); - int startOfFunctionCall(int endOfExpression) const; void setActionAndClangPosition(CompletionAction action, diff --git a/src/plugins/clangcodemodel/clangdiagnosticmanager.cpp b/src/plugins/clangcodemodel/clangdiagnosticmanager.cpp index 8bc0b925c29..8fcbe3477b0 100644 --- a/src/plugins/clangcodemodel/clangdiagnosticmanager.cpp +++ b/src/plugins/clangcodemodel/clangdiagnosticmanager.cpp @@ -91,7 +91,7 @@ QChar selectionEndChar(const QChar startSymbol) return QLatin1Char('"'); if (startSymbol == '<') return QLatin1Char('>'); - return QChar(); + return {}; } void selectToLocationEnd(QTextCursor &cursor) diff --git a/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp b/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp index aaca6380d2e..706c5101a3a 100644 --- a/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp +++ b/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp @@ -209,12 +209,12 @@ TextEditor::BlockRange toTextEditorBlock(QTextDocument *textDocument, const ClangBackEnd::SourceRangeContainer &sourceRangeContainer) { - return TextEditor::BlockRange(::Utils::Text::positionInText(textDocument, - sourceRangeContainer.start.line, - sourceRangeContainer.start.column), - ::Utils::Text::positionInText(textDocument, - sourceRangeContainer.end.line, - sourceRangeContainer.end.column)); + return {::Utils::Text::positionInText(textDocument, + sourceRangeContainer.start.line, + sourceRangeContainer.start.column), + ::Utils::Text::positionInText(textDocument, + sourceRangeContainer.end.line, + sourceRangeContainer.end.column)}; } QList diff --git a/src/plugins/clangcodemodel/clangfollowsymbol.cpp b/src/plugins/clangcodemodel/clangfollowsymbol.cpp index e5c66f6c6b1..96df23ab20a 100644 --- a/src/plugins/clangcodemodel/clangfollowsymbol.cpp +++ b/src/plugins/clangcodemodel/clangfollowsymbol.cpp @@ -35,6 +35,8 @@ #include #include +#include + namespace ClangCodeModel { namespace Internal { @@ -199,7 +201,7 @@ void ClangFollowSymbol::findLink(const CppTools::CursorInEditor &data, if (m_watcher) m_watcher->cancel(); - m_watcher.reset(new FutureSymbolWatcher()); + m_watcher = std::make_unique(); QObject::connect(m_watcher.get(), &FutureSymbolWatcher::finished, [=, filePath=data.filePath(), callback=std::move(processLinkCallback)]() mutable { diff --git a/src/plugins/clangcodemodel/clanghighlightingresultreporter.cpp b/src/plugins/clangcodemodel/clanghighlightingresultreporter.cpp index 125d4405a72..27eeea1af4a 100644 --- a/src/plugins/clangcodemodel/clanghighlightingresultreporter.cpp +++ b/src/plugins/clangcodemodel/clanghighlightingresultreporter.cpp @@ -138,10 +138,7 @@ TextEditor::HighlightingResult toHighlightingResult( { const auto textStyles = toTextStyles(tokenInfo.types); - return TextEditor::HighlightingResult(tokenInfo.line, - tokenInfo.column, - tokenInfo.length, - textStyles); + return {tokenInfo.line, tokenInfo.column, tokenInfo.length, textStyles}; } } // anonymous diff --git a/src/plugins/clangcodemodel/clangoverviewmodel.cpp b/src/plugins/clangcodemodel/clangoverviewmodel.cpp index e182fa7e885..8c92e2f2461 100644 --- a/src/plugins/clangcodemodel/clangoverviewmodel.cpp +++ b/src/plugins/clangcodemodel/clangoverviewmodel.cpp @@ -233,8 +233,8 @@ bool OverviewModel::isGenerated(const QModelIndex &) const auto item = static_cast(itemForIndex(sourceIndex)); if (!item) return {}; - return ::Utils::LineColumn(static_cast(item->token.line), - static_cast(item->token.column)); + return {static_cast(item->token.line), + static_cast(item->token.column)}; } OverviewModel::Range OverviewModel::rangeFromIndex(const QModelIndex &sourceIndex) const From 8789c5ab710f6b70384056415c9f8b1961c4a942 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 11 Feb 2019 12:24:27 +0100 Subject: [PATCH 5/9] QmlProfiler, PerfProfiler: Properly style panel widgets We need to set the "panelwidget" property for the foreground color to be set. Now that we do this correctly we don't need to hack around in the palette anymore in QmlProfiler. Change-Id: Icdc737e1c74d16ec76a12dbbdf6f8f64062bd19c Fixes: QTCREATORBUG-21961 Reviewed-by: Christian Stenger --- src/plugins/perfprofiler/perfprofilertool.cpp | 2 ++ src/plugins/qmlprofiler/qmlprofilertool.cpp | 4 +--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/perfprofiler/perfprofilertool.cpp b/src/plugins/perfprofiler/perfprofilertool.cpp index 28bbe0fecad..17361031890 100644 --- a/src/plugins/perfprofiler/perfprofilertool.cpp +++ b/src/plugins/perfprofiler/perfprofilertool.cpp @@ -164,7 +164,9 @@ PerfProfilerTool::PerfProfilerTool(QObject *parent) : m_filterMenu = new QMenu(m_filterButton); m_aggregateButton = new QToolButton; m_recordedLabel = new QLabel; + m_recordedLabel->setProperty("panelwidget", true); m_delayLabel = new QLabel; + m_delayLabel->setProperty("panelwidget", true); m_perspective.setAboutToActivateCallback([this]() { createViews(); }); } diff --git a/src/plugins/qmlprofiler/qmlprofilertool.cpp b/src/plugins/qmlprofiler/qmlprofilertool.cpp index 1196429d7dc..3ea47f86386 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertool.cpp @@ -213,9 +213,7 @@ QmlProfilerTool::QmlProfilerTool() this, &QmlProfilerTool::toggleVisibleFeature); d->m_timeLabel = new QLabel(); - QPalette palette; - palette.setColor(QPalette::WindowText, Qt::white); - d->m_timeLabel->setPalette(palette); + d->m_timeLabel->setProperty("panelwidget", true); d->m_timeLabel->setIndent(10); updateTimeDisplay(); connect(d->m_timeLabel, &QObject::destroyed, &d->m_recordingTimer, &QTimer::stop); From 0a974cb59f9b14050e0492615ecb0a40940615c5 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 11 Feb 2019 10:11:35 +0100 Subject: [PATCH 6/9] PerfProfiler: Drop [kernel] from expanded row labels We don't treat the kernel symbols as special anymore and the extra row messes up the other labels. Change-Id: I562b683322172a9b166a89b7c7087b4e69a1646c Reviewed-by: Christian Kandeler --- src/plugins/perfprofiler/perftimelinemodel.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/plugins/perfprofiler/perftimelinemodel.cpp b/src/plugins/perfprofiler/perftimelinemodel.cpp index b1469725513..c2a383161b9 100644 --- a/src/plugins/perfprofiler/perftimelinemodel.cpp +++ b/src/plugins/perfprofiler/perftimelinemodel.cpp @@ -82,10 +82,6 @@ QVariantList PerfTimelineModel::labels() const sample.insert(QLatin1String("id"), PerfEvent::LastSpecialTypeId); result << sample; - QVariantMap kernel; - kernel.insert(QLatin1String("description"), tr("[kernel]")); - result << kernel; - const PerfProfilerTraceManager *manager = traceManager(); const bool aggregated = manager->aggregateAddresses(); for (int i = 0; i < m_locationOrder.length(); ++i) { From 82466375b91cf0767f48de1ad17bae1ddd94dcef Mon Sep 17 00:00:00 2001 From: David Schulz Date: Thu, 7 Feb 2019 08:50:16 +0100 Subject: [PATCH 7/9] TextEditor: Show info when multiple highlight definitions are available Show an editor info bar when multiple highlight definitions can be found for a single file or mime type. Add a combo box to the info that allows the user to choose between them. Change-Id: I07278d065e19d4e04fba24a6d789c8b6c9f55d60 Reviewed-by: Eike Ziller --- src/plugins/texteditor/highlighter.cpp | 5 +++ src/plugins/texteditor/highlighter.h | 1 + src/plugins/texteditor/texteditor.cpp | 47 +++++++++++++------- src/plugins/texteditor/texteditorconstants.h | 3 +- 4 files changed, 39 insertions(+), 17 deletions(-) diff --git a/src/plugins/texteditor/highlighter.cpp b/src/plugins/texteditor/highlighter.cpp index c88a5aacb59..857c0f88cc7 100644 --- a/src/plugins/texteditor/highlighter.cpp +++ b/src/plugins/texteditor/highlighter.cpp @@ -121,6 +121,11 @@ Highlighter::Definition Highlighter::definitionForFileName(const QString &fileNa return highlightRepository()->definitionForFileName(fileName); } +Highlighter::Definition Highlighter::definitionForName(const QString &name) +{ + return highlightRepository()->definitionForName(name); +} + Highlighter::Definitions Highlighter::definitionsForDocument(const TextDocument *document) { const Utils::MimeType mimeType = Utils::mimeTypeForName(document->mimeType()); diff --git a/src/plugins/texteditor/highlighter.h b/src/plugins/texteditor/highlighter.h index cec2b0fb698..776f92faf35 100644 --- a/src/plugins/texteditor/highlighter.h +++ b/src/plugins/texteditor/highlighter.h @@ -46,6 +46,7 @@ public: static Definition definitionForDocument(const TextDocument *document); static Definition definitionForMimeType(const QString &mimeType); static Definition definitionForFileName(const QString &fileName); + static Definition definitionForName(const QString &name); static Definitions definitionsForDocument(const TextDocument *document); static Definitions definitionsForMimeType(const QString &mimeType); diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index 6cf1b701366..51a7da5e31c 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -611,7 +611,7 @@ public: void updateCodeFoldingVisible(); void reconfigure(); - void updateSyntaxInfoBar(bool showInfo); + void updateSyntaxInfoBar(const Highlighter::Definitions &definitions, const QString &fileName); void configureGenericHighlighter(const KSyntaxHighlighting::Definition &definition); public: @@ -3274,27 +3274,43 @@ void TextEditorWidgetPrivate::reconfigure() q->configureGenericHighlighter(); } -void TextEditorWidgetPrivate::updateSyntaxInfoBar(bool showInfo) +void TextEditorWidgetPrivate::updateSyntaxInfoBar(const Highlighter::Definitions &definitions, + const QString &fileName) { - Id id(Constants::INFO_SYNTAX_DEFINITION); + Id missing(Constants::INFO_MISSING_SYNTAX_DEFINITION); + Id multiple(Constants::INFO_MULTIPLE_SYNTAX_DEFINITIONS); InfoBar *infoBar = m_document->infoBar(); - if (showInfo) { - InfoBarEntry info(id, - BaseTextEditor::tr( - "A highlight definition was not found for this file. " - "Would you like to update highlight definition files?"), + if (definitions.isEmpty() && infoBar->canInfoBeAdded(missing) + && !TextEditorSettings::highlighterSettings().isIgnoredFilePattern(fileName)) { + InfoBarEntry info(missing, + BaseTextEditor::tr("A highlight definition was not found for this file. " + "Would you like to update highlight definition files?"), InfoBarEntry::GlobalSuppressionEnabled); - info.setCustomButtonInfo(BaseTextEditor::tr("Update Definitions"), [&]() { - m_document->infoBar()->removeInfo(id); + info.setCustomButtonInfo(BaseTextEditor::tr("Update Definitions"), [missing, this]() { + m_document->infoBar()->removeInfo(missing); Highlighter::updateDefinitions([widget = QPointer(q)]() { if (widget) widget->configureGenericHighlighter(); }); }); + + infoBar->removeInfo(multiple); + infoBar->addInfo(info); + } else if (definitions.size() > 1) { + InfoBarEntry info(multiple, + BaseTextEditor::tr("More than one highlight definition was found for this file. " + "Which one should be used to highlight this file?")); + info.setComboInfo(Utils::transform(definitions, &Highlighter::Definition::name), + [this](const QString &definition) { + this->configureGenericHighlighter(Highlighter::definitionForName(definition)); + }); + + infoBar->removeInfo(missing); infoBar->addInfo(info); } else { - infoBar->removeInfo(id); + infoBar->removeInfo(multiple); + infoBar->removeInfo(missing); } } @@ -8514,11 +8530,10 @@ QString TextEditorWidget::textAt(int from, int to) const void TextEditorWidget::configureGenericHighlighter() { - const Highlighter::Definition definition = Highlighter::definitionForDocument(textDocument()); - d->configureGenericHighlighter(definition); - d->updateSyntaxInfoBar(!definition.isValid() - && !TextEditorSettings::highlighterSettings().isIgnoredFilePattern( - textDocument()->filePath().fileName())); + const Highlighter::Definitions definitions = Highlighter::definitionsForDocument(textDocument()); + d->configureGenericHighlighter(definitions.isEmpty() ? Highlighter::Definition() + : definitions.first()); + d->updateSyntaxInfoBar(definitions, textDocument()->filePath().fileName()); } int TextEditorWidget::blockNumberForVisibleRow(int row) const diff --git a/src/plugins/texteditor/texteditorconstants.h b/src/plugins/texteditor/texteditorconstants.h index 22fa68d83bd..949b4934570 100644 --- a/src/plugins/texteditor/texteditorconstants.h +++ b/src/plugins/texteditor/texteditorconstants.h @@ -188,7 +188,8 @@ const char GOTO_NEXT_WORD_WITH_SELECTION[] = "TextEditor.GotoNextWordWithSelecti const char GOTO_PREVIOUS_WORD_CAMEL_CASE_WITH_SELECTION[] = "TextEditor.GotoPreviousWordCamelCaseWithSelection"; const char GOTO_NEXT_WORD_CAMEL_CASE_WITH_SELECTION[] = "TextEditor.GotoNextWordCamelCaseWithSelection"; const char C_TEXTEDITOR_MIMETYPE_TEXT[] = "text/plain"; -const char INFO_SYNTAX_DEFINITION[] = "TextEditor.InfoSyntaxDefinition"; +const char INFO_MISSING_SYNTAX_DEFINITION[] = "TextEditor.InfoSyntaxDefinition"; +const char INFO_MULTIPLE_SYNTAX_DEFINITIONS[] = "TextEditor.InfoMultipleSyntaxDefinitions"; const char TASK_OPEN_FILE[] = "TextEditor.Task.OpenFile"; const char CIRCULAR_PASTE[] = "TextEditor.CircularPaste"; const char SWITCH_UTF8BOM[] = "TextEditor.SwitchUtf8bom"; From 749bc50e1b2202846730d636d4d969bba3f24c82 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Fri, 8 Feb 2019 15:50:49 +0100 Subject: [PATCH 8/9] QmakeProjectManager: Prevent adding files to the project a second time We check the child nodes of the current project and only add the new file if it doesn't occur there already. Fixes: QTCREATORBUG-19546 Change-Id: Ic784a117515eb7e433ebf1d08db1708da6cf5440 Reviewed-by: Joerg Bornemann --- .../qmakeprojectmanager/qmakenodes.cpp | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/plugins/qmakeprojectmanager/qmakenodes.cpp b/src/plugins/qmakeprojectmanager/qmakenodes.cpp index ab518780abd..7ae34f31b62 100644 --- a/src/plugins/qmakeprojectmanager/qmakenodes.cpp +++ b/src/plugins/qmakeprojectmanager/qmakenodes.cpp @@ -171,7 +171,28 @@ bool QmakePriFileNode::removeSubProject(const QString &proFilePath) bool QmakePriFileNode::addFiles(const QStringList &filePaths, QStringList *notAdded) { QmakePriFile *pri = priFile(); - return pri ? pri->addFiles(filePaths, notAdded) : false; + if (!pri) + return false; + QList matchingNodes = findNodes([filePaths](const Node *n) { + return n->nodeType() == NodeType::File && filePaths.contains(n->filePath().toString()); + }); + matchingNodes = filtered(matchingNodes, [](const Node *n) { + for (const Node *parent = n->parentFolderNode(); parent; + parent = parent->parentFolderNode()) { + if (dynamic_cast(parent)) + return false; + } + return true; + }); + QStringList alreadyPresentFiles = transform(matchingNodes, + [](const Node *n) { return n->filePath().toString(); }); + alreadyPresentFiles.removeDuplicates(); + QStringList actualFilePaths = filePaths; + for (const QString &e : alreadyPresentFiles) + actualFilePaths.removeOne(e); + if (notAdded) + *notAdded = alreadyPresentFiles; + return pri->addFiles(actualFilePaths, notAdded); } bool QmakePriFileNode::removeFiles(const QStringList &filePaths, QStringList *notRemoved) From 6ae786bcc8e317c9a8faa2354b2e9a1fe1cc4db6 Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Mon, 11 Feb 2019 13:46:20 +0100 Subject: [PATCH 9/9] TextEditor: Fix build for Qt5.9 Do not use functions that are not supported with the minimum supported Qt for building QC. Partially reverts 963dc84cc5d1. Change-Id: Ife03143a7cf5a8f428754040e7004efe42d70a8a Reviewed-by: Christian Stenger Reviewed-by: Eike Ziller --- src/plugins/clangcodemodel/clangdiagnostictooltipwidget.cpp | 4 ++++ src/plugins/debugger/debuggertooltipmanager.cpp | 6 +++++- src/plugins/texteditor/texteditor.cpp | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/plugins/clangcodemodel/clangdiagnostictooltipwidget.cpp b/src/plugins/clangcodemodel/clangdiagnostictooltipwidget.cpp index 4811e1b5431..af8c13e76d1 100644 --- a/src/plugins/clangcodemodel/clangdiagnostictooltipwidget.cpp +++ b/src/plugins/clangcodemodel/clangdiagnostictooltipwidget.cpp @@ -386,10 +386,14 @@ private: static int widthLimit() { +#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) auto screen = QGuiApplication::screenAt(QCursor::pos()); if (!screen) screen = QGuiApplication::primaryScreen(); return screen->availableGeometry().width() / 2; +#else + return QApplication::desktop()->availableGeometry(QCursor::pos()).width() / 2; +#endif } private: diff --git a/src/plugins/debugger/debuggertooltipmanager.cpp b/src/plugins/debugger/debuggertooltipmanager.cpp index 2f8cef1d243..6f23a9df629 100644 --- a/src/plugins/debugger/debuggertooltipmanager.cpp +++ b/src/plugins/debugger/debuggertooltipmanager.cpp @@ -624,11 +624,15 @@ void DebuggerToolTipWidget::computeSize() // Add a bit of space to account for tooltip border, and not // touch the border of the screen. QPoint pos(x(), y()); - QTC_ASSERT(QApplication::desktop(), return); +#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) auto screen = QGuiApplication::screenAt(pos); if (!screen) screen = QGuiApplication::primaryScreen(); QRect desktopRect = screen->availableGeometry(); +#else + QTC_ASSERT(QApplication::desktop(), return); + QRect desktopRect = QApplication::desktop()->availableGeometry(); +#endif const int maxWidth = desktopRect.right() - pos.x() - 5 - 5; const int maxHeight = desktopRect.bottom() - pos.y() - 5 - 5; diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index 51a7da5e31c..5ac69be40ce 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -8252,7 +8252,11 @@ void TextEditorWidgetPrivate::updateTabStops() // to be set as an int. A work around is to access directly the QTextOption. qreal charWidth = QFontMetricsF(q->font()).width(QLatin1Char(' ')); QTextOption option = q->document()->defaultTextOption(); +#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) option.setTabStopDistance(charWidth * m_document->tabSettings().m_tabSize); +#else + option.setTabStop(charWidth * m_document->tabSettings().m_tabSize); +#endif q->document()->setDefaultTextOption(option); }