コード例 #1
0
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);
}
コード例 #2
0
void PsiToolBar::contextMenuEvent(QContextMenuEvent *e)
{
	e->accept();

	if ( !d->customizeable )
		return;

	Q3PopupMenu pm;
	pm.insertItem(IconsetFactory::icon("psi/toolbars").icon(), tr("Configure &Toolbar..."), 0);

	int ret = pm.exec( e->globalPos() );

	if ( ret == 0 ) {
		d->psi->doToolbars();
	}
}
コード例 #3
0
ファイル: ColMsgTable.cpp プロジェクト: kralf/bouml
void ColMsgTable::button_pressed(int row, int col, int, const QPoint &) {
  if ((((unsigned) row) >= flat_msg_list.count()) || (col > CMD_COL))
    // wrong signal
    return;
  
  if (col == MSG_COL)
    edit_msg(row);
  else if (col <= HI_RANK_COL)
    change_ranks(row, col);
  else {
    Q3PopupMenu m;

    m.insertItem(new MenuTitle(QString(TR("rank ")) + text(row, ABS_RANK_COL)
			       + " : " + text(row, HI_RANK_COL),
			       m.font()),
		 -1);
    m.insertSeparator();
    m.insertItem(TR("Edit message"), 1);
    m.insertItem(TR("Change ranks"), 2);
    m.insertSeparator();
    m.insertItem(TR("Delete it"), 3);
    if (!flat_msg_list[row]->msgs.isEmpty())
      m.insertItem(TR("Delete recursively"), 4);
    
    switch (m.exec(QCursor::pos())) {
    case 1:
      edit_msg(row);
      // no break;
    default:
      return;
    case 2:
      change_ranks(row, col);
      return;
    case 3:
      flat_msg_list[row]->delete_it(FALSE, view->get_msgs());
      break;
    case 4:
      flat_msg_list[row]->delete_it(TRUE, view->get_msgs());
      break;
    }
    
    view->update_msgs();
    refresh();
  }
}
コード例 #4
0
ファイル: HubCanvas.cpp プロジェクト: harmegnies/douml
void HubCanvas::menu(const QPoint &)
{
    Q3PopupMenu m;

    MenuFactory::createTitle(m, TR("Network connexion"));
    m.insertSeparator();
    m.insertItem(TR("Remove from diagram"), 0);

    switch (m.exec(QCursor::pos())) {
    case 0:
        delete_it();
        break;

    default:
        return;
    }

    package_modified();
}
コード例 #5
0
void TableEditor::contextMenu(int,int,const QPoint &pos)
{
    Q3PopupMenu *menu = new Q3PopupMenu(viewport());
    menu->insertItem(tr("Copy"),1);
    menu->insertItem(tr("Paste"),2);
	int nSelRows=0;
	Q3MemArray<int> selRows(numRows());
	for(int r=0;r<numRows()-1;r++) if(isRowSelected(r,1)) selRows[nSelRows++]=r;
	selRows.resize(nSelRows);
	if(nSelRows) menu->insertItem(tr("Delete rows"),3);
	//menu->insertItem("Clear",3);
    int r=menu->exec(pos,0);
	switch(r)
	{
	case 1: copy(); break;
	case 2: paste(); break;
	case 3: removeRows(selRows); break;
    }
}
コード例 #6
0
ファイル: ArrowJunctionCanvas.cpp プロジェクト: kralf/bouml
void ArrowJunctionCanvas::menu(const QPoint&) {
#if 0
  if (lines.at(0)->may_join()) {
    Q3PopupMenu m;
    
    m.insertItem(new MenuTitle(TR("Line break"), m.font()), -1);
    m.insertSeparator();
    m.insertItem(TR("Remove from diagram"), 0);
    
    switch (m.exec(QCursor::pos())) {
    case 0:
      // removes the point replacing the lines around it by a single line
      lines.at(0)->join(lines.at(1), this);
      break;
    default:
      return;
    }
    
    package_modified();
  }
#endif
}
コード例 #7
0
ファイル: CodLinkCanvas.cpp プロジェクト: kralf/bouml
void CodLinkCanvas::menu(const QPoint&) {
  bool new_dirs;
  CodDirsCanvas * d = find_dirs();
  CodObjCanvas * from;
  CodObjCanvas * to;

  get_start_end(from, to);
  
  if (d == 0) {
    new_dirs = TRUE;
    (d = dirs = new CodDirsCanvas(the_canvas(), this, 0))->show();
  }
  else
    new_dirs = FALSE;
  
  Q3PopupMenu m;
  Q3PopupMenu geo;
  
  m.insertItem(new MenuTitle(TR("Link"), m.font()), -1);
  m.insertSeparator();
  m.insertItem(TR("add messages to ") + from->get_full_name(), 1);
  m.insertItem(TR("add messages to ") + to->get_full_name(), 2);
  m.insertSeparator();
  m.insertItem(TR("Edit its messages"), 3);
  m.insertItem(TR("Edit all the messages"), 4);
  m.insertSeparator();
  m.insertItem(TR("Select linked items"), 7);
  m.insertSeparator();
  if (!new_dirs) {
    m.insertItem(TR("Edit drawing settings"), 5);
    m.insertSeparator();
  }
  if (get_start() != get_end()) {
    init_geometry_menu(geo, 10);
    m.insertItem(TR("Geometry (Ctrl+l)"), &geo);
    m.insertSeparator();
  }
  m.insertItem(TR("Remove from diagram"), 6);
  
  int rank = m.exec(QCursor::pos());
  
  switch (rank) {
  case 1:
    {
      CodAddMsgDialog dialog(to, from, d,
			     (ColDiagramView *) the_canvas()->get_view(),
			     FALSE);
      
      dialog.raise();
      if (dialog.exec() != QDialog::Accepted)
	return;
    }
    break;
  case 2:
    {
      CodAddMsgDialog dialog(from, to, d,
			     (ColDiagramView *) the_canvas()->get_view(),
			     TRUE);
      
      dialog.raise();
      if (dialog.exec() != QDialog::Accepted)
	return;
    }
    break;
  case 3:
    CodEditMsgDialog::exec((ColDiagramView *) the_canvas()->get_view(), d->get_msgs());
    return;
  case 4:
    CodEditMsgDialog::exec((ColDiagramView *) the_canvas()->get_view(),
			   ((ColDiagramView *) the_canvas()->get_view())->get_msgs());
    return;
  case 5:
    if (d->edit_drawing_settings())
      modified();
    return;
  case 6:
    delete_it();
    ((ColDiagramView *) the_canvas()->get_view())->update_msgs();
    break;
  case 7:
    select_associated();
    return;
  default:
    if (rank >= 10) {
      rank -= 10;
      if (rank == RecenterBegin)
	set_decenter(-1.0, decenter_end);
      else if (rank == RecenterEnd)
	set_decenter(decenter_begin, -1.0);
      else if (rank != (int) geometry)
	set_geometry((LineGeometry) rank, TRUE);
      else
	return;
    }
    else
      return;
  }
  
  package_modified();
  
  if (new_dirs && (dirs != 0)) {
    if (dirs->get_msgs().count() == 0) {
      dirs->delete_it();
      dirs = 0;
    }
    else
      dirs->update_pos(beginp, endp);
  }
}
コード例 #8
0
ファイル: gcuserview.cpp プロジェクト: mblsha/psi
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);
}