Merge branch 'error-details'

Conflicts:
	gui/resultstree.h
	gui/resultsview.cpp
This commit is contained in:
Kimmo Varis 2010-11-24 17:24:36 +02:00
commit 458af3c931
7 changed files with 115 additions and 41 deletions

View File

@ -65,6 +65,7 @@ ShowTypes;
#define SETTINGS_TOOLBARS_VIEW_SHOW "Toolbars/ShowView"
#define SETTINGS_LOG_VIEW_WIDTH "Log/View width"
#define SETTINGS_LOG_VIEW_HEIGHT "Log/View height"
#define SETTINGS_MAINWND_SPLITTER_STATE "Mainwindow/Vertical splitter state"
/// @}
#endif

View File

@ -207,7 +207,7 @@ void MainWindow::SaveSettings()
mApplications->SaveSettings(mSettings);
mSettings->setValue(SETTINGS_LANGUAGE, mTranslation->GetCurrentLanguage());
mUI.mResults->SaveSettings();
mUI.mResults->SaveSettings(mSettings);
}
void MainWindow::DoCheckFiles(const QStringList &files)

View File

@ -36,6 +36,7 @@
#include <QFileDialog>
#include <QClipboard>
#include <QContextMenuEvent>
#include <QModelIndex>
#include "erroritem.h"
#include "settings.h"
#include "applicationlist.h"
@ -53,7 +54,7 @@ ResultsTree::ResultsTree(QWidget * parent) :
setModel(&mModel);
QStringList labels;
labels << tr("File") << tr("Severity") << tr("Line") << tr("Summary") << tr("Message");
labels << tr("File") << tr("Severity") << tr("Line") << tr("Summary");
mModel.setHorizontalHeaderLabels(labels);
setExpandsOnDoubleClick(false);
setSortingEnabled(true);
@ -191,7 +192,6 @@ QStandardItem *ResultsTree::AddBacktraceFiles(QStandardItem *parent,
//TODO message has parameter names so we'll need changes to the core
//cppcheck so we can get proper translations
list << CreateNormalItem(tr(item.summary.toLatin1()));
list << CreateNormalItem(tr(item.message.toLatin1()));
// Check for duplicate rows and don't add them if found
for (int i = 0; i < parent->rowCount(); i++)
@ -210,20 +210,15 @@ QStandardItem *ResultsTree::AddBacktraceFiles(QStandardItem *parent,
// the fourth column is the summary so check it last
if (parent->child(i, 3)->text() == list[3]->text())
{
// the fifth column is the message so check it last
if (parent->child(i, 4)->text() == list[4]->text())
{
#if defined(_WIN32)
const QString first = parent->child(i, 0)->text().toLower();
const QString second = list[0]->text().toLower();
if (first == second)
return 0;
#else
// this row matches so don't add it
const QString first = parent->child(i, 0)->text().toLower();
const QString second = list[0]->text().toLower();
if (first == second)
return 0;
#else
// this row matches so don't add it
return 0;
#endif // _WIN32
}
}
}
}
@ -942,8 +937,13 @@ bool ResultsTree::HasResults() const
void ResultsTree::Translate()
{
QStringList labels;
labels << tr("File") << tr("Severity") << tr("Line") << tr("Summary") << tr("Message");
labels << tr("File") << tr("Severity") << tr("Line") << tr("Summary");
mModel.setHorizontalHeaderLabels(labels);
//TODO go through all the errors in the tree and translate severity and message
}
void ResultsTree::currentChanged(const QModelIndex &current, const QModelIndex &previous)
{
QTreeView::currentChanged(current, previous);
emit SelectionChanged(current);
}

View File

@ -32,6 +32,8 @@
class Report;
class ErrorItem;
class ErrorLine;
class QModelIndex;
class QWidget;
/// @addtogroup GUI
/// @{
@ -131,6 +133,13 @@ signals:
*/
void ResultsHidden(bool hidden);
/**
* @brief Signal for selection change in result tree.
*
* @param index Model index to specify new selected item.
*/
void SelectionChanged(const QModelIndex &current);
protected slots:
/**
* @brief Slot to quickstart an error with default application
@ -170,6 +179,14 @@ protected slots:
*/
void HideResult();
/**
* @brief Slot for selection change in the results tree.
*
* @param index Model index to specify new selected item.
* @param index Model index to specify previous selected item.
*/
virtual void currentChanged(const QModelIndex &current, const QModelIndex &previous);
protected:
/**

View File

@ -19,6 +19,12 @@
#include <QDebug>
#include <QFile>
#include <QMessageBox>
#include <QStandardItemModel>
#include <QStandardItem>
#include <QVariant>
#include <QString>
#include <QModelIndex>
#include <QSettings>
#include "erroritem.h"
#include "resultsview.h"
#include "resultstree.h"
@ -35,28 +41,30 @@ ResultsView::ResultsView(QWidget * parent) :
mUI.setupUi(this);
connect(mUI.mTree, SIGNAL(ResultsHidden(bool)), this, SIGNAL(ResultsHidden(bool)));
connect(mUI.mTree, SIGNAL(SelectionChanged(const QModelIndex &)), this, SLOT(UpdateDetails(const QModelIndex &)));
}
void ResultsView::Initialize(QSettings *settings, ApplicationList *list)
{
mUI.mProgress->setMinimum(0);
mUI.mProgress->setVisible(false);
QByteArray state = settings->value(SETTINGS_MAINWND_SPLITTER_STATE).toByteArray();
mUI.mVerticalSplitter->restoreState(state);
mShowNoErrorsMessage = settings->value(SETTINGS_SHOW_NO_ERRORS, true).toBool();
mUI.mTree->Initialize(settings, list);
}
ResultsView::~ResultsView()
{
//dtor
}
void ResultsView::Clear()
{
mUI.mTree->Clear();
mUI.mDetails->setText("");
mErrorsFound = false;
//Clear the progressbar
@ -206,9 +214,12 @@ bool ResultsView::HasResults() const
return mUI.mTree->HasResults();
}
void ResultsView::SaveSettings()
void ResultsView::SaveSettings(QSettings *settings)
{
mUI.mTree->SaveSettings();
QByteArray state = mUI.mVerticalSplitter->saveState();
settings->setValue(SETTINGS_MAINWND_SPLITTER_STATE, state);
mUI.mVerticalSplitter->restoreState(state);
}
void ResultsView::Translate()
@ -255,3 +266,17 @@ void ResultsView::ReadErrorsXml(const QString &filename)
}
mUI.mTree->SetCheckDirectory("");
}
void ResultsView::UpdateDetails(const QModelIndex &index)
{
QStandardItemModel *model = qobject_cast<QStandardItemModel*>(mUI.mTree->model());
QStandardItem *item = model->itemFromIndex(index);
// Make sure we are working with the first column
if (item->parent() && item->column() != 0)
item = item->parent()->child(item->row(), 0);
QVariantMap data = item->data().toMap();
QString message = data["message"].toString();
mUI.mDetails->setText(message);
}

View File

@ -29,6 +29,8 @@
#include "ui_resultsview.h"
class ErrorItem;
class QModelIndex;
class QSettings;
/// @addtogroup GUI
/// @{
@ -120,8 +122,9 @@ public:
/**
* @brief Save View's settings
*
* @param settings program settings.
*/
void SaveSettings();
void SaveSettings(QSettings *settings);
/**
* @brief Translate this view
@ -184,6 +187,13 @@ public slots:
*/
void ShowHiddenResults();
/**
* @brief Update detailed message when selected item is changed.
*
* @param index Position of new selected item.
*/
void UpdateDetails(const QModelIndex &index);
protected:
/**
* @brief Have any errors been found

View File

@ -30,27 +30,44 @@
<number>0</number>
</property>
<item>
<widget class="QProgressBar" name="mProgress">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="value">
<number>24</number>
</property>
</widget>
</item>
<item>
<widget class="ResultsTree" name="mTree">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QProgressBar" name="mProgress">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="value">
<number>24</number>
</property>
</widget>
</item>
<item>
<widget class="QSplitter" name="mVerticalSplitter">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="ResultsTree" name="mTree">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
<widget class="QTextEdit" name="mDetails">
<property name="undoRedoEnabled">
<bool>false</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
@ -61,6 +78,10 @@
<header>resultstree.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>mTree</tabstop>
<tabstop>mDetails</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>