void PrivacyListsItemDialog::SetItem (const PrivacyListItem& item) { Ui_.Action_->setCurrentIndex (item.GetAction () == PrivacyListItem::AAllow ? ANAllow : ANDeny); TypeNum index = TNJID; switch (item.GetType ()) { case PrivacyListItem::TJid: index = TNJID; break; case PrivacyListItem::TGroup: index = TNGroup; break; case PrivacyListItem::TSubscription: index = TNSubscription; break; case PrivacyListItem::TNone: break; } Ui_.Type_->setCurrentIndex (index); on_Type__currentIndexChanged (index); if (index == TNSubscription) { const int idx = Ui_.Value_->findData (item.GetValue ()); if (idx >= 0) Ui_.Value_->setCurrentIndex (idx); } else Ui_.Value_->setEditText (item.GetValue ()); const PrivacyListItem::StanzaTypes stanzas = item.GetStanzaTypes (); if (stanzas != PrivacyListItem::STAll) { if (stanzas & PrivacyListItem::STMessage) Ui_.StanzaMessage_->setCheckState (Qt::Checked); if (stanzas & PrivacyListItem::STIq) Ui_.StanzaIQ_->setCheckState (Qt::Checked); if (stanzas & PrivacyListItem::STPresenceIn) Ui_.StanzaInPres_->setCheckState (Qt::Checked); if (stanzas & PrivacyListItem::STPresenceOut) Ui_.StanzaOutPres_->setCheckState (Qt::Checked); } }
QList<QStandardItem*> PrivacyListsConfigDialog::ToRow (const PrivacyListItem& item) const { QList<QStandardItem*> modelItems; switch (item.GetType ()) { case PrivacyListItem::TNone: modelItems << new QStandardItem (tr ("None")); break; case PrivacyListItem::TJid: modelItems << new QStandardItem (tr ("JID")); break; case PrivacyListItem::TSubscription: modelItems << new QStandardItem (tr ("Subscription")); break; case PrivacyListItem::TGroup: modelItems << new QStandardItem (tr ("Group")); break; } modelItems << new QStandardItem (item.GetValue ()); modelItems << new QStandardItem (item.GetAction () == PrivacyListItem::AAllow ? tr ("Allow") : tr ("Deny")); QStringList stanzasList; const PrivacyListItem::StanzaTypes types = item.GetStanzaTypes (); if (types == PrivacyListItem::STAll || types == PrivacyListItem::STNone) stanzasList << tr ("All"); else { if (types & PrivacyListItem::STMessage) stanzasList << tr ("Messages"); if (types & PrivacyListItem::STPresenceIn) stanzasList << tr ("Incoming presences"); if (types & PrivacyListItem::STPresenceOut) stanzasList << tr ("Outgoing presences"); if (types & PrivacyListItem::STIq) stanzasList << tr ("IQ"); } modelItems << new QStandardItem (stanzasList.join ("; ")); return modelItems; }