QSize PipelineTreeWidget::sizeHint() const {
        int height = 0;

        // First of all, sum up the heights of top-level items and their children
        for (int i = 0; i < model()->rowCount(); i++) {
            QModelIndex index = model()->index(i, 0);
            height += sizeHintForRow(i);

            if (model()->hasChildren(index)) {
                for (int j = 0; j < model()->rowCount(index); ++j) {
                    QModelIndex cIndex = index.child(j, 0);
                    height += sizeHintForIndex(cIndex).height();

                    if (model()->hasChildren(cIndex)) {
                        height += model()->rowCount(cIndex) * sizeHintForIndex(cIndex.child(0, 0)).height();
                    }
                }                
            }
        }

        // Next, add the heights of the horizontal scrollbar, header, and frame
        height += horizontalScrollBar()->sizeHint().height();
        height += 2 * header()->sizeHint().height();
        height += 2 * frameWidth();

        return QSize(QTreeView::sizeHint().width(), std::max(height, 200));
    }
unsigned int KateArgumentHintTree::rowHeight(const QModelIndex& index) const {
  uint max = sizeHintForIndex(index).height();

  for(int a = 0; a < index.model()->columnCount(index.parent()); ++a) {
    QModelIndex i = index.sibling(index.row(), a);
    uint cSize = sizeHintForIndex(i).height();
    if(cSize > max)
      max = cSize;
  }
  return max;
}
int FocusedTreeView::sizeHintForColumn(int column) const {
    QModelIndex i = indexAt(QPoint(0, 0));
    if(i.isValid()) {
        QSize hint = sizeHintForIndex(i);
        int maxWidth = hint.width();
        if(hint.height()) {
            //Also consider one item above, because else we can get problems with
            //the vertical scroll-bar
            for(int a = -1; a < (height() / hint.height())+1; ++a) {
                QModelIndex current = i.sibling(i.row()+a, column);
                QSize tempHint = sizeHintForIndex(current);
                if(tempHint.width() > maxWidth)
                    maxWidth = tempHint.width();
            }
        }
        return maxWidth;
    }
    return columnWidth(column);
}
int KateCompletionTree::columnTextViewportPosition(int column) const
{
    int ret = columnViewportPosition(column);
    QModelIndex i = model()->index(0, column, QModelIndex());
    QModelIndex base = model()->index(0, 0, QModelIndex());

    //If it's just a group header, use the first child
    if (base.isValid() && model()->rowCount(base)) {
        i = base.child(0, column);
    }

    if (i.isValid()) {
        QIcon icon = i.data(Qt::DecorationRole).value<QIcon>();
        if (!icon.isNull()) {
            ret += icon.actualSize(sizeHintForIndex(i)).width();
        }
    }
    return ret;
}