Fixed #9724 (GUI: The tags do not work anymore)
This commit is contained in:
parent
b249d9be31
commit
9af288e1dd
|
@ -141,7 +141,6 @@ MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) :
|
||||||
connect(mUI.mResults, &ResultsView::gotResults, this, &MainWindow::resultsAdded);
|
connect(mUI.mResults, &ResultsView::gotResults, this, &MainWindow::resultsAdded);
|
||||||
connect(mUI.mResults, &ResultsView::resultsHidden, mUI.mActionShowHidden, &QAction::setEnabled);
|
connect(mUI.mResults, &ResultsView::resultsHidden, mUI.mActionShowHidden, &QAction::setEnabled);
|
||||||
connect(mUI.mResults, &ResultsView::checkSelected, this, &MainWindow::performSelectedFilesCheck);
|
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.mResults, &ResultsView::suppressIds, this, &MainWindow::suppressIds);
|
||||||
connect(mUI.mResults, &ResultsView::editFunctionContract, this, &MainWindow::editFunctionContract);
|
connect(mUI.mResults, &ResultsView::editFunctionContract, this, &MainWindow::editFunctionContract);
|
||||||
connect(mUI.mMenuView, &QMenu::aboutToShow, this, &MainWindow::aboutToShowViewMenu);
|
connect(mUI.mMenuView, &QMenu::aboutToShow, this, &MainWindow::aboutToShowViewMenu);
|
||||||
|
@ -1810,13 +1809,6 @@ void MainWindow::selectPlatform()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::tagged()
|
|
||||||
{
|
|
||||||
const QString &lastResults = getLastResults();
|
|
||||||
if (!lastResults.isEmpty())
|
|
||||||
mUI.mResults->save(lastResults, Report::XMLV2);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::suppressIds(QStringList ids)
|
void MainWindow::suppressIds(QStringList ids)
|
||||||
{
|
{
|
||||||
if (!mProjectFile)
|
if (!mProjectFile)
|
||||||
|
|
|
@ -221,9 +221,6 @@ protected slots:
|
||||||
/** @brief Selects the platform as analyzed platform. */
|
/** @brief Selects the platform as analyzed platform. */
|
||||||
void selectPlatform();
|
void selectPlatform();
|
||||||
|
|
||||||
/** Some results were tagged */
|
|
||||||
void tagged();
|
|
||||||
|
|
||||||
/** Suppress error ids */
|
/** Suppress error ids */
|
||||||
void suppressIds(QStringList ids);
|
void suppressIds(QStringList ids);
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,8 @@ void ProjectFile::clear()
|
||||||
mCheckUnknownFunctionReturn.clear();
|
mCheckUnknownFunctionReturn.clear();
|
||||||
safeChecks.clear();
|
safeChecks.clear();
|
||||||
mVsConfigurations.clear();
|
mVsConfigurations.clear();
|
||||||
|
mTags.clear();
|
||||||
|
mWarningTags.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ProjectFile::read(const QString &filename)
|
bool ProjectFile::read(const QString &filename)
|
||||||
|
@ -188,6 +190,9 @@ bool ProjectFile::read(const QString &filename)
|
||||||
if (xmlReader.name() == CppcheckXml::TagsElementName)
|
if (xmlReader.name() == CppcheckXml::TagsElementName)
|
||||||
readStringList(mTags, xmlReader, CppcheckXml::TagElementName);
|
readStringList(mTags, xmlReader, CppcheckXml::TagElementName);
|
||||||
|
|
||||||
|
if (xmlReader.name() == CppcheckXml::TagWarningsElementName)
|
||||||
|
readTagWarnings(xmlReader, xmlReader.attributes().value(QString(), CppcheckXml::TagAttributeName).toString());
|
||||||
|
|
||||||
if (xmlReader.name() == CppcheckXml::MaxCtuDepthElementName)
|
if (xmlReader.name() == CppcheckXml::MaxCtuDepthElementName)
|
||||||
mMaxCtuDepth = readInt(xmlReader, mMaxCtuDepth);
|
mMaxCtuDepth = readInt(xmlReader, mMaxCtuDepth);
|
||||||
|
|
||||||
|
@ -636,6 +641,41 @@ void ProjectFile::readSuppressions(QXmlStreamReader &reader)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ProjectFile::readTagWarnings(QXmlStreamReader &reader, QString tag)
|
||||||
|
{
|
||||||
|
QXmlStreamReader::TokenType type;
|
||||||
|
do {
|
||||||
|
type = reader.readNext();
|
||||||
|
switch (type) {
|
||||||
|
case QXmlStreamReader::StartElement:
|
||||||
|
// Read library-elements
|
||||||
|
if (reader.name().toString() == CppcheckXml::WarningElementName) {
|
||||||
|
std::size_t cppcheckId = reader.attributes().value(QString(), CppcheckXml::CppcheckIdAttributeName).toULongLong();
|
||||||
|
mWarningTags[cppcheckId] = tag;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case QXmlStreamReader::EndElement:
|
||||||
|
if (reader.name().toString() != CppcheckXml::WarningElementName)
|
||||||
|
return;
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Not handled
|
||||||
|
case QXmlStreamReader::NoToken:
|
||||||
|
case QXmlStreamReader::Invalid:
|
||||||
|
case QXmlStreamReader::StartDocument:
|
||||||
|
case QXmlStreamReader::EndDocument:
|
||||||
|
case QXmlStreamReader::Characters:
|
||||||
|
case QXmlStreamReader::Comment:
|
||||||
|
case QXmlStreamReader::DTD:
|
||||||
|
case QXmlStreamReader::EntityReference:
|
||||||
|
case QXmlStreamReader::ProcessingInstruction:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} while (true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ProjectFile::readStringList(QStringList &stringlist, QXmlStreamReader &reader, const char elementname[])
|
void ProjectFile::readStringList(QStringList &stringlist, QXmlStreamReader &reader, const char elementname[])
|
||||||
{
|
{
|
||||||
QXmlStreamReader::TokenType type;
|
QXmlStreamReader::TokenType type;
|
||||||
|
@ -734,6 +774,20 @@ void ProjectFile::setVSConfigurations(const QStringList &vsConfigs)
|
||||||
mVsConfigurations = vsConfigs;
|
mVsConfigurations = vsConfigs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProjectFile::setWarningTags(std::size_t cppcheckId, QString tag)
|
||||||
|
{
|
||||||
|
if (tag.isEmpty())
|
||||||
|
mWarningTags.erase(cppcheckId);
|
||||||
|
else if (cppcheckId > 0)
|
||||||
|
mWarningTags[cppcheckId] = tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ProjectFile::getWarningTags(std::size_t cppcheckId) const
|
||||||
|
{
|
||||||
|
auto it = mWarningTags.find(cppcheckId);
|
||||||
|
return (it != mWarningTags.end()) ? it->second : QString();
|
||||||
|
}
|
||||||
|
|
||||||
bool ProjectFile::write(const QString &filename)
|
bool ProjectFile::write(const QString &filename)
|
||||||
{
|
{
|
||||||
if (!filename.isEmpty())
|
if (!filename.isEmpty())
|
||||||
|
@ -883,7 +937,7 @@ bool ProjectFile::write(const QString &filename)
|
||||||
if (!suppression.symbolName.empty())
|
if (!suppression.symbolName.empty())
|
||||||
xmlWriter.writeAttribute("symbolName", QString::fromStdString(suppression.symbolName));
|
xmlWriter.writeAttribute("symbolName", QString::fromStdString(suppression.symbolName));
|
||||||
if (suppression.cppcheckId > 0)
|
if (suppression.cppcheckId > 0)
|
||||||
xmlWriter.writeAttribute("cppcheck-id", QString::number(suppression.cppcheckId));
|
xmlWriter.writeAttribute(CppcheckXml::CppcheckIdAttributeName, QString::number(suppression.cppcheckId));
|
||||||
if (!suppression.errorId.empty())
|
if (!suppression.errorId.empty())
|
||||||
xmlWriter.writeCharacters(QString::fromStdString(suppression.errorId));
|
xmlWriter.writeCharacters(QString::fromStdString(suppression.errorId));
|
||||||
xmlWriter.writeEndElement();
|
xmlWriter.writeEndElement();
|
||||||
|
@ -914,6 +968,26 @@ bool ProjectFile::write(const QString &filename)
|
||||||
CppcheckXml::ToolElementName);
|
CppcheckXml::ToolElementName);
|
||||||
|
|
||||||
writeStringList(xmlWriter, mTags, CppcheckXml::TagsElementName, CppcheckXml::TagElementName);
|
writeStringList(xmlWriter, mTags, CppcheckXml::TagsElementName, CppcheckXml::TagElementName);
|
||||||
|
if (!mWarningTags.empty()) {
|
||||||
|
QStringList tags;
|
||||||
|
for (const auto wt: mWarningTags) {
|
||||||
|
if (!tags.contains(wt.second))
|
||||||
|
tags.append(wt.second);
|
||||||
|
}
|
||||||
|
for (const QString &tag: tags) {
|
||||||
|
xmlWriter.writeStartElement(CppcheckXml::TagWarningsElementName);
|
||||||
|
xmlWriter.writeAttribute(CppcheckXml::TagAttributeName, tag);
|
||||||
|
QStringList warnings;
|
||||||
|
for (const auto wt: mWarningTags) {
|
||||||
|
if (wt.second == tag) {
|
||||||
|
xmlWriter.writeStartElement(CppcheckXml::WarningElementName);
|
||||||
|
xmlWriter.writeAttribute(CppcheckXml::CppcheckIdAttributeName, QString::number(wt.first));
|
||||||
|
xmlWriter.writeEndElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xmlWriter.writeEndElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
xmlWriter.writeEndDocument();
|
xmlWriter.writeEndDocument();
|
||||||
file.close();
|
file.close();
|
||||||
|
|
|
@ -331,6 +331,12 @@ public:
|
||||||
mTags = tags;
|
mTags = tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Set tags for a warning */
|
||||||
|
void setWarningTags(std::size_t cppcheckId, QString tags);
|
||||||
|
|
||||||
|
/** Get tags for a warning */
|
||||||
|
QString getWarningTags(std::size_t cppcheckId) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Write project file (to disk).
|
* @brief Write project file (to disk).
|
||||||
* @param filename Filename to use.
|
* @param filename Filename to use.
|
||||||
|
@ -437,6 +443,12 @@ protected:
|
||||||
*/
|
*/
|
||||||
void readSuppressions(QXmlStreamReader &reader);
|
void readSuppressions(QXmlStreamReader &reader);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Read tag warnings, what warnings are tagged with a specific tag
|
||||||
|
* @param reader XML stream reader.
|
||||||
|
*/
|
||||||
|
void readTagWarnings(QXmlStreamReader &reader, QString tag);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Read string list
|
* @brief Read string list
|
||||||
* @param stringlist destination string list
|
* @param stringlist destination string list
|
||||||
|
@ -552,10 +564,15 @@ private:
|
||||||
bool mClangTidy;
|
bool mClangTidy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Warning tags
|
* @brief Tags
|
||||||
*/
|
*/
|
||||||
QStringList mTags;
|
QStringList mTags;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Warning tags
|
||||||
|
*/
|
||||||
|
std::map<std::size_t, QString> mWarningTags;
|
||||||
|
|
||||||
/** Max CTU depth */
|
/** Max CTU depth */
|
||||||
int mMaxCtuDepth;
|
int mMaxCtuDepth;
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,23 @@
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
#include "xmlreportv2.h"
|
#include "xmlreportv2.h"
|
||||||
|
|
||||||
|
static const char COLUMN[] = "column";
|
||||||
|
static const char CPPCHECKID[] = "cppcheckId";
|
||||||
|
static const char CWE[] = "cwe";
|
||||||
|
static const char ERRORID[] = "id";
|
||||||
|
static const char FILENAME[] = "file";
|
||||||
|
static const char FILE0[] = "file0";
|
||||||
|
static const char FUNCTION[] = "function";
|
||||||
|
static const char HIDE[] = "hide";
|
||||||
|
static const char INCOMPLETE[] = "incomplete";
|
||||||
|
static const char INCONCLUSIVE[] = "inconclusive";
|
||||||
|
static const char LINE[] = "line";
|
||||||
|
static const char MESSAGE[] = "message";
|
||||||
|
static const char SEVERITY[] = "severity";
|
||||||
|
static const char SINCEDATE[] = "sinceDate";
|
||||||
|
static const char SUMMARY[] = "summary";
|
||||||
|
static const char TAGS[] = "tags";
|
||||||
|
|
||||||
// These must match column headers given in ResultsTree::translate()
|
// These must match column headers given in ResultsTree::translate()
|
||||||
static const int COLUMN_SINCE_DATE = 6;
|
static const int COLUMN_SINCE_DATE = 6;
|
||||||
static const int COLUMN_TAGS = 7;
|
static const int COLUMN_TAGS = 7;
|
||||||
|
@ -175,7 +192,9 @@ bool ResultsTree::addErrorItem(const ErrorItem &item)
|
||||||
line.message = item.message;
|
line.message = item.message;
|
||||||
line.severity = item.severity;
|
line.severity = item.severity;
|
||||||
line.sinceDate = item.sinceDate;
|
line.sinceDate = item.sinceDate;
|
||||||
line.tags = item.tags;
|
if (const ProjectFile *activeProject = ProjectFile::getActiveProject()) {
|
||||||
|
line.tags = activeProject->getWarningTags(item.cppcheckId);
|
||||||
|
}
|
||||||
//Create the base item for the error and ensure it has a proper
|
//Create the base item for the error and ensure it has a proper
|
||||||
//file item as a parent
|
//file item as a parent
|
||||||
QStandardItem* fileItem = ensureFileItem(loc.file, item.file0, hide);
|
QStandardItem* fileItem = ensureFileItem(loc.file, item.file0, hide);
|
||||||
|
@ -190,22 +209,22 @@ bool ResultsTree::addErrorItem(const ErrorItem &item)
|
||||||
|
|
||||||
//Add user data to that item
|
//Add user data to that item
|
||||||
QMap<QString, QVariant> data;
|
QMap<QString, QVariant> data;
|
||||||
data["severity"] = ShowTypes::SeverityToShowType(item.severity);
|
data[SEVERITY] = ShowTypes::SeverityToShowType(item.severity);
|
||||||
data["summary"] = item.summary;
|
data[SUMMARY] = item.summary;
|
||||||
data["message"] = item.message;
|
data[MESSAGE] = item.message;
|
||||||
data["file"] = loc.file;
|
data[FILENAME] = loc.file;
|
||||||
data["line"] = loc.line;
|
data[LINE] = loc.line;
|
||||||
data["column"] = loc.column;
|
data[COLUMN] = loc.column;
|
||||||
data["id"] = item.errorId;
|
data[ERRORID] = item.errorId;
|
||||||
data["incomplete"] = item.incomplete;
|
data[INCOMPLETE] = item.incomplete;
|
||||||
data["cwe"] = item.cwe;
|
data[CWE] = item.cwe;
|
||||||
data["cppcheckId"] = item.cppcheckId;
|
data[CPPCHECKID] = item.cppcheckId;
|
||||||
data["inconclusive"] = item.inconclusive;
|
data[INCONCLUSIVE] = item.inconclusive;
|
||||||
data["file0"] = stripPath(item.file0, true);
|
data[FILE0] = stripPath(item.file0, true);
|
||||||
data["function"] = item.function;
|
data[FUNCTION] = item.function;
|
||||||
data["sinceDate"] = item.sinceDate;
|
data[SINCEDATE] = item.sinceDate;
|
||||||
data["tags"] = item.tags;
|
data[TAGS] = line.tags;
|
||||||
data["hide"] = hide;
|
data[HIDE] = hide;
|
||||||
stditem->setData(QVariant(data));
|
stditem->setData(QVariant(data));
|
||||||
|
|
||||||
//Add backtrace files as children
|
//Add backtrace files as children
|
||||||
|
@ -226,17 +245,17 @@ bool ResultsTree::addErrorItem(const ErrorItem &item)
|
||||||
|
|
||||||
// Add user data to that item
|
// Add user data to that item
|
||||||
QMap<QString, QVariant> child_data;
|
QMap<QString, QVariant> child_data;
|
||||||
child_data["severity"] = ShowTypes::SeverityToShowType(line.severity);
|
child_data[SEVERITY] = ShowTypes::SeverityToShowType(line.severity);
|
||||||
child_data["summary"] = line.summary;
|
child_data[SUMMARY] = line.summary;
|
||||||
child_data["message"] = line.message;
|
child_data[MESSAGE] = line.message;
|
||||||
child_data["file"] = e.file;
|
child_data[FILENAME] = e.file;
|
||||||
child_data["line"] = e.line;
|
child_data[LINE] = e.line;
|
||||||
child_data["column"] = e.column;
|
child_data[COLUMN] = e.column;
|
||||||
child_data["id"] = line.errorId;
|
child_data[ERRORID] = line.errorId;
|
||||||
child_data["incomplete"] = line.incomplete;
|
child_data[INCOMPLETE] = line.incomplete;
|
||||||
child_data["cwe"] = line.cwe;
|
child_data[CWE] = line.cwe;
|
||||||
child_data["cppcheckId"] = line.cppcheckId;
|
child_data[CPPCHECKID] = line.cppcheckId;
|
||||||
child_data["inconclusive"] = line.inconclusive;
|
child_data[INCONCLUSIVE] = line.inconclusive;
|
||||||
child_item->setData(QVariant(child_data));
|
child_item->setData(QVariant(child_data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -363,8 +382,8 @@ void ResultsTree::clear(const QString &filename)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
QVariantMap data = fileItem->data().toMap();
|
QVariantMap data = fileItem->data().toMap();
|
||||||
if (stripped == data["file"].toString() ||
|
if (stripped == data[FILENAME].toString() ||
|
||||||
filename == data["file0"].toString()) {
|
filename == data[FILE0].toString()) {
|
||||||
mModel.removeRow(i);
|
mModel.removeRow(i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -380,7 +399,7 @@ void ResultsTree::clearRecheckFile(const QString &filename)
|
||||||
|
|
||||||
QString actualfile((!mCheckPath.isEmpty() && filename.startsWith(mCheckPath)) ? filename.mid(mCheckPath.length() + 1) : filename);
|
QString actualfile((!mCheckPath.isEmpty() && filename.startsWith(mCheckPath)) ? filename.mid(mCheckPath.length() + 1) : filename);
|
||||||
QVariantMap data = fileItem->data().toMap();
|
QVariantMap data = fileItem->data().toMap();
|
||||||
QString storedfile = data["file"].toString();
|
QString storedfile = data[FILENAME].toString();
|
||||||
storedfile = ((!mCheckPath.isEmpty() && storedfile.startsWith(mCheckPath)) ? storedfile.mid(mCheckPath.length() + 1) : storedfile);
|
storedfile = ((!mCheckPath.isEmpty() && storedfile.startsWith(mCheckPath)) ? storedfile.mid(mCheckPath.length() + 1) : storedfile);
|
||||||
if (actualfile == storedfile) {
|
if (actualfile == storedfile) {
|
||||||
mModel.removeRow(i);
|
mModel.removeRow(i);
|
||||||
|
@ -450,7 +469,7 @@ void ResultsTree::showHiddenResults()
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
QVariantMap data = fileItem->data().toMap();
|
QVariantMap data = fileItem->data().toMap();
|
||||||
data["hide"] = false;
|
data[HIDE] = false;
|
||||||
fileItem->setData(QVariant(data));
|
fileItem->setData(QVariant(data));
|
||||||
|
|
||||||
int errorcount = fileItem->rowCount();
|
int errorcount = fileItem->rowCount();
|
||||||
|
@ -458,7 +477,7 @@ void ResultsTree::showHiddenResults()
|
||||||
QStandardItem *child = fileItem->child(j, 0);
|
QStandardItem *child = fileItem->child(j, 0);
|
||||||
if (child) {
|
if (child) {
|
||||||
data = child->data().toMap();
|
data = child->data().toMap();
|
||||||
data["hide"] = false;
|
data[HIDE] = false;
|
||||||
child->setData(QVariant(data));
|
child->setData(QVariant(data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -500,21 +519,21 @@ void ResultsTree::refreshTree()
|
||||||
QVariantMap data = userdata.toMap();
|
QVariantMap data = userdata.toMap();
|
||||||
|
|
||||||
//Check if this error should be hidden
|
//Check if this error should be hidden
|
||||||
bool hide = (data["hide"].toBool() || !mShowSeverities.isShown(ShowTypes::VariantToShowType(data["severity"])));
|
bool hide = (data[HIDE].toBool() || !mShowSeverities.isShown(ShowTypes::VariantToShowType(data[SEVERITY])));
|
||||||
|
|
||||||
//If specified, filter on summary, message, filename, and id
|
//If specified, filter on summary, message, filename, and id
|
||||||
if (!hide && !mFilter.isEmpty()) {
|
if (!hide && !mFilter.isEmpty()) {
|
||||||
if (!data["summary"].toString().contains(mFilter, Qt::CaseInsensitive) &&
|
if (!data[SUMMARY].toString().contains(mFilter, Qt::CaseInsensitive) &&
|
||||||
!data["message"].toString().contains(mFilter, Qt::CaseInsensitive) &&
|
!data[MESSAGE].toString().contains(mFilter, Qt::CaseInsensitive) &&
|
||||||
!data["file"].toString().contains(mFilter, Qt::CaseInsensitive) &&
|
!data[FILENAME].toString().contains(mFilter, Qt::CaseInsensitive) &&
|
||||||
!data["id"].toString().contains(mFilter, Qt::CaseInsensitive)) {
|
!data[ERRORID].toString().contains(mFilter, Qt::CaseInsensitive)) {
|
||||||
hide = true;
|
hide = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tool filter
|
// Tool filter
|
||||||
if (!hide) {
|
if (!hide) {
|
||||||
if (data["id"].toString().startsWith("clang"))
|
if (data[ERRORID].toString().startsWith("clang"))
|
||||||
hide = !mShowClang;
|
hide = !mShowClang;
|
||||||
else
|
else
|
||||||
hide = !mShowCppcheck;
|
hide = !mShowCppcheck;
|
||||||
|
@ -561,8 +580,8 @@ QStandardItem *ResultsTree::ensureFileItem(const QString &fullpath, const QStrin
|
||||||
|
|
||||||
//Add user data to that item
|
//Add user data to that item
|
||||||
QMap<QString, QVariant> data;
|
QMap<QString, QVariant> data;
|
||||||
data["file"] = fullpath;
|
data[FILENAME] = fullpath;
|
||||||
data["file0"] = file0;
|
data[FILE0] = file0;
|
||||||
item->setData(QVariant(data));
|
item->setData(QVariant(data));
|
||||||
mModel.appendRow(item);
|
mModel.appendRow(item);
|
||||||
|
|
||||||
|
@ -753,7 +772,7 @@ void ResultsTree::startApplication(QStandardItem *target, int application)
|
||||||
QVariantMap data = target->data().toMap();
|
QVariantMap data = target->data().toMap();
|
||||||
|
|
||||||
//Replace (file) with filename
|
//Replace (file) with filename
|
||||||
QString file = data["file"].toString();
|
QString file = data[FILENAME].toString();
|
||||||
file = QDir::toNativeSeparators(file);
|
file = QDir::toNativeSeparators(file);
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
file.replace(QString("\\"), QString("\\\\"));
|
file.replace(QString("\\"), QString("\\\\"));
|
||||||
|
@ -789,11 +808,11 @@ void ResultsTree::startApplication(QStandardItem *target, int application)
|
||||||
QString params = app.getParameters();
|
QString params = app.getParameters();
|
||||||
params.replace("(file)", file, Qt::CaseInsensitive);
|
params.replace("(file)", file, Qt::CaseInsensitive);
|
||||||
|
|
||||||
QVariant line = data["line"];
|
QVariant line = data[LINE];
|
||||||
params.replace("(line)", QString("%1").arg(line.toInt()), Qt::CaseInsensitive);
|
params.replace("(line)", QString("%1").arg(line.toInt()), Qt::CaseInsensitive);
|
||||||
|
|
||||||
params.replace("(message)", data["message"].toString(), Qt::CaseInsensitive);
|
params.replace("(message)", data[MESSAGE].toString(), Qt::CaseInsensitive);
|
||||||
params.replace("(severity)", data["severity"].toString(), Qt::CaseInsensitive);
|
params.replace("(severity)", data[SEVERITY].toString(), Qt::CaseInsensitive);
|
||||||
|
|
||||||
QString program = app.getPath();
|
QString program = app.getPath();
|
||||||
|
|
||||||
|
@ -889,14 +908,14 @@ void ResultsTree::copy()
|
||||||
QVariantMap data = item->data().toMap();
|
QVariantMap data = item->data().toMap();
|
||||||
if (!data.contains("id"))
|
if (!data.contains("id"))
|
||||||
continue;
|
continue;
|
||||||
QString inconclusive = data["inconclusive"].toBool() ? ",inconclusive" : "";
|
QString inconclusive = data[INCONCLUSIVE].toBool() ? ",inconclusive" : "";
|
||||||
text += '[' + data["file"].toString() + ':' + QString::number(data["line"].toInt())
|
text += '[' + data[FILENAME].toString() + ':' + QString::number(data[LINE].toInt())
|
||||||
+ "] ("
|
+ "] ("
|
||||||
+ QString::fromStdString(Severity::toString(ShowTypes::ShowTypeToSeverity((ShowTypes::ShowType)data["severity"].toInt()))) + inconclusive
|
+ QString::fromStdString(Severity::toString(ShowTypes::ShowTypeToSeverity((ShowTypes::ShowType)data[SEVERITY].toInt()))) + inconclusive
|
||||||
+ ") "
|
+ ") "
|
||||||
+ data["message"].toString()
|
+ data[MESSAGE].toString()
|
||||||
+ " ["
|
+ " ["
|
||||||
+ data["id"].toString()
|
+ data[ERRORID].toString()
|
||||||
+ "]\n";
|
+ "]\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -914,7 +933,7 @@ void ResultsTree::hideResult()
|
||||||
QStandardItem *item = mModel.itemFromIndex(index);
|
QStandardItem *item = mModel.itemFromIndex(index);
|
||||||
//Set the "hide" flag for this item
|
//Set the "hide" flag for this item
|
||||||
QVariantMap data = item->data().toMap();
|
QVariantMap data = item->data().toMap();
|
||||||
data["hide"] = true;
|
data[HIDE] = true;
|
||||||
item->setData(QVariant(data));
|
item->setData(QVariant(data));
|
||||||
|
|
||||||
refreshTree();
|
refreshTree();
|
||||||
|
@ -934,7 +953,7 @@ void ResultsTree::recheckSelectedFiles()
|
||||||
while (item->parent())
|
while (item->parent())
|
||||||
item = item->parent();
|
item = item->parent();
|
||||||
QVariantMap data = item->data().toMap();
|
QVariantMap data = item->data().toMap();
|
||||||
QString currentFile = data["file"].toString();
|
QString currentFile = data[FILENAME].toString();
|
||||||
if (!currentFile.isEmpty()) {
|
if (!currentFile.isEmpty()) {
|
||||||
QString fileNameWithCheckPath;
|
QString fileNameWithCheckPath;
|
||||||
QFileInfo curfileInfo(currentFile);
|
QFileInfo curfileInfo(currentFile);
|
||||||
|
@ -948,8 +967,8 @@ void ResultsTree::recheckSelectedFiles()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Path::isHeader(currentFile.toStdString())) {
|
if (Path::isHeader(currentFile.toStdString())) {
|
||||||
if (!data["file0"].toString().isEmpty() && !selectedItems.contains(data["file0"].toString())) {
|
if (!data[FILE0].toString().isEmpty() && !selectedItems.contains(data[FILE0].toString())) {
|
||||||
selectedItems<<((!mCheckPath.isEmpty() && (data["file0"].toString().indexOf(mCheckPath) != 0)) ? (mCheckPath + "/" + data["file0"].toString()) : data["file0"].toString());
|
selectedItems<<((!mCheckPath.isEmpty() && (data[FILE0].toString().indexOf(mCheckPath) != 0)) ? (mCheckPath + "/" + data[FILE0].toString()) : data[FILE0].toString());
|
||||||
if (!selectedItems.contains(fileNameWithCheckPath))
|
if (!selectedItems.contains(fileNameWithCheckPath))
|
||||||
selectedItems<<fileNameWithCheckPath;
|
selectedItems<<fileNameWithCheckPath;
|
||||||
}
|
}
|
||||||
|
@ -970,7 +989,7 @@ void ResultsTree::hideAllIdResult()
|
||||||
mContextItem = mContextItem->parent()->child(mContextItem->row(), 0);
|
mContextItem = mContextItem->parent()->child(mContextItem->row(), 0);
|
||||||
QVariantMap data = mContextItem->data().toMap();
|
QVariantMap data = mContextItem->data().toMap();
|
||||||
|
|
||||||
QString messageId = data["id"].toString();
|
QString messageId = data[ERRORID].toString();
|
||||||
|
|
||||||
mHiddenMessageId.append(messageId);
|
mHiddenMessageId.append(messageId);
|
||||||
|
|
||||||
|
@ -994,8 +1013,8 @@ void ResultsTree::hideAllIdResult()
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantMap userdata = child->data().toMap();
|
QVariantMap userdata = child->data().toMap();
|
||||||
if (userdata["id"].toString() == messageId) {
|
if (userdata[ERRORID].toString() == messageId) {
|
||||||
userdata["hide"] = true;
|
userdata[HIDE] = true;
|
||||||
child->setData(QVariant(userdata));
|
child->setData(QVariant(userdata));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1021,7 +1040,7 @@ void ResultsTree::suppressSelectedIds()
|
||||||
QVariantMap data = item->data().toMap();
|
QVariantMap data = item->data().toMap();
|
||||||
if (!data.contains("id"))
|
if (!data.contains("id"))
|
||||||
continue;
|
continue;
|
||||||
selectedIds << data["id"].toString();
|
selectedIds << data[ERRORID].toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete all errors with selected message Ids
|
// delete all errors with selected message Ids
|
||||||
|
@ -1030,7 +1049,7 @@ void ResultsTree::suppressSelectedIds()
|
||||||
for (int j = 0; j < file->rowCount();) {
|
for (int j = 0; j < file->rowCount();) {
|
||||||
QStandardItem *errorItem = file->child(j, 0);
|
QStandardItem *errorItem = file->child(j, 0);
|
||||||
QVariantMap userdata = errorItem->data().toMap();
|
QVariantMap userdata = errorItem->data().toMap();
|
||||||
if (selectedIds.contains(userdata["id"].toString())) {
|
if (selectedIds.contains(userdata[ERRORID].toString())) {
|
||||||
file->removeRow(j);
|
file->removeRow(j);
|
||||||
} else {
|
} else {
|
||||||
j++;
|
j++;
|
||||||
|
@ -1067,10 +1086,10 @@ void ResultsTree::suppressCppcheckID()
|
||||||
const QVariantMap data = item->data().toMap();
|
const QVariantMap data = item->data().toMap();
|
||||||
if (projectFile && data.contains("cppcheckId")) {
|
if (projectFile && data.contains("cppcheckId")) {
|
||||||
Suppressions::Suppression suppression;
|
Suppressions::Suppression suppression;
|
||||||
suppression.cppcheckId = data["cppcheckId"].toULongLong();
|
suppression.cppcheckId = data[CPPCHECKID].toULongLong();
|
||||||
suppression.errorId = data["id"].toString().toStdString();
|
suppression.errorId = data[ERRORID].toString().toStdString();
|
||||||
suppression.fileName = data["file"].toString().toStdString();
|
suppression.fileName = data[FILENAME].toString().toStdString();
|
||||||
suppression.lineNumber = data["line"].toInt();
|
suppression.lineNumber = data[LINE].toInt();
|
||||||
projectFile->addSuppression(suppression);
|
projectFile->addSuppression(suppression);
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
@ -1102,18 +1121,22 @@ void ResultsTree::tagSelectedItems(const QString &tag)
|
||||||
if (!mSelectionModel)
|
if (!mSelectionModel)
|
||||||
return;
|
return;
|
||||||
bool isTagged = false;
|
bool isTagged = false;
|
||||||
|
ProjectFile *currentProject = ProjectFile::getActiveProject();
|
||||||
foreach (QModelIndex index, mSelectionModel->selectedRows()) {
|
foreach (QModelIndex index, mSelectionModel->selectedRows()) {
|
||||||
QStandardItem *item = mModel.itemFromIndex(index);
|
QStandardItem *item = mModel.itemFromIndex(index);
|
||||||
QVariantMap data = item->data().toMap();
|
QVariantMap data = item->data().toMap();
|
||||||
if (data.contains("tags")) {
|
if (data.contains("tags")) {
|
||||||
data["tags"] = tag;
|
data[TAGS] = tag;
|
||||||
item->setData(QVariant(data));
|
item->setData(QVariant(data));
|
||||||
item->parent()->child(index.row(), COLUMN_TAGS)->setText(tag);
|
item->parent()->child(index.row(), COLUMN_TAGS)->setText(tag);
|
||||||
isTagged = true;
|
if (currentProject && data.contains(CPPCHECKID)) {
|
||||||
|
isTagged = true;
|
||||||
|
currentProject->setWarningTags(data[CPPCHECKID].toULongLong(), tag);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isTagged)
|
if (isTagged)
|
||||||
emit tagged();
|
currentProject->write();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResultsTree::context(int application)
|
void ResultsTree::context(int application)
|
||||||
|
@ -1137,7 +1160,7 @@ QString ResultsTree::getFilePath(QStandardItem *target, bool fullPath)
|
||||||
QString pathStr;
|
QString pathStr;
|
||||||
|
|
||||||
//Replace (file) with filename
|
//Replace (file) with filename
|
||||||
QString file = data["file"].toString();
|
QString file = data[FILENAME].toString();
|
||||||
pathStr = QDir::toNativeSeparators(file);
|
pathStr = QDir::toNativeSeparators(file);
|
||||||
if (!fullPath) {
|
if (!fullPath) {
|
||||||
QFileInfo fi(pathStr);
|
QFileInfo fi(pathStr);
|
||||||
|
@ -1237,12 +1260,12 @@ void ResultsTree::updateFromOldReport(const QString &filename)
|
||||||
|
|
||||||
// New error .. set the "sinceDate" property
|
// New error .. set the "sinceDate" property
|
||||||
if (oldErrorIndex >= 0 && !oldErrors[oldErrorIndex].sinceDate.isEmpty()) {
|
if (oldErrorIndex >= 0 && !oldErrors[oldErrorIndex].sinceDate.isEmpty()) {
|
||||||
data["sinceDate"] = oldErrors[oldErrorIndex].sinceDate;
|
data[SINCEDATE] = oldErrors[oldErrorIndex].sinceDate;
|
||||||
error->setData(data);
|
error->setData(data);
|
||||||
fileItem->child(j, COLUMN_SINCE_DATE)->setText(oldErrors[oldErrorIndex].sinceDate);
|
fileItem->child(j, COLUMN_SINCE_DATE)->setText(oldErrors[oldErrorIndex].sinceDate);
|
||||||
} else if (oldErrorIndex < 0 || data["sinceDate"].toString().isEmpty()) {
|
} else if (oldErrorIndex < 0 || data[SINCEDATE].toString().isEmpty()) {
|
||||||
const QString sinceDate = QDate::currentDate().toString(Qt::SystemLocaleShortDate);
|
const QString sinceDate = QDate::currentDate().toString(Qt::SystemLocaleShortDate);
|
||||||
data["sinceDate"] = sinceDate;
|
data[SINCEDATE] = sinceDate;
|
||||||
error->setData(data);
|
error->setData(data);
|
||||||
fileItem->child(j, COLUMN_SINCE_DATE)->setText(sinceDate);
|
fileItem->child(j, COLUMN_SINCE_DATE)->setText(sinceDate);
|
||||||
if (oldErrorIndex < 0)
|
if (oldErrorIndex < 0)
|
||||||
|
@ -1253,7 +1276,7 @@ void ResultsTree::updateFromOldReport(const QString &filename)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const ErrorItem &oldErrorItem = oldErrors[oldErrorIndex];
|
const ErrorItem &oldErrorItem = oldErrors[oldErrorIndex];
|
||||||
data["tags"] = oldErrorItem.tags;
|
data[TAGS] = oldErrorItem.tags;
|
||||||
error->setData(data);
|
error->setData(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1264,23 +1287,23 @@ void ResultsTree::readErrorItem(const QStandardItem *error, ErrorItem *item) con
|
||||||
// Get error's user data
|
// Get error's user data
|
||||||
QVariantMap data = error->data().toMap();
|
QVariantMap data = error->data().toMap();
|
||||||
|
|
||||||
item->severity = ShowTypes::ShowTypeToSeverity(ShowTypes::VariantToShowType(data["severity"]));
|
item->severity = ShowTypes::ShowTypeToSeverity(ShowTypes::VariantToShowType(data[SEVERITY]));
|
||||||
item->summary = data["summary"].toString();
|
item->summary = data[SUMMARY].toString();
|
||||||
item->message = data["message"].toString();
|
item->message = data[MESSAGE].toString();
|
||||||
item->errorId = data["id"].toString();
|
item->errorId = data[ERRORID].toString();
|
||||||
item->incomplete = data["incomplete"].toBool();
|
item->incomplete = data[INCOMPLETE].toBool();
|
||||||
item->cwe = data["cwe"].toInt();
|
item->cwe = data[CWE].toInt();
|
||||||
item->cppcheckId = data["cppcheckId"].toULongLong();
|
item->cppcheckId = data[CPPCHECKID].toULongLong();
|
||||||
item->inconclusive = data["inconclusive"].toBool();
|
item->inconclusive = data[INCONCLUSIVE].toBool();
|
||||||
item->file0 = data["file0"].toString();
|
item->file0 = data[FILE0].toString();
|
||||||
item->sinceDate = data["sinceDate"].toString();
|
item->sinceDate = data[SINCEDATE].toString();
|
||||||
item->tags = data["tags"].toString();
|
item->tags = data[TAGS].toString();
|
||||||
|
|
||||||
if (error->rowCount() == 0) {
|
if (error->rowCount() == 0) {
|
||||||
QErrorPathItem e;
|
QErrorPathItem e;
|
||||||
e.file = stripPath(data["file"].toString(), true);
|
e.file = stripPath(data[FILENAME].toString(), true);
|
||||||
e.line = data["line"].toUInt();
|
e.line = data[LINE].toInt();
|
||||||
e.info = data["message"].toString();
|
e.info = data[MESSAGE].toString();
|
||||||
item->errorPath << e;
|
item->errorPath << e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1292,9 +1315,9 @@ void ResultsTree::readErrorItem(const QStandardItem *error, ErrorItem *item) con
|
||||||
QVariantMap child_data = child_userdata.toMap();
|
QVariantMap child_data = child_userdata.toMap();
|
||||||
|
|
||||||
QErrorPathItem e;
|
QErrorPathItem e;
|
||||||
e.file = stripPath(child_data["file"].toString(), true);
|
e.file = stripPath(child_data[FILENAME].toString(), true);
|
||||||
e.line = child_data["line"].toUInt();
|
e.line = child_data[LINE].toUInt();
|
||||||
e.info = child_data["message"].toString();
|
e.info = child_data[MESSAGE].toString();
|
||||||
item->errorPath << e;
|
item->errorPath << e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1362,7 +1385,7 @@ void ResultsTree::refreshFilePaths(QStandardItem *item)
|
||||||
QVariantMap data = userdata.toMap();
|
QVariantMap data = userdata.toMap();
|
||||||
|
|
||||||
//Get list of files
|
//Get list of files
|
||||||
QString file = data["file"].toString();
|
QString file = data[FILENAME].toString();
|
||||||
|
|
||||||
//Update this error's text
|
//Update this error's text
|
||||||
error->setText(stripPath(file, false));
|
error->setText(stripPath(file, false));
|
||||||
|
@ -1382,7 +1405,7 @@ void ResultsTree::refreshFilePaths(QStandardItem *item)
|
||||||
QVariantMap child_data = child_userdata.toMap();
|
QVariantMap child_data = child_userdata.toMap();
|
||||||
|
|
||||||
//Get list of files
|
//Get list of files
|
||||||
QString child_files = child_data["file"].toString();
|
QString child_files = child_data[FILENAME].toString();
|
||||||
//Update file's path
|
//Update file's path
|
||||||
child->setText(stripPath(child_files, false));
|
child->setText(stripPath(child_files, false));
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,6 @@ ResultsView::ResultsView(QWidget * parent) :
|
||||||
connect(mUI.mTree, &ResultsTree::resultsHidden, this, &ResultsView::resultsHidden);
|
connect(mUI.mTree, &ResultsTree::resultsHidden, this, &ResultsView::resultsHidden);
|
||||||
connect(mUI.mTree, &ResultsTree::checkSelected, this, &ResultsView::checkSelected);
|
connect(mUI.mTree, &ResultsTree::checkSelected, this, &ResultsView::checkSelected);
|
||||||
connect(mUI.mTree, &ResultsTree::treeSelectionChanged, this, &ResultsView::updateDetails);
|
connect(mUI.mTree, &ResultsTree::treeSelectionChanged, this, &ResultsView::updateDetails);
|
||||||
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(mUI.mTree, &ResultsTree::editFunctionContract, this, &ResultsView::editFunctionContract);
|
connect(mUI.mTree, &ResultsTree::editFunctionContract, this, &ResultsView::editFunctionContract);
|
||||||
connect(this, &ResultsView::showResults, mUI.mTree, &ResultsTree::showResults);
|
connect(this, &ResultsView::showResults, mUI.mTree, &ResultsTree::showResults);
|
||||||
|
|
|
@ -218,11 +218,6 @@ signals:
|
||||||
*/
|
*/
|
||||||
void checkSelected(QStringList selectedFilesList);
|
void checkSelected(QStringList selectedFilesList);
|
||||||
|
|
||||||
/**
|
|
||||||
* Some results have been tagged
|
|
||||||
*/
|
|
||||||
void tagged();
|
|
||||||
|
|
||||||
/** Suppress Ids */
|
/** Suppress Ids */
|
||||||
void suppressIds(QStringList ids);
|
void suppressIds(QStringList ids);
|
||||||
|
|
||||||
|
|
|
@ -161,6 +161,10 @@ namespace CppcheckXml {
|
||||||
const char ToolsElementName[] = "tools";
|
const char ToolsElementName[] = "tools";
|
||||||
const char TagsElementName[] = "tags";
|
const char TagsElementName[] = "tags";
|
||||||
const char TagElementName[] = "tag";
|
const char TagElementName[] = "tag";
|
||||||
|
const char TagWarningsElementName[] = "tag-warnings";
|
||||||
|
const char TagAttributeName[] = "tag";
|
||||||
|
const char WarningElementName[] = "warning";
|
||||||
|
const char CppcheckIdAttributeName[] = "cppcheck-id";
|
||||||
const char CheckHeadersElementName[] = "check-headers";
|
const char CheckHeadersElementName[] = "check-headers";
|
||||||
const char CheckUnusedTemplatesElementName[] = "check-unused-templates";
|
const char CheckUnusedTemplatesElementName[] = "check-unused-templates";
|
||||||
const char MaxCtuDepthElementName[] = "max-ctu-depth";
|
const char MaxCtuDepthElementName[] = "max-ctu-depth";
|
||||||
|
|
Loading…
Reference in New Issue