2010-07-10 19:30:31 +02:00
|
|
|
/*
|
|
|
|
* Cppcheck - A tool for static C/C++ code analysis
|
2011-01-09 20:33:36 +01:00
|
|
|
* Copyright (C) 2007-2011 Daniel Marjamäki and Cppcheck team.
|
2010-07-10 19:30:31 +02:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ERRORITEM_H
|
|
|
|
#define ERRORITEM_H
|
|
|
|
|
|
|
|
#include <QString>
|
|
|
|
#include <QStringList>
|
2010-07-14 13:24:46 +02:00
|
|
|
#include <QMetaType>
|
2011-03-07 20:10:30 +01:00
|
|
|
#include "errorlogger.h"
|
2010-07-10 19:30:31 +02:00
|
|
|
|
2010-07-11 00:04:53 +02:00
|
|
|
class ErrorLine;
|
|
|
|
|
2010-07-10 19:30:31 +02:00
|
|
|
/// @addtogroup GUI
|
|
|
|
/// @{
|
|
|
|
|
2011-03-07 20:10:30 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief GUI versions of severity conversions.
|
|
|
|
* GUI needs its own versions of conversions since GUI uses Qt's QString
|
|
|
|
* instead of the std::string used by lib/cli.
|
|
|
|
*/
|
|
|
|
class GuiSeverity : Severity
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static QString toString(SeverityType severity)
|
|
|
|
{
|
|
|
|
switch (severity)
|
|
|
|
{
|
|
|
|
case none:
|
|
|
|
return "";
|
|
|
|
case error:
|
|
|
|
return "error";
|
|
|
|
case warning:
|
|
|
|
return "warning";
|
|
|
|
case style:
|
|
|
|
return "style";
|
|
|
|
case performance:
|
|
|
|
return "performance";
|
|
|
|
case portability:
|
|
|
|
return "portability";
|
|
|
|
case information:
|
|
|
|
return "information";
|
|
|
|
case debug:
|
|
|
|
return "debug";
|
|
|
|
};
|
|
|
|
return "???";
|
|
|
|
}
|
|
|
|
|
|
|
|
static SeverityType fromString(const QString &severity)
|
|
|
|
{
|
|
|
|
if (severity.isEmpty())
|
|
|
|
return none;
|
|
|
|
if (severity == "none")
|
|
|
|
return none;
|
|
|
|
if (severity == "error")
|
|
|
|
return error;
|
|
|
|
if (severity == "warning")
|
|
|
|
return warning;
|
|
|
|
if (severity == "style")
|
|
|
|
return style;
|
|
|
|
if (severity == "performance")
|
|
|
|
return performance;
|
|
|
|
if (severity == "portability")
|
|
|
|
return portability;
|
|
|
|
if (severity == "information")
|
|
|
|
return information;
|
|
|
|
if (severity == "debug")
|
|
|
|
return debug;
|
|
|
|
return none;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2010-07-10 19:30:31 +02:00
|
|
|
/**
|
|
|
|
* @brief A class containing error data for one error.
|
2011-01-07 20:48:02 +01:00
|
|
|
*
|
2011-01-06 19:45:07 +01:00
|
|
|
* The paths are stored with internal ("/") separators. Only when we show the
|
|
|
|
* path or copy if for user (to clipboard) we convert to native separators.
|
|
|
|
* Full path is stored instead of relative path for flexibility. It is easy
|
|
|
|
* to get the relative path from full path when needed.
|
2010-07-10 19:30:31 +02:00
|
|
|
*/
|
|
|
|
class ErrorItem
|
|
|
|
{
|
|
|
|
public:
|
2010-07-11 00:04:53 +02:00
|
|
|
ErrorItem() { }
|
|
|
|
ErrorItem(const ErrorItem &item);
|
|
|
|
ErrorItem(const ErrorLine &line);
|
2010-07-14 13:24:46 +02:00
|
|
|
~ErrorItem() { }
|
2010-07-11 00:04:53 +02:00
|
|
|
|
2010-08-28 19:37:21 +02:00
|
|
|
/**
|
|
|
|
* @brief Convert error item to string.
|
|
|
|
* @return Error item as string.
|
|
|
|
*/
|
|
|
|
QString ToString() const;
|
|
|
|
|
2010-07-10 19:30:31 +02:00
|
|
|
QString file;
|
|
|
|
QStringList files;
|
2010-07-10 19:54:33 +02:00
|
|
|
QList<unsigned int> lines;
|
2010-07-10 19:30:31 +02:00
|
|
|
QString id;
|
2011-03-07 20:10:30 +01:00
|
|
|
Severity::SeverityType severity;
|
2010-11-11 21:51:00 +01:00
|
|
|
QString summary;
|
|
|
|
QString message;
|
2010-07-10 19:30:31 +02:00
|
|
|
};
|
|
|
|
|
2010-07-14 13:24:46 +02:00
|
|
|
Q_DECLARE_METATYPE(ErrorItem);
|
|
|
|
|
2010-07-10 19:30:31 +02:00
|
|
|
/**
|
|
|
|
* @brief A class containing error data for one shown error line.
|
|
|
|
*/
|
|
|
|
class ErrorLine
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
QString file;
|
2010-07-12 00:51:36 +02:00
|
|
|
unsigned int line;
|
2010-07-10 19:30:31 +02:00
|
|
|
QString id;
|
2011-03-07 20:20:09 +01:00
|
|
|
Severity::SeverityType severity;
|
2010-11-11 21:51:00 +01:00
|
|
|
QString summary;
|
|
|
|
QString message;
|
2010-07-10 19:30:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/// @}
|
|
|
|
#endif // ERRORITEM_H
|