| 1 | // For license of this file, see <project-root-folder>/LICENSE.md.cxx . . $ `<file>/src/librssguard/services/abstract/accountcheckmodel.cpp`/ |
| 2 | |
| 3 | #include "services/abstract/accountcheckmodel.h"cxx . . $ `<file>/src/librssguard/services/abstract/accountcheckmodel.h`/ |
| 4 | |
| 5 | #include "3rd-party/boolinq/boolinq.h"cxx . . $ `<file>/src/librssguard/3rd-party/boolinq/boolinq.h`/ |
| 6 | #include "definitions/definitions.h"cxx . . $ `<file>/src/librssguard/definitions/definitions.h`/ |
| 7 | #include "services/abstract/feed.h"cxx . . $ `<file>/src/librssguard/services/abstract/feed.h`/ |
| 8 | |
| 9 | AccountCheckModelcxx . . $ AccountCheckModel#::AccountCheckModelcxx . . $ AccountCheckModel#AccountCheckModel(749de1b6ae65bddd).(QObjectcxx . . $ QObject#* parent) |
| 10 | : QAbstractItemModelcxx . . $ QAbstractItemModel#QAbstractItemModel(749de1b6ae65bddd).(parent), m_rootItemcxx . . $ AccountCheckModel#m_rootItem.(nullptr), m_recursiveChangecxx . . $ AccountCheckModel#m_recursiveChange.(false) {} |
| 11 | |
| 12 | RootItemcxx . . $ RootItem#* AccountCheckModelcxx . . $ AccountCheckModel#::itemForIndexcxx . . $ AccountCheckModel#itemForIndex(8787ab140507818d).(const QModelIndexcxx . . $ QModelIndex#& index) const { |
| 13 | if (index.isValidcxx . . $ QModelIndex#isValid(3482b152b9333168).() && index.modelcxx . . $ QModelIndex#model(9e8e94cc3b959740).() == this) { |
| 14 | return static_cast<RootItemcxx . . $ RootItem#*>(index.internalPointercxx . . $ QModelIndex#internalPointer(9c85a4740a0511c5).()); |
| 15 | } |
| 16 | else { |
| 17 | return m_rootItemcxx . . $ AccountCheckModel#m_rootItem.; |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | RootItemcxx . . $ RootItem#* AccountCheckModelcxx . . $ AccountCheckModel#::rootItemcxx . . $ AccountCheckModel#rootItem(e4f4b13bf6686a09).() const { |
| 22 | return m_rootItemcxx . . $ AccountCheckModel#m_rootItem.; |
| 23 | } |
| 24 | |
| 25 | void AccountCheckModelcxx . . $ AccountCheckModel#::setRootItemcxx . . $ AccountCheckModel#setRootItem(1ce4f84de393a7b0).(RootItemcxx . . $ RootItem#* root_item, bool delete_previous_root, bool with_layout_change) { |
| 26 | if (with_layout_change) { |
| 27 | emitcxx . . $ `<external>/4830994369567095248/qtmetamacros.h:51:10`! layoutAboutToBeChangedcxx . . $ QAbstractItemModel#layoutAboutToBeChanged(17ff3201f1a6fa68).(); |
| 28 | } |
| 29 | |
| 30 | beginResetModelcxx . . $ QAbstractItemModel#beginResetModel(49f6e7a06ebc5aa8).(); |
| 31 | |
| 32 | if (delete_previous_root && m_rootItemcxx . . $ AccountCheckModel#m_rootItem. != nullptr) { |
| 33 | m_rootItemcxx . . $ AccountCheckModel#m_rootItem.->deleteLatercxx . . $ QObject#deleteLater(49f6e7a06ebc5aa8).(); |
| 34 | } |
| 35 | |
| 36 | m_checkStatescxx . . $ AccountCheckModel#m_checkStates..clearcxx . . $ QHash#clear(7d74265ff1b37f0c).(); |
| 37 | m_rootItemcxx . . $ AccountCheckModel#m_rootItem. = root_item; |
| 38 | |
| 39 | endResetModelcxx . . $ QAbstractItemModel#endResetModel(49f6e7a06ebc5aa8).(); |
| 40 | |
| 41 | if (with_layout_change) { |
| 42 | emitcxx . . $ `<external>/4830994369567095248/qtmetamacros.h:51:10`! layoutChangedcxx . . $ QAbstractItemModel#layoutChanged(17ff3201f1a6fa68).(); |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | void AccountCheckModelcxx . . $ AccountCheckModel#::checkAllItemscxx . . $ AccountCheckModel#checkAllItems(49f6e7a06ebc5aa8).() { |
| 47 | if (m_rootItemcxx . . $ AccountCheckModel#m_rootItem. != nullptr) { |
| 48 | auto chi = m_rootItemcxx . . $ AccountCheckModel#m_rootItem.->childItemscxx . . $ RootItem#childItems(f275a58a8bc5f139).(); |
| 49 | |
| 50 | for (RootItemcxx . . $ RootItem#* root_child : stdcxx . . $ std/::as_constcxx . . $ std/as_const(1dc117cbefefc300).(chi)) { |
| 51 | if (root_child->kindcxx . . $ RootItem#kind(faa800885e6a64b).() == RootItemcxx . . $ RootItem#::Kindcxx . . $ RootItem#Kind#::Feedcxx . . $ RootItem#Kind#Feed. || root_child->kindcxx . . $ RootItem#kind(faa800885e6a64b).() == RootItemcxx . . $ RootItem#::Kindcxx . . $ RootItem#Kind#::Categorycxx . . $ RootItem#Kind#Category.) { |
| 52 | setItemCheckedcxx . . $ AccountCheckModel#setItemChecked(92a4bcd4aac93bc1).(root_child, Qtcxx . . $ Qt/::CheckStatecxx . . $ Qt/CheckState#::Checkedcxx . . $ Qt/Checked.); |
| 53 | } |
| 54 | } |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | void AccountCheckModelcxx . . $ AccountCheckModel#::uncheckAllItemscxx . . $ AccountCheckModel#uncheckAllItems(49f6e7a06ebc5aa8).() { |
| 59 | if (m_rootItemcxx . . $ AccountCheckModel#m_rootItem. != nullptr) { |
| 60 | auto chi = m_rootItemcxx . . $ AccountCheckModel#m_rootItem.->childItemscxx . . $ RootItem#childItems(f275a58a8bc5f139).(); |
| 61 | |
| 62 | for (RootItemcxx . . $ RootItem#* root_child : stdcxx . . $ std/::as_constcxx . . $ std/as_const(1dc117cbefefc300).(chi)) { |
| 63 | if (root_child->kindcxx . . $ RootItem#kind(faa800885e6a64b).() == RootItemcxx . . $ RootItem#::Kindcxx . . $ RootItem#Kind#::Feedcxx . . $ RootItem#Kind#Feed. || root_child->kindcxx . . $ RootItem#kind(faa800885e6a64b).() == RootItemcxx . . $ RootItem#::Kindcxx . . $ RootItem#Kind#::Categorycxx . . $ RootItem#Kind#Category.) { |
| 64 | setDatacxx . . $ AccountCheckModel#setData(6d1d8401440d0a2c).(indexForItemcxx . . $ AccountCheckModel#indexForItem(12881790cc0639ef).(root_child), Qtcxx . . $ QVariant#QVariant(f349c77f591a7878).::CheckStatecxx . . $ Qt/CheckState#::Uncheckedcxx . . $ Qt/Unchecked., Qtcxx . . $ Qt/::ItemDataRolecxx . . $ Qt/ItemDataRole#::CheckStateRolecxx . . $ Qt/CheckStateRole.); |
| 65 | } |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | QModelIndexcxx . . $ QModelIndex# AccountCheckModelcxx . . $ AccountCheckModel#::indexcxx . . $ AccountCheckModel#index(37dbccf64c4e392).(int row, int column, const QModelIndexcxx . . $ QModelIndex#& parent) const { |
| 71 | if (!hasIndexcxx . . $ QAbstractItemModel#hasIndex(e1845fe050e3319c).(row, column, parent)) { |
| 72 | return {cxx . . $ QModelIndex#QModelIndex(ced63f7c635d850d).}; |
| 73 | } |
| 74 | |
| 75 | RootItemcxx . . $ RootItem#* parent_item = itemForIndexcxx . . $ AccountCheckModel#itemForIndex(8787ab140507818d).(parent); |
| 76 | RootItemcxx . . $ RootItem#* child_item = parent_item->childcxx . . $ RootItem#child(6eb183cf16468031).(row); |
| 77 | |
| 78 | if (child_item != nullptr) { |
| 79 | return createIndexcxx . . $ QAbstractItemModel#createIndex(522a1722cba8a7e8).(row, column, child_item); |
| 80 | } |
| 81 | else { |
| 82 | return {cxx . . $ QModelIndex#QModelIndex(ced63f7c635d850d).}; |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | QModelIndexcxx . . $ QModelIndex# AccountCheckModelcxx . . $ AccountCheckModel#::indexForItemcxx . . $ AccountCheckModel#indexForItem(12881790cc0639ef).(RootItemcxx . . $ RootItem#* item) const { |
| 87 | if (item == nullptr || item->kindcxx . . $ RootItem#kind(faa800885e6a64b).() == RootItemcxx . . $ RootItem#::Kindcxx . . $ RootItem#Kind#::ServiceRootcxx . . $ RootItem#Kind#ServiceRoot. || item->kindcxx . . $ RootItem#kind(faa800885e6a64b).() == RootItemcxx . . $ RootItem#::Kindcxx . . $ RootItem#Kind#::Rootcxx . . $ RootItem#Kind#Root.) { |
| 88 | // Root item lies on invalid index. |
| 89 | return QModelIndexcxx . . $ QModelIndex#QModelIndex(ced63f7c635d850d).(); |
| 90 | } |
| 91 | |
| 92 | QListcxx . . $ QList#<QModelIndexcxx . . $ QModelIndex#> parentscxx . . $ QList#QList(ced63f7c635d850d).; |
| 93 | |
| 94 | // Start with root item (which obviously has invalid index). |
| 95 | parents <<cxx . . $ QList#`operator<<`(457f2c2a0db63381). indexForItemcxx . . $ AccountCheckModel#indexForItem(12881790cc0639ef).(m_rootItemcxx . . $ AccountCheckModel#m_rootItem.); |
| 96 | |
| 97 | while (!parents.isEmptycxx . . $ QList#isEmpty(3482b152b9333168).()) { |
| 98 | QModelIndexcxx . . $ QModelIndex# active_index = parents.takeFirstcxx . . $ QList#takeFirst(5f357b03ed472e5e).(); |
| 99 | int row_count = rowCountcxx . . $ AccountCheckModel#rowCount(e3878d4d6cd9529c).(active_index); |
| 100 | |
| 101 | if (row_count > 0) { |
| 102 | // This index has children. |
| 103 | // Lets take a look if our target item is among them. |
| 104 | RootItemcxx . . $ RootItem#* active_item = itemForIndexcxx . . $ AccountCheckModel#itemForIndex(8787ab140507818d).(active_index); |
| 105 | int candidate_index = active_item->childItemscxx . . $ RootItem#childItems(f275a58a8bc5f139).().indexOfcxx . . $ QListSpecialMethodsBase#indexOf(284c58bbf0d07092).(item); |
| 106 | |
| 107 | if (candidate_index >= 0) { |
| 108 | // We found our item. |
| 109 | return indexcxx . . $ AccountCheckModel#index(37dbccf64c4e392).(candidate_index, 0, active_index); |
| 110 | } |
| 111 | else { |
| 112 | // Item is not found, add all "categories" from active_item. |
| 113 | for (int i = 0; i < row_count; i++) { |
| 114 | RootItemcxx . . $ RootItem#* possible_category = active_item->childcxx . . $ RootItem#child(6eb183cf16468031).(i); |
| 115 | |
| 116 | if (possible_category->kindcxx . . $ RootItem#kind(faa800885e6a64b).() == RootItemcxx . . $ RootItem#::Kindcxx . . $ RootItem#Kind#::Categorycxx . . $ RootItem#Kind#Category.) { |
| 117 | parents <<cxx . . $ QList#`operator<<`(457f2c2a0db63381). indexcxx . . $ AccountCheckModel#index(37dbccf64c4e392).(i, 0, active_index); |
| 118 | } |
| 119 | } |
| 120 | } |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | return QModelIndexcxx . . $ QModelIndex#QModelIndex(ced63f7c635d850d).(); |
| 125 | } |
| 126 | |
| 127 | QModelIndexcxx . . $ QModelIndex# AccountCheckModelcxx . . $ AccountCheckModel#::parentcxx . . $ AccountCheckModel#parent(f800c6f2fa4cbe57).(const QModelIndexcxx . . $ QModelIndex#& child) const { |
| 128 | if (!child.isValidcxx . . $ QModelIndex#isValid(3482b152b9333168).()) { |
| 129 | return {cxx . . $ QModelIndex#QModelIndex(ced63f7c635d850d).}; |
| 130 | } |
| 131 | |
| 132 | RootItemcxx . . $ RootItem#* child_item = itemForIndexcxx . . $ AccountCheckModel#itemForIndex(8787ab140507818d).(child); |
| 133 | RootItemcxx . . $ RootItem#* parent_item = child_item->parentcxx . . $ RootItem#parent(e4f4b13bf6686a09).(); |
| 134 | |
| 135 | if (parent_item == m_rootItemcxx . . $ AccountCheckModel#m_rootItem. || parent_item == nullptr) { |
| 136 | return {cxx . . $ QModelIndex#QModelIndex(ced63f7c635d850d).}; |
| 137 | } |
| 138 | else { |
| 139 | return createIndexcxx . . $ QAbstractItemModel#createIndex(522a1722cba8a7e8).(parent_item->rowcxx . . $ RootItem#row(455f465bc33b4cdf).(), 0, parent_item); |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | int AccountCheckModelcxx . . $ AccountCheckModel#::rowCountcxx . . $ AccountCheckModel#rowCount(e3878d4d6cd9529c).(const QModelIndexcxx . . $ QModelIndex#& parent) const { |
| 144 | if (parent.columncxx . . $ QModelIndex#column(ea6fe5115c70a13f).() > 0) { |
| 145 | return 0; |
| 146 | } |
| 147 | else { |
| 148 | RootItemcxx . . $ RootItem#* item = itemForIndexcxx . . $ AccountCheckModel#itemForIndex(8787ab140507818d).(parent); |
| 149 | |
| 150 | if (item != nullptr) { |
| 151 | return item->childCountcxx . . $ RootItem#childCount(455f465bc33b4cdf).(); |
| 152 | } |
| 153 | else { |
| 154 | return 0; |
| 155 | } |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | int AccountCheckModelcxx . . $ AccountCheckModel#::columnCountcxx . . $ AccountCheckModel#columnCount(e3878d4d6cd9529c).(const QModelIndexcxx . . $ QModelIndex#& parent) const { |
| 160 | Q_UNUSEDcxx . . $ `<external>/17563275351362271547/qtpreprocessorsupport.h:20:9`!(parent) |
| 161 | return 1; |
| 162 | } |
| 163 | |
| 164 | QVariantcxx . . $ QVariant# AccountCheckModelcxx . . $ AccountCheckModel#::datacxx . . $ AccountCheckModel#data(69b5b18a001c0029).(const QModelIndexcxx . . $ QModelIndex#& index, int role) const { |
| 165 | if (index.columncxx . . $ QModelIndex#column(ea6fe5115c70a13f).() != 0) { |
| 166 | return QVariantcxx . . $ QVariant#QVariant(ced63f7c635d850d).(); |
| 167 | } |
| 168 | |
| 169 | RootItemcxx . . $ RootItem#* item = itemForIndexcxx . . $ AccountCheckModel#itemForIndex(8787ab140507818d).(index); |
| 170 | |
| 171 | if (role == Qtcxx . . $ Qt/::ItemDataRolecxx . . $ Qt/ItemDataRole#::CheckStateRolecxx . . $ Qt/CheckStateRole.) { |
| 172 | if (m_checkStatescxx . . $ AccountCheckModel#m_checkStates..containscxx . . $ QHash#contains(5247d2cea5ab73ba).(item)) { |
| 173 | return m_checkStatescxx . . $ QVariant#QVariant(f349c77f591a7878)..valuecxx . . $ QHash#value(5f65a9ee2c9899ff).(item); |
| 174 | } |
| 175 | else { |
| 176 | return static_castcxx . . $ QVariant#QVariant(f349c77f591a7878).<int>(Qtcxx . . $ Qt/::CheckStatecxx . . $ Qt/CheckState#::Uncheckedcxx . . $ Qt/Unchecked.); |
| 177 | } |
| 178 | } |
| 179 | else if (role == Qtcxx . . $ Qt/::ItemDataRolecxx . . $ Qt/ItemDataRole#::DecorationRolecxx . . $ Qt/DecorationRole.) { |
| 180 | return item->datacxx . . $ RootItem#data(db8258505c7ad0b0).(0, Qtcxx . . $ Qt/::ItemDataRolecxx . . $ Qt/ItemDataRole#::DecorationRolecxx . . $ Qt/DecorationRole.); |
| 181 | } |
| 182 | else if (role == Qtcxx . . $ Qt/::ItemDataRolecxx . . $ Qt/ItemDataRole#::EditRolecxx . . $ Qt/EditRole.) { |
| 183 | return QVariantcxx . . $ QVariant#::fromValuecxx . . $ QVariant#fromValue(8eccd985207c29dd).(item); |
| 184 | } |
| 185 | else if (role == Qtcxx . . $ Qt/::ItemDataRolecxx . . $ Qt/ItemDataRole#::DisplayRolecxx . . $ Qt/DisplayRole.) { |
| 186 | switch (item->kindcxx . . $ RootItem#kind(faa800885e6a64b).()) { |
| 187 | case RootItemcxx . . $ RootItem#::Kindcxx . . $ RootItem#Kind#::Categorycxx . . $ RootItem#Kind#Category.: |
| 188 | return QVariantcxx . . $ QVariant#QVariant(132dd6869045752b).(item->datacxx . . $ RootItem#data(db8258505c7ad0b0).(index.columncxx . . $ QModelIndex#column(ea6fe5115c70a13f).(), role).toStringcxx . . $ QVariant#toString(6ef7b6c27b00b43d).() +cxx . . $ operator+(adfbdceb504720ce). QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!(" ") +cxx . . $ operator+(adfbdceb504720ce). trcxx . . $ AccountCheckModel#tr(75d9f1c324b4579d).("(category)")); |
| 189 | |
| 190 | case RootItemcxx . . $ RootItem#::Kindcxx . . $ RootItem#Kind#::Feedcxx . . $ RootItem#Kind#Feed.: |
| 191 | return QVariantcxx . . $ QVariant#QVariant(132dd6869045752b).(item->datacxx . . $ RootItem#data(db8258505c7ad0b0).(index.columncxx . . $ QModelIndex#column(ea6fe5115c70a13f).(), role).toStringcxx . . $ QVariant#toString(6ef7b6c27b00b43d).() +cxx . . $ operator+(adfbdceb504720ce). QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!(" ") +cxx . . $ operator+(adfbdceb504720ce). trcxx . . $ AccountCheckModel#tr(75d9f1c324b4579d).("(feed)")); |
| 192 | |
| 193 | default: |
| 194 | return itemcxx . . $ QVariant#QVariant(132dd6869045752b).->titlecxx . . $ RootItem#title(6ef7b6c27b00b43d).(); |
| 195 | } |
| 196 | } |
| 197 | else if (role == Qtcxx . . $ Qt/::ItemDataRolecxx . . $ Qt/ItemDataRole#::ToolTipRolecxx . . $ Qt/ToolTipRole.) { |
| 198 | if (item->kindcxx . . $ RootItem#kind(faa800885e6a64b).() == RootItemcxx . . $ RootItem#::Kindcxx . . $ RootItem#Kind#::Feedcxx . . $ RootItem#Kind#Feed.) { |
| 199 | auto desc = item->descriptioncxx . . $ RootItem#description(6ef7b6c27b00b43d).(); |
| 200 | auto url = item->toFeedcxx . . $ RootItem#toFeed(6205f4b142e8b232).()->sourcecxx . . $ Feed#source(6ef7b6c27b00b43d).(); |
| 201 | |
| 202 | QStringcxx . . $ QString# txt = urlcxx . . $ QString#QString(132dd6869045752b).; |
| 203 | |
| 204 | if (!desc.isEmptycxx . . $ QString#isEmpty(3482b152b9333168).()) { |
| 205 | txt +=cxx . . $ QString#`operator+=`(6a89d0b7f4d2681c). QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("\n\n%1").argcxx . . $ QString#arg(ad0bca07273edcc2).(desc); |
| 206 | } |
| 207 | |
| 208 | return txtcxx . . $ QVariant#QVariant(132dd6869045752b).; |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | return QVariantcxx . . $ QVariant#QVariant(ced63f7c635d850d).(); |
| 213 | } |
| 214 | |
| 215 | bool AccountCheckModelcxx . . $ AccountCheckModel#::setDatacxx . . $ AccountCheckModel#setData(6d1d8401440d0a2c).(const QModelIndexcxx . . $ QModelIndex#& index, const QVariantcxx . . $ QVariant#& value, int role) { |
| 216 | if (index.isValidcxx . . $ QModelIndex#isValid(3482b152b9333168).() && index.columncxx . . $ QModelIndex#column(ea6fe5115c70a13f).() == 0 && role == Qtcxx . . $ Qt/::CheckStateRolecxx . . $ Qt/CheckStateRole.) { |
| 217 | RootItemcxx . . $ RootItem#* item = itemForIndexcxx . . $ AccountCheckModel#itemForIndex(8787ab140507818d).(index); |
| 218 | |
| 219 | if (item == m_rootItemcxx . . $ AccountCheckModel#m_rootItem.) { |
| 220 | // Cannot set data on root item. |
| 221 | return false; |
| 222 | } |
| 223 | |
| 224 | // Change data for the actual item. |
| 225 | m_checkStatescxx . . $ AccountCheckModel#m_checkStates.[cxx . . $ QHash#`operator[]`(bbd415b616967878).item] = static_cast<Qtcxx . . $ Qt/::CheckStatecxx . . $ Qt/CheckState#>(value.toIntcxx . . $ QVariant#toInt(5bd9a3493f6a7a21).()); |
| 226 | emitcxx . . $ `<external>/4830994369567095248/qtmetamacros.h:51:10`! dataChangedcxx . . $ QAbstractItemModel#dataChanged(8b1756e6b8804e36).(index, index); |
| 227 | emitcxx . . $ `<external>/4830994369567095248/qtmetamacros.h:51:10`! checkStateChangedcxx . . $ AccountCheckModel#checkStateChanged(27c7256c73dc5c45).(item, m_checkStatescxx . . $ AccountCheckModel#m_checkStates.[cxx . . $ QHash#`operator[]`(bbd415b616967878).item]); |
| 228 | |
| 229 | if (m_recursiveChangecxx . . $ AccountCheckModel#m_recursiveChange.) { |
| 230 | return true; |
| 231 | } |
| 232 | |
| 233 | // Set new data for all descendants of this actual item. |
| 234 | auto chi = item->childItemscxx . . $ RootItem#childItems(f275a58a8bc5f139).(); |
| 235 | |
| 236 | for (RootItemcxx . . $ RootItem#* child : stdcxx . . $ std/::as_constcxx . . $ std/as_const(1dc117cbefefc300).(chi)) { |
| 237 | setDatacxx . . $ AccountCheckModel#setData(6d1d8401440d0a2c).(indexForItemcxx . . $ AccountCheckModel#indexForItem(12881790cc0639ef).(child), value, Qtcxx . . $ Qt/::CheckStateRolecxx . . $ Qt/CheckStateRole.); |
| 238 | } |
| 239 | |
| 240 | // Now we need to change new data to all parents. |
| 241 | QModelIndexcxx . . $ QModelIndex# parent_index = index; |
| 242 | |
| 243 | m_recursiveChangecxx . . $ AccountCheckModel#m_recursiveChange. = true; |
| 244 | |
| 245 | // Iterate all valid parents. |
| 246 | while ((parent_index =cxx . . $ QModelIndex#`operator=`(4665afb3441ab1ca). parent_index.parentcxx . . $ QModelIndex#parent(a394cbc57608ce34).()).isValidcxx . . $ QModelIndex#isValid(3482b152b9333168).()) { |
| 247 | // We now have parent index. Get parent item too. |
| 248 | item = item->parentcxx . . $ RootItem#parent(e4f4b13bf6686a09).(); |
| 249 | |
| 250 | // Check children of this new parent item. |
| 251 | bool all_checked = true; |
| 252 | bool all_unchecked = true; |
| 253 | auto childr = item->childItemscxx . . $ RootItem#childItems(f275a58a8bc5f139).(); |
| 254 | |
| 255 | for (RootItemcxx . . $ RootItem#* child_of_parent : stdcxx . . $ std/::as_constcxx . . $ std/as_const(1dc117cbefefc300).(childr)) { |
| 256 | if (m_checkStatescxx . . $ AccountCheckModel#m_checkStates..containscxx . . $ QHash#contains(5247d2cea5ab73ba).(child_of_parent)) { |
| 257 | all_checked &= m_checkStatescxx . . $ AccountCheckModel#m_checkStates.[cxx . . $ QHash#`operator[]`(bbd415b616967878).child_of_parent] == Qtcxx . . $ Qt/::CheckStatecxx . . $ Qt/CheckState#::Checkedcxx . . $ Qt/Checked.; |
| 258 | all_unchecked &= m_checkStatescxx . . $ AccountCheckModel#m_checkStates.[cxx . . $ QHash#`operator[]`(bbd415b616967878).child_of_parent] == Qtcxx . . $ Qt/::CheckStatecxx . . $ Qt/CheckState#::Uncheckedcxx . . $ Qt/Unchecked.; |
| 259 | } |
| 260 | else { |
| 261 | all_checked = false; |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | if (all_checked) { |
| 266 | setDatacxx . . $ AccountCheckModel#setData(6d1d8401440d0a2c).(parent_index, Qtcxx . . $ QVariant#QVariant(f349c77f591a7878).::CheckStatecxx . . $ Qt/CheckState#::Checkedcxx . . $ Qt/Checked., Qtcxx . . $ Qt/::CheckStateRolecxx . . $ Qt/CheckStateRole.); |
| 267 | } |
| 268 | else if (all_unchecked) { |
| 269 | setDatacxx . . $ AccountCheckModel#setData(6d1d8401440d0a2c).(parent_index, Qtcxx . . $ QVariant#QVariant(f349c77f591a7878).::CheckStatecxx . . $ Qt/CheckState#::Uncheckedcxx . . $ Qt/Unchecked., Qtcxx . . $ Qt/::CheckStateRolecxx . . $ Qt/CheckStateRole.); |
| 270 | } |
| 271 | else { |
| 272 | setDatacxx . . $ AccountCheckModel#setData(6d1d8401440d0a2c).(parent_index, Qtcxx . . $ QVariant#QVariant(f349c77f591a7878).::CheckStatecxx . . $ Qt/CheckState#::PartiallyCheckedcxx . . $ Qt/PartiallyChecked., Qtcxx . . $ Qt/::CheckStateRolecxx . . $ Qt/CheckStateRole.); |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | m_recursiveChangecxx . . $ AccountCheckModel#m_recursiveChange. = false; |
| 277 | return true; |
| 278 | } |
| 279 | |
| 280 | return false; |
| 281 | } |
| 282 | |
| 283 | Qtcxx . . $ Qt/::ItemFlagscxx . . $ Qt/ItemFlags# AccountCheckModelcxx . . $ AccountCheckModel#::flagscxx . . $ AccountCheckModel#flags(36b38c1b3d3f7b45).(const QModelIndexcxx . . $ QModelIndex#& index) const { |
| 284 | if (!index.isValidcxx . . $ QModelIndex#isValid(3482b152b9333168).() || (itemForIndexcxx . . $ AccountCheckModel#itemForIndex(8787ab140507818d).(index)->kindcxx . . $ RootItem#kind(faa800885e6a64b).() != RootItemcxx . . $ RootItem#::Kindcxx . . $ RootItem#Kind#::Categorycxx . . $ RootItem#Kind#Category. && |
| 285 | itemForIndexcxx . . $ AccountCheckModel#itemForIndex(8787ab140507818d).(index)->kindcxx . . $ RootItem#kind(faa800885e6a64b).() != RootItemcxx . . $ RootItem#::Kindcxx . . $ RootItem#Kind#::Feedcxx . . $ RootItem#Kind#Feed.)) { |
| 286 | return Qtcxx . . $ QFlags#QFlags(93d577a3e9528307).::ItemFlagcxx . . $ Qt/ItemFlag#::NoItemFlagscxx . . $ Qt/NoItemFlags.; |
| 287 | } |
| 288 | |
| 289 | Qtcxx . . $ Qt/::ItemFlagscxx . . $ Qt/ItemFlags# flags = Qtcxx . . $ Qt/::ItemFlagcxx . . $ Qt/ItemFlag#::ItemIsEnabledcxx . . $ Qt/ItemIsEnabled. |cxx . . $ Qt/`operator|`(bcda3d535fff4cd0). Qtcxx . . $ Qt/::ItemFlagcxx . . $ Qt/ItemFlag#::ItemIsSelectablecxx . . $ Qt/ItemIsSelectable.; |
| 290 | |
| 291 | if (index.columncxx . . $ QModelIndex#column(ea6fe5115c70a13f).() == 0) { |
| 292 | flags |=cxx . . $ QFlags#`operator|=`(fd64b2b07d6098e0). Qtcxx . . $ Qt/::ItemFlagcxx . . $ Qt/ItemFlag#::ItemIsUserCheckablecxx . . $ Qt/ItemIsUserCheckable.; |
| 293 | } |
| 294 | |
| 295 | return flags; |
| 296 | } |
| 297 | |
| 298 | QListcxx . . $ QList#<RootItemcxx . . $ RootItem#*> AccountCheckModelcxx . . $ AccountCheckModel#::checkedItemscxx . . $ AccountCheckModel#checkedItems(8f33d497292471a8).() const { |
| 299 | auto keys = m_checkStatescxx . . $ AccountCheckModel#m_checkStates..keyscxx . . $ QHash#keys(bf6c511543d55010).(); |
| 300 | auto res = boolinqcxx . . $ boolinq/::fromcxx . . $ boolinq/from(1a44d082b2747720).(keys) |
| 301 | .wherecxx . . $ boolinq/Linq#where(d169c8e6e9294137).([cxx . . $ std/function#function(bdc3712e480e4d04).&](const auto& key) { |
| 302 | return m_checkStatescxx . . $ AccountCheckModel#m_checkStates..valuecxx . . $ QHash#value(5f65a9ee2c9899ff).(key) ==cxx . . $ `operator==`(84f74245ecaf5083). Qtcxx . . $ Qt/::CheckStatecxx . . $ Qt/CheckState#::Checkedcxx . . $ Qt/Checked.; |
| 303 | }) |
| 304 | .toStdListcxx . . $ boolinq/Linq#toStdList(2989115be80c3067).(); |
| 305 | |
| 306 | return FROM_STD_LISTcxx . . $ `src/librssguard/definitions/definitions.h:405:9`!(QList<RootItem*>, res); |
| 307 | } |
| 308 | |
| 309 | bool AccountCheckModelcxx . . $ AccountCheckModel#::isItemCheckedcxx . . $ AccountCheckModel#isItemChecked(adff9bc3a348c0ca).(RootItemcxx . . $ RootItem#* item) const { |
| 310 | return m_checkStatescxx . . $ AccountCheckModel#m_checkStates..valuecxx . . $ QHash#value(a3740c909796fedc).(item, Qtcxx . . $ Qt/::CheckStatecxx . . $ Qt/CheckState#::Uncheckedcxx . . $ Qt/Unchecked.) != Qtcxx . . $ Qt/::CheckStatecxx . . $ Qt/CheckState#::Uncheckedcxx . . $ Qt/Unchecked.; |
| 311 | } |
| 312 | |
| 313 | bool AccountCheckModelcxx . . $ AccountCheckModel#::setItemCheckedcxx . . $ AccountCheckModel#setItemChecked(92a4bcd4aac93bc1).(RootItemcxx . . $ RootItem#* item, Qtcxx . . $ Qt/::CheckStatecxx . . $ Qt/CheckState# check) { |
| 314 | return setDatacxx . . $ AccountCheckModel#setData(6d1d8401440d0a2c).(indexForItemcxx . . $ AccountCheckModel#indexForItem(12881790cc0639ef).(item), checkcxx . . $ QVariant#QVariant(f349c77f591a7878)., Qtcxx . . $ Qt/::ItemDataRolecxx . . $ Qt/ItemDataRole#::CheckStateRolecxx . . $ Qt/CheckStateRole.); |
| 315 | } |
| 316 | |
| 317 | AccountCheckSortedModelcxx . . $ AccountCheckSortedModel#::AccountCheckSortedModelcxx . . $ AccountCheckSortedModel#AccountCheckSortedModel(749de1b6ae65bddd).(QObjectcxx . . $ QObject#* parent) |
| 318 | : QSortFilterProxyModelcxx . . $ QSortFilterProxyModel#(parent), m_sourceModelcxx . . $ AccountCheckSortedModel#m_sourceModel.(new AccountCheckModelcxx . . $ AccountCheckModel#(parent)) { |
| 319 | setDynamicSortFiltercxx . . $ QSortFilterProxyModel#setDynamicSortFilter(b45ddcbc8423892c).(false); |
| 320 | setSourceModelcxx . . $ QSortFilterProxyModel#setSourceModel(c6e1f1e42522b780).(m_sourceModelcxx . . $ AccountCheckSortedModel#m_sourceModel.); |
| 321 | sortcxx . . $ QSortFilterProxyModel#sort(11168df8d4e8286d).(0, Qtcxx . . $ Qt/::SortOrdercxx . . $ Qt/SortOrder#::AscendingOrdercxx . . $ Qt/AscendingOrder.); |
| 322 | } |
| 323 | |
| 324 | bool AccountCheckSortedModelcxx . . $ AccountCheckSortedModel#::lessThancxx . . $ AccountCheckSortedModel#lessThan(38842d0605fc2db).(const QModelIndexcxx . . $ QModelIndex#& source_left, const QModelIndexcxx . . $ QModelIndex#& source_right) const { |
| 325 | auto* lhs = m_sourceModelcxx . . $ AccountCheckSortedModel#m_sourceModel.->itemForIndexcxx . . $ AccountCheckModel#itemForIndex(8787ab140507818d).(source_left); |
| 326 | auto* rhs = m_sourceModelcxx . . $ AccountCheckSortedModel#m_sourceModel.->itemForIndexcxx . . $ AccountCheckModel#itemForIndex(8787ab140507818d).(source_right); |
| 327 | |
| 328 | if (lhs != nullptr && rhs != nullptr) { |
| 329 | QListcxx . . $ QList#<RootItemcxx . . $ RootItem#::Kindcxx . . $ RootItem#Kind#> priorities = {cxx . . $ QList#QList(b6da5b9a9f304025).RootItemcxx . . $ RootItem#::Kindcxx . . $ RootItem#Kind#::Categorycxx . . $ RootItem#Kind#Category., |
| 330 | RootItemcxx . . $ RootItem#::Kindcxx . . $ RootItem#Kind#::Feedcxx . . $ RootItem#Kind#Feed., |
| 331 | RootItemcxx . . $ RootItem#::Kindcxx . . $ RootItem#Kind#::Labelscxx . . $ RootItem#Kind#Labels., |
| 332 | RootItemcxx . . $ RootItem#::Kindcxx . . $ RootItem#Kind#::Importantcxx . . $ RootItem#Kind#Important., |
| 333 | RootItemcxx . . $ RootItem#::Kindcxx . . $ RootItem#Kind#::Unreadcxx . . $ RootItem#Kind#Unread., |
| 334 | RootItemcxx . . $ RootItem#::Kindcxx . . $ RootItem#Kind#::Bincxx . . $ RootItem#Kind#Bin.}; |
| 335 | |
| 336 | if (lhs->keepOnTopcxx . . $ RootItem#keepOnTop(50ce9a9e25b4a850).()) { |
| 337 | return sortOrdercxx . . $ QSortFilterProxyModel#sortOrder(3d035b40950d32d6).() == Qtcxx . . $ Qt/::SortOrdercxx . . $ Qt/SortOrder#::AscendingOrdercxx . . $ Qt/AscendingOrder.; |
| 338 | } |
| 339 | else if (rhs->keepOnTopcxx . . $ RootItem#keepOnTop(50ce9a9e25b4a850).()) { |
| 340 | return sortOrdercxx . . $ QSortFilterProxyModel#sortOrder(3d035b40950d32d6).() == Qtcxx . . $ Qt/::SortOrdercxx . . $ Qt/SortOrder#::DescendingOrdercxx . . $ Qt/DescendingOrder.; |
| 341 | } |
| 342 | |
| 343 | auto left_priority = priorities.indexOfcxx . . $ QListSpecialMethodsBase#indexOf(284c58bbf0d07092).(lhs->kindcxx . . $ RootItem#kind(faa800885e6a64b).()); |
| 344 | auto right_priority = priorities.indexOfcxx . . $ QListSpecialMethodsBase#indexOf(284c58bbf0d07092).(rhs->kindcxx . . $ RootItem#kind(faa800885e6a64b).()); |
| 345 | |
| 346 | if (left_priority == right_priority) { |
| 347 | return QStringcxx . . $ QString#::localeAwareComparecxx . . $ QString#localeAwareCompare(c6f4e55073dadb56).(lhs->titlecxx . . $ RootItem#title(6ef7b6c27b00b43d).().toLowercxx . . $ QString#toLower(30b3b70527b1c61a).(), rhs->titlecxx . . $ RootItem#title(6ef7b6c27b00b43d).().toLowercxx . . $ QString#toLower(30b3b70527b1c61a).()) < 0; |
| 348 | } |
| 349 | else { |
| 350 | return sortOrdercxx . . $ QSortFilterProxyModel#sortOrder(3d035b40950d32d6).() == Qtcxx . . $ Qt/::SortOrdercxx . . $ Qt/SortOrder#::AscendingOrdercxx . . $ Qt/AscendingOrder. ? left_priority < right_priority |
| 351 | : right_priority < left_priority; |
| 352 | } |
| 353 | } |
| 354 | |
| 355 | return false; |
| 356 | } |
| 357 | |
| 358 | AccountCheckModelcxx . . $ AccountCheckModel#* AccountCheckSortedModelcxx . . $ AccountCheckSortedModel#::sourceModelcxx . . $ AccountCheckSortedModel#sourceModel(8eb4d7bf7b39d944).() const { |
| 359 | return m_sourceModelcxx . . $ AccountCheckSortedModel#m_sourceModel.; |
| 360 | } |
| 361 | |
| 362 | void AccountCheckSortedModelcxx . . $ AccountCheckSortedModel#::setRootItemcxx . . $ AccountCheckSortedModel#setRootItem(1ce4f84de393a7b0).(RootItemcxx . . $ RootItem#* root_item, bool delete_previous_root, bool with_layout_change) { |
| 363 | setSourceModelcxx . . $ QSortFilterProxyModel#setSourceModel(c6e1f1e42522b780).(nullptr); |
| 364 | m_sourceModelcxx . . $ AccountCheckSortedModel#m_sourceModel.->setRootItemcxx . . $ AccountCheckModel#setRootItem(1ce4f84de393a7b0).(root_item, delete_previous_root, with_layout_change); |
| 365 | setSourceModelcxx . . $ QSortFilterProxyModel#setSourceModel(c6e1f1e42522b780).(m_sourceModelcxx . . $ AccountCheckSortedModel#m_sourceModel.); |
| 366 | } |
| 367 | |
| 368 | void AccountCheckSortedModelcxx . . $ AccountCheckSortedModel#::checkAllItemscxx . . $ AccountCheckSortedModel#checkAllItems(49f6e7a06ebc5aa8).() { |
| 369 | m_sourceModelcxx . . $ AccountCheckSortedModel#m_sourceModel.->checkAllItemscxx . . $ AccountCheckModel#checkAllItems(49f6e7a06ebc5aa8).(); |
| 370 | } |
| 371 | |
| 372 | void AccountCheckSortedModelcxx . . $ AccountCheckSortedModel#::uncheckAllItemscxx . . $ AccountCheckSortedModel#uncheckAllItems(49f6e7a06ebc5aa8).() { |
| 373 | m_sourceModelcxx . . $ AccountCheckSortedModel#m_sourceModel.->uncheckAllItemscxx . . $ AccountCheckModel#uncheckAllItems(49f6e7a06ebc5aa8).(); |
| 374 | } |
| 375 | |
| 376 | bool AccountCheckSortedModelcxx . . $ AccountCheckSortedModel#::filterAcceptsRowcxx . . $ AccountCheckSortedModel#filterAcceptsRow(5556b7879475181c).(int source_row, const QModelIndexcxx . . $ QModelIndex#& source_parent) const { |
| 377 | auto kind = m_sourceModelcxx . . $ AccountCheckSortedModel#m_sourceModel.->itemForIndexcxx . . $ AccountCheckModel#itemForIndex(8787ab140507818d).(m_sourceModelcxx . . $ AccountCheckSortedModel#m_sourceModel.->indexcxx . . $ AccountCheckModel#index(37dbccf64c4e392).(source_row, 0, source_parent))->kindcxx . . $ RootItem#kind(faa800885e6a64b).(); |
| 378 | |
| 379 | return kind == RootItemcxx . . $ RootItem#::Kindcxx . . $ RootItem#Kind#::Rootcxx . . $ RootItem#Kind#Root. || kind == RootItemcxx . . $ RootItem#::Kindcxx . . $ RootItem#Kind#::ServiceRootcxx . . $ RootItem#Kind#ServiceRoot. || kind == RootItemcxx . . $ RootItem#::Kindcxx . . $ RootItem#Kind#::Categorycxx . . $ RootItem#Kind#Category. || |
| 380 | kind == RootItemcxx . . $ RootItem#::Kindcxx . . $ RootItem#Kind#::Feedcxx . . $ RootItem#Kind#Feed.; |
| 381 | } |