GUI: Added buttons to show/hide clang/cppcheck results

This commit is contained in:
Daniel Marjamäki 2017-08-20 12:21:46 +02:00
parent f6184bba0d
commit 34a96a56be
10 changed files with 151 additions and 50 deletions

View File

@ -310,6 +310,7 @@ QString CheckThread::getAddonPath() const
void CheckThread::parseAddonErrors(QString err, QString tool)
{
Q_UNUSED(tool);
QTextStream in(&err, QIODevice::ReadOnly);
while (!in.atEnd()) {
QString line = in.readLine();

View File

@ -27,5 +27,6 @@
<file>images/go-previous.png</file>
<file>images/applications-development.png</file>
<file>images/applications-system.png</file>
<file>images/llvm-dragon.svg</file>
</qresource>
</RCC>

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 116 KiB

View File

@ -95,6 +95,8 @@ MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) :
connect(mUI.mActionShowPortability, &QAction::toggled, this, &MainWindow::showPortability);
connect(mUI.mActionShowPerformance, &QAction::toggled, this, &MainWindow::showPerformance);
connect(mUI.mActionShowInformation, &QAction::toggled, this, &MainWindow::showInformation);
connect(mUI.mActionShowCppcheck, &QAction::toggled, mUI.mResults, &ResultsView::showCppcheckResults);
connect(mUI.mActionShowClang, &QAction::toggled, mUI.mResults, &ResultsView::showClangResults);
connect(mUI.mActionCheckAll, &QAction::triggered, this, &MainWindow::checkAll);
connect(mUI.mActionUncheckAll, &QAction::triggered, this, &MainWindow::uncheckAll);
connect(mUI.mActionCollapseAll, &QAction::triggered, mUI.mResults, &ResultsView::collapseAllResults);
@ -268,6 +270,8 @@ void MainWindow::loadSettings()
mUI.mActionShowPortability->setChecked(types->isShown(ShowTypes::ShowPortability));
mUI.mActionShowPerformance->setChecked(types->isShown(ShowTypes::ShowPerformance));
mUI.mActionShowInformation->setChecked(types->isShown(ShowTypes::ShowInformation));
mUI.mActionShowCppcheck->setChecked(true);
mUI.mActionShowClang->setChecked(true);
const bool stdCpp03 = mSettings->value(SETTINGS_STD_CPP03, false).toBool();
mUI.mActionCpp03->setChecked(stdCpp03);

View File

@ -62,7 +62,7 @@
<x>0</x>
<y>0</y>
<width>640</width>
<height>20</height>
<height>25</height>
</rect>
</property>
<widget class="QMenu" name="mMenuFile">
@ -128,7 +128,7 @@
</widget>
<widget class="QMenu" name="mMenuAnalyze">
<property name="title">
<string>Analyze</string>
<string>A&amp;nalyze</string>
</property>
<widget class="QMenu" name="menuCpp_standard">
<property name="title">
@ -139,7 +139,7 @@
</widget>
<widget class="QMenu" name="menuC_standard">
<property name="title">
<string>C standard</string>
<string>&amp;C standard</string>
</property>
<addaction name="mActionC89"/>
<addaction name="mActionC99"/>
@ -184,11 +184,8 @@
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="mActionAnalyzeDirectory"/>
<addaction name="mActionOpenProjectFile"/>
<addaction name="mActionShowScratchpad"/>
<addaction name="mActionSave"/>
<addaction name="mActionReanalyzeModified"/>
<addaction name="mActionReanalyzeAll"/>
<addaction name="mActionStop"/>
<addaction name="mActionClearResults"/>
@ -211,6 +208,8 @@
<addaction name="mActionShowPortability"/>
<addaction name="mActionShowPerformance"/>
<addaction name="mActionShowInformation"/>
<addaction name="mActionShowCppcheck"/>
<addaction name="mActionShowClang"/>
</widget>
<widget class="QToolBar" name="mToolBarFilter">
<property name="windowTitle">
@ -292,7 +291,7 @@
<normaloff>:/images/view-recheck.png</normaloff>:/images/view-recheck.png</iconset>
</property>
<property name="text">
<string>&amp;Reanalyze all files</string>
<string>Reanal&amp;yze all files</string>
</property>
</action>
<action name="mActionStop">
@ -357,7 +356,7 @@
<normaloff>:/images/applications-development.png</normaloff>:/images/applications-development.png</iconset>
</property>
<property name="text">
<string>Style warnings</string>
<string>Style war&amp;nings</string>
</property>
<property name="iconText">
<string>Show style warnings</string>
@ -375,7 +374,7 @@
<normaloff>:/images/showerrors.png</normaloff>:/images/showerrors.png</iconset>
</property>
<property name="text">
<string>Errors</string>
<string>E&amp;rrors</string>
</property>
<property name="iconText">
<string>Show errors</string>
@ -462,7 +461,7 @@
<normaloff>:/images/scratchpad.png</normaloff>:/images/scratchpad.png</iconset>
</property>
<property name="text">
<string>Show S&amp;cratchpad...</string>
<string>Sh&amp;ow Scratchpad...</string>
</property>
</action>
<action name="mActionNewProjectFile">
@ -512,7 +511,7 @@
<normaloff>:/images/showwarnings.png</normaloff>:/images/showwarnings.png</iconset>
</property>
<property name="text">
<string>Warnings</string>
<string>&amp;Warnings</string>
</property>
<property name="iconText">
<string>Show warnings</string>
@ -530,7 +529,7 @@
<normaloff>:/images/showperformance.png</normaloff>:/images/showperformance.png</iconset>
</property>
<property name="text">
<string>Performance warnings</string>
<string>Per&amp;formance warnings</string>
</property>
<property name="iconText">
<string>Show performance warnings</string>
@ -556,7 +555,7 @@
<normaloff>:/images/dialog-information.png</normaloff>:/images/dialog-information.png</iconset>
</property>
<property name="text">
<string>Information</string>
<string>&amp;Information</string>
</property>
<property name="toolTip">
<string>Show information messages</string>
@ -571,12 +570,42 @@
<normaloff>:/images/applications-system.png</normaloff>:/images/applications-system.png</iconset>
</property>
<property name="text">
<string>Portability</string>
<string>&amp;Portability</string>
</property>
<property name="toolTip">
<string>Show portability warnings</string>
</property>
</action>
<action name="mActionShowCppcheck">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="gui.qrc">
<normaloff>:/cppcheck-gui.png</normaloff>:/cppcheck-gui.png</iconset>
</property>
<property name="text">
<string>Cppcheck</string>
</property>
<property name="toolTip">
<string>Show Cppcheck results</string>
</property>
</action>
<action name="mActionShowClang">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="gui.qrc">
<normaloff>:/images/llvm-dragon.svg</normaloff>:/images/llvm-dragon.svg</iconset>
</property>
<property name="text">
<string>Clang</string>
</property>
<property name="toolTip">
<string>Show Clang results</string>
</property>
</action>
<action name="mActionToolBarFilter">
<property name="checkable">
<bool>true</bool>
@ -590,7 +619,7 @@
</action>
<action name="mActionProjectMRU">
<property name="text">
<string notr="true">Project MRU placeholder</string>
<string notr="true">Project &amp;MRU placeholder</string>
</property>
<property name="visible">
<bool>true</bool>
@ -641,7 +670,7 @@
<bool>false</bool>
</property>
<property name="text">
<string>Platforms</string>
<string>P&amp;latforms</string>
</property>
<property name="visible">
<bool>false</bool>
@ -655,7 +684,7 @@
<bool>true</bool>
</property>
<property name="text">
<string>C++11</string>
<string>C++&amp;11</string>
</property>
</action>
<action name="mActionC99">
@ -666,7 +695,7 @@
<bool>true</bool>
</property>
<property name="text">
<string>C99</string>
<string>C&amp;99</string>
</property>
</action>
<action name="mActionPosix">
@ -674,7 +703,7 @@
<bool>true</bool>
</property>
<property name="text">
<string>Posix</string>
<string>&amp;Posix</string>
</property>
</action>
<action name="mActionC11">
@ -682,7 +711,7 @@
<bool>true</bool>
</property>
<property name="text">
<string>C11</string>
<string>C&amp;11</string>
</property>
</action>
<action name="mActionC89">
@ -690,7 +719,7 @@
<bool>true</bool>
</property>
<property name="text">
<string>C89</string>
<string>&amp;C89</string>
</property>
</action>
<action name="mActionCpp03">
@ -698,7 +727,7 @@
<bool>true</bool>
</property>
<property name="text">
<string>C++03</string>
<string>&amp;C++03</string>
</property>
</action>
<action name="mActionPrint">
@ -719,7 +748,7 @@
</action>
<action name="mActionLibraryEditor">
<property name="text">
<string>Library Editor...</string>
<string>&amp;Library Editor...</string>
</property>
<property name="toolTip">
<string>Open library editor</string>
@ -730,7 +759,7 @@
<bool>true</bool>
</property>
<property name="text">
<string>Auto-detect language</string>
<string>&amp;Auto-detect language</string>
</property>
</action>
<action name="mActionEnforceCpp">
@ -738,7 +767,7 @@
<bool>true</bool>
</property>
<property name="text">
<string>Enforce C++</string>
<string>&amp;Enforce C++</string>
</property>
</action>
<action name="mActionEnforceC">
@ -746,7 +775,7 @@
<bool>true</bool>
</property>
<property name="text">
<string>Enforce C</string>
<string>E&amp;nforce C</string>
</property>
</action>
</widget>

View File

@ -122,6 +122,14 @@ public:
return mAddons;
}
bool getClangAnalyzer() const {
return mAddons.contains("clang-analyzer");
}
bool getClangTidy() const {
return mAddons.contains("clang-tidy");
}
QStringList getTags() const {
return mTags;
}

View File

@ -64,7 +64,9 @@ ResultsTree::ResultsTree(QWidget * parent) :
mShowErrorId(false),
mVisibleErrors(false),
mSelectionModel(0),
mThread(nullptr)
mThread(nullptr),
mShowCppcheck(true),
mShowClang(true)
{
setModel(&mModel);
translate(); // Adds columns to grid
@ -400,6 +402,18 @@ void ResultsTree::showResults(ShowTypes::ShowType type, bool show)
}
}
void ResultsTree::showCppcheckResults(bool show)
{
mShowCppcheck = show;
refreshTree();
}
void ResultsTree::showClangResults(bool show)
{
mShowClang = show;
refreshTree();
}
void ResultsTree::filterResults(const QString& filter)
{
mFilter = filter;
@ -478,6 +492,14 @@ void ResultsTree::refreshTree()
}
}
// Tool filter
if (!hide) {
if (data["id"].toString().startsWith("clang"))
hide = !mShowClang;
else
hide = !mShowCppcheck;
}
if (!hide) {
mVisibleErrors = true;
}

View File

@ -79,15 +79,6 @@ public:
*/
void clearRecheckFile(const QString &filename);
/**
* @brief Function to show/hide certain type of errors
* Refreshes the tree.
*
* @param type Type of error to show/hide
* @param show Should specified errors be shown (true) or hidden (false)
*/
void showResults(ShowTypes::ShowType type, bool show);
/**
* @brief Function to filter the displayed list of errors.
* Refreshes the tree.
@ -217,6 +208,34 @@ signals:
/** Suppress Ids */
void suppressIds(QStringList ids);
public slots:
/**
* @brief Function to show/hide certain type of errors
* Refreshes the tree.
*
* @param type Type of error to show/hide
* @param show Should specified errors be shown (true) or hidden (false)
*/
void showResults(ShowTypes::ShowType type, bool show);
/**
* @brief Show/hide cppcheck errors.
* Refreshes the tree.
*
* @param show Should specified errors be shown (true) or hidden (false)
*/
void showCppcheckResults(bool show);
/**
* @brief Show/hide clang-tidy/clang-analyzer errors.
* Refreshes the tree.
*
* @param show Should specified errors be shown (true) or hidden (false)
*/
void showClangResults(bool show);
protected slots:
/**
* @brief Slot to quickstart an error with default application
@ -528,6 +547,9 @@ private:
QItemSelectionModel *mSelectionModel;
ThreadHandler *mThread;
bool mShowCppcheck;
bool mShowClang;
};
/// @}
#endif // RESULTSTREE_H

View File

@ -53,6 +53,9 @@ ResultsView::ResultsView(QWidget * parent) :
connect(mUI.mTree, &ResultsTree::selectionChanged, this, &ResultsView::updateDetails);
connect(mUI.mTree, &ResultsTree::tagged, this, &ResultsView::tagged);
connect(mUI.mTree, &ResultsTree::suppressIds, this, &ResultsView::suppressIds);
connect(this, &ResultsView::showResults, mUI.mTree, &ResultsTree::showResults);
connect(this, &ResultsView::showCppcheckResults, mUI.mTree, &ResultsTree::showCppcheckResults);
connect(this, &ResultsView::showClangResults, mUI.mTree, &ResultsTree::showClangResults);
}
void ResultsView::initialize(QSettings *settings, ApplicationList *list, ThreadHandler *checkThreadHandler)
@ -112,11 +115,6 @@ void ResultsView::error(const ErrorItem &item)
}
}
void ResultsView::showResults(ShowTypes::ShowType type, bool show)
{
mUI.mTree->showResults(type, show);
}
void ResultsView::collapseAllResults()
{
mUI.mTree->collapseAll();

View File

@ -52,15 +52,6 @@ public:
mUI.mTree->setTags(tags);
}
/**
* @brief Function to show/hide certain type of errors
* Refreshes the tree.
*
* @param type Type of error to show/hide
* @param show Should specified errors be shown (true) or hidden (false)
*/
void showResults(ShowTypes::ShowType type, bool show);
/**
* @brief Clear results and statistics and reset progressinfo.
* @param results Remove all the results from view?
@ -225,6 +216,30 @@ signals:
/** Suppress Ids */
void suppressIds(QStringList ids);
/**
* @brief Show/hide certain type of errors
* Refreshes the tree.
*
* @param type Type of error to show/hide
* @param show Should specified errors be shown (true) or hidden (false)
*/
void showResults(ShowTypes::ShowType type, bool show);
/**
* @brief Show/hide cppcheck errors.
* Refreshes the tree.
*
* @param show Should specified errors be shown (true) or hidden (false)
*/
void showCppcheckResults(bool show);
/**
* @brief Show/hide clang-tidy/clang-analyzer errors.
* Refreshes the tree.
*
* @param show Should specified errors be shown (true) or hidden (false)
*/
void showClangResults(bool show);
public slots:
/**