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::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.mResults, &ResultsView::editFunctionContract, this, &MainWindow::editFunctionContract);
|
||||
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)
|
||||
{
|
||||
if (!mProjectFile)
|
||||
|
|
|
@ -221,9 +221,6 @@ protected slots:
|
|||
/** @brief Selects the platform as analyzed platform. */
|
||||
void selectPlatform();
|
||||
|
||||
/** Some results were tagged */
|
||||
void tagged();
|
||||
|
||||
/** Suppress error ids */
|
||||
void suppressIds(QStringList ids);
|
||||
|
||||
|
|
|
@ -72,6 +72,8 @@ void ProjectFile::clear()
|
|||
mCheckUnknownFunctionReturn.clear();
|
||||
safeChecks.clear();
|
||||
mVsConfigurations.clear();
|
||||
mTags.clear();
|
||||
mWarningTags.clear();
|
||||
}
|
||||
|
||||
bool ProjectFile::read(const QString &filename)
|
||||
|
@ -188,6 +190,9 @@ bool ProjectFile::read(const QString &filename)
|
|||
if (xmlReader.name() == CppcheckXml::TagsElementName)
|
||||
readStringList(mTags, xmlReader, CppcheckXml::TagElementName);
|
||||
|
||||
if (xmlReader.name() == CppcheckXml::TagWarningsElementName)
|
||||
readTagWarnings(xmlReader, xmlReader.attributes().value(QString(), CppcheckXml::TagAttributeName).toString());
|
||||
|
||||
if (xmlReader.name() == CppcheckXml::MaxCtuDepthElementName)
|
||||
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[])
|
||||
{
|
||||
QXmlStreamReader::TokenType type;
|
||||
|
@ -734,6 +774,20 @@ void ProjectFile::setVSConfigurations(const QStringList &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)
|
||||
{
|
||||
if (!filename.isEmpty())
|
||||
|
@ -883,7 +937,7 @@ bool ProjectFile::write(const QString &filename)
|
|||
if (!suppression.symbolName.empty())
|
||||
xmlWriter.writeAttribute("symbolName", QString::fromStdString(suppression.symbolName));
|
||||
if (suppression.cppcheckId > 0)
|
||||
xmlWriter.writeAttribute("cppcheck-id", QString::number(suppression.cppcheckId));
|
||||
xmlWriter.writeAttribute(CppcheckXml::CppcheckIdAttributeName, QString::number(suppression.cppcheckId));
|
||||
if (!suppression.errorId.empty())
|
||||
xmlWriter.writeCharacters(QString::fromStdString(suppression.errorId));
|
||||
xmlWriter.writeEndElement();
|
||||
|
@ -914,6 +968,26 @@ bool ProjectFile::write(const QString &filename)
|
|||
CppcheckXml::ToolElementName);
|
||||
|
||||
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();
|
||||
file.close();
|
||||
|
|
|
@ -331,6 +331,12 @@ public:
|
|||
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).
|
||||
* @param filename Filename to use.
|
||||
|
@ -437,6 +443,12 @@ protected:
|
|||
*/
|
||||
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
|
||||
* @param stringlist destination string list
|
||||
|
@ -552,10 +564,15 @@ private:
|
|||
bool mClangTidy;
|
||||
|
||||
/**
|
||||
* @brief Warning tags
|
||||
* @brief Tags
|
||||
*/
|
||||
QStringList mTags;
|
||||
|
||||
/**
|
||||
* @brief Warning tags
|
||||
*/
|
||||
std::map<std::size_t, QString> mWarningTags;
|
||||
|
||||
/** Max CTU depth */
|
||||
int mMaxCtuDepth;
|
||||
|
||||
|
|
|
@ -49,6 +49,23 @@
|
|||
#include "path.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()
|
||||
static const int COLUMN_SINCE_DATE = 6;
|
||||
static const int COLUMN_TAGS = 7;
|
||||
|
@ -175,7 +192,9 @@ bool ResultsTree::addErrorItem(const ErrorItem &item)
|
|||
line.message = item.message;
|
||||
line.severity = item.severity;
|
||||
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
|
||||
//file item as a parent
|
||||
QStandardItem* fileItem = ensureFileItem(loc.file, item.file0, hide);
|
||||
|
@ -190,22 +209,22 @@ bool ResultsTree::addErrorItem(const ErrorItem &item)
|
|||
|
||||
//Add user data to that item
|
||||
QMap<QString, QVariant> data;
|
||||
data["severity"] = ShowTypes::SeverityToShowType(item.severity);
|
||||
data["summary"] = item.summary;
|
||||
data["message"] = item.message;
|
||||
data["file"] = loc.file;
|
||||
data["line"] = loc.line;
|
||||
data["column"] = loc.column;
|
||||
data["id"] = item.errorId;
|
||||
data["incomplete"] = item.incomplete;
|
||||
data["cwe"] = item.cwe;
|
||||
data["cppcheckId"] = item.cppcheckId;
|
||||
data["inconclusive"] = item.inconclusive;
|
||||
data["file0"] = stripPath(item.file0, true);
|
||||
data["function"] = item.function;
|
||||
data["sinceDate"] = item.sinceDate;
|
||||
data["tags"] = item.tags;
|
||||
data["hide"] = hide;
|
||||
data[SEVERITY] = ShowTypes::SeverityToShowType(item.severity);
|
||||
data[SUMMARY] = item.summary;
|
||||
data[MESSAGE] = item.message;
|
||||
data[FILENAME] = loc.file;
|
||||
data[LINE] = loc.line;
|
||||
data[COLUMN] = loc.column;
|
||||
data[ERRORID] = item.errorId;
|
||||
data[INCOMPLETE] = item.incomplete;
|
||||
data[CWE] = item.cwe;
|
||||
data[CPPCHECKID] = item.cppcheckId;
|
||||
data[INCONCLUSIVE] = item.inconclusive;
|
||||
data[FILE0] = stripPath(item.file0, true);
|
||||
data[FUNCTION] = item.function;
|
||||
data[SINCEDATE] = item.sinceDate;
|
||||
data[TAGS] = line.tags;
|
||||
data[HIDE] = hide;
|
||||
stditem->setData(QVariant(data));
|
||||
|
||||
//Add backtrace files as children
|
||||
|
@ -226,17 +245,17 @@ bool ResultsTree::addErrorItem(const ErrorItem &item)
|
|||
|
||||
// Add user data to that item
|
||||
QMap<QString, QVariant> child_data;
|
||||
child_data["severity"] = ShowTypes::SeverityToShowType(line.severity);
|
||||
child_data["summary"] = line.summary;
|
||||
child_data["message"] = line.message;
|
||||
child_data["file"] = e.file;
|
||||
child_data["line"] = e.line;
|
||||
child_data["column"] = e.column;
|
||||
child_data["id"] = line.errorId;
|
||||
child_data["incomplete"] = line.incomplete;
|
||||
child_data["cwe"] = line.cwe;
|
||||
child_data["cppcheckId"] = line.cppcheckId;
|
||||
child_data["inconclusive"] = line.inconclusive;
|
||||
child_data[SEVERITY] = ShowTypes::SeverityToShowType(line.severity);
|
||||
child_data[SUMMARY] = line.summary;
|
||||
child_data[MESSAGE] = line.message;
|
||||
child_data[FILENAME] = e.file;
|
||||
child_data[LINE] = e.line;
|
||||
child_data[COLUMN] = e.column;
|
||||
child_data[ERRORID] = line.errorId;
|
||||
child_data[INCOMPLETE] = line.incomplete;
|
||||
child_data[CWE] = line.cwe;
|
||||
child_data[CPPCHECKID] = line.cppcheckId;
|
||||
child_data[INCONCLUSIVE] = line.inconclusive;
|
||||
child_item->setData(QVariant(child_data));
|
||||
}
|
||||
}
|
||||
|
@ -363,8 +382,8 @@ void ResultsTree::clear(const QString &filename)
|
|||
continue;
|
||||
|
||||
QVariantMap data = fileItem->data().toMap();
|
||||
if (stripped == data["file"].toString() ||
|
||||
filename == data["file0"].toString()) {
|
||||
if (stripped == data[FILENAME].toString() ||
|
||||
filename == data[FILE0].toString()) {
|
||||
mModel.removeRow(i);
|
||||
break;
|
||||
}
|
||||
|
@ -380,7 +399,7 @@ void ResultsTree::clearRecheckFile(const QString &filename)
|
|||
|
||||
QString actualfile((!mCheckPath.isEmpty() && filename.startsWith(mCheckPath)) ? filename.mid(mCheckPath.length() + 1) : filename);
|
||||
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);
|
||||
if (actualfile == storedfile) {
|
||||
mModel.removeRow(i);
|
||||
|
@ -450,7 +469,7 @@ void ResultsTree::showHiddenResults()
|
|||
continue;
|
||||
|
||||
QVariantMap data = fileItem->data().toMap();
|
||||
data["hide"] = false;
|
||||
data[HIDE] = false;
|
||||
fileItem->setData(QVariant(data));
|
||||
|
||||
int errorcount = fileItem->rowCount();
|
||||
|
@ -458,7 +477,7 @@ void ResultsTree::showHiddenResults()
|
|||
QStandardItem *child = fileItem->child(j, 0);
|
||||
if (child) {
|
||||
data = child->data().toMap();
|
||||
data["hide"] = false;
|
||||
data[HIDE] = false;
|
||||
child->setData(QVariant(data));
|
||||
}
|
||||
}
|
||||
|
@ -500,21 +519,21 @@ void ResultsTree::refreshTree()
|
|||
QVariantMap data = userdata.toMap();
|
||||
|
||||
//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 (!hide && !mFilter.isEmpty()) {
|
||||
if (!data["summary"].toString().contains(mFilter, Qt::CaseInsensitive) &&
|
||||
!data["message"].toString().contains(mFilter, Qt::CaseInsensitive) &&
|
||||
!data["file"].toString().contains(mFilter, Qt::CaseInsensitive) &&
|
||||
!data["id"].toString().contains(mFilter, Qt::CaseInsensitive)) {
|
||||
if (!data[SUMMARY].toString().contains(mFilter, Qt::CaseInsensitive) &&
|
||||
!data[MESSAGE].toString().contains(mFilter, Qt::CaseInsensitive) &&
|
||||
!data[FILENAME].toString().contains(mFilter, Qt::CaseInsensitive) &&
|
||||
!data[ERRORID].toString().contains(mFilter, Qt::CaseInsensitive)) {
|
||||
hide = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Tool filter
|
||||
if (!hide) {
|
||||
if (data["id"].toString().startsWith("clang"))
|
||||
if (data[ERRORID].toString().startsWith("clang"))
|
||||
hide = !mShowClang;
|
||||
else
|
||||
hide = !mShowCppcheck;
|
||||
|
@ -561,8 +580,8 @@ QStandardItem *ResultsTree::ensureFileItem(const QString &fullpath, const QStrin
|
|||
|
||||
//Add user data to that item
|
||||
QMap<QString, QVariant> data;
|
||||
data["file"] = fullpath;
|
||||
data["file0"] = file0;
|
||||
data[FILENAME] = fullpath;
|
||||
data[FILE0] = file0;
|
||||
item->setData(QVariant(data));
|
||||
mModel.appendRow(item);
|
||||
|
||||
|
@ -753,7 +772,7 @@ void ResultsTree::startApplication(QStandardItem *target, int application)
|
|||
QVariantMap data = target->data().toMap();
|
||||
|
||||
//Replace (file) with filename
|
||||
QString file = data["file"].toString();
|
||||
QString file = data[FILENAME].toString();
|
||||
file = QDir::toNativeSeparators(file);
|
||||
#ifdef Q_OS_WIN
|
||||
file.replace(QString("\\"), QString("\\\\"));
|
||||
|
@ -789,11 +808,11 @@ void ResultsTree::startApplication(QStandardItem *target, int application)
|
|||
QString params = app.getParameters();
|
||||
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("(message)", data["message"].toString(), Qt::CaseInsensitive);
|
||||
params.replace("(severity)", data["severity"].toString(), Qt::CaseInsensitive);
|
||||
params.replace("(message)", data[MESSAGE].toString(), Qt::CaseInsensitive);
|
||||
params.replace("(severity)", data[SEVERITY].toString(), Qt::CaseInsensitive);
|
||||
|
||||
QString program = app.getPath();
|
||||
|
||||
|
@ -889,14 +908,14 @@ void ResultsTree::copy()
|
|||
QVariantMap data = item->data().toMap();
|
||||
if (!data.contains("id"))
|
||||
continue;
|
||||
QString inconclusive = data["inconclusive"].toBool() ? ",inconclusive" : "";
|
||||
text += '[' + data["file"].toString() + ':' + QString::number(data["line"].toInt())
|
||||
QString inconclusive = data[INCONCLUSIVE].toBool() ? ",inconclusive" : "";
|
||||
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";
|
||||
}
|
||||
|
||||
|
@ -914,7 +933,7 @@ void ResultsTree::hideResult()
|
|||
QStandardItem *item = mModel.itemFromIndex(index);
|
||||
//Set the "hide" flag for this item
|
||||
QVariantMap data = item->data().toMap();
|
||||
data["hide"] = true;
|
||||
data[HIDE] = true;
|
||||
item->setData(QVariant(data));
|
||||
|
||||
refreshTree();
|
||||
|
@ -934,7 +953,7 @@ void ResultsTree::recheckSelectedFiles()
|
|||
while (item->parent())
|
||||
item = item->parent();
|
||||
QVariantMap data = item->data().toMap();
|
||||
QString currentFile = data["file"].toString();
|
||||
QString currentFile = data[FILENAME].toString();
|
||||
if (!currentFile.isEmpty()) {
|
||||
QString fileNameWithCheckPath;
|
||||
QFileInfo curfileInfo(currentFile);
|
||||
|
@ -948,8 +967,8 @@ void ResultsTree::recheckSelectedFiles()
|
|||
return;
|
||||
}
|
||||
if (Path::isHeader(currentFile.toStdString())) {
|
||||
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());
|
||||
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());
|
||||
if (!selectedItems.contains(fileNameWithCheckPath))
|
||||
selectedItems<<fileNameWithCheckPath;
|
||||
}
|
||||
|
@ -970,7 +989,7 @@ void ResultsTree::hideAllIdResult()
|
|||
mContextItem = mContextItem->parent()->child(mContextItem->row(), 0);
|
||||
QVariantMap data = mContextItem->data().toMap();
|
||||
|
||||
QString messageId = data["id"].toString();
|
||||
QString messageId = data[ERRORID].toString();
|
||||
|
||||
mHiddenMessageId.append(messageId);
|
||||
|
||||
|
@ -994,8 +1013,8 @@ void ResultsTree::hideAllIdResult()
|
|||
}
|
||||
|
||||
QVariantMap userdata = child->data().toMap();
|
||||
if (userdata["id"].toString() == messageId) {
|
||||
userdata["hide"] = true;
|
||||
if (userdata[ERRORID].toString() == messageId) {
|
||||
userdata[HIDE] = true;
|
||||
child->setData(QVariant(userdata));
|
||||
}
|
||||
}
|
||||
|
@ -1021,7 +1040,7 @@ void ResultsTree::suppressSelectedIds()
|
|||
QVariantMap data = item->data().toMap();
|
||||
if (!data.contains("id"))
|
||||
continue;
|
||||
selectedIds << data["id"].toString();
|
||||
selectedIds << data[ERRORID].toString();
|
||||
}
|
||||
|
||||
// delete all errors with selected message Ids
|
||||
|
@ -1030,7 +1049,7 @@ void ResultsTree::suppressSelectedIds()
|
|||
for (int j = 0; j < file->rowCount();) {
|
||||
QStandardItem *errorItem = file->child(j, 0);
|
||||
QVariantMap userdata = errorItem->data().toMap();
|
||||
if (selectedIds.contains(userdata["id"].toString())) {
|
||||
if (selectedIds.contains(userdata[ERRORID].toString())) {
|
||||
file->removeRow(j);
|
||||
} else {
|
||||
j++;
|
||||
|
@ -1067,10 +1086,10 @@ void ResultsTree::suppressCppcheckID()
|
|||
const QVariantMap data = item->data().toMap();
|
||||
if (projectFile && data.contains("cppcheckId")) {
|
||||
Suppressions::Suppression suppression;
|
||||
suppression.cppcheckId = data["cppcheckId"].toULongLong();
|
||||
suppression.errorId = data["id"].toString().toStdString();
|
||||
suppression.fileName = data["file"].toString().toStdString();
|
||||
suppression.lineNumber = data["line"].toInt();
|
||||
suppression.cppcheckId = data[CPPCHECKID].toULongLong();
|
||||
suppression.errorId = data[ERRORID].toString().toStdString();
|
||||
suppression.fileName = data[FILENAME].toString().toStdString();
|
||||
suppression.lineNumber = data[LINE].toInt();
|
||||
projectFile->addSuppression(suppression);
|
||||
changed = true;
|
||||
}
|
||||
|
@ -1102,18 +1121,22 @@ void ResultsTree::tagSelectedItems(const QString &tag)
|
|||
if (!mSelectionModel)
|
||||
return;
|
||||
bool isTagged = false;
|
||||
ProjectFile *currentProject = ProjectFile::getActiveProject();
|
||||
foreach (QModelIndex index, mSelectionModel->selectedRows()) {
|
||||
QStandardItem *item = mModel.itemFromIndex(index);
|
||||
QVariantMap data = item->data().toMap();
|
||||
if (data.contains("tags")) {
|
||||
data["tags"] = tag;
|
||||
data[TAGS] = tag;
|
||||
item->setData(QVariant(data));
|
||||
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)
|
||||
emit tagged();
|
||||
currentProject->write();
|
||||
}
|
||||
|
||||
void ResultsTree::context(int application)
|
||||
|
@ -1137,7 +1160,7 @@ QString ResultsTree::getFilePath(QStandardItem *target, bool fullPath)
|
|||
QString pathStr;
|
||||
|
||||
//Replace (file) with filename
|
||||
QString file = data["file"].toString();
|
||||
QString file = data[FILENAME].toString();
|
||||
pathStr = QDir::toNativeSeparators(file);
|
||||
if (!fullPath) {
|
||||
QFileInfo fi(pathStr);
|
||||
|
@ -1237,12 +1260,12 @@ void ResultsTree::updateFromOldReport(const QString &filename)
|
|||
|
||||
// New error .. set the "sinceDate" property
|
||||
if (oldErrorIndex >= 0 && !oldErrors[oldErrorIndex].sinceDate.isEmpty()) {
|
||||
data["sinceDate"] = oldErrors[oldErrorIndex].sinceDate;
|
||||
data[SINCEDATE] = oldErrors[oldErrorIndex].sinceDate;
|
||||
error->setData(data);
|
||||
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);
|
||||
data["sinceDate"] = sinceDate;
|
||||
data[SINCEDATE] = sinceDate;
|
||||
error->setData(data);
|
||||
fileItem->child(j, COLUMN_SINCE_DATE)->setText(sinceDate);
|
||||
if (oldErrorIndex < 0)
|
||||
|
@ -1253,7 +1276,7 @@ void ResultsTree::updateFromOldReport(const QString &filename)
|
|||
continue;
|
||||
|
||||
const ErrorItem &oldErrorItem = oldErrors[oldErrorIndex];
|
||||
data["tags"] = oldErrorItem.tags;
|
||||
data[TAGS] = oldErrorItem.tags;
|
||||
error->setData(data);
|
||||
}
|
||||
}
|
||||
|
@ -1264,23 +1287,23 @@ void ResultsTree::readErrorItem(const QStandardItem *error, ErrorItem *item) con
|
|||
// Get error's user data
|
||||
QVariantMap data = error->data().toMap();
|
||||
|
||||
item->severity = ShowTypes::ShowTypeToSeverity(ShowTypes::VariantToShowType(data["severity"]));
|
||||
item->summary = data["summary"].toString();
|
||||
item->message = data["message"].toString();
|
||||
item->errorId = data["id"].toString();
|
||||
item->incomplete = data["incomplete"].toBool();
|
||||
item->cwe = data["cwe"].toInt();
|
||||
item->cppcheckId = data["cppcheckId"].toULongLong();
|
||||
item->inconclusive = data["inconclusive"].toBool();
|
||||
item->file0 = data["file0"].toString();
|
||||
item->sinceDate = data["sinceDate"].toString();
|
||||
item->tags = data["tags"].toString();
|
||||
item->severity = ShowTypes::ShowTypeToSeverity(ShowTypes::VariantToShowType(data[SEVERITY]));
|
||||
item->summary = data[SUMMARY].toString();
|
||||
item->message = data[MESSAGE].toString();
|
||||
item->errorId = data[ERRORID].toString();
|
||||
item->incomplete = data[INCOMPLETE].toBool();
|
||||
item->cwe = data[CWE].toInt();
|
||||
item->cppcheckId = data[CPPCHECKID].toULongLong();
|
||||
item->inconclusive = data[INCONCLUSIVE].toBool();
|
||||
item->file0 = data[FILE0].toString();
|
||||
item->sinceDate = data[SINCEDATE].toString();
|
||||
item->tags = data[TAGS].toString();
|
||||
|
||||
if (error->rowCount() == 0) {
|
||||
QErrorPathItem e;
|
||||
e.file = stripPath(data["file"].toString(), true);
|
||||
e.line = data["line"].toUInt();
|
||||
e.info = data["message"].toString();
|
||||
e.file = stripPath(data[FILENAME].toString(), true);
|
||||
e.line = data[LINE].toInt();
|
||||
e.info = data[MESSAGE].toString();
|
||||
item->errorPath << e;
|
||||
}
|
||||
|
||||
|
@ -1292,9 +1315,9 @@ void ResultsTree::readErrorItem(const QStandardItem *error, ErrorItem *item) con
|
|||
QVariantMap child_data = child_userdata.toMap();
|
||||
|
||||
QErrorPathItem e;
|
||||
e.file = stripPath(child_data["file"].toString(), true);
|
||||
e.line = child_data["line"].toUInt();
|
||||
e.info = child_data["message"].toString();
|
||||
e.file = stripPath(child_data[FILENAME].toString(), true);
|
||||
e.line = child_data[LINE].toUInt();
|
||||
e.info = child_data[MESSAGE].toString();
|
||||
item->errorPath << e;
|
||||
}
|
||||
}
|
||||
|
@ -1362,7 +1385,7 @@ void ResultsTree::refreshFilePaths(QStandardItem *item)
|
|||
QVariantMap data = userdata.toMap();
|
||||
|
||||
//Get list of files
|
||||
QString file = data["file"].toString();
|
||||
QString file = data[FILENAME].toString();
|
||||
|
||||
//Update this error's text
|
||||
error->setText(stripPath(file, false));
|
||||
|
@ -1382,7 +1405,7 @@ void ResultsTree::refreshFilePaths(QStandardItem *item)
|
|||
QVariantMap child_data = child_userdata.toMap();
|
||||
|
||||
//Get list of files
|
||||
QString child_files = child_data["file"].toString();
|
||||
QString child_files = child_data[FILENAME].toString();
|
||||
//Update file's path
|
||||
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::checkSelected, this, &ResultsView::checkSelected);
|
||||
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::editFunctionContract, this, &ResultsView::editFunctionContract);
|
||||
connect(this, &ResultsView::showResults, mUI.mTree, &ResultsTree::showResults);
|
||||
|
|
|
@ -218,11 +218,6 @@ signals:
|
|||
*/
|
||||
void checkSelected(QStringList selectedFilesList);
|
||||
|
||||
/**
|
||||
* Some results have been tagged
|
||||
*/
|
||||
void tagged();
|
||||
|
||||
/** Suppress Ids */
|
||||
void suppressIds(QStringList ids);
|
||||
|
||||
|
|
|
@ -161,6 +161,10 @@ namespace CppcheckXml {
|
|||
const char ToolsElementName[] = "tools";
|
||||
const char TagsElementName[] = "tags";
|
||||
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 CheckUnusedTemplatesElementName[] = "check-unused-templates";
|
||||
const char MaxCtuDepthElementName[] = "max-ctu-depth";
|
||||
|
|
Loading…
Reference in New Issue