コード例 #1
0
ファイル: sourceview.cpp プロジェクト: serghei/kde-kdesdk
void SourceView::doUpdate(int changeType)
{
  // Special case ?
  if (changeType == selectedItemChanged) {

      if (!_selectedItem) {
	  clearSelection();
	  return;
      }

      TraceLine* sLine = 0;
      if (_selectedItem->type() == TraceItem::Line)
	  sLine = (TraceLine*) _selectedItem;
      if (_selectedItem->type() == TraceItem::Instr)
	  sLine = ((TraceInstr*)_selectedItem)->line();

      SourceItem* si = (SourceItem*)QListView::selectedItem();
      if (si) {
	  if (si->line() == sLine) return;
	  if (si->lineCall() &&
	      (si->lineCall()->call()->called() == _selectedItem)) return;
      }

      QListViewItem *item, *item2;
      for (item = firstChild();item;item = item->nextSibling()) {
	  si = (SourceItem*)item;
	  if (si->line() == sLine) {
	      ensureItemVisible(item);
              _inSelectionUpdate = true;
	      setCurrentItem(item);
              _inSelectionUpdate = false;
	      break;
	  }
	  item2 = item->firstChild();
	  for (;item2;item2 = item2->nextSibling()) {
	      si = (SourceItem*)item2;
	      if (!si->lineCall()) continue;
	      if (si->lineCall()->call()->called() == _selectedItem) {
		  ensureItemVisible(item2);
                  _inSelectionUpdate = true;
		  setCurrentItem(item2);
                  _inSelectionUpdate = false;
		  break;
	      }
	  }
	  if (item2) break;
      }
      return;
  }

  if (changeType == groupTypeChanged) {
    QListViewItem *item, *item2;
    for (item = firstChild();item;item = item->nextSibling())
      for (item2 = item->firstChild();item2;item2 = item2->nextSibling())
        ((SourceItem*)item2)->updateGroup();
  }

  refresh();
}
コード例 #2
0
ファイル: sourceview.cpp プロジェクト: serghei/kde-kdesdk
void SourceView::updateSourceItems()
{
    setColumnWidth(1, 50);
    setColumnWidth(2, _costType2 ? 50:0);
    // Allow resizing of column 2
    setColumnWidthMode(2, QListView::Maximum);
    
    if (_costType)
      setColumnText(1, _costType->name());
    if (_costType2)
      setColumnText(2, _costType2->name());

    SourceItem* si;
    QListViewItem* item  = firstChild();
    for (;item;item = item->nextSibling()) {
	si = (SourceItem*)item;
	TraceLine* l = si->line();
	if (!l) continue;

	si->updateCost();

	QListViewItem *next, *i  = si->firstChild();
	for (;i;i = next) {
	    next = i->nextSibling();
	    ((SourceItem*)i)->updateCost();
	}
    }

    if (!_costType2) {
      setColumnWidthMode(2, QListView::Manual);
      setColumnWidth(2, 0);
    }
}