| 1 | // For license of this file, see <project-root-folder>/LICENSE.md.cxx . . $ `<file>/src/librssguard/services/abstract/category.cpp`/ |
| 2 | |
| 3 | #include "services/abstract/category.h"cxx . . $ `<file>/src/librssguard/services/abstract/category.h`/ |
| 4 | |
| 5 | #include "database/databasequeries.h"cxx . . $ `<file>/src/librssguard/database/databasequeries.h`/ |
| 6 | #include "miscellaneous/application.h"cxx . . $ `<file>/src/librssguard/miscellaneous/application.h`/ |
| 7 | #include "services/abstract/cacheforserviceroot.h"cxx . . $ `<file>/src/librssguard/services/abstract/cacheforserviceroot.h`/ |
| 8 | #include "services/abstract/feed.h"cxx . . $ `<file>/src/librssguard/services/abstract/feed.h`/ |
| 9 | #include "services/abstract/serviceroot.h"cxx . . $ `<file>/src/librssguard/services/abstract/serviceroot.h`/ |
| 10 | |
| 11 | Categorycxx . . $ Category#::Categorycxx . . $ Category#Category(cb16baca005cfe86).(RootItemcxx . . $ RootItem#* parent) : RootItemcxx . . $ RootItem#(parent) { |
| 12 | setKindcxx . . $ RootItem#setKind(77afe77d4ce7bfe8).(RootItemcxx . . $ RootItem#::Kindcxx . . $ RootItem#Kind#::Categorycxx . . $ RootItem#Kind#Category.); |
| 13 | } |
| 14 | |
| 15 | Categorycxx . . $ Category#::Categorycxx . . $ Category#Category(aea3bb20c3173a6e).(const Categorycxx . . $ Category#& other) : RootItemcxx . . $ RootItem#(other) { |
| 16 | setKindcxx . . $ RootItem#setKind(77afe77d4ce7bfe8).(RootItemcxx . . $ RootItem#::Kindcxx . . $ RootItem#Kind#::Categorycxx . . $ RootItem#Kind#Category.); |
| 17 | } |
| 18 | |
| 19 | void Categorycxx . . $ Category#::updateCountscxx . . $ Category#updateCounts(b45ddcbc8423892c).(bool including_total_count) { |
| 20 | QListcxx . . $ QList#<Feedcxx . . $ Feed#*> feedscxx . . $ QList#QList(ced63f7c635d850d).; |
| 21 | auto str = childItemscxx . . $ RootItem#childItems(f275a58a8bc5f139).(); |
| 22 | |
| 23 | for (RootItemcxx . . $ RootItem#* child : stdcxx . . $ std/::as_constcxx . . $ std/as_const(1dc117cbefefc300).(str)) { |
| 24 | if (child->kindcxx . . $ RootItem#kind(faa800885e6a64b).() == RootItemcxx . . $ RootItem#::Kindcxx . . $ RootItem#Kind#::Feedcxx . . $ RootItem#Kind#Feed.) { |
| 25 | feeds.appendcxx . . $ QList#append(200d2dc08238a4ed).(child->toFeedcxx . . $ RootItem#toFeed(6205f4b142e8b232).()); |
| 26 | } |
| 27 | else if (child->kindcxx . . $ RootItem#kind(faa800885e6a64b).() == RootItemcxx . . $ RootItem#::Kindcxx . . $ RootItem#Kind#::Categorycxx . . $ RootItem#Kind#Category.) { |
| 28 | child->updateCountscxx . . $ RootItem#updateCounts(b45ddcbc8423892c).(including_total_count); |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | if (feeds.isEmptycxx . . $ QList#isEmpty(3482b152b9333168).()) { |
| 33 | return; |
| 34 | } |
| 35 | |
| 36 | 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).()); |
| 37 | bool ok; |
| 38 | auto counts = DatabaseQueriescxx . . $ DatabaseQueries#::getMessageCountsForCategorycxx . . $ DatabaseQueries#getMessageCountsForCategory(b20aeb44528a646c).(database, |
| 39 | customIdcxx . . $ RootItem#customId(6ef7b6c27b00b43d).(), |
| 40 | getParentServiceRootcxx . . $ RootItem#getParentServiceRoot(56209a8cf0725652).()->accountIdcxx . . $ ServiceRoot#accountId(455f465bc33b4cdf).(), |
| 41 | including_total_count, |
| 42 | &ok); |
| 43 | |
| 44 | if (ok) { |
| 45 | for (Feedcxx . . $ Feed#* feed : feeds) { |
| 46 | if (counts.containscxx . . $ QMap#contains(8877ebe272b9620d).(feed->customIdcxx . . $ RootItem#customId(6ef7b6c27b00b43d).())) { |
| 47 | feed->setCountOfUnreadMessagescxx . . $ Feed#setCountOfUnreadMessages(d4f767463ce0a6b3).(counts.valuecxx . . $ QMap#value(6f0b2e7f225a8193).(feed->customIdcxx . . $ RootItem#customId(6ef7b6c27b00b43d).()).m_unreadcxx . . $ ArticleCounts#m_unread.); |
| 48 | |
| 49 | if (including_total_count) { |
| 50 | feed->setCountOfAllMessagescxx . . $ Feed#setCountOfAllMessages(d4f767463ce0a6b3).(counts.valuecxx . . $ QMap#value(6f0b2e7f225a8193).(feed->customIdcxx . . $ RootItem#customId(6ef7b6c27b00b43d).()).m_totalcxx . . $ ArticleCounts#m_total.); |
| 51 | } |
| 52 | } |
| 53 | } |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | bool Categorycxx . . $ Category#::cleanMessagescxx . . $ Category#cleanMessages(efaadfb7dc14930a).(bool clean_read_only) { |
| 58 | return getParentServiceRootcxx . . $ RootItem#getParentServiceRoot(56209a8cf0725652).()->cleanFeedscxx . . $ ServiceRoot#cleanFeeds(773bb01e64ccf77d).(getSubTreeFeedscxx . . $ RootItem#getSubTreeFeeds(7d493c88c85a9a14).(), clean_read_only); |
| 59 | } |
| 60 | |
| 61 | bool Categorycxx . . $ Category#::markAsReadUnreadcxx . . $ Category#markAsReadUnread(c2f07a1f8834328b).(RootItemcxx . . $ RootItem#::ReadStatuscxx . . $ RootItem#ReadStatus# status) { |
| 62 | ServiceRootcxx . . $ ServiceRoot#* service = getParentServiceRootcxx . . $ RootItem#getParentServiceRoot(56209a8cf0725652).(); |
| 63 | auto* cache = dynamic_cast<CacheForServiceRootcxx . . $ CacheForServiceRoot#*>(service); |
| 64 | |
| 65 | if (cache != nullptr) { |
| 66 | cache->addMessageStatesToCachecxx . . $ CacheForServiceRoot#addMessageStatesToCache(c21502b1d481d06b).(service->customIDSOfMessagesForItemcxx . . $ ServiceRoot#customIDSOfMessagesForItem(2acd0df652f9aeb7).(this, status), status); |
| 67 | } |
| 68 | |
| 69 | return service->markFeedsReadUnreadcxx . . $ ServiceRoot#markFeedsReadUnread(cd8129ce0f5261b5).(getSubTreeFeedscxx . . $ RootItem#getSubTreeFeeds(7d493c88c85a9a14).(), status); |
| 70 | } |
| 71 | |
| 72 | QStringcxx . . $ QString# Categorycxx . . $ Category#::additionalTooltipcxx . . $ Category#additionalTooltip(6ef7b6c27b00b43d).() const { |
| 73 | return trcxx . . $ Category#tr(75d9f1c324b4579d).("Number of feeds: %1\n" |
| 74 | "Number of categories: %2\n" |
| 75 | "Number of disabled feeds: %3") |
| 76 | .argcxx . . $ QString#arg(89b093bd48b6d6c0).(QStringcxx . . $ QString#::numbercxx . . $ QString#number(391c8d1a7da534d1).(getSubTreeFeedscxx . . $ RootItem#getSubTreeFeeds(7d493c88c85a9a14).().sizecxx . . $ QList#size(6b0412d51016192f).()), |
| 77 | QStringcxx . . $ QString#::numbercxx . . $ QString#number(391c8d1a7da534d1).(getSubTreeCategoriescxx . . $ RootItem#getSubTreeCategories(d8651057aa4a83be).().sizecxx . . $ QList#size(6b0412d51016192f).() - 1), |
| 78 | QStringcxx . . $ QString#::numbercxx . . $ QString#number(391c8d1a7da534d1).(getSubTreecxx . . $ RootItem#getSubTree(38d8ae5645f2bbf1).<RootItemcxx . . $ RootItem#>([cxx . . $ std/function#function(bdc3712e480e4d04).](const RootItemcxx . . $ RootItem#* ri) { |
| 79 | return ri->kindcxx . . $ RootItem#kind(faa800885e6a64b).() == RootItemcxx . . $ RootItem#::Kindcxx . . $ RootItem#Kind#::Feedcxx . . $ RootItem#Kind#Feed. && ri->toFeedcxx . . $ RootItem#toFeed(6205f4b142e8b232).()->isSwitchedOffcxx . . $ Feed#isSwitchedOff(50ce9a9e25b4a850).(); |
| 80 | }).sizecxx . . $ QList#size(6b0412d51016192f).())); |
| 81 | } |