Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions gui/resultstree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <QFileDialog>
#include <QClipboard>
#include <QDesktopServices>
#include <QListWidget>
#include <QUrl>
#include <QContextMenuEvent>
#include <QModelIndex>
Expand Down Expand Up @@ -871,6 +872,35 @@ void ResultsTree::copy()
clipboard->setText(text);
}

void ResultsTree::hideId(QString errorId)
{
int filecount = mModel.rowCount();
for (int i = 0; i < filecount; i++) {
//Get file i
QStandardItem *file = mModel.item(i, 0);
if (!file) {
continue;
}

//Get the amount of errors this file contains
int errorcount = file->rowCount();

for (int j = 0; j < errorcount; j++) {
//Get the error itself
QStandardItem *child = file->child(j, 0);
if (!child) {
continue;
}

QVariantMap userdata = child->data().toMap();
if (userdata["id"].toString() == errorId) {
userdata["hide"] = true;
child->setData(QVariant(userdata));
}
}
}
refreshTree();
}
void ResultsTree::hideResult()
{
if (!mSelectionModel)
Expand Down Expand Up @@ -1365,3 +1395,10 @@ void ResultsTree::currentChanged(const QModelIndex &current, const QModelIndex &
QTreeView::currentChanged(current, previous);
emit selectionChanged(current);
}

void ResultsTree::on_mCheckerListWidget_itemClicked(QListWidgetItem *item)
{
QMessageBox msg(QMessageBox::Information, tr("Cppcheck"), item->text(), QMessageBox::Ok, this);

hideId(item->text());
}
9 changes: 9 additions & 0 deletions gui/resultstree.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <QStandardItem>
#include <QSettings>
#include <QContextMenuEvent>
#include <QListWidget>
#include "errorlogger.h" // Severity
#include "showtypes.h"

Expand Down Expand Up @@ -69,6 +70,12 @@ class ResultsTree : public QTreeView {
*/
void clear();

/**
* @brief Hide a given item by error ID
* @param errorId
*/
void hideId(QString errorId);

/**
* @brief Clear errors for a specific file from the tree
*/
Expand Down Expand Up @@ -236,6 +243,8 @@ public slots:
*/
void showClangResults(bool show);

void ResultsTree::on_mCheckerListWidget_itemClicked(QListWidgetItem *item);

protected slots:
/**
* @brief Slot to quickstart an error with default application
Expand Down
28 changes: 27 additions & 1 deletion gui/resultsview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ ResultsView::ResultsView(QWidget * parent) :
connect(this, &ResultsView::collapseAllResults, mUI.mTree, &ResultsTree::collapseAll);
connect(this, &ResultsView::expandAllResults, mUI.mTree, &ResultsTree::expandAll);
connect(this, &ResultsView::showHiddenResults, mUI.mTree, &ResultsTree::showHiddenResults);

connect(mUI.mCheckerListWidget, &QListWidget::itemClicked, mUI.mTree, &ResultsTree::on_mCheckerListWidget_itemClicked);
mUI.mListLog->setContextMenuPolicy(Qt::CustomContextMenu);
}

Expand Down Expand Up @@ -342,9 +342,34 @@ void ResultsView::readErrorsXml(const QString &filename)
msgBox.exec();
}

mUI.mCheckerListWidget->clear();
ErrorItem item;
foreach (item, errors) {
mUI.mTree->addErrorItem(item);
bool found=false;
for(int i=0;i<mUI.mCheckerListWidget->count();i++){
QListWidgetItem *lItem = mUI.mCheckerListWidget->item(i);
if(lItem->text()==item.errorId){
found=true;
break;
}
}
if(!found){
QListWidgetItem *listItem = new QListWidgetItem();
listItem->setData(Qt::DisplayRole, item.errorId);
listItem->setData(Qt::CheckStateRole, Qt::Checked);
mUI.mCheckerListWidget->addItem(listItem);
}
}
for(int i=0;i<mUI.mCheckerListWidget->count();i++){
int count=0;
QListWidgetItem *lItem = mUI.mCheckerListWidget->item(i);

foreach(item, errors) {
if(item.errorId==lItem->text())
count++;
}
lItem->setText(lItem->text()+" ("+QString::number(count)+")");
}

QString dir;
Expand Down Expand Up @@ -464,3 +489,4 @@ void ResultsView::on_mListLog_customContextMenuRequested(const QPoint &pos)

contextMenu.exec(globalPos);
}

53 changes: 27 additions & 26 deletions gui/resultsview.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>459</width>
<height>357</height>
<width>525</width>
<height>397</height>
</rect>
</property>
<property name="sizePolicy">
Expand All @@ -26,18 +26,6 @@
<string>Results</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QProgressBar" name="mProgress">
<property name="sizePolicy">
Expand All @@ -56,19 +44,32 @@
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="ResultsTree" name="mTree">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="ResultsTree" name="mTree">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
</widget>
<widget class="QListWidget" name="mCheckerListWidget">
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</widget>
<widget class="QTabWidget" name="tabWidget">
<property name="tabPosition">
Expand Down