2009-03-01 08:38:21 +01:00
|
|
|
/*
|
|
|
|
* Cppcheck - A tool for static C/C++ code analysis
|
2010-04-13 21:23:17 +02:00
|
|
|
* Copyright (C) 2007-2010 Daniel Marjamäki and Cppcheck team.
|
2009-03-01 08:38:21 +01: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
|
2009-09-27 17:08:31 +02:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2009-03-01 08:38:21 +01:00
|
|
|
*/
|
|
|
|
|
2009-06-14 14:09:52 +02:00
|
|
|
#include <QApplication>
|
2009-03-02 20:56:51 +01:00
|
|
|
#include <QDebug>
|
2009-05-23 13:26:04 +02:00
|
|
|
#include <QMenu>
|
|
|
|
#include <QSignalMapper>
|
|
|
|
#include <QProcess>
|
2009-06-03 20:18:22 +02:00
|
|
|
#include <QDir>
|
2009-06-09 08:30:28 +02:00
|
|
|
#include <QMessageBox>
|
2009-06-14 14:09:52 +02:00
|
|
|
#include <QFileInfo>
|
2010-07-11 13:22:55 +02:00
|
|
|
#include <QFileDialog>
|
2009-06-14 14:09:52 +02:00
|
|
|
#include <QClipboard>
|
2010-07-10 19:30:31 +02:00
|
|
|
#include "erroritem.h"
|
2009-06-24 09:54:56 +02:00
|
|
|
#include "resultstree.h"
|
|
|
|
#include "xmlreport.h"
|
2009-05-23 13:26:04 +02:00
|
|
|
|
2009-07-02 10:32:29 +02:00
|
|
|
ResultsTree::ResultsTree(QWidget * parent) :
|
2010-04-15 20:08:51 +02:00
|
|
|
QTreeView(parent),
|
|
|
|
mContextItem(0),
|
|
|
|
mVisibleErrors(false)
|
2009-03-01 08:38:21 +01:00
|
|
|
{
|
2010-04-02 07:30:58 +02:00
|
|
|
for (int i = 0; i < SHOW_NONE; i++)
|
2009-11-24 17:25:27 +01:00
|
|
|
mShowTypes[i] = false;
|
|
|
|
|
2009-03-01 08:38:21 +01:00
|
|
|
setModel(&mModel);
|
|
|
|
QStringList labels;
|
2009-05-23 13:26:04 +02:00
|
|
|
labels << tr("File") << tr("Severity") << tr("Line") << tr("Message");
|
2009-03-01 08:38:21 +01:00
|
|
|
mModel.setHorizontalHeaderLabels(labels);
|
2009-05-23 17:45:05 +02:00
|
|
|
setExpandsOnDoubleClick(false);
|
2009-06-04 16:46:19 +02:00
|
|
|
setSortingEnabled(true);
|
2009-07-02 10:32:29 +02:00
|
|
|
|
2009-05-23 17:45:05 +02:00
|
|
|
connect(this, SIGNAL(doubleClicked(const QModelIndex &)),
|
|
|
|
this, SLOT(QuickStartApplication(const QModelIndex &)));
|
2009-03-01 08:38:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ResultsTree::~ResultsTree()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-07-02 10:32:29 +02:00
|
|
|
void ResultsTree::Initialize(QSettings *settings, ApplicationList *list)
|
|
|
|
{
|
|
|
|
mSettings = settings;
|
|
|
|
mApplications = list;
|
|
|
|
LoadSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-03-01 08:38:21 +01:00
|
|
|
QStandardItem *ResultsTree::CreateItem(const QString &name)
|
|
|
|
{
|
|
|
|
QStandardItem *item = new QStandardItem(name);
|
|
|
|
item->setEditable(false);
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
2010-07-10 19:30:31 +02:00
|
|
|
void ResultsTree::AddErrorItem(const ErrorItem &item)
|
2009-03-01 08:38:21 +01:00
|
|
|
{
|
2010-07-10 19:30:31 +02:00
|
|
|
if (item.files.isEmpty())
|
2009-05-23 10:17:27 +02:00
|
|
|
{
|
2009-03-22 13:32:07 +01:00
|
|
|
return;
|
2009-05-23 10:17:27 +02:00
|
|
|
}
|
2009-03-22 13:32:07 +01:00
|
|
|
|
2010-07-10 19:30:31 +02:00
|
|
|
QString realfile = StripPath(item.files[0], false);
|
2009-03-22 13:32:07 +01:00
|
|
|
|
2010-04-02 07:30:58 +02:00
|
|
|
if (realfile.isEmpty())
|
2009-05-23 10:17:27 +02:00
|
|
|
{
|
2009-07-02 12:48:32 +02:00
|
|
|
realfile = tr("Undefined file");
|
2009-05-23 10:17:27 +02:00
|
|
|
}
|
|
|
|
|
2010-07-10 19:30:31 +02:00
|
|
|
bool hide = !mShowTypes[SeverityToShowType(item.severity)];
|
2009-06-09 09:51:27 +02:00
|
|
|
|
2009-11-19 23:43:46 +01:00
|
|
|
//if there is at least one error that is not hidden, we have a visible error
|
2010-04-02 07:30:58 +02:00
|
|
|
if (!hide)
|
2009-06-09 09:51:27 +02:00
|
|
|
{
|
|
|
|
mVisibleErrors = true;
|
|
|
|
}
|
|
|
|
|
2010-07-10 19:30:31 +02:00
|
|
|
ErrorLine line;
|
|
|
|
line.file = realfile;
|
|
|
|
line.id = item.id;
|
2010-07-11 00:07:40 +02:00
|
|
|
line.line = QString::number(item.lines[0]);
|
2010-07-10 19:30:31 +02:00
|
|
|
line.msg = item.msg;
|
|
|
|
line.severity = item.severity;
|
2009-05-23 10:17:27 +02:00
|
|
|
//Create the base item for the error and ensure it has a proper
|
|
|
|
//file item as a parent
|
2010-07-10 19:30:31 +02:00
|
|
|
QStandardItem *stditem = AddBacktraceFiles(EnsureFileItem(line.file, hide),
|
|
|
|
line,
|
|
|
|
hide,
|
|
|
|
SeverityToIcon(line.severity));
|
|
|
|
|
|
|
|
if (!stditem)
|
2009-11-16 17:09:30 +01:00
|
|
|
return;
|
|
|
|
|
2009-05-23 10:17:27 +02:00
|
|
|
//Add user data to that item
|
|
|
|
QMap<QString, QVariant> data;
|
2010-07-11 00:07:40 +02:00
|
|
|
data["severity"] = SeverityToShowType(item.severity);
|
|
|
|
data["message"] = item.msg;
|
|
|
|
data["file"] = item.files[0];
|
|
|
|
data["line"] = QString::number(item.lines[0]);
|
|
|
|
data["id"] = item.id;
|
2010-07-10 19:30:31 +02:00
|
|
|
stditem->setData(QVariant(data));
|
2009-05-23 10:17:27 +02:00
|
|
|
|
|
|
|
//Add backtrace files as children
|
2010-07-10 19:30:31 +02:00
|
|
|
for (int i = 1; i < item.files.size() && i < item.lines.size(); i++)
|
2009-05-23 10:17:27 +02:00
|
|
|
{
|
2010-07-11 00:07:40 +02:00
|
|
|
line.file = StripPath(item.files[i], false);
|
2010-07-10 19:30:31 +02:00
|
|
|
line.line = item.lines[i];
|
2009-11-19 23:43:46 +01:00
|
|
|
QStandardItem *child_item;
|
2010-07-10 19:30:31 +02:00
|
|
|
child_item = AddBacktraceFiles(stditem,
|
|
|
|
line,
|
2009-11-19 23:43:46 +01:00
|
|
|
hide,
|
|
|
|
":images/go-down.png");
|
|
|
|
|
|
|
|
//Add user data to that item
|
|
|
|
QMap<QString, QVariant> child_data;
|
2010-07-10 19:30:31 +02:00
|
|
|
child_data["severity"] = SeverityToShowType(line.severity);
|
|
|
|
child_data["message"] = line.msg;
|
2010-07-11 00:07:40 +02:00
|
|
|
child_data["file"] = item.files[i];
|
2010-07-10 19:30:31 +02:00
|
|
|
child_data["line"] = line.line;
|
|
|
|
child_data["id"] = line.id;
|
2009-11-19 23:43:46 +01:00
|
|
|
child_item->setData(QVariant(child_data));
|
2009-05-23 10:17:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//TODO just hide/show current error and it's file
|
|
|
|
//since this does a lot of unnecessary work
|
2010-04-02 07:30:58 +02:00
|
|
|
if (!hide)
|
2009-05-23 13:26:04 +02:00
|
|
|
{
|
2009-05-23 10:33:38 +02:00
|
|
|
ShowFileItem(realfile);
|
|
|
|
}
|
2009-05-23 10:17:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QStandardItem *ResultsTree::AddBacktraceFiles(QStandardItem *parent,
|
2010-07-10 19:30:31 +02:00
|
|
|
const ErrorLine &item,
|
2009-05-26 17:21:39 +02:00
|
|
|
const bool hide,
|
|
|
|
const QString &icon)
|
2009-05-23 10:17:27 +02:00
|
|
|
|
|
|
|
{
|
2010-04-02 07:30:58 +02:00
|
|
|
if (!parent)
|
2009-05-23 13:26:04 +02:00
|
|
|
{
|
2009-05-23 10:33:38 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2009-05-23 10:17:27 +02:00
|
|
|
|
|
|
|
QList<QStandardItem*> list;
|
2010-07-10 19:30:31 +02:00
|
|
|
list << CreateItem(item.file);
|
|
|
|
list << CreateItem(tr(item.severity.toLatin1()));
|
|
|
|
list << CreateItem(QString("%1").arg(item.line));
|
2009-07-02 12:48:32 +02:00
|
|
|
//TODO message has parameter names so we'll need changes to the core
|
|
|
|
//cppcheck so we can get proper translations
|
2010-07-10 19:30:31 +02:00
|
|
|
list << CreateItem(tr(item.msg.toLatin1()));
|
2009-05-23 10:17:27 +02:00
|
|
|
|
2009-11-16 17:09:30 +01:00
|
|
|
// Check for duplicate rows and don't add them if found
|
2010-04-02 07:30:58 +02:00
|
|
|
for (int i = 0; i < parent->rowCount(); i++)
|
2009-11-16 17:09:30 +01:00
|
|
|
{
|
|
|
|
// the first column is the file name and is always the same so skip it
|
|
|
|
|
|
|
|
// the third column is the line number so check it first
|
2010-04-02 07:30:58 +02:00
|
|
|
if (parent->child(i, 2)->text() == list[2]->text())
|
2009-11-16 17:09:30 +01:00
|
|
|
{
|
|
|
|
// the second column is the severity so check it next
|
2010-04-02 07:30:58 +02:00
|
|
|
if (parent->child(i, 1)->text() == list[1]->text())
|
2009-11-16 17:09:30 +01:00
|
|
|
{
|
|
|
|
// the forth column is the message so check it last
|
2010-04-02 07:30:58 +02:00
|
|
|
if (parent->child(i, 3)->text() == list[3]->text())
|
2009-11-16 17:09:30 +01:00
|
|
|
{
|
|
|
|
// this row matches so don't add it
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-23 10:33:38 +02:00
|
|
|
parent->appendRow(list);
|
2009-05-23 10:17:27 +02:00
|
|
|
|
2009-05-23 13:26:04 +02:00
|
|
|
setRowHidden(parent->rowCount() - 1, parent->index(), hide);
|
2009-05-23 10:17:27 +02:00
|
|
|
|
2010-04-02 07:30:58 +02:00
|
|
|
if (!icon.isEmpty())
|
2009-05-26 17:23:06 +02:00
|
|
|
{
|
2009-05-26 17:21:39 +02:00
|
|
|
list[0]->setIcon(QIcon(icon));
|
|
|
|
}
|
|
|
|
|
2009-05-23 10:17:27 +02:00
|
|
|
//TODO Does this leak memory? Should items from list be deleted?
|
|
|
|
|
|
|
|
return list[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
ShowTypes ResultsTree::VariantToShowType(const QVariant &data)
|
|
|
|
{
|
|
|
|
int value = data.toInt();
|
2010-07-03 11:58:56 +02:00
|
|
|
if (value < SHOW_STYLE && value > SHOW_ERRORS)
|
2009-05-23 10:17:27 +02:00
|
|
|
{
|
|
|
|
return SHOW_NONE;
|
|
|
|
}
|
|
|
|
return (ShowTypes)value;
|
2009-03-22 18:39:44 +01:00
|
|
|
}
|
2009-03-01 08:38:21 +01:00
|
|
|
|
2009-03-22 18:41:32 +01:00
|
|
|
ShowTypes ResultsTree::SeverityToShowType(const QString & severity)
|
2009-03-22 18:39:44 +01:00
|
|
|
{
|
2010-04-02 07:30:58 +02:00
|
|
|
if (severity == "error")
|
2009-03-22 18:39:44 +01:00
|
|
|
return SHOW_ERRORS;
|
2010-04-02 07:30:58 +02:00
|
|
|
if (severity == "style")
|
2009-03-22 18:39:44 +01:00
|
|
|
return SHOW_STYLE;
|
|
|
|
|
|
|
|
return SHOW_NONE;
|
2009-03-01 08:38:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
QStandardItem *ResultsTree::FindFileItem(const QString &name)
|
|
|
|
{
|
|
|
|
QList<QStandardItem *> list = mModel.findItems(name);
|
2010-04-02 07:30:58 +02:00
|
|
|
if (list.size() > 0)
|
2009-05-23 10:17:27 +02:00
|
|
|
{
|
2009-03-01 08:38:21 +01:00
|
|
|
return list[0];
|
2009-05-23 10:17:27 +02:00
|
|
|
}
|
2009-03-01 08:38:21 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ResultsTree::Clear()
|
|
|
|
{
|
|
|
|
mModel.removeRows(0, mModel.rowCount());
|
|
|
|
}
|
|
|
|
|
|
|
|
void ResultsTree::LoadSettings()
|
|
|
|
{
|
2010-04-02 07:30:58 +02:00
|
|
|
for (int i = 0; i < mModel.columnCount(); i++)
|
2009-03-01 08:38:21 +01:00
|
|
|
{
|
|
|
|
//mFileTree.columnWidth(i);
|
2009-07-02 10:32:29 +02:00
|
|
|
QString temp = QString(SETTINGS_RESULT_COLUMN_WIDTH).arg(i);
|
|
|
|
setColumnWidth(i, mSettings->value(temp, 800 / mModel.columnCount()).toInt());
|
2009-03-01 08:38:21 +01:00
|
|
|
}
|
2009-06-03 20:18:22 +02:00
|
|
|
|
2009-07-02 10:32:29 +02:00
|
|
|
mSaveFullPath = mSettings->value(SETTINGS_SAVE_FULL_PATH, false).toBool();
|
|
|
|
mSaveAllErrors = mSettings->value(SETTINGS_SAVE_ALL_ERRORS, false).toBool();
|
|
|
|
mShowFullPath = mSettings->value(SETTINGS_SHOW_FULL_PATH, false).toBool();
|
2009-03-01 08:38:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void ResultsTree::SaveSettings()
|
|
|
|
{
|
2010-04-02 07:30:58 +02:00
|
|
|
for (int i = 0; i < mModel.columnCount(); i++)
|
2009-03-01 08:38:21 +01:00
|
|
|
{
|
2009-07-02 10:32:29 +02:00
|
|
|
QString temp = QString(SETTINGS_RESULT_COLUMN_WIDTH).arg(i);
|
|
|
|
mSettings->setValue(temp, columnWidth(i));
|
2009-03-01 08:38:21 +01:00
|
|
|
}
|
|
|
|
}
|
2009-03-22 18:39:44 +01:00
|
|
|
|
|
|
|
void ResultsTree::ShowResults(ShowTypes type, bool show)
|
|
|
|
{
|
2010-04-02 07:30:58 +02:00
|
|
|
if (type != SHOW_NONE && mShowTypes[type] != show)
|
2009-03-22 18:39:44 +01:00
|
|
|
{
|
2009-05-23 10:17:27 +02:00
|
|
|
mShowTypes[type] = show;
|
|
|
|
RefreshTree();
|
2009-03-22 18:39:44 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ResultsTree::RefreshTree()
|
|
|
|
{
|
2009-06-09 09:51:27 +02:00
|
|
|
mVisibleErrors = false;
|
2009-05-23 10:17:27 +02:00
|
|
|
//Get the amount of files in the tree
|
|
|
|
int filecount = mModel.rowCount();
|
|
|
|
|
2010-04-02 07:30:58 +02:00
|
|
|
for (int i = 0; i < filecount; i++)
|
2009-03-22 18:39:44 +01:00
|
|
|
{
|
2009-05-23 10:17:27 +02:00
|
|
|
//Get file i
|
2009-05-23 13:26:04 +02:00
|
|
|
QStandardItem *file = mModel.item(i, 0);
|
2010-04-02 07:30:58 +02:00
|
|
|
if (!file)
|
2009-03-22 18:39:44 +01:00
|
|
|
{
|
2009-05-23 10:17:27 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Get the amount of errors this file contains
|
|
|
|
int errorcount = file->rowCount();
|
|
|
|
|
|
|
|
//By default it shouldn't be visible
|
|
|
|
bool show = false;
|
|
|
|
|
2010-04-02 07:30:58 +02:00
|
|
|
for (int j = 0; j < errorcount; j++)
|
2009-05-23 10:17:27 +02:00
|
|
|
{
|
|
|
|
//Get the error itself
|
2009-05-23 13:26:04 +02:00
|
|
|
QStandardItem *child = file->child(j, 0);
|
2010-04-02 07:30:58 +02:00
|
|
|
if (!child)
|
2009-05-23 10:17:27 +02:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Get error's user data
|
|
|
|
QVariant userdata = child->data();
|
|
|
|
//Convert it to QVariantMap
|
|
|
|
QVariantMap data = userdata.toMap();
|
|
|
|
|
|
|
|
//Check if this error should be hidden
|
|
|
|
bool hide = !mShowTypes[VariantToShowType(data["severity"])];
|
|
|
|
|
2010-04-02 07:30:58 +02:00
|
|
|
if (!hide)
|
2009-06-09 09:51:27 +02:00
|
|
|
{
|
|
|
|
mVisibleErrors = true;
|
|
|
|
}
|
|
|
|
|
2009-05-23 10:17:27 +02:00
|
|
|
//Hide/show accordingly
|
2009-05-23 13:26:04 +02:00
|
|
|
setRowHidden(j, file->index(), hide);
|
2009-05-23 10:17:27 +02:00
|
|
|
|
2009-11-19 23:43:46 +01:00
|
|
|
//If it was shown then the file itself has to be shown as well
|
2010-04-02 07:30:58 +02:00
|
|
|
if (!hide)
|
2009-05-23 10:17:27 +02:00
|
|
|
{
|
|
|
|
show = true;
|
|
|
|
}
|
2009-03-22 18:39:44 +01:00
|
|
|
}
|
2009-05-23 10:17:27 +02:00
|
|
|
|
|
|
|
//Show the file if any of it's errors are visible
|
2009-05-23 13:26:04 +02:00
|
|
|
setRowHidden(i, QModelIndex(), !show);
|
2009-03-22 18:39:44 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-14 14:09:52 +02:00
|
|
|
QStandardItem *ResultsTree::EnsureFileItem(const QString &fullpath, bool hide)
|
2009-03-22 18:39:44 +01:00
|
|
|
{
|
2009-06-14 14:09:52 +02:00
|
|
|
QString name = StripPath(fullpath, false);
|
2009-05-23 10:17:27 +02:00
|
|
|
QStandardItem *item = FindFileItem(name);
|
2009-03-22 18:39:44 +01:00
|
|
|
|
2010-04-02 07:30:58 +02:00
|
|
|
if (item)
|
2009-05-23 10:17:27 +02:00
|
|
|
{
|
|
|
|
return item;
|
2009-03-22 18:39:44 +01:00
|
|
|
}
|
2009-05-23 10:17:27 +02:00
|
|
|
|
|
|
|
item = CreateItem(name);
|
2009-05-28 10:32:32 +02:00
|
|
|
item->setIcon(QIcon(":images/text-x-generic.png"));
|
2009-05-23 10:17:27 +02:00
|
|
|
|
2009-06-14 14:09:52 +02:00
|
|
|
//Add user data to that item
|
|
|
|
QMap<QString, QVariant> data;
|
2009-11-19 23:43:46 +01:00
|
|
|
data["file"] = fullpath;
|
2009-06-14 14:09:52 +02:00
|
|
|
item->setData(QVariant(data));
|
2009-05-23 10:17:27 +02:00
|
|
|
mModel.appendRow(item);
|
|
|
|
|
2009-06-09 08:30:28 +02:00
|
|
|
setRowHidden(mModel.rowCount() - 1, QModelIndex(), hide);
|
|
|
|
|
2009-05-23 10:17:27 +02:00
|
|
|
return item;
|
2009-03-22 18:39:44 +01:00
|
|
|
}
|
|
|
|
|
2009-05-23 10:17:27 +02:00
|
|
|
void ResultsTree::ShowFileItem(const QString &name)
|
|
|
|
{
|
|
|
|
QStandardItem *item = FindFileItem(name);
|
2010-04-02 07:30:58 +02:00
|
|
|
if (item)
|
2009-05-23 10:17:27 +02:00
|
|
|
{
|
2009-05-23 13:26:04 +02:00
|
|
|
setRowHidden(0, mModel.indexFromItem(item), false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
|
|
|
|
{
|
|
|
|
QModelIndex index = indexAt(e->pos());
|
2010-04-02 07:30:58 +02:00
|
|
|
if (index.isValid())
|
2009-05-23 13:26:04 +02:00
|
|
|
{
|
|
|
|
mContextItem = mModel.itemFromIndex(index);
|
|
|
|
|
2009-06-14 14:09:52 +02:00
|
|
|
//Create a new context menu
|
|
|
|
QMenu menu(this);
|
2009-05-23 13:26:04 +02:00
|
|
|
|
2009-06-14 14:09:52 +02:00
|
|
|
//Store all applications in a list
|
|
|
|
QList<QAction*> actions;
|
2009-05-23 13:26:04 +02:00
|
|
|
|
2009-06-14 14:09:52 +02:00
|
|
|
//Create a signal mapper so we don't have to store data to class
|
|
|
|
//member variables
|
|
|
|
QSignalMapper *signalMapper = new QSignalMapper(this);
|
|
|
|
|
2010-04-02 07:30:58 +02:00
|
|
|
if (mContextItem && mApplications->GetApplicationCount() > 0 && mContextItem->parent())
|
2009-06-14 14:09:52 +02:00
|
|
|
{
|
2009-05-23 13:26:04 +02:00
|
|
|
//Go through all applications and add them to the context menu
|
2010-04-02 07:30:58 +02:00
|
|
|
for (int i = 0; i < mApplications->GetApplicationCount(); i++)
|
2009-05-23 13:26:04 +02:00
|
|
|
{
|
|
|
|
//Create an action for the application
|
2009-07-02 10:32:29 +02:00
|
|
|
QAction *start = new QAction(mApplications->GetApplicationName(i), &menu);
|
2009-05-23 13:26:04 +02:00
|
|
|
|
|
|
|
//Add it to our list so we can disconnect later on
|
|
|
|
actions << start;
|
|
|
|
|
|
|
|
//Add it to context menu
|
|
|
|
menu.addAction(start);
|
|
|
|
|
|
|
|
//Connect the signal to signal mapper
|
|
|
|
connect(start, SIGNAL(triggered()), signalMapper, SLOT(map()));
|
|
|
|
|
|
|
|
//Add a new mapping
|
|
|
|
signalMapper->setMapping(start, i);
|
|
|
|
}
|
|
|
|
|
|
|
|
connect(signalMapper, SIGNAL(mapped(int)),
|
|
|
|
this, SLOT(Context(int)));
|
2009-06-14 14:09:52 +02:00
|
|
|
}
|
2009-05-23 13:26:04 +02:00
|
|
|
|
2009-06-14 14:09:52 +02:00
|
|
|
// Add menuitems to copy full path/filename to clipboard
|
2010-04-02 07:30:58 +02:00
|
|
|
if (mContextItem)
|
2009-06-14 14:09:52 +02:00
|
|
|
{
|
2010-04-02 07:30:58 +02:00
|
|
|
if (mApplications->GetApplicationCount() > 0)
|
2009-06-14 14:09:52 +02:00
|
|
|
{
|
|
|
|
menu.addSeparator();
|
|
|
|
}
|
|
|
|
|
|
|
|
//Create an action for the application
|
2009-12-06 17:46:24 +01:00
|
|
|
QAction *copyfilename = new QAction(tr("Copy filename"), &menu);
|
|
|
|
QAction *copypath = new QAction(tr("Copy full path"), &menu);
|
|
|
|
QAction *copymessage = new QAction(tr("Copy message"), &menu);
|
2009-06-14 14:09:52 +02:00
|
|
|
|
|
|
|
menu.addAction(copyfilename);
|
|
|
|
menu.addAction(copypath);
|
2009-12-06 17:46:24 +01:00
|
|
|
menu.addAction(copymessage);
|
2009-06-14 14:09:52 +02:00
|
|
|
|
|
|
|
connect(copyfilename, SIGNAL(triggered()), this, SLOT(CopyFilename()));
|
|
|
|
connect(copypath, SIGNAL(triggered()), this, SLOT(CopyFullPath()));
|
2009-12-06 17:46:24 +01:00
|
|
|
connect(copymessage, SIGNAL(triggered()), this, SLOT(CopyMessage()));
|
2009-06-14 14:09:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//Start the menu
|
|
|
|
menu.exec(e->globalPos());
|
2009-05-23 13:26:04 +02:00
|
|
|
|
2010-04-02 07:30:58 +02:00
|
|
|
if (mContextItem && mApplications->GetApplicationCount() > 0 && mContextItem->parent())
|
2009-06-14 14:09:52 +02:00
|
|
|
{
|
2009-05-23 13:26:04 +02:00
|
|
|
//Disconnect all signals
|
2010-04-02 07:30:58 +02:00
|
|
|
for (int i = 0; i < actions.size(); i++)
|
2009-05-23 13:26:04 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
disconnect(actions[i], SIGNAL(triggered()), signalMapper, SLOT(map()));
|
|
|
|
}
|
|
|
|
|
|
|
|
disconnect(signalMapper, SIGNAL(mapped(int)),
|
|
|
|
this, SLOT(Context(int)));
|
|
|
|
//And remove the signal mapper
|
|
|
|
delete signalMapper;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-23 17:45:05 +02:00
|
|
|
void ResultsTree::StartApplication(QStandardItem *target, int application)
|
2009-05-23 13:26:04 +02:00
|
|
|
{
|
2010-07-11 13:22:55 +02:00
|
|
|
//If there are no applications specified, tell the user about it
|
2010-04-02 07:30:58 +02:00
|
|
|
if (mApplications->GetApplicationCount() == 0)
|
2009-06-09 08:30:28 +02:00
|
|
|
{
|
2009-07-03 16:46:39 +02:00
|
|
|
QMessageBox msg(QMessageBox::Information,
|
2009-06-09 09:51:27 +02:00
|
|
|
tr("Cppcheck"),
|
2009-07-03 16:46:39 +02:00
|
|
|
tr("Configure the text file viewer program in Cppcheck preferences/Applications."),
|
2009-06-09 21:42:13 +02:00
|
|
|
QMessageBox::Ok,
|
|
|
|
this);
|
2009-06-09 09:51:27 +02:00
|
|
|
msg.exec();
|
2009-06-09 08:30:28 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-04-02 07:30:58 +02:00
|
|
|
if (target && application >= 0 && application < mApplications->GetApplicationCount() && target->parent())
|
2009-05-23 13:26:04 +02:00
|
|
|
{
|
2009-11-16 17:02:28 +01:00
|
|
|
// Make sure we are working with the first column
|
2010-04-02 07:30:58 +02:00
|
|
|
if (target->column() != 0)
|
2009-11-16 17:02:28 +01:00
|
|
|
target = target->parent()->child(target->row(), 0);
|
|
|
|
|
2009-05-23 17:45:05 +02:00
|
|
|
QVariantMap data = target->data().toMap();
|
2009-05-23 13:26:04 +02:00
|
|
|
|
2009-07-02 10:32:29 +02:00
|
|
|
QString program = mApplications->GetApplicationPath(application);
|
2009-05-23 13:26:04 +02:00
|
|
|
|
|
|
|
//Replace (file) with filename
|
2009-11-19 23:43:46 +01:00
|
|
|
QString file = data["file"].toString();
|
2010-07-11 13:22:55 +02:00
|
|
|
|
|
|
|
QFileInfo info(file);
|
|
|
|
if (!info.exists())
|
|
|
|
{
|
|
|
|
if (info.isAbsolute())
|
|
|
|
{
|
|
|
|
QMessageBox msgbox(this);
|
|
|
|
msgbox.setWindowTitle("Cppcheck");
|
|
|
|
msgbox.setText(tr("Could not find the file!"));
|
|
|
|
msgbox.setIcon(QMessageBox::Critical);
|
|
|
|
msgbox.exec();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-07-11 15:20:19 +02:00
|
|
|
QDir checkdir(mCheckPath);
|
|
|
|
if (checkdir.isAbsolute() && checkdir.exists())
|
|
|
|
{
|
|
|
|
file = mCheckPath + "/" + file;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
QString dir = AskFileDir(file);
|
|
|
|
dir += '/';
|
|
|
|
file = dir + file;
|
|
|
|
}
|
2010-07-11 13:22:55 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-02 07:30:58 +02:00
|
|
|
if (file.indexOf(" ") > -1)
|
2009-05-23 13:26:04 +02:00
|
|
|
{
|
2009-11-19 23:43:46 +01:00
|
|
|
file.insert(0, "\"");
|
|
|
|
file.append("\"");
|
2009-05-23 13:26:04 +02:00
|
|
|
}
|
|
|
|
|
2009-11-19 23:43:46 +01:00
|
|
|
program.replace("(file)", file, Qt::CaseInsensitive);
|
2009-05-23 13:26:04 +02:00
|
|
|
|
2009-11-19 23:43:46 +01:00
|
|
|
QVariant line = data["line"];
|
|
|
|
program.replace("(line)", QString("%1").arg(line.toInt()), Qt::CaseInsensitive);
|
2009-05-23 13:26:04 +02:00
|
|
|
|
|
|
|
program.replace("(message)", data["message"].toString(), Qt::CaseInsensitive);
|
|
|
|
program.replace("(severity)", data["severity"].toString(), Qt::CaseInsensitive);
|
|
|
|
|
2009-06-08 15:47:53 +02:00
|
|
|
bool success = QProcess::startDetached(program);
|
2010-04-02 07:30:58 +02:00
|
|
|
if (!success)
|
2009-06-08 15:47:53 +02:00
|
|
|
{
|
2009-07-02 10:32:29 +02:00
|
|
|
QString app = mApplications->GetApplicationName(application);
|
|
|
|
QString text = tr("Could not start %1\n\nPlease check the application path and parameters are correct.").arg(app);
|
2009-06-08 15:47:53 +02:00
|
|
|
|
|
|
|
QMessageBox msgbox(this);
|
|
|
|
msgbox.setWindowTitle("Cppcheck");
|
|
|
|
msgbox.setText(text);
|
|
|
|
msgbox.setIcon(QMessageBox::Critical);
|
2009-06-09 09:51:27 +02:00
|
|
|
|
2009-06-08 15:47:53 +02:00
|
|
|
msgbox.exec();
|
|
|
|
}
|
2009-05-23 10:17:27 +02:00
|
|
|
}
|
|
|
|
}
|
2009-05-23 17:45:05 +02:00
|
|
|
|
2010-07-11 13:22:55 +02:00
|
|
|
QString ResultsTree::AskFileDir(const QString &file)
|
|
|
|
{
|
|
|
|
QString text = tr("Could not find file:\n%1\nPlease select the directory where file is located.").arg(file);
|
|
|
|
QMessageBox msgbox(this);
|
|
|
|
msgbox.setWindowTitle("Cppcheck");
|
|
|
|
msgbox.setText(text);
|
|
|
|
msgbox.setIcon(QMessageBox::Warning);
|
|
|
|
msgbox.exec();
|
|
|
|
|
|
|
|
QString dir = QFileDialog::getExistingDirectory(this, tr("Select Directory"),
|
|
|
|
"",
|
|
|
|
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
2010-07-11 15:20:19 +02:00
|
|
|
mCheckPath = dir;
|
2010-07-11 13:22:55 +02:00
|
|
|
return dir;
|
|
|
|
}
|
|
|
|
|
2009-06-14 14:09:52 +02:00
|
|
|
void ResultsTree::CopyFilename()
|
|
|
|
{
|
|
|
|
CopyPath(mContextItem, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ResultsTree::CopyFullPath()
|
|
|
|
{
|
|
|
|
CopyPath(mContextItem, true);
|
|
|
|
}
|
2009-05-23 17:45:05 +02:00
|
|
|
|
2009-12-06 17:46:24 +01:00
|
|
|
void ResultsTree::CopyMessage()
|
|
|
|
{
|
2010-04-02 07:30:58 +02:00
|
|
|
if (mContextItem)
|
2009-12-06 17:46:24 +01:00
|
|
|
{
|
|
|
|
// Make sure we are working with the first column
|
2010-04-02 07:30:58 +02:00
|
|
|
if (mContextItem->column() != 0)
|
2009-12-06 17:46:24 +01:00
|
|
|
mContextItem = mContextItem->parent()->child(mContextItem->row(), 0);
|
|
|
|
|
|
|
|
QVariantMap data = mContextItem->data().toMap();
|
|
|
|
|
|
|
|
QString message = data["message"].toString();
|
|
|
|
|
|
|
|
QClipboard *clipboard = QApplication::clipboard();
|
|
|
|
clipboard->setText(message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-23 17:45:05 +02:00
|
|
|
void ResultsTree::Context(int application)
|
|
|
|
{
|
|
|
|
StartApplication(mContextItem, application);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ResultsTree::QuickStartApplication(const QModelIndex &index)
|
|
|
|
{
|
|
|
|
StartApplication(mModel.itemFromIndex(index), 0);
|
|
|
|
}
|
2009-05-26 17:21:39 +02:00
|
|
|
|
2009-06-14 14:09:52 +02:00
|
|
|
void ResultsTree::CopyPath(QStandardItem *target, bool fullPath)
|
|
|
|
{
|
2010-04-02 07:30:58 +02:00
|
|
|
if (target)
|
2009-06-14 14:09:52 +02:00
|
|
|
{
|
2009-11-19 23:43:46 +01:00
|
|
|
// Make sure we are working with the first column
|
2010-04-02 07:30:58 +02:00
|
|
|
if (target->column() != 0)
|
2009-11-19 23:43:46 +01:00
|
|
|
target = target->parent()->child(target->row(), 0);
|
|
|
|
|
2009-06-14 14:09:52 +02:00
|
|
|
QVariantMap data = target->data().toMap();
|
|
|
|
QString pathStr;
|
|
|
|
|
|
|
|
//Replace (file) with filename
|
2009-11-19 23:43:46 +01:00
|
|
|
QString file = data["file"].toString();
|
|
|
|
pathStr = file;
|
2010-04-02 07:30:58 +02:00
|
|
|
if (!fullPath)
|
2009-06-14 14:09:52 +02:00
|
|
|
{
|
2009-11-19 23:43:46 +01:00
|
|
|
QFileInfo fi(pathStr);
|
|
|
|
pathStr = fi.fileName();
|
2009-06-14 14:09:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QClipboard *clipboard = QApplication::clipboard();
|
|
|
|
clipboard->setText(pathStr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-26 17:21:39 +02:00
|
|
|
QString ResultsTree::SeverityToIcon(const QString &severity)
|
|
|
|
{
|
2010-04-02 07:30:58 +02:00
|
|
|
if (severity == "possible error")
|
2009-06-01 23:06:44 +02:00
|
|
|
return ":images/dialog-warning.png";
|
2010-04-02 07:30:58 +02:00
|
|
|
if (severity == "error")
|
2009-06-01 23:06:44 +02:00
|
|
|
return ":images/dialog-error.png";
|
2010-04-02 07:30:58 +02:00
|
|
|
if (severity == "style" || severity == "possible style")
|
2009-06-01 23:06:44 +02:00
|
|
|
return ":images/dialog-information.png";
|
2009-05-26 17:21:39 +02:00
|
|
|
|
|
|
|
return "";
|
|
|
|
}
|
2009-06-03 20:18:22 +02:00
|
|
|
|
2009-06-24 09:54:56 +02:00
|
|
|
void ResultsTree::SaveResults(Report *report)
|
2009-06-03 20:18:22 +02:00
|
|
|
{
|
2009-06-24 09:54:56 +02:00
|
|
|
report->WriteHeader();
|
2009-06-03 20:18:22 +02:00
|
|
|
|
2010-04-02 07:30:58 +02:00
|
|
|
for (int i = 0; i < mModel.rowCount(); i++)
|
2009-06-03 20:18:22 +02:00
|
|
|
{
|
|
|
|
QStandardItem *item = mModel.item(i, 0);
|
2010-04-02 07:30:58 +02:00
|
|
|
if (!isRowHidden(i, item->index()))
|
2009-07-04 21:29:48 +02:00
|
|
|
SaveErrors(report, item);
|
2009-06-03 20:18:22 +02:00
|
|
|
}
|
|
|
|
|
2009-06-24 09:54:56 +02:00
|
|
|
report->WriteFooter();
|
2009-06-03 20:18:22 +02:00
|
|
|
}
|
|
|
|
|
2009-06-24 09:54:56 +02:00
|
|
|
void ResultsTree::SaveErrors(Report *report, QStandardItem *item)
|
2009-06-03 20:18:22 +02:00
|
|
|
{
|
2010-04-02 07:30:58 +02:00
|
|
|
if (!item)
|
2009-06-03 20:18:22 +02:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-04-02 07:30:58 +02:00
|
|
|
for (int i = 0; i < item->rowCount(); i++)
|
2009-06-03 20:18:22 +02:00
|
|
|
{
|
|
|
|
QStandardItem *error = item->child(i, 0);
|
|
|
|
|
2010-04-02 07:30:58 +02:00
|
|
|
if (!error)
|
2009-06-03 20:18:22 +02:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2010-04-02 07:30:58 +02:00
|
|
|
if (isRowHidden(i, item->index()) && !mSaveAllErrors)
|
2009-06-03 20:18:22 +02:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Get error's user data
|
|
|
|
QVariant userdata = error->data();
|
|
|
|
//Convert it to QVariantMap
|
|
|
|
QVariantMap data = userdata.toMap();
|
|
|
|
|
2010-07-10 17:20:45 +02:00
|
|
|
ErrorItem item;
|
|
|
|
item.severity = ShowTypeToString(VariantToShowType(data["severity"]));
|
|
|
|
item.msg = data["message"].toString();
|
|
|
|
item.id = data["id"].toString();
|
2009-11-19 23:43:46 +01:00
|
|
|
QString file = StripPath(data["file"].toString(), true);
|
2010-07-10 19:54:33 +02:00
|
|
|
unsigned int line = data["line"].toUInt();
|
2009-06-03 20:18:22 +02:00
|
|
|
|
2010-07-10 17:20:45 +02:00
|
|
|
item.files << file;
|
|
|
|
item.lines << line;
|
2009-11-19 23:43:46 +01:00
|
|
|
|
2010-04-02 07:30:58 +02:00
|
|
|
for (int j = 0; j < error->rowCount(); j++)
|
2009-06-03 20:18:22 +02:00
|
|
|
{
|
2009-11-19 23:43:46 +01:00
|
|
|
QStandardItem *child_error = error->child(j, 0);
|
|
|
|
//Get error's user data
|
|
|
|
QVariant child_userdata = child_error->data();
|
|
|
|
//Convert it to QVariantMap
|
|
|
|
QVariantMap child_data = child_userdata.toMap();
|
2009-06-03 20:18:22 +02:00
|
|
|
|
2009-11-19 23:43:46 +01:00
|
|
|
file = StripPath(child_data["file"].toString(), true);
|
2010-07-10 19:54:33 +02:00
|
|
|
line = child_data["line"].toUInt();
|
2009-06-03 20:18:22 +02:00
|
|
|
|
2010-07-10 17:20:45 +02:00
|
|
|
item.files << file;
|
|
|
|
item.lines << line;
|
2009-11-19 23:43:46 +01:00
|
|
|
}
|
2009-06-03 20:18:22 +02:00
|
|
|
|
2010-07-10 17:20:45 +02:00
|
|
|
report->WriteError(item);
|
2009-06-03 20:18:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QString ResultsTree::ShowTypeToString(ShowTypes type)
|
|
|
|
{
|
2010-04-02 07:30:58 +02:00
|
|
|
switch (type)
|
2009-06-03 20:18:22 +02:00
|
|
|
{
|
|
|
|
case SHOW_STYLE:
|
2009-07-02 12:48:32 +02:00
|
|
|
return tr("style");
|
2009-06-03 20:18:22 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SHOW_ERRORS:
|
2009-07-02 12:48:32 +02:00
|
|
|
return tr("error");
|
2009-06-03 20:18:22 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SHOW_NONE:
|
|
|
|
return "";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
void ResultsTree::UpdateSettings(bool showFullPath,
|
|
|
|
bool saveFullPath,
|
|
|
|
bool saveAllErrors)
|
|
|
|
{
|
2010-04-02 07:30:58 +02:00
|
|
|
if (mShowFullPath != showFullPath)
|
2009-06-03 20:18:22 +02:00
|
|
|
{
|
|
|
|
mShowFullPath = showFullPath;
|
|
|
|
RefreshFilePaths();
|
|
|
|
}
|
|
|
|
|
|
|
|
mSaveFullPath = saveFullPath;
|
|
|
|
mSaveAllErrors = saveAllErrors;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ResultsTree::SetCheckDirectory(const QString &dir)
|
|
|
|
{
|
|
|
|
mCheckPath = dir;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString ResultsTree::StripPath(const QString &path, bool saving)
|
|
|
|
{
|
2010-04-02 07:30:58 +02:00
|
|
|
if ((!saving && mShowFullPath) || (saving && mSaveFullPath))
|
2009-06-03 20:18:22 +02:00
|
|
|
{
|
|
|
|
return QString(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
QDir dir(mCheckPath);
|
|
|
|
return dir.relativeFilePath(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ResultsTree::RefreshFilePaths(QStandardItem *item)
|
|
|
|
{
|
2010-04-02 07:30:58 +02:00
|
|
|
if (!item)
|
2009-06-03 20:18:22 +02:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Mark that this file's path hasn't been updated yet
|
|
|
|
bool updated = false;
|
|
|
|
|
|
|
|
//Loop through all errors within this file
|
2010-04-02 07:30:58 +02:00
|
|
|
for (int i = 0; i < item->rowCount(); i++)
|
2009-06-03 20:18:22 +02:00
|
|
|
{
|
|
|
|
//Get error i
|
|
|
|
QStandardItem *error = item->child(i, 0);
|
|
|
|
|
2010-04-02 07:30:58 +02:00
|
|
|
if (!error)
|
2009-06-03 20:18:22 +02:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Get error's user data
|
|
|
|
QVariant userdata = error->data();
|
|
|
|
//Convert it to QVariantMap
|
|
|
|
QVariantMap data = userdata.toMap();
|
|
|
|
|
|
|
|
//Get list of files
|
2009-11-19 23:43:46 +01:00
|
|
|
QString file = data["file"].toString();
|
2009-06-03 20:18:22 +02:00
|
|
|
|
|
|
|
//Update this error's text
|
2009-11-19 23:43:46 +01:00
|
|
|
error->setText(StripPath(file, false));
|
2009-06-03 20:18:22 +02:00
|
|
|
|
|
|
|
//If this error has backtraces make sure the files list has enough filenames
|
2010-04-02 07:30:58 +02:00
|
|
|
if (error->hasChildren())
|
2009-06-03 20:18:22 +02:00
|
|
|
{
|
|
|
|
//Loop through all files within the error
|
2010-04-02 07:30:58 +02:00
|
|
|
for (int j = 0; j < error->rowCount(); j++)
|
2009-06-03 20:18:22 +02:00
|
|
|
{
|
|
|
|
//Get file
|
2009-11-19 23:43:46 +01:00
|
|
|
QStandardItem *child = error->child(j, 0);
|
2010-04-02 07:30:58 +02:00
|
|
|
if (!child)
|
2009-06-03 20:18:22 +02:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2009-11-19 23:43:46 +01:00
|
|
|
//Get childs's user data
|
|
|
|
QVariant child_userdata = child->data();
|
|
|
|
//Convert it to QVariantMap
|
|
|
|
QVariantMap child_data = child_userdata.toMap();
|
|
|
|
|
|
|
|
//Get list of files
|
|
|
|
QString child_files = child_data["file"].toString();
|
2009-06-03 20:18:22 +02:00
|
|
|
//Update file's path
|
2009-11-19 23:43:46 +01:00
|
|
|
child->setText(StripPath(child_files, false));
|
2009-06-03 20:18:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//if the main file hasn't been updated yet, update it now
|
2010-04-02 07:30:58 +02:00
|
|
|
if (!updated)
|
2009-06-03 20:18:22 +02:00
|
|
|
{
|
|
|
|
updated = true;
|
|
|
|
item->setText(error->text());
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ResultsTree::RefreshFilePaths()
|
|
|
|
{
|
|
|
|
qDebug("Refreshing file paths");
|
|
|
|
|
|
|
|
//Go through all file items (these are parent items that contain the errors)
|
2010-04-02 07:30:58 +02:00
|
|
|
for (int i = 0; i < mModel.rowCount(); i++)
|
2009-06-03 20:18:22 +02:00
|
|
|
{
|
|
|
|
RefreshFilePaths(mModel.item(i, 0));
|
|
|
|
}
|
|
|
|
}
|
2009-06-09 09:51:27 +02:00
|
|
|
|
2009-06-20 22:05:17 +02:00
|
|
|
bool ResultsTree::HasVisibleResults() const
|
2009-06-09 09:51:27 +02:00
|
|
|
{
|
|
|
|
return mVisibleErrors;
|
|
|
|
}
|
2009-06-20 22:42:12 +02:00
|
|
|
|
|
|
|
bool ResultsTree::HasResults() const
|
|
|
|
{
|
|
|
|
return mModel.rowCount() > 0;
|
|
|
|
}
|
2009-07-02 10:32:29 +02:00
|
|
|
|
2009-07-02 10:46:26 +02:00
|
|
|
void ResultsTree::Translate()
|
2009-07-02 10:32:29 +02:00
|
|
|
{
|
|
|
|
QStringList labels;
|
|
|
|
labels << tr("File") << tr("Severity") << tr("Line") << tr("Message");
|
|
|
|
mModel.setHorizontalHeaderLabels(labels);
|
2009-07-02 12:48:32 +02:00
|
|
|
//TODO go through all the errors in the tree and translate severity and message
|
2009-07-02 10:32:29 +02:00
|
|
|
}
|
|
|
|
|