Exemplo n.º 1
0
void CoverageView::context(QListViewItem* i, const QPoint & p, int c)
{
  QPopupMenu popup;

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

  if (f) {
    QString name = f->name();
    if ((int)name.length()>Configuration::maxSymbolLength())
	name = name.left(Configuration::maxSymbolLength()) + "...";
    popup.insertItem(i18n("Go to '%1'").arg(name), 93);
    popup.insertSeparator();
  }

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

  int r = popup.exec(p);
  if (r == 93) activated(f);
}
Exemplo n.º 2
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);
}
Exemplo n.º 3
0
void SourceView::context(QListViewItem* i, const QPoint & p, int c)
{
  QPopupMenu popup;

  // Menu entry:
  TraceLineCall* lc = i ? ((SourceItem*) i)->lineCall() : 0;
  TraceLineJump* lj = i ? ((SourceItem*) i)->lineJump() : 0;
  TraceFunction* f = lc ? lc->call()->called() : 0;
  TraceLine* line = lj ? lj->lineTo() : 0;

  if (f) {
    QString name = f->name();
    if ((int)name.length()>Configuration::maxSymbolLength())
      name = name.left(Configuration::maxSymbolLength()) + "...";
    popup.insertItem(i18n("Go to '%1'").arg(name), 93);
    popup.insertSeparator();
  }
  else if (line) {
    popup.insertItem(i18n("Go to Line %1").arg(line->name()), 93);
    popup.insertSeparator();
  }

  if ((c == 1) || (c == 2)) {
    addCostMenu(&popup);
    popup.insertSeparator();
  }
  addGoMenu(&popup);

  int r = popup.exec(p);
  if (r == 93) {
    if (f) activated(f);
    if (line) activated(line);
  }
}
Exemplo n.º 4
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);
}
Exemplo n.º 5
0
void CostTypeView::context(QListViewItem* i, const QPoint & p, int)
{
  QPopupMenu popup;

  TraceCostType* ct = i ? ((CostTypeItem*) i)->costType() : 0;

  if (ct)
    popup.insertItem(i18n("Set Secondary Event Type"), 99);
  if (_costType2)
    popup.insertItem(i18n("Remove Secondary Event Type"), 98);
  if (popup.count()>0)
    popup.insertSeparator();

  if (ct && !ct->isReal()) {
      popup.insertItem(i18n("Edit Long Name"), 93);
      popup.insertItem(i18n("Edit Short Name"), 94);
      popup.insertItem(i18n("Edit Formula"), 95);
      popup.insertItem(i18n("Remove"), 96);
      popup.insertSeparator();
  }

  addGoMenu(&popup);

  popup.insertSeparator();
  popup.insertItem(i18n("New Cost Type ..."), 97);

  int r = popup.exec(p);
  if (r == 98) selectedCostType2(0);
  else if (r == 99) selectedCostType2(ct);
  else if (r == 93) i->startRename(0);
  else if (r == 94) i->startRename(3);
  else if (r == 95) i->startRename(5);
  else if (r == 96) {

    // search for a previous type 
    TraceCostType* prev = 0, *ct = 0;
    TraceCostMapping* m = _data->mapping();
    for (int i=0;i<m->realCount();i++) {
	ct = m->realType(i);
	if (ct) prev = ct;
    }
    for (int i=0;i<m->virtualCount();i++) {
	ct = m->virtualType(i);
	if (ct == _costType) break;
	if (ct) prev = ct;
    }

    if (_data->mapping()->remove(ct)) {
      // select previous cost type
      selectedCostType(prev);
      if (_costType2 == ct)
	selectedCostType2(prev);
      refresh();
    }
  }
  else if (r == 97) {
    int i = 1;
    while(1) {
      if (!TraceCostType::knownVirtualType(i18n("New%1").arg(i)))
	break;
      i++;
    }
    // add same new cost type to this mapping and to known types
    QString shortName = i18n("New%1").arg(i);
    QString longName  = i18n("New Cost Type %1").arg(i);
    TraceCostType::add(new TraceCostType(shortName, longName, "0"));
    _data->mapping()->add(new TraceCostType(shortName, longName, "0"));
    refresh();
  }
}