void GCUserView::qlv_contextMenuRequested(Q3ListViewItem *i, const QPoint &pos, int) { if(!i || !i->parent() || !gcDlg_) return; QPointer<GCUserViewItem> lvi = (GCUserViewItem *)i; bool self = gcDlg_->nick() == i->text(0); GCUserViewItem* c = (GCUserViewItem*) findEntry(gcDlg_->nick()); if (!c) { qWarning(QString("groupchatdlg.cpp: Self ('%1') not found in contactlist").arg(gcDlg_->nick())); return; } Q3PopupMenu *pm = new Q3PopupMenu; pm->insertItem(IconsetFactory::icon("psi/sendMessage").icon(), tr("Send &message"), 0); pm->insertItem(IconsetFactory::icon("psi/start-chat").icon(), tr("Open &chat window"), 1); pm->insertSeparator(); pm->insertItem(tr("&Kick"),10); pm->setItemEnabled(10, MUCManager::canKick(c->s.mucItem(),lvi->s.mucItem())); pm->insertItem(tr("&Ban"),11); pm->setItemEnabled(11, MUCManager::canBan(c->s.mucItem(),lvi->s.mucItem())); Q3PopupMenu* rm = new Q3PopupMenu(pm); rm->insertItem(tr("Visitor"),12); rm->setItemChecked(12, lvi->s.mucItem().role() == MUCItem::Visitor); rm->setItemEnabled(12, (!self || lvi->s.mucItem().role() == MUCItem::Visitor) && MUCManager::canSetRole(c->s.mucItem(),lvi->s.mucItem(),MUCItem::Visitor)); rm->insertItem(tr("Participant"),13); rm->setItemChecked(13, lvi->s.mucItem().role() == MUCItem::Participant); rm->setItemEnabled(13, (!self || lvi->s.mucItem().role() == MUCItem::Participant) && MUCManager::canSetRole(c->s.mucItem(),lvi->s.mucItem(),MUCItem::Participant)); rm->insertItem(tr("Moderator"),14); rm->setItemChecked(14, lvi->s.mucItem().role() == MUCItem::Moderator); rm->setItemEnabled(14, (!self || lvi->s.mucItem().role() == MUCItem::Moderator) && MUCManager::canSetRole(c->s.mucItem(),lvi->s.mucItem(),MUCItem::Moderator)); pm->insertItem(tr("Change role"),rm); /*Q3PopupMenu* am = new Q3PopupMenu(pm); am->insertItem(tr("Unaffiliated"),15); am->setItemChecked(15, lvi->s.mucItem().affiliation() == MUCItem::NoAffiliation); am->setItemEnabled(15, (!self || lvi->s.mucItem().affiliation() == MUCItem::NoAffiliation) && MUCManager::canSetAffiliation(c->s.mucItem(),lvi->s.mucItem(),MUCItem::NoAffiliation)); am->insertItem(tr("Member"),16); am->setItemChecked(16, lvi->s.mucItem().affiliation() == MUCItem::Member); am->setItemEnabled(16, (!self || lvi->s.mucItem().affiliation() == MUCItem::Member) && MUCManager::canSetAffiliation(c->s.mucItem(),lvi->s.mucItem(),MUCItem::Member)); am->insertItem(tr("Administrator"),17); am->setItemChecked(17, lvi->s.mucItem().affiliation() == MUCItem::Admin); am->setItemEnabled(17, (!self || lvi->s.mucItem().affiliation() == MUCItem::Admin) && MUCManager::canSetAffiliation(c->s.mucItem(),lvi->s.mucItem(),MUCItem::Admin)); am->insertItem(tr("Owner"),18); am->setItemChecked(18, lvi->s.mucItem().affiliation() == MUCItem::Owner); am->setItemEnabled(18, (!self || lvi->s.mucItem().affiliation() == MUCItem::Owner) && MUCManager::canSetAffiliation(c->s.mucItem(),lvi->s.mucItem(),MUCItem::Owner)); pm->insertItem(tr("Change affiliation"),am);*/ pm->insertSeparator(); //pm->insertItem(tr("Send &file"), 4); //pm->insertSeparator(); pm->insertItem(tr("Check &Status"), 2); pm->insertItem(IconsetFactory::icon("psi/vCard").icon(), tr("User &Info"), 3); int x = pm->exec(pos); bool enabled = pm->isItemEnabled(x) || rm->isItemEnabled(x); delete pm; if(x == -1 || !enabled || lvi.isNull()) return; action(lvi->text(0), lvi->s, x); }
void GCUserView::qlv_contextMenuRequested(Q3ListViewItem *i, const QPoint &pos, int) { if(!i || !i->parent() || !gcDlg_) return; QPointer<GCUserViewItem> lvi = (GCUserViewItem *)i; bool self = gcDlg_->nick() == i->text(0); GCUserViewItem* c = (GCUserViewItem*) findEntry(gcDlg_->nick()); if (!c) { qWarning() << QString("groupchatdlg.cpp: Self ('%1') not found in contactlist").arg(gcDlg_->nick()); return; } Q3PopupMenu *pm = new Q3PopupMenu; pm->insertItem(IconsetFactory::icon("psi/sendMessage").icon(), tr("Send &Message"), 0); pm->insertItem(IconsetFactory::icon("psi/start-chat").icon(), tr("Open &Chat Window"), 1); pm->insertSeparator(); // Kick and Ban submenus QStringList reasons = PsiOptions::instance()->getOption("options.muc.reasons").toStringList(); int cntReasons=reasons.count(); if (cntReasons>99) cntReasons=99; // Only first 99 reasons Q3PopupMenu *kickMenu = new Q3PopupMenu(pm); kickMenu->insertItem(tr("No reason"),10); kickMenu->insertItem(tr("Custom reason"),100); kickMenu->insertSeparator(); bool canKick=MUCManager::canKick(c->s.mucItem(),lvi->s.mucItem()); for (int i=0; i<cntReasons; ++i) kickMenu->insertItem(reasons[i], 101+i); kickMenu->setEnabled(canKick); Q3PopupMenu *banMenu = new Q3PopupMenu(pm); banMenu->insertItem(tr("No reason"),11); banMenu->insertItem(tr("Custom reason"),200); banMenu->insertSeparator(); bool canBan=MUCManager::canBan(c->s.mucItem(),lvi->s.mucItem()); for (int i=0; i<cntReasons; ++i) banMenu->insertItem(reasons[i], 201+i); banMenu->setEnabled(canBan); pm->insertItem(tr("&Kick"), kickMenu); pm->setItemEnabled(10, canKick); pm->insertItem(tr("&Ban"), banMenu); pm->setItemEnabled(11, canBan); Q3PopupMenu* rm = new Q3PopupMenu(pm); rm->insertItem(tr("Visitor"),12); rm->setItemChecked(12, lvi->s.mucItem().role() == MUCItem::Visitor); rm->setItemEnabled(12, (!self || lvi->s.mucItem().role() == MUCItem::Visitor) && MUCManager::canSetRole(c->s.mucItem(),lvi->s.mucItem(),MUCItem::Visitor)); rm->insertItem(tr("Participant"),13); rm->setItemChecked(13, lvi->s.mucItem().role() == MUCItem::Participant); rm->setItemEnabled(13, (!self || lvi->s.mucItem().role() == MUCItem::Participant) && MUCManager::canSetRole(c->s.mucItem(),lvi->s.mucItem(),MUCItem::Participant)); rm->insertItem(tr("Moderator"),14); rm->setItemChecked(14, lvi->s.mucItem().role() == MUCItem::Moderator); rm->setItemEnabled(14, (!self || lvi->s.mucItem().role() == MUCItem::Moderator) && MUCManager::canSetRole(c->s.mucItem(),lvi->s.mucItem(),MUCItem::Moderator)); pm->insertItem(tr("Change Role"),rm); /*Q3PopupMenu* am = new Q3PopupMenu(pm); am->insertItem(tr("Unaffiliated"),15); am->setItemChecked(15, lvi->s.mucItem().affiliation() == MUCItem::NoAffiliation); am->setItemEnabled(15, (!self || lvi->s.mucItem().affiliation() == MUCItem::NoAffiliation) && MUCManager::canSetAffiliation(c->s.mucItem(),lvi->s.mucItem(),MUCItem::NoAffiliation)); am->insertItem(tr("Member"),16); am->setItemChecked(16, lvi->s.mucItem().affiliation() == MUCItem::Member); am->setItemEnabled(16, (!self || lvi->s.mucItem().affiliation() == MUCItem::Member) && MUCManager::canSetAffiliation(c->s.mucItem(),lvi->s.mucItem(),MUCItem::Member)); am->insertItem(tr("Administrator"),17); am->setItemChecked(17, lvi->s.mucItem().affiliation() == MUCItem::Admin); am->setItemEnabled(17, (!self || lvi->s.mucItem().affiliation() == MUCItem::Admin) && MUCManager::canSetAffiliation(c->s.mucItem(),lvi->s.mucItem(),MUCItem::Admin)); am->insertItem(tr("Owner"),18); am->setItemChecked(18, lvi->s.mucItem().affiliation() == MUCItem::Owner); am->setItemEnabled(18, (!self || lvi->s.mucItem().affiliation() == MUCItem::Owner) && MUCManager::canSetAffiliation(c->s.mucItem(),lvi->s.mucItem(),MUCItem::Owner)); pm->insertItem(tr("Change Affiliation"),am);*/ pm->insertSeparator(); //pm->insertItem(tr("Send &File"), 4); //pm->insertSeparator(); pm->insertItem(tr("Check &Status"), 2); pm->insertItem(IconsetFactory::icon("psi/vCard").icon(), tr("User &Info"), 3); int x = pm->exec(pos); bool enabled = pm->isItemEnabled(x) || rm->isItemEnabled(x) || kickMenu->isItemEnabled(x) || banMenu->isItemEnabled(x); delete pm; if(x == -1 || !enabled || lvi.isNull()) return; action(lvi->text(0), lvi->s, x); }