From 99b0cf0ac9ea69c97efe1e2bf951a5b5c1186b58 Mon Sep 17 00:00:00 2001 From: Eberhard Graether Date: Mon, 11 Dec 2017 22:59:48 +0100 Subject: [PATCH] ui: Group include validation results by file and add line breaks for readability --- src/lib_gui/qt/window/QtTextEditDialog.cpp | 1 + .../QtProjectWizzardContentPaths.cpp | 70 +++++++++++++------ 2 files changed, 50 insertions(+), 21 deletions(-) diff --git a/src/lib_gui/qt/window/QtTextEditDialog.cpp b/src/lib_gui/qt/window/QtTextEditDialog.cpp index 53adda0e..adb01b7c 100644 --- a/src/lib_gui/qt/window/QtTextEditDialog.cpp +++ b/src/lib_gui/qt/window/QtTextEditDialog.cpp @@ -52,6 +52,7 @@ void QtTextEditDialog::populateWindow(QWidget* widget) m_text = new QPlainTextEdit(); m_text->setObjectName("textField"); m_text->setLineWrapMode(QPlainTextEdit::NoWrap); + m_text->setTabStopWidth(8 * m_text->fontMetrics().width('9')); layout->addWidget(m_text); widget->setLayout(layout); diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp index 1e612161..f095f88b 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp @@ -24,7 +24,9 @@ #include "utility/utilityFile.h" #include "utility/utilityPathDetection.h" -QtProjectWizzardContentPaths::QtProjectWizzardContentPaths(std::shared_ptr settings, QtProjectWizzardWindow* window) +QtProjectWizzardContentPaths::QtProjectWizzardContentPaths( + std::shared_ptr settings, QtProjectWizzardWindow* window +) : QtProjectWizzardContent(window) , m_settings(settings) , m_makePathsRelativeToProjectFileLocation(true) @@ -238,15 +240,17 @@ QtProjectWizzardContentPathsCDBHeader::QtProjectWizzardContentPathsCDBHeader( setTitleString("Header Files & Directories to Index"); setHelpString( - "Your Compilation Database already specifies which source files are part of your project. But Sourcetrail still needs to know which " - "header files to index as part of your project and which to skip. Choosing to skip indexing your system headers or external frameworks will " - "significantly improve the overall indexing performance.
" + "Your Compilation Database already specifies which source files are part of your project. But Sourcetrail still " + "needs to know which header files to index as part of your project and which to skip. Choosing to skip indexing " + "your system headers or external frameworks will significantly improve the overall indexing performance.
" "
" - "Use this list to define which header files should be indexed by Sourcetrail. Provide a directory to recursively add all contained files.
" + "Use this list to define which header files should be indexed by Sourcetrail. Provide a directory to recursively " + "add all contained files.
" "
" "You can make use of environment variables with ${ENV_VAR}.
" "
" - "Hint: Just enter the root path of your project if you want Sourcetrail to index all contained headers it encounters.
" + "Hint: Just enter the root path of your project if you want Sourcetrail to index all contained headers it " + "encounters.
" ); } @@ -266,7 +270,8 @@ void QtProjectWizzardContentPathsCDBHeader::load() { if (m_settings->getSourcePaths().empty()) { - std::shared_ptr cdbSettings = std::dynamic_pointer_cast(m_settings); + std::shared_ptr cdbSettings = + std::dynamic_pointer_cast(m_settings); std::set sourcePaths; const FilePath projectPath = m_settings->getProjectDirectoryPath(); @@ -333,7 +338,8 @@ void QtProjectWizzardContentPathsCDBHeader::buttonClicked() if (!m_filesDialog) { - const FilePath cdbPath = std::dynamic_pointer_cast(m_settings)->getCompilationDatabasePathExpandedAndAbsolute(); + const FilePath cdbPath = + std::dynamic_pointer_cast(m_settings)->getCompilationDatabasePathExpandedAndAbsolute(); if (!cdbPath.exists()) { QMessageBox msgBox; @@ -398,12 +404,14 @@ QtProjectWizzardContentPathsHeaderSearch::QtProjectWizzardContentPathsHeaderSear std::shared_ptr settings, QtProjectWizzardWindow* window, bool isCDB ) : QtProjectWizzardContentPaths(settings, window) - , m_showValidationResultFunctor(std::bind(&QtProjectWizzardContentPathsHeaderSearch::showValidationResult, this, std::placeholders::_1)) + , m_showValidationResultFunctor(std::bind( + &QtProjectWizzardContentPathsHeaderSearch::showValidationResult, this, std::placeholders::_1)) , m_isCdb(isCDB) { setTitleString(m_isCdb ? "Additional Include Paths" : "Include Paths"); setHelpString( - ((m_isCdb ? "Note: Use the Additional Include Paths to add paths that are missing in the Compilation Database.

" : "") + std::string( + ((m_isCdb ? "Note: Use the Additional Include Paths to add paths that are missing in the Compilation " + "Database.

" : "") + std::string( "Include Paths are used for resolving #include directives in the indexed source and header files. These paths are " "usually passed to the compiler with the '-I' or '-iquote' flags.
" "
" @@ -487,7 +495,8 @@ void QtProjectWizzardContentPathsHeaderSearch::validateButtonClicked() headerSearchPaths = ApplicationSettings::getInstance()->getHeaderSearchPathsExpanded(); - if (std::shared_ptr cxxSettings = std::dynamic_pointer_cast(m_settings)) + if (std::shared_ptr cxxSettings = + std::dynamic_pointer_cast(m_settings)) { indexedFilePaths = cxxSettings->getSourcePaths(); utility::append(headerSearchPaths, cxxSettings->getHeaderSearchPathsExpandedAndAbsolute()); @@ -527,18 +536,34 @@ void QtProjectWizzardContentPathsHeaderSearch::showValidationResult(const std::v } else { - std::string detailedText = ""; + std::map> orderedIncludes; for (const IncludeDirective& unresolvedInclude: unresolvedIncludes) { - detailedText += unresolvedInclude.getIncludingFile().str() + "[" + std::to_string(unresolvedInclude.getLineNumber()) + "]: " + unresolvedInclude.getDirective() + "\n"; + orderedIncludes[unresolvedInclude.getIncludingFile().str()].emplace( + unresolvedInclude.getLineNumber(), unresolvedInclude.getDirective()); + } + + std::string detailedText = ""; + for (const auto& p: orderedIncludes) + { + detailedText += p.first + "\n"; + + for (const auto& p2: p.second) + { + detailedText += std::to_string(p2.first) + ":\t" + p2.second + "\n"; + } + + detailedText += "\n"; } m_filesDialog = std::make_shared("Unresolved Include Directives", - ("

The indexed files contain " + std::to_string(unresolvedIncludes.size()) + " include directive" + (unresolvedIncludes.size() == 1 ? "" : "s") + " that could " - "not be resolved correctly. Please check the details and add the respective header search paths.

" - "

Note: This is only a quick pass that does not regard block commenting or conditional preprocessor directives. This means that " - "some of the unresolved includes may actually not be required by the indexer.

").c_str() - ); + ("

The indexed files contain " + std::to_string(unresolvedIncludes.size()) + " include directive" + + (unresolvedIncludes.size() == 1 ? "" : "s") + " that could not be resolved correctly. Please check the details " + "and add the respective header search paths.

" + "

Note: This is only a quick pass that does not regard block commenting or conditional preprocessor " + "directives. This means that some of the unresolved includes may actually not be required by the indexer.

" + ).c_str()); + m_filesDialog->setup(); m_filesDialog->setCloseVisible(false); m_filesDialog->setReadOnly(true); @@ -657,7 +682,8 @@ QtProjectWizzardContentPathsClassJava::QtProjectWizzardContentPathsClassJava( setTitleString("Class Path"); setHelpString( "Enter all the .jar files your project depends on. If your project depends on uncompiled java code that should " - "not be indexed, please add the root directory of those .java files here (the one where all the package names are relative to).
" + "not be indexed, please add the root directory of those .java files here (the one where all the package names " + "are relative to).
" "
" "You can make use of environment variables with ${ENV_VAR}." ); @@ -678,7 +704,8 @@ void QtProjectWizzardContentPathsClassJava::populate(QGridLayout* layout, int& r void QtProjectWizzardContentPathsClassJava::load() { - std::shared_ptr javaSettings = std::dynamic_pointer_cast(m_settings); + std::shared_ptr javaSettings = + std::dynamic_pointer_cast(m_settings); if (javaSettings) { m_list->setList(javaSettings->getClasspath()); @@ -688,7 +715,8 @@ void QtProjectWizzardContentPathsClassJava::load() void QtProjectWizzardContentPathsClassJava::save() { - std::shared_ptr javaSettings = std::dynamic_pointer_cast(m_settings); + std::shared_ptr javaSettings = + std::dynamic_pointer_cast(m_settings); if (javaSettings) { javaSettings->setClasspath(m_list->getList());