many of feeds-list actions are now multiple selection-aware, it is possible to mark multiple selected items read/unread, delete, manually sort etc.
This commit is contained in:
parent
5d7cb9dfcd
commit
6cd1d09578
2 changed files with 79 additions and 42 deletions
|
@ -199,7 +199,9 @@ void FeedsModel::removeItem(RootItem* deleting_item) {
|
||||||
deleting_item->getParentServiceRoot()->updateCounts(true);
|
deleting_item->getParentServiceRoot()->updateCounts(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
deleting_item->deleteLater();
|
delete deleting_item;
|
||||||
|
// deleting_item->deleteLater();
|
||||||
|
|
||||||
notifyWithCounts();
|
notifyWithCounts();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,13 +171,13 @@ void FeedsView::addFeedIntoSelectedAccount() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedsView::addCategoryIntoSelectedAccount() {
|
void FeedsView::addCategoryIntoSelectedAccount() {
|
||||||
const RootItem* selected = selectedItem();
|
RootItem* selected = selectedItem();
|
||||||
|
|
||||||
if (selected != nullptr) {
|
if (selected != nullptr) {
|
||||||
ServiceRoot* root = selected->getParentServiceRoot();
|
ServiceRoot* root = selected->getParentServiceRoot();
|
||||||
|
|
||||||
if (root->supportsCategoryAdding()) {
|
if (root->supportsCategoryAdding()) {
|
||||||
root->addNewCategory(selectedItem());
|
root->addNewCategory(selected);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
qApp->showGuiMessage(Notification::Event::GeneralEvent,
|
qApp->showGuiMessage(Notification::Event::GeneralEvent,
|
||||||
|
@ -231,7 +231,9 @@ void FeedsView::updateSelectedItems() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedsView::clearSelectedFeeds() {
|
void FeedsView::clearSelectedFeeds() {
|
||||||
m_sourceModel->markItemCleared(selectedItem(), false, true);
|
for (auto* it : selectedItems()) {
|
||||||
|
m_sourceModel->markItemCleared(it, false, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedsView::clearAllFeeds() {
|
void FeedsView::clearAllFeeds() {
|
||||||
|
@ -373,46 +375,59 @@ void FeedsView::deleteSelectedItem() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
if (!currentIndex().isValid()) {
|
if (!currentIndex().isValid()) {
|
||||||
// Changes are done, unlock the update master lock and exit.
|
qApp->feedUpdateLock()->unlock();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
QList<RootItem*> selected_items = selectedItems();
|
||||||
|
auto std_deletable_items = boolinq::from(selected_items)
|
||||||
|
.where([](RootItem* it) {
|
||||||
|
return it->canBeDeleted();
|
||||||
|
})
|
||||||
|
.toStdList();
|
||||||
|
|
||||||
|
if (std_deletable_items.empty()) {
|
||||||
qApp->feedUpdateLock()->unlock();
|
qApp->feedUpdateLock()->unlock();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RootItem* selected_item = selectedItem();
|
if (qsizetype(std_deletable_items.size()) < selected_items.size()) {
|
||||||
|
qApp->showGuiMessage(Notification::Event::GeneralEvent,
|
||||||
|
GuiMessage(tr("Some items won't be deleted"),
|
||||||
|
tr("Some selected items will not be deleted, because they cannot be deleted."),
|
||||||
|
QSystemTrayIcon::MessageIcon::Warning));
|
||||||
|
}
|
||||||
|
|
||||||
if (selected_item != nullptr) {
|
// Ask user first.
|
||||||
if (selected_item->canBeDeleted()) {
|
if (MsgBox::show(qApp->mainFormWidget(),
|
||||||
// Ask user first.
|
QMessageBox::Icon::Question,
|
||||||
if (MsgBox::show(qApp->mainFormWidget(),
|
tr("Deleting %n items", nullptr, int(std_deletable_items.size())),
|
||||||
QMessageBox::Icon::Question,
|
tr("You are about to completely delete %n items.", nullptr, int(std_deletable_items.size())),
|
||||||
tr("Deleting \"%1\"").arg(selected_item->title()),
|
tr("Are you sure?"),
|
||||||
tr("You are about to completely delete item \"%1\".").arg(selected_item->title()),
|
QString(),
|
||||||
tr("Are you sure?"),
|
QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No,
|
||||||
QString(),
|
QMessageBox::StandardButton::Yes) == QMessageBox::StandardButton::No) {
|
||||||
QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No,
|
// User refused.
|
||||||
QMessageBox::StandardButton::Yes) == QMessageBox::StandardButton::No) {
|
qApp->feedUpdateLock()->unlock();
|
||||||
// User refused.
|
return;
|
||||||
qApp->feedUpdateLock()->unlock();
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We have deleteable item selected, remove it via GUI.
|
auto std_pointed_items = boolinq::from(std_deletable_items)
|
||||||
if (!selected_item->deleteViaGui()) {
|
.select([](RootItem* it) {
|
||||||
m_proxyModel->invalidate();
|
return QPointer<RootItem>(it);
|
||||||
|
})
|
||||||
|
.toStdList();
|
||||||
|
|
||||||
qApp->showGuiMessage(Notification::Event::GeneralEvent,
|
for (const QPointer<RootItem>& pnt : std_pointed_items) {
|
||||||
{tr("Cannot delete \"%1\"").arg(selected_item->title()),
|
if (pnt.isNull()) {
|
||||||
tr("This item cannot be deleted because something critically failed. Submit bug report."),
|
continue;
|
||||||
QSystemTrayIcon::MessageIcon::Critical});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
qApp->showGuiMessage(Notification::Event::GeneralEvent,
|
if (pnt->deleteViaGui()) {
|
||||||
{tr("Cannot delete \"%1\"").arg(selected_item->title()),
|
m_proxyModel->invalidate();
|
||||||
tr("This item cannot be deleted, because it does not support it\nor this functionality is "
|
|
||||||
"not implemented yet."),
|
|
||||||
QSystemTrayIcon::MessageIcon::Critical});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -421,37 +436,57 @@ void FeedsView::deleteSelectedItem() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedsView::moveSelectedItemUp() {
|
void FeedsView::moveSelectedItemUp() {
|
||||||
m_sourceModel->changeSortOrder(selectedItem(), false, false, selectedItem()->sortOrder() - 1);
|
for (RootItem* it : selectedItems()) {
|
||||||
|
m_sourceModel->changeSortOrder(it, false, false, it->sortOrder() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
m_proxyModel->invalidate();
|
m_proxyModel->invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedsView::moveSelectedItemTop() {
|
void FeedsView::moveSelectedItemTop() {
|
||||||
m_sourceModel->changeSortOrder(selectedItem(), true, false);
|
for (RootItem* it : selectedItems()) {
|
||||||
|
m_sourceModel->changeSortOrder(it, true, false);
|
||||||
|
}
|
||||||
|
|
||||||
m_proxyModel->invalidate();
|
m_proxyModel->invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedsView::moveSelectedItemBottom() {
|
void FeedsView::moveSelectedItemBottom() {
|
||||||
m_sourceModel->changeSortOrder(selectedItem(), false, true);
|
for (RootItem* it : selectedItems()) {
|
||||||
|
m_sourceModel->changeSortOrder(it, false, true);
|
||||||
|
}
|
||||||
|
|
||||||
m_proxyModel->invalidate();
|
m_proxyModel->invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedsView::moveSelectedItemDown() {
|
void FeedsView::moveSelectedItemDown() {
|
||||||
m_sourceModel->changeSortOrder(selectedItem(), false, false, selectedItem()->sortOrder() + 1);
|
for (RootItem* it : selectedItems()) {
|
||||||
|
m_sourceModel->changeSortOrder(it, false, false, it->sortOrder() + 1);
|
||||||
|
}
|
||||||
|
|
||||||
m_proxyModel->invalidate();
|
m_proxyModel->invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedsView::rearrangeCategoriesOfSelectedItem() {
|
void FeedsView::rearrangeCategoriesOfSelectedItem() {
|
||||||
m_sourceModel->sortDirectDescendants(selectedItem(), RootItem::Kind::Category);
|
for (RootItem* it : selectedItems()) {
|
||||||
|
m_sourceModel->sortDirectDescendants(it, RootItem::Kind::Category);
|
||||||
|
}
|
||||||
|
|
||||||
m_proxyModel->invalidate();
|
m_proxyModel->invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedsView::rearrangeFeedsOfSelectedItem() {
|
void FeedsView::rearrangeFeedsOfSelectedItem() {
|
||||||
m_sourceModel->sortDirectDescendants(selectedItem(), RootItem::Kind::Feed);
|
for (RootItem* it : selectedItems()) {
|
||||||
|
m_sourceModel->sortDirectDescendants(it, RootItem::Kind::Feed);
|
||||||
|
}
|
||||||
|
|
||||||
m_proxyModel->invalidate();
|
m_proxyModel->invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedsView::markSelectedItemReadStatus(RootItem::ReadStatus read) {
|
void FeedsView::markSelectedItemReadStatus(RootItem::ReadStatus read) {
|
||||||
m_sourceModel->markItemRead(selectedItem(), read);
|
for (RootItem* it : selectedItems()) {
|
||||||
|
m_sourceModel->markItemRead(it, read);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedsView::markSelectedItemRead() {
|
void FeedsView::markSelectedItemRead() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue