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