void AddToBlockedRunner::AddToList (const QString& name, PrivacyList list, bool activate) { deleteLater (); if (list.GetName ().isEmpty ()) list.SetName (name); auto items = list.GetItems (); const auto& presentIds = QSet<QString>::fromList (Util::Map (items, &PrivacyListItem::GetValue)); bool modified = false; for (const auto& id : Ids_) { if (presentIds.contains (id)) continue; items.prepend ({ id, PrivacyListItem::Type::Jid }); modified = true; } if (!modified) return; list.SetItems (items); const auto plm = Conn_->GetPrivacyListsManager (); plm->SetList (list); if (activate) plm->ActivateList (list.GetName (), PrivacyListsManager::ListType::Default); }
void GlooxCLEntry::checkIsBlocked (const PrivacyList& list) { const auto& items = list.GetItems (); const auto& jid = GetJID (); const auto pos = std::find_if (items.begin (), items.end (), [&jid] (const PrivacyListItem& item) { return item.GetType () == PrivacyListItem::TJid && item.GetAction () == PrivacyListItem::ADeny && item.GetValue () == jid; }); BlockContact_->setChecked (pos != items.end ()); }
void PrivacyListsConfigDialog::handleGotList (const PrivacyList& list) { disconnect (Manager_, SIGNAL (gotList (const PrivacyList&)), this, SLOT (handleGotList (const PrivacyList&))); Ui_.StatusLabel_->setText (QString ()); ReinitModel (); Lists_ [list.GetName ()] = list; QList<PrivacyListItem> items = list.GetItems (); if (!items.isEmpty () && items.last ().GetType () == PrivacyListItem::TNone) { const PrivacyListItem& item = items.takeLast (); Ui_.DefaultPolicy_->setCurrentIndex (item.GetAction () == PrivacyListItem::AAllow ? 0 : 1); } Q_FOREACH (const PrivacyListItem& item, items) Model_->appendRow (ToRow (item)); }