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.
This commit is contained in:
Vesa Pikki 2009-06-09 09:30:28 +03:00
parent 0fe601a1c9
commit 814cd37c90
5 changed files with 35 additions and 3 deletions

View File

@ -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);

View File

@ -23,6 +23,7 @@
#include <QSignalMapper>
#include <QProcess>
#include <QDir>
#include <QMessageBox>
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();

View File

@ -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

View File

@ -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,

View File

@ -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);