double fix selected items fetch and fix multiple popup questions when clearing multiple feeds
This commit is contained in:
parent
6eea00e628
commit
5b090c7030
6 changed files with 38 additions and 30 deletions
|
@ -516,19 +516,8 @@ bool FeedsModel::markItemRead(RootItem* item, RootItem::ReadStatus read) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool FeedsModel::markItemCleared(RootItem* item, bool clean_read_only, bool ask) {
|
||||
bool FeedsModel::markItemCleared(RootItem* item, bool clean_read_only) {
|
||||
if (item != nullptr) {
|
||||
if (ask && MsgBox::show(nullptr,
|
||||
QMessageBox::Icon::Question,
|
||||
tr("Are you sure?"),
|
||||
tr("Do you really want to clean all articles from selected item?"),
|
||||
{},
|
||||
{},
|
||||
QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No,
|
||||
QMessageBox::StandardButton::No) != QMessageBox::StandardButton::Yes) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return item->cleanMessages(clean_read_only);
|
||||
}
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ class RSSGUARD_DLLSPEC FeedsModel : public QAbstractItemModel {
|
|||
|
||||
// Feeds operations.
|
||||
bool markItemRead(RootItem* item, RootItem::ReadStatus read);
|
||||
bool markItemCleared(RootItem* item, bool clean_read_only, bool ask);
|
||||
bool markItemCleared(RootItem* item, bool clean_read_only);
|
||||
|
||||
// Signals that properties (probably counts)
|
||||
// of ALL items have changed.
|
||||
|
|
|
@ -900,11 +900,11 @@ void FormMain::createConnections() {
|
|||
connect(m_ui->m_actionClearSelectedItems,
|
||||
&QAction::triggered,
|
||||
tabWidget()->feedMessageViewer()->feedsView(),
|
||||
&FeedsView::clearSelectedFeeds);
|
||||
&FeedsView::clearSelectedItems);
|
||||
connect(m_ui->m_actionClearAllItems,
|
||||
&QAction::triggered,
|
||||
tabWidget()->feedMessageViewer()->feedsView(),
|
||||
&FeedsView::clearAllFeeds);
|
||||
&FeedsView::clearAllItems);
|
||||
connect(m_ui->m_actionUpdateSelectedItems,
|
||||
&QAction::triggered,
|
||||
tabWidget()->feedMessageViewer()->feedsView(),
|
||||
|
|
|
@ -73,14 +73,13 @@ void FeedsView::setSortingEnabled(bool enable) {
|
|||
|
||||
QList<Feed*> FeedsView::selectedFeeds() const {
|
||||
auto its = selectedItems();
|
||||
auto std_feeds = boolinq::from(its)
|
||||
.select([](RootItem* it) {
|
||||
return it->toFeed();
|
||||
})
|
||||
.where([](Feed* fd) {
|
||||
return fd != nullptr;
|
||||
})
|
||||
.toStdList();
|
||||
QList<Feed*> feeds;
|
||||
|
||||
for (RootItem* it : its) {
|
||||
feeds.append(it->getSubTreeFeeds());
|
||||
}
|
||||
|
||||
auto std_feeds = boolinq::from(feeds).distinct().toStdList();
|
||||
|
||||
return FROM_STD_LIST(QList<Feed*>, std_feeds);
|
||||
}
|
||||
|
@ -233,14 +232,34 @@ void FeedsView::updateSelectedItems() {
|
|||
qApp->feedReader()->updateFeeds(selectedFeeds());
|
||||
}
|
||||
|
||||
void FeedsView::clearSelectedFeeds() {
|
||||
void FeedsView::clearSelectedItems() {
|
||||
if (MsgBox::show(nullptr,
|
||||
QMessageBox::Icon::Question,
|
||||
tr("Are you sure?"),
|
||||
tr("Do you really want to clean all articles from selected items?"),
|
||||
{},
|
||||
{},
|
||||
QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No,
|
||||
QMessageBox::StandardButton::No) != QMessageBox::StandardButton::Yes) {
|
||||
}
|
||||
|
||||
for (auto* it : selectedItems()) {
|
||||
m_sourceModel->markItemCleared(it, false, true);
|
||||
m_sourceModel->markItemCleared(it, false);
|
||||
}
|
||||
}
|
||||
|
||||
void FeedsView::clearAllFeeds() {
|
||||
m_sourceModel->markItemCleared(m_sourceModel->rootItem(), false, true);
|
||||
void FeedsView::clearAllItems() {
|
||||
if (MsgBox::show(nullptr,
|
||||
QMessageBox::Icon::Question,
|
||||
tr("Are you sure?"),
|
||||
tr("Do you really want to clean all articles from selected items?"),
|
||||
{},
|
||||
{},
|
||||
QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No,
|
||||
QMessageBox::StandardButton::No) != QMessageBox::StandardButton::Yes) {
|
||||
}
|
||||
|
||||
m_sourceModel->markItemCleared(m_sourceModel->rootItem(), false);
|
||||
}
|
||||
|
||||
void FeedsView::editItems(const QList<RootItem*>& items) {
|
||||
|
|
|
@ -62,8 +62,8 @@ class RSSGUARD_DLLSPEC FeedsView : public BaseTreeView {
|
|||
void openSelectedItemsInNewspaperMode();
|
||||
|
||||
// Feed clearers.
|
||||
void clearSelectedFeeds();
|
||||
void clearAllFeeds();
|
||||
void clearSelectedItems();
|
||||
void clearAllItems();
|
||||
|
||||
// Base manipulators.
|
||||
void editItems(const QList<RootItem*>& items);
|
||||
|
|
|
@ -398,7 +398,7 @@ void FeedReader::quit() {
|
|||
}
|
||||
|
||||
if (qApp->settings()->value(GROUP(Messages), SETTING(Messages::ClearReadOnExit)).toBool()) {
|
||||
m_feedsModel->markItemCleared(m_feedsModel->rootItem(), true, false);
|
||||
m_feedsModel->markItemCleared(m_feedsModel->rootItem(), true);
|
||||
}
|
||||
|
||||
m_feedsModel->stopServiceAccounts();
|
||||
|
|
Loading…
Add table
Reference in a new issue