bool Plugin::IsEntryAllowed (QObject *entryObj) const { ICLEntry *entry = qobject_cast<ICLEntry*> (entryObj); if (!entry) return true; if ((entry->GetEntryFeatures () & ICLEntry::FMaskLongetivity) == ICLEntry::FPermanentEntry) return true; if (AllowedEntries_.contains (entryObj)) return true; return false; }
bool SortFilterProxyModel::filterAcceptsRow (int row, const QModelIndex& parent) const { if (MUCMode_) { if (!MUCEntry_) return false; const QModelIndex& idx = sourceModel ()->index (row, 0, parent); switch (GetType (idx)) { case Core::CLETAccount: { QObject *acc = qobject_cast<ICLEntry*> (MUCEntry_)->GetParentAccount (); return acc == idx.data (Core::CLRAccountObject).value<QObject*> (); } case Core::CLETCategory: { const QString& gName = idx.data ().toString (); return gName == qobject_cast<IMUCEntry*> (MUCEntry_)->GetGroupName () || qobject_cast<ICLEntry*> (MUCEntry_)->Groups ().contains (gName); } default: break; } } else { const QModelIndex& idx = sourceModel ()->index (row, 0, parent); if (!filterRegExp ().isEmpty ()) return GetType (idx) == Core::CLETContact ? idx.data ().toString ().contains (filterRegExp ()) : true; if (idx.data (Core::CLRUnreadMsgCount).toInt ()) return true; const auto type = GetType (idx); if (type == Core::CLETContact) { ICLEntry *entry = GetEntry (idx); const State state = entry->GetStatus ().State_; if (!ShowOffline_ && state == SOffline && !idx.data (Core::CLRUnreadMsgCount).toInt ()) return false; if (HideMUCParts_ && entry->GetEntryType () == ICLEntry::ETPrivateChat) return false; if (!ShowSelfContacts_ && entry->GetEntryFeatures () & ICLEntry::FSelfContact) return false; } else if (type == Core::CLETCategory) { if (!ShowOffline_ && !idx.data (Core::CLRNumOnline).toInt ()) return false; for (int subRow = 0; subRow < sourceModel ()->rowCount (idx); ++subRow) if (filterAcceptsRow (subRow, idx)) return true; return false; } else if (type == Core::CLETAccount) { const auto& accObj = idx.data (Core::CLRAccountObject).value<QObject*> (); auto acc = qobject_cast<IAccount*> (accObj); return acc->IsShownInRoster (); } } return QSortFilterProxyModel::filterAcceptsRow (row, parent); }