Example #1
0
void CoverageView::refresh()
{
    clear();
    setColumnWidth(0, 50);
    if (!_showCallers)
	setColumnWidth(1, 50);

    if (!_data || !_activeItem) return;

    TraceItem::CostType t = _activeItem->type();
    TraceFunction* f = 0;
    if (t == TraceItem::Function) f = (TraceFunction*) _activeItem;
    if (t == TraceItem::FunctionCycle) f = (TraceFunction*) _activeItem;
    if (!f) return;

    TraceFunction* ff;
    TraceFunctionList l;

    _hc.clear(Configuration::maxListCount());
    SubCost realSum = f->inclusive()->subCost(_costType);

    if (_showCallers)
      l = Coverage::coverage(f, Coverage::Caller, _costType);
    else
      l = Coverage::coverage(f, Coverage::Called, _costType);

    for (ff=l.first();ff;ff=l.next()) {
      Coverage* c = (Coverage*) ff->assoziation(Coverage::Rtti);
      if (c && (c->inclusive()>0.0))
	_hc.addCost(ff, SubCost(realSum * c->inclusive()));
    }

    for(int i=0;i<_hc.realCount();i++) {
      ff = (TraceFunction*) _hc[i];
      Coverage* c = (Coverage*) ff->assoziation(Coverage::Rtti);
      if (_showCallers)
	new CallerCoverageItem(this, c, f, _costType, _groupType);
      else
	new CalleeCoverageItem(this, c, f, _costType, _groupType);
    }
    if (_hc.hasMore()) {
      // a placeholder for all the functions skipped ...
      ff = (TraceFunction*) _hc[_hc.maxSize()-1];
      Coverage* c = (Coverage*) ff->assoziation(Coverage::Rtti);
      if (_showCallers)
	new CallerCoverageItem(this, _hc.count() - _hc.maxSize(),
			       c, f, _costType, _groupType);
      else
	new CalleeCoverageItem(this, _hc.count() - _hc.maxSize(),
			       c, f, _costType, _groupType);
    }
}