GUI: Output debug errors to log view.

Debug errors were not shown anywhere in the GUI, they were just
ignored. This commit adds new signal for those debug errors and
directs them to checking log.

Solves ticket #1898 (GUI: Handle internal errors from lib)
This commit is contained in:
Kimmo Varis 2010-08-28 20:37:21 +03:00
parent 35afc4c63f
commit 20a4f1e195
7 changed files with 44 additions and 1 deletions

View File

@ -37,3 +37,12 @@ ErrorItem::ErrorItem(const ErrorLine &line)
severity = line.severity; severity = line.severity;
msg = line.msg; msg = line.msg;
} }
QString ErrorItem::ToString() const
{
QString str = file + " - " + id + " - " + severity +"\n";
str += " " + msg;
for (int i = 0; i < files.size(); i++)
str += " " + files[i] + ": " + lines[i] + "\n";
return str;
}

View File

@ -39,6 +39,12 @@ public:
ErrorItem(const ErrorLine &line); ErrorItem(const ErrorLine &line);
~ErrorItem() { } ~ErrorItem() { }
/**
* @brief Convert error item to string.
* @return Error item as string.
*/
QString ToString() const;
QString file; QString file;
QStringList files; QStringList files;
QList<unsigned int> lines; QList<unsigned int> lines;

View File

@ -819,6 +819,14 @@ void MainWindow::Log(const QString &logline)
} }
} }
void MainWindow::DebugError(const ErrorItem &item)
{
if (mLogView)
{
mLogView->AppendLine(item.ToString());
}
}
void MainWindow::EnableProjectActions(bool enable) void MainWindow::EnableProjectActions(bool enable)
{ {
mUI.mActionCloseProjectFile->setEnabled(enable); mUI.mActionCloseProjectFile->setEnabled(enable);

View File

@ -36,6 +36,7 @@ class ThreadHandler;
class LogView; class LogView;
class HelpWindow; class HelpWindow;
class Project; class Project;
class ErrorItem;
/// @addtogroup GUI /// @addtogroup GUI
/// @{ /// @{
@ -218,6 +219,12 @@ protected slots:
*/ */
void Log(const QString &logline); void Log(const QString &logline);
/**
* @brief Handle new debug error.
*
*/
void DebugError(const ErrorItem &item);
protected: protected:
/** /**

View File

@ -146,6 +146,9 @@ void ThreadHandler::Initialize(ResultsView *view)
connect(&mResults, SIGNAL(Log(const QString &)), connect(&mResults, SIGNAL(Log(const QString &)),
parent(), SLOT(Log(const QString &))); parent(), SLOT(Log(const QString &)));
connect(&mResults, SIGNAL(Error(const ErrorItem &)),
parent(), SLOT(Error(const ErrorItem &)));
} }
void ThreadHandler::LoadSettings(QSettings &settings) void ThreadHandler::LoadSettings(QSettings &settings)

View File

@ -71,7 +71,10 @@ void ThreadResult::reportErr(const ErrorLogger::ErrorMessage &msg)
item.msg = QString(msg._msg.c_str()); item.msg = QString(msg._msg.c_str());
item.severity = QString::fromStdString(Severity::toString(msg._severity)); item.severity = QString::fromStdString(Severity::toString(msg._severity));
if (msg._severity != Severity::debug)
emit Error(item); emit Error(item);
else
emit DebugError(item);
} }
QString ThreadResult::GetNextFile() QString ThreadResult::GetNextFile()

View File

@ -100,6 +100,13 @@ signals:
*/ */
void Log(const QString &logline); void Log(const QString &logline);
/**
* @brief Signal of a debug error
*
* @param item Error data
*/
void DebugError(const ErrorItem &item);
protected: protected:
/** /**