Also added icon source to AUTHORS file.
Also added toolbar with the default actions.
Added icons to result files and errors.
This commit is contained in:
Vesa Pikki 2009-05-26 18:21:39 +03:00
parent c7c9966fa3
commit 76c7290e12
16 changed files with 107 additions and 6 deletions

View File

@ -11,3 +11,5 @@ Reijo Tomperi
Slava Semushin
Vesa Pikki
GUI graphics courtesy of Tango Desktop Project:
http://tango.freedesktop.org

BIN
gui/images/dialog-error.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 925 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 954 B

BIN
gui/images/edit-clear.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
gui/images/go-down.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 874 B

BIN
gui/images/help-browser.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
gui/images/media-floppy.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 787 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
gui/images/process-stop.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 523 B

BIN
gui/images/view-refresh.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -24,6 +24,7 @@
#include <QDirIterator>
#include <QMenuBar>
#include <QMessageBox>
#include <QToolBar>
#include "../src/filelister.h"
#include "../src/cppcheckexecutor.h"
@ -43,13 +44,17 @@ MainWindow::MainWindow() :
mActionShowCheckAll(tr("Check all"), this),
mActionShowUncheckAll(tr("Uncheck all"), this),
mActionAbout(tr("About"), this),
mActionStop(tr("Stop checking"), this),
mActionSave(tr("Save results to a file"), this),
mResults(mSettings, mApplications)
{
QMenu *menu = menuBar()->addMenu(tr("&File"));
menu->addAction(&mActionCheckFiles);
menu->addAction(&mActionCheckDirectory);
menu->addAction(&mActionReCheck);
menu->addAction(&mActionStop);
menu->addAction(&mActionClearResults);
menu->addAction(&mActionSave);
menu->addSeparator();
menu->addAction(&mActionExit);
@ -93,12 +98,42 @@ MainWindow::MainWindow() :
connect(&mActionReCheck, SIGNAL(triggered()), this, SLOT(ReCheck()));
connect(&mActionAbout, SIGNAL(triggered()), this, SLOT(About()));
//TODO: This crashed
//connect(&mActionStop, SIGNAL(triggered()), &mThread, SLOT(Stop()));
connect(&mActionSave, SIGNAL(triggered()), this, SLOT(Save()));
connect(&mActionAbout, SIGNAL(triggered()), this, SLOT(About()));
connect(&mThread, SIGNAL(Done()), this, SLOT(CheckDone()));
//Toolbar
QToolBar *toolbar = addToolBar("Toolbar");
toolbar->setIconSize(QSize(22,22));
mActionCheckDirectory.setIcon(QIcon("icon.svg"));
mActionReCheck.setIcon(QIcon("images/view-refresh.png"));
mActionSettings.setIcon(QIcon("images/preferences-system.png"));
mActionAbout.setIcon(QIcon("images/help-browser.png"));
mActionStop.setIcon(QIcon("images/process-stop.png"));
mActionSave.setIcon(QIcon("images/media-floppy.png"));
mActionClearResults.setIcon(QIcon("images/edit-clear.png"));
toolbar->addAction(&mActionCheckDirectory);
toolbar->addAction(&mActionSave);
toolbar->addAction(&mActionReCheck);
toolbar->addAction(&mActionStop);
toolbar->addAction(&mActionClearResults);
toolbar->addAction(&mActionSettings);
toolbar->addAction(&mActionAbout);
LoadSettings();
mThread.Initialize(&mResults);
setWindowTitle(tr("Cppcheck"));
EnableCheckButtons(true);
}
MainWindow::~MainWindow()
@ -272,6 +307,7 @@ void MainWindow::ClearResults()
void MainWindow::EnableCheckButtons(bool enable)
{
mActionStop.setEnabled(!enable);
mActionCheckFiles.setEnabled(enable);
mActionReCheck.setEnabled(enable);
mActionCheckDirectory.setEnabled(enable);
@ -350,3 +386,13 @@ void MainWindow::About()
).arg(version));
msgBox.exec();
}
void MainWindow::Save()
{
QMessageBox msgBox;
msgBox.setWindowTitle(tr("Not implemented yet..."));
msgBox.setText(tr("Not implemented yet..."));
msgBox.exec();
}

View File

@ -120,6 +120,13 @@ public slots:
*/
void About();
/**
* @brief Slot to stop processing files
*
*/
void Save();
protected slots:
/**
@ -274,6 +281,17 @@ protected:
*/
QAction mActionAbout;
/**
* @brief Action stop checking files
*
*/
QAction mActionStop;
/**
* @brief Action save found errors to a file
*
*/
QAction mActionSave;
/**

View File

@ -84,7 +84,8 @@ void ResultsTree::AddErrorItem(const QString &file,
lines[0].toInt(),
severity,
message,
hide);
hide,
SeverityToIcon(severity));
//Add user data to that item
@ -95,10 +96,17 @@ void ResultsTree::AddErrorItem(const QString &file,
data["lines"] = lines;
item->setData(QVariant(data));
//Add backtrace files as children
for (int i = 1;i < files.size() && i < lines.size();i++)
{
AddBacktraceFiles(item, files[i], lines[i].toInt(), severity, message, hide);
AddBacktraceFiles(item,
files[i],
lines[i].toInt(),
severity,
message,
hide,
"images/go-down.png");
}
//TODO just hide/show current error and it's file
@ -114,7 +122,8 @@ QStandardItem *ResultsTree::AddBacktraceFiles(QStandardItem *parent,
const int line,
const QString &severity,
const QString &message,
const bool hide)
const bool hide,
const QString &icon)
{
if (!parent)
@ -135,6 +144,10 @@ QStandardItem *ResultsTree::AddBacktraceFiles(QStandardItem *parent,
setRowHidden(parent->rowCount() - 1, parent->index(), hide);
if (!icon.isEmpty()) {
list[0]->setIcon(QIcon(icon));
}
//TODO Does this leak memory? Should items from list be deleted?
return list[0];
@ -271,6 +284,7 @@ QStandardItem *ResultsTree::EnsureFileItem(const QString &name)
}
item = CreateItem(name);
item->setIcon(QIcon("images/text-x-generic.png"));
mModel.appendRow(item);
@ -396,3 +410,15 @@ void ResultsTree::QuickStartApplication(const QModelIndex &index)
{
StartApplication(mModel.itemFromIndex(index), 0);
}
QString ResultsTree::SeverityToIcon(const QString &severity)
{
if (severity == "all")
return "images/dialog-warning.png";
if (severity == "error")
return "images/dialog-error.png";
if (severity == "style")
return "images/dialog-information.png";
return "";
}

View File

@ -85,6 +85,13 @@ protected slots:
*/
void Context(int application);
protected:
/**
* @brief Convert a severity string to a icon filename
*
* @param severity Severity string
* @param Icon filename
*/
QString SeverityToIcon(const QString &severity);
/**
* @brief Helper function to open an error within target with application
@ -110,7 +117,8 @@ protected:
* @param line Line numer
* @param severity Error severity
* @param message Error message
* @param hide Should this be hidden (true) or shown (false)
* @param hide Should this be hidden (true) or shown (false)
* @param addicon Should a default backtrace item icon be added
* @return newly created QStandardItem *
*/
QStandardItem *AddBacktraceFiles(QStandardItem *parent,
@ -118,7 +126,8 @@ protected:
const int line,
const QString &severity,
const QString &message,
const bool hide);
const bool hide,
const QString &icon);
/**