New Feature "Scratchpad" added to GUI. (#4166)
This commit is contained in:
parent
e7904bd7a8
commit
70ad457992
|
@ -42,6 +42,7 @@ FORMS = about.ui \
|
|||
main.ui \
|
||||
projectfile.ui \
|
||||
resultsview.ui \
|
||||
scratchpad.ui \
|
||||
settings.ui \
|
||||
stats.ui \
|
||||
selectfilesdialog.ui
|
||||
|
@ -87,6 +88,7 @@ HEADERS += aboutdialog.h \
|
|||
report.h \
|
||||
resultstree.h \
|
||||
resultsview.h \
|
||||
scratchpad.h \
|
||||
settingsdialog.h \
|
||||
showtypes.h \
|
||||
statsdialog.h \
|
||||
|
@ -119,6 +121,7 @@ SOURCES += aboutdialog.cpp \
|
|||
report.cpp \
|
||||
resultstree.cpp \
|
||||
resultsview.cpp \
|
||||
scratchpad.cpp \
|
||||
settingsdialog.cpp \
|
||||
showtypes.cpp \
|
||||
statsdialog.cpp \
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
<file>images/showerrors.png</file>
|
||||
<file>images/showstylewarnings.png</file>
|
||||
<file>images/openproject.png</file>
|
||||
<file>images/scratchpad.png</file>
|
||||
<file>images/showwarnings.png</file>
|
||||
<file>images/showperformance.png</file>
|
||||
<file>images/utilities-system-monitor.png</file>
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 444 B |
12
gui/main.ui
12
gui/main.ui
|
@ -112,6 +112,7 @@
|
|||
<addaction name="separator"/>
|
||||
<addaction name="mActionShowHidden"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="mActionShowScratchpad"/>
|
||||
<addaction name="mActionViewLog"/>
|
||||
<addaction name="mActionViewStats"/>
|
||||
</widget>
|
||||
|
@ -165,6 +166,7 @@
|
|||
</attribute>
|
||||
<addaction name="mActionCheckDirectory"/>
|
||||
<addaction name="mActionOpenProjectFile"/>
|
||||
<addaction name="mActionShowScratchpad"/>
|
||||
<addaction name="mActionSave"/>
|
||||
<addaction name="mActionRecheck"/>
|
||||
<addaction name="mActionStop"/>
|
||||
|
@ -424,6 +426,16 @@
|
|||
<string>Open P&roject File...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="mActionShowScratchpad">
|
||||
<property name="icon">
|
||||
<iconset resource="gui.qrc">
|
||||
<normaloff>:/images/scratchpad.png</normaloff>:/images/scratchpad.png
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Show S&cratchpad...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="mActionNewProjectFile">
|
||||
<property name="text">
|
||||
<string>&New Project File...</string>
|
||||
|
|
|
@ -35,8 +35,10 @@
|
|||
#include "projectfile.h"
|
||||
#include "project.h"
|
||||
#include "report.h"
|
||||
#include "scratchpad.h"
|
||||
#include "statsdialog.h"
|
||||
#include "settingsdialog.h"
|
||||
#include "threadresult.h"
|
||||
#include "translationhandler.h"
|
||||
#include "logview.h"
|
||||
#include "filelist.h"
|
||||
|
@ -50,6 +52,7 @@ MainWindow::MainWindow() :
|
|||
mApplications(new ApplicationList(this)),
|
||||
mTranslation(new TranslationHandler(this)),
|
||||
mLogView(NULL),
|
||||
mScratchPad(NULL),
|
||||
mProject(NULL),
|
||||
mPlatformActions(new QActionGroup(this)),
|
||||
mExiting(false)
|
||||
|
@ -116,6 +119,7 @@ MainWindow::MainWindow() :
|
|||
// File menu
|
||||
connect(mUI.mActionNewProjectFile, SIGNAL(triggered()), this, SLOT(NewProjectFile()));
|
||||
connect(mUI.mActionOpenProjectFile, SIGNAL(triggered()), this, SLOT(OpenProjectFile()));
|
||||
connect(mUI.mActionShowScratchpad, SIGNAL(triggered()), this, SLOT(ShowScratchpad()));
|
||||
connect(mUI.mActionCloseProjectFile, SIGNAL(triggered()), this, SLOT(CloseProjectFile()));
|
||||
connect(mUI.mActionEditProjectFile, SIGNAL(triggered()), this, SLOT(EditProjectFile()));
|
||||
|
||||
|
@ -182,6 +186,7 @@ MainWindow::~MainWindow()
|
|||
{
|
||||
delete mLogView;
|
||||
delete mProject;
|
||||
delete mScratchPad;
|
||||
}
|
||||
|
||||
void MainWindow::HandleCLIParams(const QStringList ¶ms)
|
||||
|
@ -331,6 +336,32 @@ void MainWindow::DoCheckFiles(const QStringList &files)
|
|||
mThread->Check(checkSettings, false);
|
||||
}
|
||||
|
||||
void MainWindow::CheckCode(const QString& code, const QString& filename)
|
||||
{
|
||||
// Initialize dummy ThreadResult as ErrorLogger
|
||||
ThreadResult result;
|
||||
result.SetFiles(QStringList(filename));
|
||||
connect(&result, SIGNAL(Progress(int, const QString&)),
|
||||
mUI.mResults, SLOT(Progress(int, const QString&)));
|
||||
connect(&result, SIGNAL(Error(const ErrorItem &)),
|
||||
mUI.mResults, SLOT(Error(const ErrorItem &)));
|
||||
connect(&result, SIGNAL(Log(const QString &)),
|
||||
this, SLOT(Log(const QString &)));
|
||||
connect(&result, SIGNAL(DebugError(const ErrorItem &)),
|
||||
this, SLOT(DebugError(const ErrorItem &)));
|
||||
|
||||
// Create CppCheck instance
|
||||
CppCheck cppcheck(result, true);
|
||||
cppcheck.settings() = GetCppcheckSettings();
|
||||
|
||||
// Check
|
||||
CheckLockDownUI();
|
||||
ClearResults();
|
||||
mUI.mResults->CheckingStarted(1);
|
||||
cppcheck.check(filename.toStdString(), code.toStdString());
|
||||
CheckDone();
|
||||
}
|
||||
|
||||
QStringList MainWindow::SelectFilesToCheck(QFileDialog::FileMode mode)
|
||||
{
|
||||
if (mProject) {
|
||||
|
@ -531,7 +562,8 @@ void MainWindow::CheckDone()
|
|||
mUI.mActionCplusplus11->setEnabled(true);
|
||||
mUI.mActionC99->setEnabled(true);
|
||||
mUI.mActionPosix->setEnabled(true);
|
||||
|
||||
if (mScratchPad)
|
||||
mScratchPad->setEnabled(true);
|
||||
|
||||
if (mUI.mResults->HasResults()) {
|
||||
mUI.mActionClearResults->setEnabled(true);
|
||||
|
@ -558,6 +590,8 @@ void MainWindow::CheckLockDownUI()
|
|||
mUI.mActionCplusplus11->setEnabled(false);
|
||||
mUI.mActionC99->setEnabled(false);
|
||||
mUI.mActionPosix->setEnabled(false);
|
||||
if (mScratchPad)
|
||||
mScratchPad->setEnabled(false);
|
||||
|
||||
for (int i = 0; i < MaxRecentProjects + 1; i++) {
|
||||
if (mRecentProjectActs[i] != NULL)
|
||||
|
@ -895,6 +929,17 @@ void MainWindow::OpenProjectFile()
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::ShowScratchpad()
|
||||
{
|
||||
if (!mScratchPad)
|
||||
mScratchPad = new ScratchPad(*this);
|
||||
|
||||
mScratchPad->show();
|
||||
|
||||
if (!mScratchPad->isActiveWindow())
|
||||
mScratchPad->activateWindow();
|
||||
}
|
||||
|
||||
void MainWindow::LoadProjectFile(const QString &filePath)
|
||||
{
|
||||
QFileInfo inf(filePath);
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
class ThreadHandler;
|
||||
class TranslationHandler;
|
||||
class ScratchPad;
|
||||
class LogView;
|
||||
class Project;
|
||||
class ErrorItem;
|
||||
|
@ -187,6 +188,12 @@ public slots:
|
|||
*/
|
||||
void OpenProjectFile();
|
||||
|
||||
/**
|
||||
* @brief Slot to open project file and start checking contained paths.
|
||||
*
|
||||
*/
|
||||
void ShowScratchpad();
|
||||
|
||||
/**
|
||||
* @brief Slot to close open project file.
|
||||
*
|
||||
|
@ -211,6 +218,14 @@ public slots:
|
|||
*/
|
||||
void ShowStatistics();
|
||||
|
||||
/**
|
||||
* @brief Checks given code
|
||||
*
|
||||
* @param code Content of the (virtual) file to be checked
|
||||
* @param filename Name of the (virtual) file to be checked - determines language.
|
||||
*/
|
||||
void CheckCode(const QString& code, const QString& filename);
|
||||
|
||||
protected slots:
|
||||
|
||||
/**
|
||||
|
@ -453,6 +468,11 @@ protected:
|
|||
*/
|
||||
LogView *mLogView;
|
||||
|
||||
/**
|
||||
* @brief Scratchpad.
|
||||
*/
|
||||
ScratchPad* mScratchPad;
|
||||
|
||||
/**
|
||||
* @brief Project (file).
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Cppcheck - A tool for static C/C++ code analysis
|
||||
* Copyright (C) 2007-2012 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 "scratchpad.h"
|
||||
#include "mainwindow.h"
|
||||
#include <QWidget>
|
||||
|
||||
ScratchPad::ScratchPad(MainWindow& mainWindow)
|
||||
: QDialog(&mainWindow)
|
||||
, mMainWindow(mainWindow)
|
||||
{
|
||||
mUI.setupUi(this);
|
||||
|
||||
connect(mUI.mCheckButton, SIGNAL(clicked()), this, SLOT(CheckButtonClicked()));
|
||||
}
|
||||
|
||||
void ScratchPad::CheckButtonClicked()
|
||||
{
|
||||
QString filename = mUI.lineEdit->text();
|
||||
if (filename.size() == 0)
|
||||
filename = "test.cpp";
|
||||
mMainWindow.CheckCode(mUI.plainTextEdit->toPlainText(), filename);
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Cppcheck - A tool for static C/C++ code analysis
|
||||
* Copyright (C) 2007-2012 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 SCRATCHPAD_H
|
||||
#define SCRATCHPAD_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "ui_scratchpad.h"
|
||||
|
||||
class MainWindow;
|
||||
|
||||
/// @addtogroup GUI
|
||||
/// @{
|
||||
|
||||
/**
|
||||
* @brief A window with a text field that .
|
||||
*/
|
||||
class ScratchPad : public QDialog {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ScratchPad(MainWindow& mainWindow);
|
||||
|
||||
private slots:
|
||||
/**
|
||||
* @brief Called when check button is clicked.
|
||||
*/
|
||||
void CheckButtonClicked();
|
||||
|
||||
private:
|
||||
Ui::ScratchPad mUI;
|
||||
MainWindow& mMainWindow;
|
||||
};
|
||||
|
||||
/// @}
|
||||
|
||||
#endif // SCRATCHPAD_H
|
|
@ -0,0 +1,98 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ScratchPad</class>
|
||||
<widget class="QDialog" name="ScratchPad">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>500</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Scratchpad</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QPlainTextEdit" name="plainTextEdit">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Courier New</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit">
|
||||
<property name="placeholderText">
|
||||
<string>filename</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="mCheckButton">
|
||||
<property name="text">
|
||||
<string>Check</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="mButtonBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Close</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>mButtonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>ScratchPad</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>20</x>
|
||||
<y>20</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>20</x>
|
||||
<y>20</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
Loading…
Reference in New Issue