Skip to content

Commit 6c6ab0a

Browse files
committed
GUI: Sent ErrorItem with Error -signal.
This commit modifies and registers ErrorItem as proper metatype so it can be used with Qt signals. Then sending Error-signals is refactored so that ErrorItem instances are sent instead of several different arguments that already contained couple of lists.
1 parent bea7144 commit 6c6ab0a

7 files changed

Lines changed: 30 additions & 59 deletions

File tree

gui/erroritem.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include <QString>
2323
#include <QStringList>
24+
#include <QMetaType>
2425

2526
class ErrorLine;
2627

@@ -36,6 +37,7 @@ class ErrorItem
3637
ErrorItem() { }
3738
ErrorItem(const ErrorItem &item);
3839
ErrorItem(const ErrorLine &line);
40+
~ErrorItem() { }
3941

4042
QString file;
4143
QStringList files;
@@ -45,6 +47,8 @@ class ErrorItem
4547
QString msg;
4648
};
4749

50+
Q_DECLARE_METATYPE(ErrorItem);
51+
4852
/**
4953
* @brief A class containing error data for one shown error line.
5054
*/

gui/main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,15 @@
2222
#include <QTranslator>
2323
#include <QMetaType>
2424
#include "mainwindow.h"
25+
#include "erroritem.h"
2526

2627
int main(int argc, char *argv[])
2728
{
2829
QApplication app(argc, argv);
2930
app.setWindowIcon(QIcon(":icon.png"));
3031

3132
// Register this metatype that is used to transfer error info
32-
qRegisterMetaType< QList<unsigned int> >("QList<unsigned int>");
33+
qRegisterMetaType<ErrorItem>("ErrorItem");
3334

3435
// Set codecs so that UTF-8 strings in sources are handled correctly.
3536
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));

gui/resultsview.cpp

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <QVBoxLayout>
2121
#include <QFile>
2222
#include <QMessageBox>
23+
#include "erroritem.h"
2324
#include "resultsview.h"
2425
#include "report.h"
2526
#include "txtreport.h"
@@ -66,22 +67,9 @@ void ResultsView::Progress(int value)
6667
mUI.mProgress->setValue(value);
6768
}
6869

69-
void ResultsView::Error(const QString &file,
70-
const QString &severity,
71-
const QString &message,
72-
const QStringList &files,
73-
const QList<unsigned int> &lines,
74-
const QString &id)
70+
void ResultsView::Error(const ErrorItem &item)
7571
{
7672
mErrorsFound = true;
77-
ErrorItem item;
78-
item.file = file;
79-
item.files = files;
80-
item.id = id;
81-
item.lines = lines;
82-
item.msg = message;
83-
item.severity = severity;
84-
8573
mUI.mTree->AddErrorItem(item);
8674
emit GotResults();
8775
}

gui/resultsview.h

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
#include "report.h"
3030
#include "ui_resultsview.h"
3131

32+
class ErrorItem;
33+
3234
/// @addtogroup GUI
3335
/// @{
3436

@@ -158,19 +160,9 @@ public slots:
158160
/**
159161
* @brief Slot for new error to be displayed
160162
*
161-
* @param file filename
162-
* @param severity error severity
163-
* @param message error message
164-
* @param files list of files affected by the error
165-
* @param lines list of file line numers affected by the error
166-
* @param id error id
167-
*/
168-
void Error(const QString &file,
169-
const QString &severity,
170-
const QString &message,
171-
const QStringList &files,
172-
const QList<unsigned int> &lines,
173-
const QString &id);
163+
* @param item Error data
164+
*/
165+
void Error(const ErrorItem &item);
174166

175167
/**
176168
* @brief Collapse all results in the result list.

gui/threadhandler.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -141,18 +141,8 @@ void ThreadHandler::Initialize(ResultsView *view)
141141
connect(&mResults, SIGNAL(Progress(int)),
142142
view, SLOT(Progress(int)));
143143

144-
connect(&mResults, SIGNAL(Error(const QString &,
145-
const QString &,
146-
const QString &,
147-
const QStringList &,
148-
const QList<unsigned int> &,
149-
const QString &)),
150-
view, SLOT(Error(const QString &,
151-
const QString &,
152-
const QString &,
153-
const QStringList &,
154-
const QList<unsigned int> &,
155-
const QString &)));
144+
connect(&mResults, SIGNAL(Error(const ErrorItem &)),
145+
view, SLOT(Error(const ErrorItem &)));
156146

157147
}
158148

gui/threadresult.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
*/
1818

1919

20-
#include "threadresult.h"
2120
#include <QDebug>
21+
#include "erroritem.h"
22+
#include "threadresult.h"
2223

2324
ThreadResult::ThreadResult() : mMaxProgress(0), mProgress(0)
2425
{
@@ -62,12 +63,15 @@ void ThreadResult::reportErr(const ErrorLogger::ErrorMessage &msg)
6263
lines << (*tok).line;
6364
}
6465

65-
emit Error(QString(callStackToString(msg._callStack).c_str()),
66-
QString(msg._severity.c_str()),
67-
QString(msg._msg.c_str()),
68-
files,
69-
lines,
70-
QString(msg._id.c_str()));
66+
ErrorItem item;
67+
item.file = QString(callStackToString(msg._callStack).c_str());
68+
item.files = files;
69+
item.id = QString(msg._id.c_str());
70+
item.lines = lines;
71+
item.msg = QString(msg._msg.c_str());
72+
item.severity = QString(msg._severity.c_str());
73+
74+
emit Error(item);
7175
}
7276

7377
QString ThreadResult::GetNextFile()

gui/threadresult.h

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
#include <QVariant>
2727
#include "../lib/errorlogger.h"
2828

29+
class ErrorItem;
30+
2931
/// @addtogroup GUI
3032
/// @{
3133

@@ -87,19 +89,9 @@ public slots:
8789
/**
8890
* @brief Signal of a new error
8991
*
90-
* @param file filename
91-
* @param severity error severity
92-
* @param message error message
93-
* @param files list of files affected by the error
94-
* @param lines list of file line numers affected by the error
95-
* @param id error id
92+
* @param item Error data
9693
*/
97-
void Error(const QString &file,
98-
const QString &severity,
99-
const QString &message,
100-
const QStringList &files,
101-
const QList<unsigned int> &lines,
102-
const QString &id);
94+
void Error(const ErrorItem &item);
10395

10496
protected:
10597

0 commit comments

Comments
 (0)