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) void CheckThread::parseAddonErrors(QString err, QString tool)
{ {
Q_UNUSED(tool);
QTextStream in(&err, QIODevice::ReadOnly); QTextStream in(&err, QIODevice::ReadOnly);
while (!in.atEnd()) { while (!in.atEnd()) {
QString line = in.readLine(); QString line = in.readLine();

View File

@ -27,5 +27,6 @@
<file>images/go-previous.png</file> <file>images/go-previous.png</file>
<file>images/applications-development.png</file> <file>images/applications-development.png</file>
<file>images/applications-system.png</file> <file>images/applications-system.png</file>
<file>images/llvm-dragon.svg</file>
</qresource> </qresource>
</RCC> </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.mActionShowPortability, &QAction::toggled, this, &MainWindow::showPortability);
connect(mUI.mActionShowPerformance, &QAction::toggled, this, &MainWindow::showPerformance); connect(mUI.mActionShowPerformance, &QAction::toggled, this, &MainWindow::showPerformance);
connect(mUI.mActionShowInformation, &QAction::toggled, this, &MainWindow::showInformation); 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.mActionCheckAll, &QAction::triggered, this, &MainWindow::checkAll);
connect(mUI.mActionUncheckAll, &QAction::triggered, this, &MainWindow::uncheckAll); connect(mUI.mActionUncheckAll, &QAction::triggered, this, &MainWindow::uncheckAll);
connect(mUI.mActionCollapseAll, &QAction::triggered, mUI.mResults, &ResultsView::collapseAllResults); connect(mUI.mActionCollapseAll, &QAction::triggered, mUI.mResults, &ResultsView::collapseAllResults);
@ -268,6 +270,8 @@ void MainWindow::loadSettings()
mUI.mActionShowPortability->setChecked(types->isShown(ShowTypes::ShowPortability)); mUI.mActionShowPortability->setChecked(types->isShown(ShowTypes::ShowPortability));
mUI.mActionShowPerformance->setChecked(types->isShown(ShowTypes::ShowPerformance)); mUI.mActionShowPerformance->setChecked(types->isShown(ShowTypes::ShowPerformance));
mUI.mActionShowInformation->setChecked(types->isShown(ShowTypes::ShowInformation)); 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(); const bool stdCpp03 = mSettings->value(SETTINGS_STD_CPP03, false).toBool();
mUI.mActionCpp03->setChecked(stdCpp03); mUI.mActionCpp03->setChecked(stdCpp03);

View File

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

View File

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

View File

@ -64,7 +64,9 @@ ResultsTree::ResultsTree(QWidget * parent) :
mShowErrorId(false), mShowErrorId(false),
mVisibleErrors(false), mVisibleErrors(false),
mSelectionModel(0), mSelectionModel(0),
mThread(nullptr) mThread(nullptr),
mShowCppcheck(true),
mShowClang(true)
{ {
setModel(&mModel); setModel(&mModel);
translate(); // Adds columns to grid 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) void ResultsTree::filterResults(const QString& filter)
{ {
mFilter = 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) { if (!hide) {
mVisibleErrors = true; mVisibleErrors = true;
} }

View File

@ -79,15 +79,6 @@ public:
*/ */
void clearRecheckFile(const QString &filename); 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. * @brief Function to filter the displayed list of errors.
* Refreshes the tree. * Refreshes the tree.
@ -217,6 +208,34 @@ signals:
/** Suppress Ids */ /** Suppress Ids */
void suppressIds(QStringList 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: protected slots:
/** /**
* @brief Slot to quickstart an error with default application * @brief Slot to quickstart an error with default application
@ -528,6 +547,9 @@ private:
QItemSelectionModel *mSelectionModel; QItemSelectionModel *mSelectionModel;
ThreadHandler *mThread; ThreadHandler *mThread;
bool mShowCppcheck;
bool mShowClang;
}; };
/// @} /// @}
#endif // RESULTSTREE_H #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::selectionChanged, this, &ResultsView::updateDetails);
connect(mUI.mTree, &ResultsTree::tagged, this, &ResultsView::tagged); connect(mUI.mTree, &ResultsTree::tagged, this, &ResultsView::tagged);
connect(mUI.mTree, &ResultsTree::suppressIds, this, &ResultsView::suppressIds); 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) 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() void ResultsView::collapseAllResults()
{ {
mUI.mTree->collapseAll(); mUI.mTree->collapseAll();

View File

@ -52,15 +52,6 @@ public:
mUI.mTree->setTags(tags); 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. * @brief Clear results and statistics and reset progressinfo.
* @param results Remove all the results from view? * @param results Remove all the results from view?
@ -225,6 +216,30 @@ signals:
/** Suppress Ids */ /** Suppress Ids */
void suppressIds(QStringList 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: public slots:
/** /**