Disable item deleting if update is ongoing.
This commit is contained in:
parent
a1b52747a8
commit
83771c9146
@ -133,7 +133,7 @@ int FeedsModel::rowCount(const QModelIndex &parent) const {
|
||||
return parent_item->childCount();
|
||||
}
|
||||
|
||||
bool FeedsModel::removeItem(const QModelIndex &index) {
|
||||
bool FeedsModel::removeItem(const QModelIndex &index) {
|
||||
if (index.isValid()) {
|
||||
QModelIndex parent_index = index.parent();
|
||||
FeedsModelRootItem *deleting_item = itemForIndex(index);
|
||||
|
@ -94,7 +94,7 @@ QString SystemFactory::getAutostartDesktopFileLocation() {
|
||||
}
|
||||
#endif
|
||||
|
||||
SystemFactory *SystemFactory::getInstance() {
|
||||
SystemFactory *SystemFactory::instance() {
|
||||
if (s_instance.isNull()) {
|
||||
s_instance = new SystemFactory(qApp);
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ class SystemFactory : public QObject {
|
||||
}
|
||||
|
||||
// Singleton getter.
|
||||
static SystemFactory *getInstance();
|
||||
static SystemFactory *instance();
|
||||
|
||||
private:
|
||||
// This read-write lock is used by application on its close.
|
||||
|
@ -103,7 +103,7 @@ void FeedMessageViewer::quitDownloader() {
|
||||
}
|
||||
|
||||
void FeedMessageViewer::updateSelectedFeeds() {
|
||||
if (SystemFactory::getInstance()->applicationCloseLock()->tryLockForRead()) {
|
||||
if (SystemFactory::instance()->applicationCloseLock()->tryLockForRead()) {
|
||||
emit feedsUpdateRequested(m_feedsView->selectedFeeds());
|
||||
}
|
||||
else {
|
||||
@ -112,7 +112,7 @@ void FeedMessageViewer::updateSelectedFeeds() {
|
||||
}
|
||||
|
||||
void FeedMessageViewer::updateAllFeeds() {
|
||||
if (SystemFactory::getInstance()->applicationCloseLock()->tryLockForRead()) {
|
||||
if (SystemFactory::instance()->applicationCloseLock()->tryLockForRead()) {
|
||||
emit feedsUpdateRequested(m_feedsView->allFeeds());
|
||||
}
|
||||
else {
|
||||
@ -146,7 +146,7 @@ void FeedMessageViewer::onFeedUpdatesProgress(FeedsModelFeed *feed,
|
||||
|
||||
void FeedMessageViewer::onFeedUpdatesFinished() {
|
||||
// Updates of some feeds finished, unlock the lock.
|
||||
SystemFactory::getInstance()->applicationCloseLock()->unlock();
|
||||
SystemFactory::instance()->applicationCloseLock()->unlock();
|
||||
FormMain::instance()->statusBar()->clearProgress();
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "gui/feedsview.h"
|
||||
|
||||
#include "core/defs.h"
|
||||
#include "core/systemfactory.h"
|
||||
#include "core/feedsmodelfeed.h"
|
||||
#include "core/feedsmodel.h"
|
||||
#include "core/feedsproxymodel.h"
|
||||
@ -9,12 +10,14 @@
|
||||
#include "core/feedsmodelstandardcategory.h"
|
||||
#include "gui/formmain.h"
|
||||
#include "gui/formstandardcategorydetails.h"
|
||||
#include "gui/systemtrayicon.h"
|
||||
|
||||
#include <QMenu>
|
||||
#include <QHeaderView>
|
||||
#include <QContextMenuEvent>
|
||||
#include <QPointer>
|
||||
#include <QPainter>
|
||||
#include <QReadWriteLock>
|
||||
|
||||
|
||||
FeedsView::FeedsView(QWidget *parent)
|
||||
@ -124,6 +127,23 @@ void FeedsView::editSelectedItem() {
|
||||
}
|
||||
|
||||
void FeedsView::deleteSelectedItem() {
|
||||
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 delete item"),
|
||||
tr("Selected item cannot be deleted because feed update is ongoing."),
|
||||
QSystemTrayIcon::Warning);
|
||||
}
|
||||
else {
|
||||
|
||||
}
|
||||
|
||||
// Thus, cannot delete and quit the method.
|
||||
return;
|
||||
}
|
||||
|
||||
QModelIndex current_index = currentIndex();
|
||||
QItemSelectionModel *selection_model = selectionModel();
|
||||
|
||||
|
@ -178,7 +178,7 @@ void FormMain::onSaveState(QSessionManager &manager) {
|
||||
void FormMain::onAboutToQuit() {
|
||||
// Make sure that we obtain close lock
|
||||
// BEFORE even trying to quit the application.
|
||||
if (SystemFactory::getInstance()->applicationCloseLock()->tryLockForWrite(CLOSE_LOCK_TIMEOUT)) {
|
||||
if (SystemFactory::instance()->applicationCloseLock()->tryLockForWrite(CLOSE_LOCK_TIMEOUT)) {
|
||||
// Application obtained permission to close
|
||||
// in a safety way.
|
||||
qDebug("Close lock obtained safely.");
|
||||
|
@ -415,7 +415,7 @@ void FormSettings::saveShortcuts() {
|
||||
|
||||
void FormSettings::loadGeneral() {
|
||||
// Load auto-start status.
|
||||
SystemFactory::AutoStartStatus autostart_status = SystemFactory::getInstance()->getAutoStartStatus();
|
||||
SystemFactory::AutoStartStatus autostart_status = SystemFactory::instance()->getAutoStartStatus();
|
||||
switch (autostart_status) {
|
||||
case SystemFactory::Enabled:
|
||||
m_ui->m_checkAutostart->setChecked(true);
|
||||
@ -438,10 +438,10 @@ void FormSettings::saveGeneral() {
|
||||
// If auto-start feature is available and user wants
|
||||
// to turn it on, then turn it on.
|
||||
if (m_ui->m_checkAutostart->isChecked()) {
|
||||
SystemFactory::getInstance()->setAutoStartStatus(SystemFactory::Enabled);
|
||||
SystemFactory::instance()->setAutoStartStatus(SystemFactory::Enabled);
|
||||
}
|
||||
else {
|
||||
SystemFactory::getInstance()->setAutoStartStatus(SystemFactory::Disabled);
|
||||
SystemFactory::instance()->setAutoStartStatus(SystemFactory::Disabled);
|
||||
}
|
||||
|
||||
// Setup in-memory database status.
|
||||
|
Loading…
x
Reference in New Issue
Block a user