diff --git a/gui/gui.pro b/gui/gui.pro index e090282ed..8c921f521 100644 --- a/gui/gui.pro +++ b/gui/gui.pro @@ -51,7 +51,6 @@ RESOURCES = gui.qrc FORMS = about.ui \ application.ui \ file.ui \ - logview.ui \ mainwindow.ui \ projectfiledialog.ui \ resultsview.ui \ @@ -95,7 +94,6 @@ HEADERS += aboutdialog.h \ erroritem.h \ filelist.h \ fileviewdialog.h \ - logview.h \ mainwindow.h \ platforms.h \ printablereport.h \ @@ -130,7 +128,6 @@ SOURCES += aboutdialog.cpp \ erroritem.cpp \ filelist.cpp \ fileviewdialog.cpp \ - logview.cpp \ main.cpp \ mainwindow.cpp\ platforms.cpp \ diff --git a/gui/logview.cpp b/gui/logview.cpp deleted file mode 100644 index 6ba4d5335..000000000 --- a/gui/logview.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2016 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 . - */ - -#include -#include -#include -#include -#include -#include -#include "common.h" -#include "logview.h" - -LogView::LogView(QWidget *parent) - : QWidget(parent) -{ - mUI.setupUi(this); - setWindowFlags(Qt::Tool); - - mUI.mButtonBox->button(QDialogButtonBox::Reset)->setText(tr("Clear")); - connect(mUI.mButtonBox->button(QDialogButtonBox::Close), SIGNAL(clicked()), this, SLOT(closeButtonClicked())); - connect(mUI.mButtonBox->button(QDialogButtonBox::Reset), SIGNAL(clicked()), this, SLOT(clearButtonClicked())); - connect(mUI.mButtonBox->button(QDialogButtonBox::Save), SIGNAL(clicked()), this, SLOT(saveButtonClicked())); - - QSettings settings; - resize(settings.value(SETTINGS_LOG_VIEW_WIDTH, 400).toInt(), - settings.value(SETTINGS_LOG_VIEW_HEIGHT, 300).toInt()); -} - -LogView::~LogView() -{ - QSettings settings; - settings.setValue(SETTINGS_LOG_VIEW_WIDTH, size().width()); - settings.setValue(SETTINGS_LOG_VIEW_HEIGHT, size().height()); -} - -void LogView::appendLine(const QString &line) -{ - mUI.mLogEdit->appendPlainText(line); -} - -void LogView::closeButtonClicked() -{ - close(); -} - -void LogView::clearButtonClicked() -{ - mUI.mLogEdit->clear(); -} - -void LogView::saveButtonClicked() -{ - QString fileName = QFileDialog::getSaveFileName(this, tr("Save Log"), - QString(), tr("Text files (*.txt *.log);;All files (*.*)")); - if (!fileName.isEmpty()) { - QFile file(fileName); - if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { - QMessageBox::warning(this, tr("Cppcheck"), - tr("Could not open file for writing: \"%1\"").arg(fileName)); - return; - } - - QTextStream out(&file); - out << mUI.mLogEdit->toPlainText(); - } -} diff --git a/gui/logview.h b/gui/logview.h deleted file mode 100644 index ec54b7768..000000000 --- a/gui/logview.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2016 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 . - */ - -#ifndef LOGVIEW_H -#define LOGVIEW_H - -#include -#include "ui_logview.h" - -/// @addtogroup GUI -/// @{ - -/** -* @brief A tool window that shows checking log. -* -*/ -class LogView : public QWidget { - Q_OBJECT -public: - explicit LogView(QWidget *parent = 0); - ~LogView(); - - /** - * @brief Append new log file to view. - * @param line String to add. - * - */ - void appendLine(const QString &line); - -protected slots: - - /** - * @brief Called when close button is clicked. - * - */ - void closeButtonClicked(); - - /** - * @brief Called when clear button is clicked. - * - */ - void clearButtonClicked(); - - /** - * @brief Called when save button is clicked. - * - */ - void saveButtonClicked(); - -private: - Ui::LogView mUI; -}; - -/// @} - -#endif // LOGVIEW_H diff --git a/gui/logview.ui b/gui/logview.ui deleted file mode 100644 index e96fce2ee..000000000 --- a/gui/logview.ui +++ /dev/null @@ -1,41 +0,0 @@ - - - LogView - - - - 0 - 0 - 400 - 300 - - - - Qt::NoContextMenu - - - Checking Log - - - - - - false - - - true - - - - - - - QDialogButtonBox::Close|QDialogButtonBox::Reset|QDialogButtonBox::Save - - - - - - - - diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 551474e49..75082652f 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -42,7 +42,6 @@ #include "settingsdialog.h" #include "threadresult.h" #include "translationhandler.h" -#include "logview.h" #include "filelist.h" #include "showtypes.h" #include "librarydialog.h" @@ -54,7 +53,6 @@ MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) : mSettings(settings), mApplications(new ApplicationList(this)), mTranslation(th), - mLogView(nullptr), mScratchPad(nullptr), mProjectFile(nullptr), mPlatformActions(new QActionGroup(this)), @@ -102,7 +100,6 @@ MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) : connect(mUI.mActionCollapseAll, &QAction::triggered, mUI.mResults, &ResultsView::collapseAllResults); connect(mUI.mActionExpandAll, &QAction::triggered, mUI.mResults, &ResultsView::expandAllResults); connect(mUI.mActionShowHidden, &QAction::triggered, mUI.mResults, &ResultsView::showHiddenResults); - connect(mUI.mActionViewLog, &QAction::triggered, this, &MainWindow::showLogView); connect(mUI.mActionViewStats, &QAction::triggered, this, &MainWindow::showStatistics); connect(mUI.mActionLibraryEditor, &QAction::triggered, this, &MainWindow::showLibraryEditor); @@ -123,6 +120,8 @@ MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) : connect(mUI.mActionAuthors, &QAction::triggered, this, &MainWindow::showAuthors); connect(mThread, &ThreadHandler::done, this, &MainWindow::analysisDone); + connect(mThread, &ThreadHandler::log, mUI.mResults, &ResultsView::log); + connect(mThread, &ThreadHandler::debugError, mUI.mResults, &ResultsView::debugError); connect(mUI.mResults, &ResultsView::gotResults, this, &MainWindow::resultsAdded); connect(mUI.mResults, &ResultsView::resultsHidden, mUI.mActionShowHidden, &QAction::setEnabled); connect(mUI.mResults, &ResultsView::checkSelected, this, &MainWindow::performSelectedFilesCheck); @@ -217,7 +216,6 @@ MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) : MainWindow::~MainWindow() { - delete mLogView; delete mProjectFile; delete mScratchPad; } @@ -1313,8 +1311,6 @@ void MainWindow::setLanguage(const QString &code) //Translate everything that is visible here mUI.retranslateUi(this); mUI.mResults->translate(); - delete mLogView; - mLogView = 0; } } @@ -1536,16 +1532,6 @@ void MainWindow::editProjectFile() } } -void MainWindow::showLogView() -{ - if (mLogView == nullptr) - mLogView = new LogView; - - mLogView->show(); - if (!mLogView->isActiveWindow()) - mLogView->activateWindow(); -} - void MainWindow::showStatistics() { StatsDialog statsDialog(this); @@ -1566,20 +1552,6 @@ void MainWindow::showLibraryEditor() libraryDialog.exec(); } -void MainWindow::log(const QString &logline) -{ - if (mLogView) { - mLogView->appendLine(logline); - } -} - -void MainWindow::debugError(const ErrorItem &item) -{ - if (mLogView) { - mLogView->appendLine(item.ToString()); - } -} - void MainWindow::filterResults() { mUI.mResults->filterResults(mLineEditFilter->text()); diff --git a/gui/mainwindow.h b/gui/mainwindow.h index 69f2b0eb8..159a982e8 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -33,7 +33,6 @@ class ThreadHandler; class TranslationHandler; class ScratchPad; -class LogView; class ProjectFile; class ErrorItem; class QAction; @@ -168,9 +167,6 @@ public slots: /** @brief Slot to edit project file. */ void editProjectFile(); - /** @brief Slot for showing the log view. */ - void showLogView(); - /** @brief Slot for showing the scan and project statistics. */ void showStatistics(); @@ -206,12 +202,6 @@ protected slots: /** @brief Open help file contents */ void openHelpContents(); - /** @brief Add new line to log. */ - void log(const QString &logline); - - /** @brief Handle new debug error. */ - void debugError(const ErrorItem &item); - /** @brief Filters the results in the result list. */ void filterResults(); @@ -414,9 +404,6 @@ private: /** @brief Current analyzed directory. */ QString mCurrentDirectory; - /** @brief Log view. */ - LogView *mLogView; - /** @brief Scratchpad. */ ScratchPad* mScratchPad; diff --git a/gui/mainwindow.ui b/gui/mainwindow.ui index 782b50532..79bbfa94d 100644 --- a/gui/mainwindow.ui +++ b/gui/mainwindow.ui @@ -113,7 +113,6 @@ - diff --git a/gui/resultstree.cpp b/gui/resultstree.cpp index 756f3b252..a76918fb9 100644 --- a/gui/resultstree.cpp +++ b/gui/resultstree.cpp @@ -633,15 +633,19 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e) menu.addSeparator(); QMenu *tagMenu = menu.addMenu(tr("Tag")); { - QAction *action = new QAction(tr("No tag"), tagMenu); - tagMenu->addAction(action); - connect(action, &QAction::triggered, [=](){ tagSelectedItems(QString()); }); + QAction *action = new QAction(tr("No tag"), tagMenu); + tagMenu->addAction(action); + connect(action, &QAction::triggered, [=]() { + tagSelectedItems(QString()); + }); } foreach (const QString tagstr, mTags) { QAction *action = new QAction(tagstr, tagMenu); tagMenu->addAction(action); - connect(action, &QAction::triggered, [=](){ tagSelectedItems(tagstr); }); + connect(action, &QAction::triggered, [=]() { + tagSelectedItems(tagstr); + }); } } } diff --git a/gui/resultsview.cpp b/gui/resultsview.cpp index 165d3e810..77ecb554d 100644 --- a/gui/resultsview.cpp +++ b/gui/resultsview.cpp @@ -406,3 +406,13 @@ void ResultsView::updateDetails(const QModelIndex &index) formattedMsg.prepend(tr("Id") + ": " + data["id"].toString() + "\n"); mUI.mDetails->setText(formattedMsg); } + +void ResultsView::log(const QString &str) +{ + mUI.mListLog->addItem(str); +} + +void ResultsView::debugError(const ErrorItem &item) +{ + mUI.mListLog->addItem(item.ToString()); +} diff --git a/gui/resultsview.h b/gui/resultsview.h index 1ff12a66d..2bc9c771b 100644 --- a/gui/resultsview.h +++ b/gui/resultsview.h @@ -285,6 +285,16 @@ public slots: */ void printPreview(); + /** + * \brief Log message + */ + void log(const QString &str); + + /** + * \brief debug message + */ + void debugError(const ErrorItem &item); + protected: /** * @brief Should we show a "No errors found dialog" every time no errors were found? diff --git a/gui/resultsview.ui b/gui/resultsview.ui index 57870cdd9..3c5a9e15c 100644 --- a/gui/resultsview.ui +++ b/gui/resultsview.ui @@ -70,13 +70,64 @@ QAbstractItemView::ExtendedSelection - - - false + + + QTabWidget::South - - true + + 1 + + + Analysis Log + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + Warning Details + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + false + + + true + + + + + diff --git a/gui/threadhandler.cpp b/gui/threadhandler.cpp index 58ad80e42..2a8d5bd5b 100644 --- a/gui/threadhandler.cpp +++ b/gui/threadhandler.cpp @@ -190,11 +190,11 @@ void ThreadHandler::initialize(ResultsView *view) connect(&mResults, &ThreadResult::error, view, &ResultsView::error); - connect(&mResults, SIGNAL(log(const QString &)), - parent(), SLOT(log(const QString &))); + connect(&mResults, &ThreadResult::log, + this, &ThreadHandler::log); - connect(&mResults, SIGNAL(debugError(const ErrorItem &)), - parent(), SLOT(debugError(const ErrorItem &))); + connect(&mResults, &ThreadResult::debugError, + this, &ThreadHandler::debugError); } void ThreadHandler::loadSettings(QSettings &settings) diff --git a/gui/threadhandler.h b/gui/threadhandler.h index 88cf7ac6a..7354fb9d4 100644 --- a/gui/threadhandler.h +++ b/gui/threadhandler.h @@ -191,6 +191,10 @@ signals: */ void done(); + void log(const QString &msg); + + void debugError(const ErrorItem &item); + public slots: /**