GUI: Add simple log view.
Adding a simple log view which shows log messages the core code emits.
This commit is contained in:
parent
f5024a7f67
commit
7e88d7b41d
10
gui/gui.pro
10
gui/gui.pro
|
@ -26,7 +26,8 @@ FORMS = main.ui \
|
||||||
settings.ui \
|
settings.ui \
|
||||||
file.ui \
|
file.ui \
|
||||||
projectfile.ui \
|
projectfile.ui \
|
||||||
about.ui
|
about.ui \
|
||||||
|
logview.ui
|
||||||
|
|
||||||
TRANSLATIONS = cppcheck_fi.ts \
|
TRANSLATIONS = cppcheck_fi.ts \
|
||||||
cppcheck_nl.ts \
|
cppcheck_nl.ts \
|
||||||
|
@ -60,7 +61,9 @@ HEADERS += mainwindow.h \
|
||||||
txtreport.h \
|
txtreport.h \
|
||||||
xmlreport.h \
|
xmlreport.h \
|
||||||
translationhandler.h \
|
translationhandler.h \
|
||||||
csvreport.h
|
csvreport.h \
|
||||||
|
logview.h
|
||||||
|
|
||||||
SOURCES += main.cpp \
|
SOURCES += main.cpp \
|
||||||
mainwindow.cpp\
|
mainwindow.cpp\
|
||||||
checkthread.cpp \
|
checkthread.cpp \
|
||||||
|
@ -81,7 +84,8 @@ SOURCES += main.cpp \
|
||||||
txtreport.cpp \
|
txtreport.cpp \
|
||||||
xmlreport.cpp \
|
xmlreport.cpp \
|
||||||
translationhandler.cpp \
|
translationhandler.cpp \
|
||||||
csvreport.cpp
|
csvreport.cpp \
|
||||||
|
logview.cpp
|
||||||
|
|
||||||
win32 {
|
win32 {
|
||||||
RC_FILE = cppcheck-gui.rc
|
RC_FILE = cppcheck-gui.rc
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
/*
|
||||||
|
* Cppcheck - A tool for static C/C++ code analysis
|
||||||
|
* Copyright (C) 2007-2010 Daniel Marjamäki and Cppcheck team.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "logview.h"
|
||||||
|
|
||||||
|
LogView::LogView(QWidget *parent)
|
||||||
|
{
|
||||||
|
mUI.setupUi(this);
|
||||||
|
setWindowFlags(Qt::Tool);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LogView::AppendLine(const QString &line)
|
||||||
|
{
|
||||||
|
mUI.mLogEdit->appendPlainText(line);
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
/*
|
||||||
|
* Cppcheck - A tool for static C/C++ code analysis
|
||||||
|
* Copyright (C) 2007-2010 Daniel Marjamäki and Cppcheck team.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef LOGVIEW_H
|
||||||
|
#define LOGVIEW_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include "ui_logview.h"
|
||||||
|
|
||||||
|
/// @addtogroup GUI
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief A tool window that shows checking log.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class LogView : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
LogView(QWidget *parent = 0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Append new log file to view.
|
||||||
|
* @param line String to add.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void AppendLine(const QString &line);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::LogView mUI;
|
||||||
|
};
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
#endif // LOGVIEW_H
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>LogView</class>
|
||||||
|
<widget class="QWidget" name="LogView">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>400</width>
|
||||||
|
<height>300</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="contextMenuPolicy">
|
||||||
|
<enum>Qt::NoContextMenu</enum>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Checking Log</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QPlainTextEdit" name="mLogEdit">
|
||||||
|
<property name="undoRedoEnabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
|
@ -100,6 +100,7 @@
|
||||||
<addaction name="mActionCollapseAll"/>
|
<addaction name="mActionCollapseAll"/>
|
||||||
<addaction name="mActionExpandAll"/>
|
<addaction name="mActionExpandAll"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
|
<addaction name="mActionViewLog"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="mMenuLanguage">
|
<widget class="QMenu" name="mMenuLanguage">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
|
@ -365,6 +366,14 @@
|
||||||
<string>&New Project File...</string>
|
<string>&New Project File...</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="mActionViewLog">
|
||||||
|
<property name="text">
|
||||||
|
<string>&Log View</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Log View</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include "projectfile.h"
|
#include "projectfile.h"
|
||||||
#include "project.h"
|
#include "project.h"
|
||||||
#include "report.h"
|
#include "report.h"
|
||||||
|
#include "logview.h"
|
||||||
#include "../lib/filelister.h"
|
#include "../lib/filelister.h"
|
||||||
|
|
||||||
// HTMLHelp is only available in Windows
|
// HTMLHelp is only available in Windows
|
||||||
|
@ -45,12 +46,14 @@ MainWindow::MainWindow() :
|
||||||
mSettings(new QSettings("Cppcheck", "Cppcheck-GUI", this)),
|
mSettings(new QSettings("Cppcheck", "Cppcheck-GUI", this)),
|
||||||
mApplications(new ApplicationList(this)),
|
mApplications(new ApplicationList(this)),
|
||||||
mTranslation(new TranslationHandler(this)),
|
mTranslation(new TranslationHandler(this)),
|
||||||
mLanguages(new QActionGroup(this))
|
mLanguages(new QActionGroup(this)),
|
||||||
|
mLogView(NULL)
|
||||||
{
|
{
|
||||||
mUI.setupUi(this);
|
mUI.setupUi(this);
|
||||||
mUI.mResults->Initialize(mSettings, mApplications);
|
mUI.mResults->Initialize(mSettings, mApplications);
|
||||||
|
|
||||||
mThread = new ThreadHandler(this);
|
mThread = new ThreadHandler(this);
|
||||||
|
mLogView = new LogView(this);
|
||||||
|
|
||||||
connect(mUI.mActionQuit, SIGNAL(triggered()), this, SLOT(close()));
|
connect(mUI.mActionQuit, SIGNAL(triggered()), this, SLOT(close()));
|
||||||
connect(mUI.mActionCheckFiles, SIGNAL(triggered()), this, SLOT(CheckFiles()));
|
connect(mUI.mActionCheckFiles, SIGNAL(triggered()), this, SLOT(CheckFiles()));
|
||||||
|
@ -65,6 +68,7 @@ MainWindow::MainWindow() :
|
||||||
connect(mUI.mActionUncheckAll, SIGNAL(triggered()), this, SLOT(UncheckAll()));
|
connect(mUI.mActionUncheckAll, SIGNAL(triggered()), this, SLOT(UncheckAll()));
|
||||||
connect(mUI.mActionCollapseAll, SIGNAL(triggered()), mUI.mResults, SLOT(CollapseAllResults()));
|
connect(mUI.mActionCollapseAll, SIGNAL(triggered()), mUI.mResults, SLOT(CollapseAllResults()));
|
||||||
connect(mUI.mActionExpandAll, SIGNAL(triggered()), mUI.mResults, SLOT(ExpandAllResults()));
|
connect(mUI.mActionExpandAll, SIGNAL(triggered()), mUI.mResults, SLOT(ExpandAllResults()));
|
||||||
|
connect(mUI.mActionViewLog, SIGNAL(triggered()), this, SLOT(ShowLogView()));
|
||||||
|
|
||||||
connect(mUI.mActionRecheck, SIGNAL(triggered()), this, SLOT(ReCheck()));
|
connect(mUI.mActionRecheck, SIGNAL(triggered()), this, SLOT(ReCheck()));
|
||||||
|
|
||||||
|
@ -114,6 +118,7 @@ MainWindow::MainWindow() :
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
{
|
{
|
||||||
|
delete mLogView;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::CreateLanguageMenuItems()
|
void MainWindow::CreateLanguageMenuItems()
|
||||||
|
@ -731,3 +736,21 @@ void MainWindow::NewProjectFile()
|
||||||
prj.Edit();
|
prj.Edit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::ShowLogView()
|
||||||
|
{
|
||||||
|
if (mLogView == NULL)
|
||||||
|
mLogView = new LogView(this);
|
||||||
|
|
||||||
|
mLogView->show();
|
||||||
|
if (!mLogView->isActiveWindow())
|
||||||
|
mLogView->activateWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::Log(const QString &logline)
|
||||||
|
{
|
||||||
|
if (mLogView)
|
||||||
|
{
|
||||||
|
mLogView->AppendLine(logline);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
|
|
||||||
#include "ui_main.h"
|
#include "ui_main.h"
|
||||||
class ThreadHandler;
|
class ThreadHandler;
|
||||||
|
class LogView;
|
||||||
|
|
||||||
/// @addtogroup GUI
|
/// @addtogroup GUI
|
||||||
/// @{
|
/// @{
|
||||||
|
@ -143,6 +144,12 @@ public slots:
|
||||||
*/
|
*/
|
||||||
void OpenProjectFile();
|
void OpenProjectFile();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Slot for showing the log view.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void ShowLogView();
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -190,6 +197,12 @@ protected slots:
|
||||||
*/
|
*/
|
||||||
void OpenHelpContents();
|
void OpenHelpContents();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Add new line to log.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void Log(const QString &logline);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -325,6 +338,11 @@ protected:
|
||||||
*/
|
*/
|
||||||
QString mCurrentDirectory;
|
QString mCurrentDirectory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Log view..
|
||||||
|
*/
|
||||||
|
LogView *mLogView;
|
||||||
|
|
||||||
};
|
};
|
||||||
/// @}
|
/// @}
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
|
|
@ -144,6 +144,8 @@ void ThreadHandler::Initialize(ResultsView *view)
|
||||||
connect(&mResults, SIGNAL(Error(const ErrorItem &)),
|
connect(&mResults, SIGNAL(Error(const ErrorItem &)),
|
||||||
view, SLOT(Error(const ErrorItem &)));
|
view, SLOT(Error(const ErrorItem &)));
|
||||||
|
|
||||||
|
connect(&mResults, SIGNAL(Log(const QString &)),
|
||||||
|
parent(), SLOT(Log(const QString &)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadHandler::LoadSettings(QSettings &settings)
|
void ThreadHandler::LoadSettings(QSettings &settings)
|
||||||
|
|
|
@ -33,7 +33,7 @@ ThreadResult::~ThreadResult()
|
||||||
|
|
||||||
void ThreadResult::reportOut(const std::string &outmsg)
|
void ThreadResult::reportOut(const std::string &outmsg)
|
||||||
{
|
{
|
||||||
Q_UNUSED(outmsg);
|
emit Log(QString::fromStdString(outmsg));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadResult::FileChecked(const QString &file)
|
void ThreadResult::FileChecked(const QString &file)
|
||||||
|
|
|
@ -93,6 +93,13 @@ signals:
|
||||||
*/
|
*/
|
||||||
void Error(const ErrorItem &item);
|
void Error(const ErrorItem &item);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Signal of a new log message
|
||||||
|
*
|
||||||
|
* @param logline Log line
|
||||||
|
*/
|
||||||
|
void Log(const QString &logline);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue