GUI: Suppressing results
This commit is contained in:
parent
5de64d6755
commit
ad82f49ae2
|
@ -371,11 +371,16 @@ void CheckThread::parseClangErrors(const QString &tool, const QString &file0, QS
|
|||
foreach (const ErrorItem &e, errorItems) {
|
||||
if (e.errorPath.isEmpty())
|
||||
continue;
|
||||
if (mSuppressions.contains(e.errorId))
|
||||
continue;
|
||||
std::list<ErrorLogger::ErrorMessage::FileLocation> callstack;
|
||||
foreach (const QErrorPathItem &path, e.errorPath) {
|
||||
callstack.push_back(ErrorLogger::ErrorMessage::FileLocation(path.file.toStdString(), path.info.toStdString(), path.line));
|
||||
}
|
||||
ErrorLogger::ErrorMessage errmsg(callstack, file0.toStdString(), errorItem.severity, errorItem.message.toStdString(), errorItem.errorId.toStdString(), false);
|
||||
const std::string f0 = file0.toStdString();
|
||||
const std::string msg = e.message.toStdString();
|
||||
const std::string id = e.errorId.toStdString();
|
||||
ErrorLogger::ErrorMessage errmsg(callstack, f0, errorItem.severity, msg, id, false);
|
||||
mResult.reportErr(errmsg);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,6 +68,10 @@ public:
|
|||
mClangPath = p;
|
||||
}
|
||||
|
||||
void setSuppressions(const QStringList s) {
|
||||
mSuppressions = s;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief method that is run in a thread
|
||||
*
|
||||
|
@ -127,6 +131,7 @@ private:
|
|||
QString mVsIncludePaths;
|
||||
QString mDataDir;
|
||||
QString mClangPath;
|
||||
QStringList mSuppressions;
|
||||
};
|
||||
/// @}
|
||||
#endif // CHECKTHREAD_H
|
||||
|
|
|
@ -127,6 +127,7 @@ MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) :
|
|||
connect(mUI.mResults, &ResultsView::resultsHidden, mUI.mActionShowHidden, &QAction::setEnabled);
|
||||
connect(mUI.mResults, &ResultsView::checkSelected, this, &MainWindow::performSelectedFilesCheck);
|
||||
connect(mUI.mResults, &ResultsView::tagged, this, &MainWindow::tagged);
|
||||
connect(mUI.mResults, &ResultsView::suppressIds, this, &MainWindow::suppressIds);
|
||||
connect(mUI.mMenuView, &QMenu::aboutToShow, this, &MainWindow::aboutToShowViewMenu);
|
||||
|
||||
// File menu
|
||||
|
@ -452,6 +453,7 @@ void MainWindow::doAnalyzeProject(ImportProject p)
|
|||
clangPath = "C:/Program Files/LLVM/bin";
|
||||
}
|
||||
mThread->setClangPath(clangPath);
|
||||
mThread->setSuppressions(mProjectFile->getSuppressions());
|
||||
#endif
|
||||
}
|
||||
mThread->setProject(p);
|
||||
|
@ -1690,3 +1692,16 @@ void MainWindow::tagged()
|
|||
if (!lastResults.isEmpty())
|
||||
mUI.mResults->save(lastResults, Report::XMLV2);
|
||||
}
|
||||
|
||||
void MainWindow::suppressIds(QStringList ids)
|
||||
{
|
||||
if (mProjectFile) {
|
||||
QStringList suppressions = mProjectFile->getSuppressions();
|
||||
foreach (QString s, ids) {
|
||||
if (!suppressions.contains(s))
|
||||
suppressions << s;
|
||||
}
|
||||
mProjectFile->setSuppressions(suppressions);
|
||||
mProjectFile->write();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -224,6 +224,9 @@ protected slots:
|
|||
/** Some results were tagged */
|
||||
void tagged();
|
||||
|
||||
/** Suppress error ids */
|
||||
void suppressIds(QStringList ids);
|
||||
|
||||
private:
|
||||
|
||||
/** Get filename for last results */
|
||||
|
|
|
@ -602,6 +602,7 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
|
|||
QAction *copymessageid = new QAction(tr("Copy message id"), &menu);
|
||||
QAction *hide = new QAction(tr("Hide"), &menu);
|
||||
QAction *hideallid = new QAction(tr("Hide all with id"), &menu);
|
||||
QAction *suppress = new QAction(tr("Suppress selected id(s)"), &menu);
|
||||
QAction *opencontainingfolder = new QAction(tr("Open containing folder"), &menu);
|
||||
|
||||
if (multipleSelection) {
|
||||
|
@ -624,6 +625,7 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
|
|||
menu.addAction(copymessageid);
|
||||
menu.addAction(hide);
|
||||
menu.addAction(hideallid);
|
||||
menu.addAction(suppress);
|
||||
menu.addAction(opencontainingfolder);
|
||||
|
||||
connect(recheckSelectedFiles, SIGNAL(triggered()), this, SLOT(recheckSelectedFiles()));
|
||||
|
@ -633,6 +635,7 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
|
|||
connect(copymessageid, SIGNAL(triggered()), this, SLOT(copyMessageId()));
|
||||
connect(hide, SIGNAL(triggered()), this, SLOT(hideResult()));
|
||||
connect(hideallid, SIGNAL(triggered()), this, SLOT(hideAllIdResult()));
|
||||
connect(suppress, SIGNAL(triggered()), this, SLOT(suppressSelectedIds()));
|
||||
connect(opencontainingfolder, SIGNAL(triggered()), this, SLOT(openContainingFolder()));
|
||||
|
||||
menu.addSeparator();
|
||||
|
@ -936,6 +939,43 @@ void ResultsTree::hideAllIdResult()
|
|||
}
|
||||
}
|
||||
|
||||
void ResultsTree::suppressSelectedIds()
|
||||
{
|
||||
if (!mSelectionModel)
|
||||
return;
|
||||
|
||||
QModelIndexList selectedRows = mSelectionModel->selectedRows();
|
||||
QSet<QString> selectedIds;
|
||||
foreach (QModelIndex index, selectedRows) {
|
||||
QStandardItem *item = mModel.itemFromIndex(index);
|
||||
if (!item->parent())
|
||||
continue;
|
||||
if (item->parent()->parent())
|
||||
item = item->parent();
|
||||
QVariantMap data = item->data().toMap();
|
||||
if (!data.contains("id"))
|
||||
continue;
|
||||
selectedIds << data["id"].toString();
|
||||
}
|
||||
|
||||
// delete all errors with selected message Ids
|
||||
for (int i = 0; i < mModel.rowCount(); i++) {
|
||||
QStandardItem * const file = mModel.item(i, 0);
|
||||
for (int j = 0; j < file->rowCount(); ) {
|
||||
QStandardItem *errorItem = file->child(j, 0);
|
||||
QVariantMap userdata = errorItem->data().toMap();
|
||||
if (selectedIds.contains(userdata["id"].toString())) {
|
||||
file->removeRow(j);
|
||||
} else {
|
||||
j++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
emit suppressIds(selectedIds.toList());
|
||||
}
|
||||
|
||||
void ResultsTree::openContainingFolder()
|
||||
{
|
||||
QString filePath = getFilePath(mContextItem, true);
|
||||
|
|
|
@ -210,6 +210,9 @@ signals:
|
|||
*/
|
||||
void tagged();
|
||||
|
||||
/** Suppress Ids */
|
||||
void suppressIds(QStringList ids);
|
||||
|
||||
protected slots:
|
||||
/**
|
||||
* @brief Slot to quickstart an error with default application
|
||||
|
@ -267,6 +270,9 @@ protected slots:
|
|||
*/
|
||||
void hideAllIdResult();
|
||||
|
||||
/** Slot for context menu item to suppress all messages with the current message id */
|
||||
void suppressSelectedIds();
|
||||
|
||||
/**
|
||||
* @brief Slot for context menu item to open the folder containing the current file.
|
||||
*/
|
||||
|
|
|
@ -52,6 +52,7 @@ ResultsView::ResultsView(QWidget * parent) :
|
|||
connect(mUI.mTree, &ResultsTree::checkSelected, this, &ResultsView::checkSelected);
|
||||
connect(mUI.mTree, &ResultsTree::selectionChanged, this, &ResultsView::updateDetails);
|
||||
connect(mUI.mTree, &ResultsTree::tagged, this, &ResultsView::tagged);
|
||||
connect(mUI.mTree, &ResultsTree::suppressIds, this, &ResultsView::suppressIds);
|
||||
}
|
||||
|
||||
void ResultsView::initialize(QSettings *settings, ApplicationList *list, ThreadHandler *checkThreadHandler)
|
||||
|
|
|
@ -218,6 +218,9 @@ signals:
|
|||
*/
|
||||
void tagged();
|
||||
|
||||
/** Suppress Ids */
|
||||
void suppressIds(QStringList ids);
|
||||
|
||||
public slots:
|
||||
|
||||
/**
|
||||
|
|
|
@ -47,6 +47,7 @@ void ThreadHandler::clearFiles()
|
|||
mResults.clearFiles();
|
||||
mAnalyseWholeProgram = false;
|
||||
mAddons.clear();
|
||||
mSuppressions.clear();
|
||||
}
|
||||
|
||||
void ThreadHandler::setFiles(const QStringList &files)
|
||||
|
@ -93,6 +94,7 @@ void ThreadHandler::check(const Settings &settings)
|
|||
|
||||
for (int i = 0; i < mRunningThreadCount; i++) {
|
||||
mThreads[i]->setAddons(mAddons);
|
||||
mThreads[i]->setSuppressions(mSuppressions);
|
||||
mThreads[i]->setVsIncludePaths(mVsIncludePaths);
|
||||
mThreads[i]->setClangPath(mClangPath);
|
||||
mThreads[i]->setDataDir(mDataDir);
|
||||
|
|
|
@ -75,6 +75,10 @@ public:
|
|||
mAddons = addons;
|
||||
}
|
||||
|
||||
void setSuppressions(const QStringList &s) {
|
||||
mSuppressions = s;
|
||||
}
|
||||
|
||||
void setVsIncludePaths(const QString &s) {
|
||||
mVsIncludePaths = s;
|
||||
}
|
||||
|
@ -250,6 +254,7 @@ protected:
|
|||
bool mAnalyseWholeProgram;
|
||||
|
||||
QStringList mAddons;
|
||||
QStringList mSuppressions;
|
||||
QString mVsIncludePaths;
|
||||
QString mClangPath;
|
||||
|
||||
|
|
Loading…
Reference in New Issue