コード例 #1
0
ファイル: diagram.cpp プロジェクト: Beachy13/doxygen
void TreeDiagram::computeLayout()
{
  QListIterator<DiagramRow> it(*this);
  DiagramRow *row;
  for (;(row=it.current()) && row->count()<maxTreeWidth;++it) {}
  if (row)
  {
    //printf("computeLayout() list row at %d\n",row->number());
    QListIterator<DiagramItem> rit(*row);
    DiagramItem *di;
    DiagramItem *opi=0;
    int delta=0;
    bool first=TRUE;
    for (;(di=rit.current());++rit)
    {
      DiagramItem *pi=di->parentItem();
      if (pi==opi && !first) { delta-=gridWidth; }
      first = pi!=opi;
      opi=pi;
      di->move(delta,0); // collapse all items in the same
                         // list (except the first)
      di->putInList();
    }
  }

  // re-organize the diagram items
  DiagramItem *root=getFirst()->getFirst();
  while (layoutTree(root,0)) { }

  // move first items of the lists
  if (row)
  {
    QListIterator<DiagramItem> rit(*row);
    DiagramItem *di;
    while ((di=rit.current()))
    {
      DiagramItem *pi=di->parentItem();
      if (pi->getChildren()->count()>1)
      {
        di->move(gridWidth,0);
        while (di && di->parentItem()==pi) { ++rit; di=rit.current(); }
      }
      else
      {
        ++rit;
      }
    }
  }
}