From 814cd37c905e9016aaf45f3189d8401dfbf166af Mon Sep 17 00:00:00 2001 From: Vesa Pikki Date: Tue, 9 Jun 2009 09:30:28 +0300 Subject: [PATCH] Added some warning messageboxes. One for when user tries to double click and there are now applications specified. Another for when user tries to check something and the file list is empty. --- gui/mainwindow.cpp | 9 +++++++++ gui/resultstree.cpp | 16 ++++++++++++++-- gui/resultstree.h | 3 ++- gui/resultsview.cpp | 9 +++++++++ gui/threadresult.cpp | 1 + 5 files changed, 35 insertions(+), 3 deletions(-) diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index b6282a69b..57a8d34d3 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -206,6 +206,15 @@ void MainWindow::DoCheckFiles(QFileDialog::FileMode mode) mResults.Clear(); mThread.ClearFiles(); + + if (fileNames.isEmpty()) + { + QMessageBox msgBox; + msgBox.setText("No suitable files found to check!"); + msgBox.exec(); + return; + } + mThread.SetFiles(RemoveUnacceptedFiles(fileNames)); mSettings.setValue(tr("Check path"), dialog.directory().absolutePath()); EnableCheckButtons(false); diff --git a/gui/resultstree.cpp b/gui/resultstree.cpp index 8486877f3..ee01a9e42 100644 --- a/gui/resultstree.cpp +++ b/gui/resultstree.cpp @@ -23,6 +23,7 @@ #include #include #include +#include ResultsTree::ResultsTree(QSettings &settings, ApplicationList &list) : mSettings(settings), @@ -81,7 +82,7 @@ void ResultsTree::AddErrorItem(const QString &file, bool hide = !mShowTypes[SeverityToShowType(severity)]; //Create the base item for the error and ensure it has a proper //file item as a parent - QStandardItem *item = AddBacktraceFiles(EnsureFileItem(realfile), + QStandardItem *item = AddBacktraceFiles(EnsureFileItem(realfile, hide), realfile, lines[0].toInt(), severity, @@ -283,7 +284,7 @@ void ResultsTree::RefreshTree() } -QStandardItem *ResultsTree::EnsureFileItem(const QString &name) +QStandardItem *ResultsTree::EnsureFileItem(const QString &name, bool hide) { QStandardItem *item = FindFileItem(name); @@ -297,6 +298,8 @@ QStandardItem *ResultsTree::EnsureFileItem(const QString &name) mModel.appendRow(item); + setRowHidden(mModel.rowCount() - 1, QModelIndex(), hide); + return item; } @@ -371,6 +374,15 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e) void ResultsTree::StartApplication(QStandardItem *target, int application) { + //If there are now application's specified, tell the user about it + if (mApplications.GetApplicationCount() == 0) + { + QMessageBox msgBox; + msgBox.setText("You can open this error by specifying applications in program's settings."); + msgBox.exec(); + return; + } + if (target && application >= 0 && application < mApplications.GetApplicationCount() && target->parent()) { QVariantMap data = target->data().toMap(); diff --git a/gui/resultstree.h b/gui/resultstree.h index 37aa8760b..0b711c7a0 100644 --- a/gui/resultstree.h +++ b/gui/resultstree.h @@ -247,9 +247,10 @@ protected: * @brief Ensures there's a item in the model for the specified file * * @param name Filename + * @param hide is the error (we want this file item for) hidden? * @return QStandardItem to be used as a parent for all errors for specified file */ - QStandardItem *EnsureFileItem(const QString &name); + QStandardItem *EnsureFileItem(const QString &name, bool hide); /** * @brief Show a file item diff --git a/gui/resultsview.cpp b/gui/resultsview.cpp index aa26994ff..2194bede4 100644 --- a/gui/resultsview.cpp +++ b/gui/resultsview.cpp @@ -30,6 +30,7 @@ ResultsView::ResultsView(QSettings &settings, ApplicationList &list) mProgress = new QProgressBar(); layout->addWidget(mProgress); mProgress->setMinimum(0); + mProgress->setVisible(false); mTree = new ResultsTree(settings, list); layout->addWidget(mTree); @@ -53,6 +54,14 @@ void ResultsView::Progress(int value, int max) { mProgress->setMaximum(max); mProgress->setValue(value); + if (value >= max) + { + mProgress->setVisible(false); + } + else + { + mProgress->setVisible(true); + } } void ResultsView::Error(const QString &file, diff --git a/gui/threadresult.cpp b/gui/threadresult.cpp index 04a01922d..5cb0d32c8 100644 --- a/gui/threadresult.cpp +++ b/gui/threadresult.cpp @@ -37,6 +37,7 @@ void ThreadResult::reportOut(const std::string &outmsg) void ThreadResult::FileChecked(const QString &file) { + QMutexLocker locker(&mutex); Q_UNUSED(file); //For later use maybe? mProgress++; emit Progress(mProgress, mMaxProgress);