From 352941f5dfcbdebbbeb8a40caa2b0b48f3a47a00 Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Sun, 11 Jul 2010 01:04:53 +0300 Subject: [PATCH] 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. --- gui/erroritem.cpp | 39 +++++++++++++++++++++++++++++++++++++++ gui/erroritem.h | 6 ++++++ gui/gui.pro | 1 + gui/main.cpp | 4 ++++ 4 files changed, 50 insertions(+) create mode 100644 gui/erroritem.cpp diff --git a/gui/erroritem.cpp b/gui/erroritem.cpp new file mode 100644 index 000000000..98f620671 --- /dev/null +++ b/gui/erroritem.cpp @@ -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 . + */ + +#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; +} diff --git a/gui/erroritem.h b/gui/erroritem.h index ed4215aad..73fc661d9 100644 --- a/gui/erroritem.h +++ b/gui/erroritem.h @@ -22,6 +22,8 @@ #include #include +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 lines; diff --git a/gui/gui.pro b/gui/gui.pro index d0c23068c..84265f8ea 100644 --- a/gui/gui.pro +++ b/gui/gui.pro @@ -71,6 +71,7 @@ SOURCES += main.cpp \ aboutdialog.cpp \ fileviewdialog.cpp \ projectfile.cpp \ + erroritem.cpp \ report.cpp \ txtreport.cpp \ xmlreport.cpp \ diff --git a/gui/main.cpp b/gui/main.cpp index 2309e7a64..02ee24eae 100644 --- a/gui/main.cpp +++ b/gui/main.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #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"); + // Set codecs so that UTF-8 strings in sources are handled correctly. QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));