GUI: Fix transporting errors.

Need to register integer list as new metatype so that Qt's type
system knows how to use it. Adding also additional constructors
for the ErrorItem.
This commit is contained in:
Kimmo Varis 2010-07-11 01:04:53 +03:00
parent faa483b8d0
commit 352941f5df
4 changed files with 50 additions and 0 deletions

39
gui/erroritem.cpp Normal file
View File

@ -0,0 +1,39 @@
/*
* Cppcheck - A tool for static C/C++ code analysis
* Copyright (C) 2007-2010 Daniel Marjamäki and Cppcheck team.
*
* 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/>.
*/
#include "erroritem.h"
ErrorItem::ErrorItem(const ErrorItem &item)
{
file = item.file;
files = item.files;
lines = item.lines;
id = item.id;
severity = item.severity;
msg = item.msg;
}
ErrorItem::ErrorItem(const ErrorLine &line)
{
file = line.file;
files.append(line.file);
lines.append(line.line.toUInt());
id = line.id;
severity = line.severity;
msg = line.msg;
}

View File

@ -22,6 +22,8 @@
#include <QString>
#include <QStringList>
class ErrorLine;
/// @addtogroup GUI
/// @{
@ -31,6 +33,10 @@
class ErrorItem
{
public:
ErrorItem() { }
ErrorItem(const ErrorItem &item);
ErrorItem(const ErrorLine &line);
QString file;
QStringList files;
QList<unsigned int> lines;

View File

@ -71,6 +71,7 @@ SOURCES += main.cpp \
aboutdialog.cpp \
fileviewdialog.cpp \
projectfile.cpp \
erroritem.cpp \
report.cpp \
txtreport.cpp \
xmlreport.cpp \

View File

@ -20,6 +20,7 @@
#include <QApplication>
#include <QTextCodec>
#include <QTranslator>
#include <QMetaType>
#include "mainwindow.h"
int main(int argc, char *argv[])
@ -27,6 +28,9 @@ int main(int argc, char *argv[])
QApplication app(argc, argv);
app.setWindowIcon(QIcon(":icon.png"));
// Register this metatype that is used to transfer error info
qRegisterMetaType<QList<unsigned int>>("QList<unsigned int>");
// Set codecs so that UTF-8 strings in sources are handled correctly.
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));