From 745dd4be1bbccaa385f6a65aaa5cc7d4a03674c7 Mon Sep 17 00:00:00 2001 From: Anton Kalmykov Date: Mon, 13 Apr 2015 22:49:52 +0300 Subject: [PATCH] Fix the loader dialog acception logic --- src/manager/forms/loaderdialog.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/manager/forms/loaderdialog.cpp b/src/manager/forms/loaderdialog.cpp index 59ae44a..098afa1 100644 --- a/src/manager/forms/loaderdialog.cpp +++ b/src/manager/forms/loaderdialog.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include "core/application.h" #include "forms/filedialog.h" #include "models/loadersmodel.h" @@ -99,16 +100,28 @@ void LoaderDialog::setItem(LoaderItem* item) void LoaderDialog::accept() { + QString name = nameEdit_->text(); + QString message = QString("The loader with name '%1' is already exist.").arg(name); + if(!item_) { if(!qApp->loaders()->createLoader(nameEdit_->text(), pathEdit_->text())) { - // TODO messagebox + QMessageBox::critical(this, "Error", message); return; } } - else { + else if(name != item_->name()) { + Storage::Loader loader = qApp->storage()->loader(name.toStdString()); + if(!loader.isNull()) { + QMessageBox::critical(this, "Error", message); + return; + } + item_->setName(nameEdit_->text()); item_->setPath(pathEdit_->text()); } + else { + item_->setPath(pathEdit_->text()); + } QDialog::accept(); }