Пример #1
0
void CoverageView::context(const QPoint & p)
{
  int c = columnAt(p.x());
  QTreeWidgetItem* i = itemAt(p);
  QMenu popup;

  TraceFunction* f = 0;
  if (i) {
      f = _showCallers ?
	  ((CallerCoverageItem*)i)->function() :
	  ((CalleeCoverageItem*)i)->function();
  }

  QAction* activateFunctionAction = 0;
  if (f) {
      QString menuText = tr("Go to '%1'").arg(GlobalConfig::shortenSymbol(f->prettyName()));
      activateFunctionAction = popup.addAction(menuText);
      popup.addSeparator();
  }

   if ((c == 0) || (!_showCallers && c == 1)) {
    addEventTypeMenu(&popup, false);
    popup.addSeparator();
  }
  addGoMenu(&popup); 

  QAction* a = popup.exec(mapToGlobal(p + QPoint(0,header()->height())));
  if (a == activateFunctionAction)
      TraceItemView::activated(f);
}
Пример #2
0
void CallView::context(const QPoint & p)
{
  QMenu popup;

  // p is in local coordinates
  int col = columnAt(p.x());
  QTreeWidgetItem* i = itemAt(p);
  TraceCall* c = i ? ((CallItem*) i)->call() : 0;
  TraceFunction *f = 0, *cycle = 0;

  QAction* activateFunctionAction = 0;
  QAction* activateCycleAction = 0;
  if (c) {
    QString name  = _showCallers ? c->callerName(true) : c->calledName(true);
    f = _showCallers ? c->caller(true) : c->called(true);
    cycle = f->cycle();

    QString menuText = tr("Go to '%1'").arg(GlobalConfig::shortenSymbol(name));
    activateFunctionAction = popup.addAction(menuText);

    if (cycle) {
	name = GlobalConfig::shortenSymbol(cycle->prettyName());
        QString menuText = tr("Go to '%1'").arg(name);
        activateCycleAction = popup.addAction(menuText);
    }

    popup.addSeparator();
  }

  if ((col == 0) || (col == 1)) {
    addEventTypeMenu(&popup);
    popup.addSeparator();
  }
  addGoMenu(&popup);

  QAction* a = popup.exec(mapToGlobal(p + QPoint(0,header()->height())));
  if (a == activateFunctionAction)
      TraceItemView::activated(f);
  else if (a == activateCycleAction)
      TraceItemView::activated(cycle);
}