| 1 | // For license of this file, see <project-root-folder>/LICENSE.md.cxx . . $ `<file>/src/librssguard/services/abstract/recyclebin.cpp`/ |
| 2 | |
| 3 | #include "services/abstract/recyclebin.h"cxx . . $ `<file>/src/librssguard/services/abstract/recyclebin.h`/ |
| 4 | |
| 5 | #include "database/databasequeries.h"cxx . . $ `<file>/src/librssguard/database/databasequeries.h`/ |
| 6 | #include "gui/messagebox.h"cxx . . $ `<file>/src/librssguard/gui/messagebox.h`/ |
| 7 | #include "miscellaneous/application.h"cxx . . $ `<file>/src/librssguard/miscellaneous/application.h`/ |
| 8 | #include "miscellaneous/iconfactory.h"cxx . . $ `<file>/src/librssguard/miscellaneous/iconfactory.h`/ |
| 9 | #include "services/abstract/cacheforserviceroot.h"cxx . . $ `<file>/src/librssguard/services/abstract/cacheforserviceroot.h`/ |
| 10 | #include "services/abstract/serviceroot.h"cxx . . $ `<file>/src/librssguard/services/abstract/serviceroot.h`/ |
| 11 | |
| 12 | RecycleBincxx . . $ RecycleBin#::RecycleBincxx . . $ RecycleBin#RecycleBin(cb16baca005cfe86).(RootItemcxx . . $ RootItem#* parent_item) : RootItemcxx . . $ RootItem#(parent_item), m_totalCountcxx . . $ RecycleBin#m_totalCount.(0), m_unreadCountcxx . . $ RecycleBin#m_unreadCount.(0) { |
| 13 | setKindcxx . . $ RootItem#setKind(77afe77d4ce7bfe8).(RootItemcxx . . $ RootItem#::Kindcxx . . $ RootItem#Kind#::Bincxx . . $ RootItem#Kind#Bin.); |
| 14 | setIdcxx . . $ RootItem#setId(d4f767463ce0a6b3).(ID_RECYCLE_BINcxx . . $ `src/librssguard/definitions/definitions.h:43:9`!); |
| 15 | setIconcxx . . $ RootItem#setIcon(71dcdac178620ed6).(qAppcxx . . $ `src/librssguard/miscellaneous/application.h:30:9`!->iconscxx . . $ Application#icons(d976db2a0d825b70).()->fromThemecxx . . $ IconFactory#fromTheme(e457fbbee8993f3).(QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("user-trash"))); |
| 16 | setTitlecxx . . $ RootItem#setTitle(3520e46b33348bf6).(trcxx . . $ RecycleBin#tr(75d9f1c324b4579d).("Recycle bin")); |
| 17 | setDescriptioncxx . . $ RootItem#setDescription(3520e46b33348bf6).(trcxx . . $ RecycleBin#tr(75d9f1c324b4579d).("Recycle bin contains all deleted articles from all feeds.")); |
| 18 | } |
| 19 | |
| 20 | QStringcxx . . $ QString# RecycleBincxx . . $ RecycleBin#::additionalTooltipcxx . . $ RecycleBin#additionalTooltip(6ef7b6c27b00b43d).() const { |
| 21 | return trcxx . . $ RecycleBin#tr(75d9f1c324b4579d).("%n deleted article(s).", nullptr, countOfAllMessagescxx . . $ RecycleBin#countOfAllMessages(455f465bc33b4cdf).()); |
| 22 | } |
| 23 | |
| 24 | int RecycleBincxx . . $ RecycleBin#::countOfUnreadMessagescxx . . $ RecycleBin#countOfUnreadMessages(455f465bc33b4cdf).() const { |
| 25 | return m_unreadCountcxx . . $ RecycleBin#m_unreadCount.; |
| 26 | } |
| 27 | |
| 28 | int RecycleBincxx . . $ RecycleBin#::countOfAllMessagescxx . . $ RecycleBin#countOfAllMessages(455f465bc33b4cdf).() const { |
| 29 | return m_totalCountcxx . . $ RecycleBin#m_totalCount.; |
| 30 | } |
| 31 | |
| 32 | void RecycleBincxx . . $ RecycleBin#::updateCountscxx . . $ RecycleBin#updateCounts(b45ddcbc8423892c).(bool update_total_count) { |
| 33 | QSqlDatabasecxx . . $ QSqlDatabase# database = qAppcxx . . $ `src/librssguard/miscellaneous/application.h:30:9`!->databasecxx . . $ Application#database(4a253a6ca99872d8).()->drivercxx . . $ DatabaseFactory#driver(5299be7c9afd522d).()->threadSafeConnectioncxx . . $ DatabaseDriver#threadSafeConnection(32d6d64cc6e35a97).(metaObjectcxx . . $ QString#QString(85c52e162fed56f9).()->classNamecxx . . $ QMetaObject#className(a9f41ea0e82d88cf).()); |
| 34 | auto ac = DatabaseQueriescxx . . $ DatabaseQueries#::getMessageCountsForBincxx . . $ DatabaseQueries#getMessageCountsForBin(133d0ce429650026).(database, getParentServiceRootcxx . . $ RootItem#getParentServiceRoot(56209a8cf0725652).()->accountIdcxx . . $ ServiceRoot#accountId(455f465bc33b4cdf).()); |
| 35 | |
| 36 | m_unreadCountcxx . . $ RecycleBin#m_unreadCount. = ac.m_unreadcxx . . $ ArticleCounts#m_unread.; |
| 37 | |
| 38 | if (update_total_count) { |
| 39 | m_totalCountcxx . . $ RecycleBin#m_totalCount. = ac.m_totalcxx . . $ ArticleCounts#m_total.; |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | QListcxx . . $ QList#<QActioncxx . . $ QAction#*> RecycleBincxx . . $ RecycleBin#::contextMenuFeedsListcxx . . $ RecycleBin#contextMenuFeedsList(c4b3bc0793dee689).() { |
| 44 | if (m_contextMenucxx . . $ RecycleBin#m_contextMenu..isEmptycxx . . $ QList#isEmpty(3482b152b9333168).()) { |
| 45 | QActioncxx . . $ QAction#* restore_action = |
| 46 | new QActioncxx . . $ QAction#QAction(ef44fe276c987e61).(qAppcxx . . $ `src/librssguard/miscellaneous/application.h:30:9`!->iconscxx . . $ Application#icons(d976db2a0d825b70).()->fromThemecxx . . $ IconFactory#fromTheme(e457fbbee8993f3).(QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("view-refresh")), trcxx . . $ RecycleBin#tr(75d9f1c324b4579d).("Restore recycle bin"), this); |
| 47 | QActioncxx . . $ QAction#* empty_action = new QActioncxx . . $ QAction#QAction(ef44fe276c987e61).(qAppcxx . . $ `src/librssguard/miscellaneous/application.h:30:9`!->iconscxx . . $ Application#icons(d976db2a0d825b70).()->fromThemecxx . . $ IconFactory#fromTheme(e457fbbee8993f3).(QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("edit-clear")), trcxx . . $ RecycleBin#tr(75d9f1c324b4579d).("Empty recycle bin"), this); |
| 48 | |
| 49 | connectcxx . . $ QObject#connect(dad3a9587f3dce3c).(restore_action, &QActioncxx . . $ QAction#::triggeredcxx . . $ QAction#triggered(b45ddcbc8423892c)., this, &RecycleBincxx . . $ RecycleBin#::restorecxx . . $ RecycleBin#restore(c9857a73d68e59ba).); |
| 50 | connectcxx . . $ QObject#connect(dad3a9587f3dce3c).(empty_action, &QActioncxx . . $ QAction#::triggeredcxx . . $ QAction#triggered(b45ddcbc8423892c)., this, &RecycleBincxx . . $ RecycleBin#::emptycxx . . $ RecycleBin#empty(c9857a73d68e59ba).); |
| 51 | |
| 52 | m_contextMenucxx . . $ RecycleBin#m_contextMenu..appendcxx . . $ QList#append(200d2dc08238a4ed).(restore_action); |
| 53 | m_contextMenucxx . . $ RecycleBin#m_contextMenu..appendcxx . . $ QList#append(200d2dc08238a4ed).(empty_action); |
| 54 | } |
| 55 | |
| 56 | return m_contextMenucxx . . $ RecycleBin#m_contextMenu.; |
| 57 | } |
| 58 | |
| 59 | QListcxx . . $ QList#<Messagecxx . . $ Message#> RecycleBincxx . . $ RecycleBin#::undeletedMessagescxx . . $ RecycleBin#undeletedMessages(96785ab56182243a).() const { |
| 60 | const int account_id = getParentServiceRootcxx . . $ RootItem#getParentServiceRoot(56209a8cf0725652).()->accountIdcxx . . $ ServiceRoot#accountId(455f465bc33b4cdf).(); |
| 61 | QSqlDatabasecxx . . $ QSqlDatabase# database = qAppcxx . . $ `src/librssguard/miscellaneous/application.h:30:9`!->databasecxx . . $ Application#database(4a253a6ca99872d8).()->drivercxx . . $ DatabaseFactory#driver(5299be7c9afd522d).()->connectioncxx . . $ DatabaseDriver#connection(32d6d64cc6e35a97).(metaObjectcxx . . $ QString#QString(85c52e162fed56f9).()->classNamecxx . . $ QMetaObject#className(a9f41ea0e82d88cf).()); |
| 62 | |
| 63 | return DatabaseQueriescxx . . $ DatabaseQueries#::getUndeletedMessagesForBincxx . . $ DatabaseQueries#getUndeletedMessagesForBin(4df15bb3942892d6).(database, account_id); |
| 64 | } |
| 65 | |
| 66 | bool RecycleBincxx . . $ RecycleBin#::markAsReadUnreadcxx . . $ RecycleBin#markAsReadUnread(c2f07a1f8834328b).(RootItemcxx . . $ RootItem#::ReadStatuscxx . . $ RootItem#ReadStatus# status) { |
| 67 | QSqlDatabasecxx . . $ QSqlDatabase# database = qAppcxx . . $ `src/librssguard/miscellaneous/application.h:30:9`!->databasecxx . . $ Application#database(4a253a6ca99872d8).()->drivercxx . . $ DatabaseFactory#driver(5299be7c9afd522d).()->connectioncxx . . $ DatabaseDriver#connection(32d6d64cc6e35a97).(metaObjectcxx . . $ QString#QString(85c52e162fed56f9).()->classNamecxx . . $ QMetaObject#className(a9f41ea0e82d88cf).()); |
| 68 | ServiceRootcxx . . $ ServiceRoot#* service = getParentServiceRootcxx . . $ RootItem#getParentServiceRoot(56209a8cf0725652).(); |
| 69 | auto* cache = dynamic_cast<CacheForServiceRootcxx . . $ CacheForServiceRoot#*>(service); |
| 70 | |
| 71 | if (cache != nullptr) { |
| 72 | cache->addMessageStatesToCachecxx . . $ CacheForServiceRoot#addMessageStatesToCache(c21502b1d481d06b).(service->customIDSOfMessagesForItemcxx . . $ ServiceRoot#customIDSOfMessagesForItem(2acd0df652f9aeb7).(this, status), status); |
| 73 | } |
| 74 | |
| 75 | if (DatabaseQueriescxx . . $ DatabaseQueries#::markBinReadUnreadcxx . . $ DatabaseQueries#markBinReadUnread(a6849f7a0a1d92ee).(database, service->accountIdcxx . . $ ServiceRoot#accountId(455f465bc33b4cdf).(), status)) { |
| 76 | updateCountscxx . . $ RecycleBin#updateCounts(b45ddcbc8423892c).(false); |
| 77 | service->itemChangedcxx . . $ ServiceRoot#itemChanged(47657a4e8825adca).(QListcxx . . $ QList#QList(ced63f7c635d850d).<RootItemcxx . . $ RootItem#*>() <<cxx . . $ QList#`operator<<`(ddd37d5bfdbbfc74). this); |
| 78 | service->requestReloadMessageListcxx . . $ ServiceRoot#requestReloadMessageList(b45ddcbc8423892c).(status == RootItemcxx . . $ RootItem#::ReadStatuscxx . . $ RootItem#ReadStatus#::Readcxx . . $ RootItem#ReadStatus#Read.); |
| 79 | return true; |
| 80 | } |
| 81 | else { |
| 82 | return false; |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | bool RecycleBincxx . . $ RecycleBin#::cleanMessagescxx . . $ RecycleBin#cleanMessages(efaadfb7dc14930a).(bool clear_only_read) { |
| 87 | QSqlDatabasecxx . . $ QSqlDatabase# database = qAppcxx . . $ `src/librssguard/miscellaneous/application.h:30:9`!->databasecxx . . $ Application#database(4a253a6ca99872d8).()->drivercxx . . $ DatabaseFactory#driver(5299be7c9afd522d).()->connectioncxx . . $ DatabaseDriver#connection(32d6d64cc6e35a97).(metaObjectcxx . . $ QString#QString(85c52e162fed56f9).()->classNamecxx . . $ QMetaObject#className(a9f41ea0e82d88cf).()); |
| 88 | ServiceRootcxx . . $ ServiceRoot#* parent_root = getParentServiceRootcxx . . $ RootItem#getParentServiceRoot(56209a8cf0725652).(); |
| 89 | |
| 90 | if (DatabaseQueriescxx . . $ DatabaseQueries#::purgeMessagesFromBincxx . . $ DatabaseQueries#purgeMessagesFromBin(c36b96d9cb3706e6).(database, clear_only_read, parent_root->accountIdcxx . . $ ServiceRoot#accountId(455f465bc33b4cdf).())) { |
| 91 | updateCountscxx . . $ RecycleBin#updateCounts(b45ddcbc8423892c).(true); |
| 92 | parent_root->itemChangedcxx . . $ ServiceRoot#itemChanged(47657a4e8825adca).(QListcxx . . $ QList#QList(ced63f7c635d850d).<RootItemcxx . . $ RootItem#*>() <<cxx . . $ QList#`operator<<`(ddd37d5bfdbbfc74). this); |
| 93 | parent_root->requestReloadMessageListcxx . . $ ServiceRoot#requestReloadMessageList(b45ddcbc8423892c).(true); |
| 94 | return true; |
| 95 | } |
| 96 | else { |
| 97 | return false; |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | bool RecycleBincxx . . $ RecycleBin#::emptycxx . . $ RecycleBin#empty(c9857a73d68e59ba).() { |
| 102 | if (MsgBoxcxx . . $ MsgBox#::showcxx . . $ MsgBox#show(699e792c6fa2d501).(nullptr, |
| 103 | QMessageBoxcxx . . $ QMessageBox#::Iconcxx . . $ QMessageBox#Icon#::Questioncxx . . $ QMessageBox#Question., |
| 104 | trcxx . . $ RecycleBin#tr(75d9f1c324b4579d).("Are you sure?"), |
| 105 | trcxx . . $ RecycleBin#tr(75d9f1c324b4579d).("Do you really want to empty your recycle bin?"), |
| 106 | {cxx . . $ QString#QString(ced63f7c635d850d).}, |
| 107 | {cxx . . $ QString#QString(ced63f7c635d850d).}, |
| 108 | QMessageBoxcxx . . $ QMessageBox#::StandardButtoncxx . . $ QMessageBox#StandardButton#::Yescxx . . $ QMessageBox#Yes. |cxx . . $ `operator|`(67530149e923fc12). QMessageBoxcxx . . $ QMessageBox#::StandardButtoncxx . . $ QMessageBox#StandardButton#::Nocxx . . $ QMessageBox#No., |
| 109 | QMessageBoxcxx . . $ QMessageBox#::StandardButtoncxx . . $ QMessageBox#StandardButton#::Nocxx . . $ QMessageBox#No.) != QMessageBoxcxx . . $ QMessageBox#::StandardButtoncxx . . $ QMessageBox#StandardButton#::Yescxx . . $ QMessageBox#Yes.) { |
| 110 | return false; |
| 111 | } |
| 112 | |
| 113 | return cleanMessagescxx . . $ RecycleBin#cleanMessages(efaadfb7dc14930a).(false); |
| 114 | } |
| 115 | |
| 116 | bool RecycleBincxx . . $ RecycleBin#::restorecxx . . $ RecycleBin#restore(c9857a73d68e59ba).() { |
| 117 | QSqlDatabasecxx . . $ QSqlDatabase# database = qAppcxx . . $ `src/librssguard/miscellaneous/application.h:30:9`!->databasecxx . . $ Application#database(4a253a6ca99872d8).()->drivercxx . . $ DatabaseFactory#driver(5299be7c9afd522d).()->connectioncxx . . $ DatabaseDriver#connection(32d6d64cc6e35a97).(metaObjectcxx . . $ QString#QString(85c52e162fed56f9).()->classNamecxx . . $ QMetaObject#className(a9f41ea0e82d88cf).()); |
| 118 | ServiceRootcxx . . $ ServiceRoot#* parent_root = getParentServiceRootcxx . . $ RootItem#getParentServiceRoot(56209a8cf0725652).(); |
| 119 | |
| 120 | if (DatabaseQueriescxx . . $ DatabaseQueries#::restoreBincxx . . $ DatabaseQueries#restoreBin(d8032dc71cca56cc).(database, parent_root->accountIdcxx . . $ ServiceRoot#accountId(455f465bc33b4cdf).())) { |
| 121 | parent_root->updateCountscxx . . $ ServiceRoot#updateCounts(b45ddcbc8423892c).(true); |
| 122 | parent_root->itemChangedcxx . . $ ServiceRoot#itemChanged(47657a4e8825adca).(parent_root->getSubTreecxx . . $ RootItem#getSubTree(38d8ae5645f2bbf1).<RootItemcxx . . $ RootItem#>()); |
| 123 | parent_root->requestReloadMessageListcxx . . $ ServiceRoot#requestReloadMessageList(b45ddcbc8423892c).(true); |
| 124 | return true; |
| 125 | } |
| 126 | else { |
| 127 | return false; |
| 128 | } |
| 129 | } |