CppEditor: Show info bar for project-less file

While at it, centralize the code for handling the info bars and actions.

Change-Id: Ied62e3db268aaff3ef87e246bfe2b50399341be3
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Nikolai Kosjar
2017-01-17 12:33:55 +01:00
parent 3080bda066
commit ec3dcfd6ad
12 changed files with 326 additions and 64 deletions

View File

@@ -97,6 +97,7 @@ CppEditorDocument::CppEditorDocument()
, m_cachedContentsRevision(-1)
, m_processorRevision(0)
, m_completionAssistProvider(0)
, m_minimizableInfoBars(*infoBar())
{
setId(CppEditor::Constants::CPPEDITOR_ID);
setSyntaxHighlighter(new CppHighlighter);
@@ -309,12 +310,30 @@ void CppEditorDocument::initializeTimer()
Qt::UniqueConnection);
}
const MinimizableInfoBars &CppEditorDocument::minimizableInfoBars() const
{
return m_minimizableInfoBars;
}
CppTools::BaseEditorDocumentProcessor *CppEditorDocument::processor()
{
if (!m_processor) {
m_processor.reset(mm()->editorDocumentProcessor(this));
connect(m_processor.data(), &CppTools::BaseEditorDocumentProcessor::projectPartInfoUpdated,
[this] (const CppTools::ProjectPartInfo &projectPartInfo)
{
const bool hasProjectPart
= projectPartInfo.hint != CppTools::ProjectPartInfo::IsFallbackMatch;
m_minimizableInfoBars.processHasProjectPart(hasProjectPart);
});
connect(m_processor.data(), &CppTools::BaseEditorDocumentProcessor::codeWarningsUpdated,
this, &CppEditorDocument::codeWarningsUpdated);
[this] (unsigned revision,
const QList<QTextEdit::ExtraSelection> selections,
const std::function<QWidget*()> &creator,
const TextEditor::RefactorMarkers &refactorMarkers) {
emit codeWarningsUpdated(revision, selections, refactorMarkers);
m_minimizableInfoBars.processHeaderDiagnostics(creator);
});
connect(m_processor.data(), &CppTools::BaseEditorDocumentProcessor::ifdefedOutBlocksUpdated,
this, &CppEditorDocument::ifdefedOutBlocksUpdated);
connect(m_processor.data(), &CppTools::BaseEditorDocumentProcessor::cppDocumentUpdated,