Disable item deleting if update is ongoing.

This commit is contained in:
Martin Rotter 2014-01-28 19:29:17 +01:00
parent 83771c9146
commit 85b9ef8d7b

View File

@ -11,6 +11,7 @@
#include "gui/formmain.h" #include "gui/formmain.h"
#include "gui/formstandardcategorydetails.h" #include "gui/formstandardcategorydetails.h"
#include "gui/systemtrayicon.h" #include "gui/systemtrayicon.h"
#include "gui/messagebox.h"
#include <QMenu> #include <QMenu>
#include <QHeaderView> #include <QHeaderView>
@ -73,6 +74,26 @@ void FeedsView::clearSelectedFeeds() {
} }
void FeedsView::addNewStandardCategory() { void FeedsView::addNewStandardCategory() {
if (!SystemFactory::instance()->applicationCloseLock()->tryLockForWrite()) {
// Lock was not obtained because
// it is used probably by feed updater or application
// is quitting.
if (SystemTrayIcon::isSystemTrayActivated()) {
SystemTrayIcon::instance()->showMessage(tr("Cannot add category"),
tr("You cannot add new category now because feed update is ongoing."),
QSystemTrayIcon::Warning);
}
else {
MessageBox::show(this,
QMessageBox::Warning,
tr("Cannot add category"),
tr("You cannot add new category now because feed update is ongoing."));
}
// Thus, cannot delete and quit the method.
return;
}
QPointer<FormStandardCategoryDetails> form_pointer = new FormStandardCategoryDetails(m_sourceModel, this); QPointer<FormStandardCategoryDetails> form_pointer = new FormStandardCategoryDetails(m_sourceModel, this);
if (form_pointer.data()->exec(NULL) == QDialog::Accepted) { if (form_pointer.data()->exec(NULL) == QDialog::Accepted) {
@ -100,9 +121,25 @@ void FeedsView::editStandardCategory(FeedsModelStandardCategory *category) {
} }
void FeedsView::editSelectedItem() { void FeedsView::editSelectedItem() {
// TODO: preda pridavanim/upravou/mazanim kanalu/kategorii if (!SystemFactory::instance()->applicationCloseLock()->tryLockForWrite()) {
// ziskat ZAPISOVACI zamek pres systemfactory::applicationCloseLock // Lock was not obtained because
// a po dokonceni cinnosti jej odevzdavat // it is used probably by feed updater or application
// is quitting.
if (SystemTrayIcon::isSystemTrayActivated()) {
SystemTrayIcon::instance()->showMessage(tr("Cannot edit item"),
tr("Selected item cannot be edited because feed update is ongoing."),
QSystemTrayIcon::Warning);
}
else {
MessageBox::show(this,
QMessageBox::Warning,
tr("Cannot edit item"),
tr("Selected item cannot be edited because feed update is ongoing."));
}
// Thus, cannot delete and quit the method.
return;
}
FeedsModelCategory *category; FeedsModelCategory *category;
FeedsModelFeed *feed; FeedsModelFeed *feed;
@ -137,7 +174,10 @@ void FeedsView::deleteSelectedItem() {
QSystemTrayIcon::Warning); QSystemTrayIcon::Warning);
} }
else { else {
MessageBox::show(this,
QMessageBox::Warning,
tr("Cannot delete item"),
tr("Selected item cannot be deleted because feed update is ongoing."));
} }
// Thus, cannot delete and quit the method. // Thus, cannot delete and quit the method.