28 #include <QHeaderView>
29 #include <QWheelEvent>
38 for (
int i = 0; i < topLevelItemCount(); ++i)
40 sz += calcHeight(topLevelItem(i));
42 if (!isHeaderHidden())
44 sz += header()->height();
51 this->wheelTicksPerScrollTick = wheelTicksPerScrollTick;
56 if (event->orientation() == Qt::Horizontal)
58 if (horizontalScrollMode() == QAbstractItemView::ScrollPerPixel)
60 hdelta +=
event->delta();
61 horizontalScrollBar()->setValue(horizontalScrollBar()->
value() - (hdelta / wheelTicksPerScrollTick));
62 hdelta = hdelta % wheelTicksPerScrollTick;
66 QTreeWidget::wheelEvent(event);
71 if (verticalScrollMode() == QAbstractItemView::ScrollPerPixel)
73 vdelta +=
event->delta();
74 verticalScrollBar()->setValue(verticalScrollBar()->
value() - (vdelta / wheelTicksPerScrollTick));
75 vdelta = hdelta % wheelTicksPerScrollTick;
79 QTreeWidget::wheelEvent(event);
87 setSizePolicy(sizePolicy().horizontalPolicy(), QSizePolicy::Fixed);
96 connect(
this, SIGNAL(collapsed(QModelIndex)),
this, SLOT(
expand()));
97 connect(
this, SIGNAL(expanded(QModelIndex)),
this, SLOT(
expand()));
101 disconnect(
this, SIGNAL(collapsed(QModelIndex)),
this, SLOT(
expand()));
102 disconnect(
this, SIGNAL(expanded(QModelIndex)),
this, SLOT(
expand()));
106 int EnhancedTreeWidget::calcHeight(QTreeWidgetItem* it)
113 for (
int i = 0; i < it->columnCount(); ++i)
115 sz =
std::max(sz, rowHeight(indexFromItem(it, i)));
117 if (it->isExpanded())
119 for (
int i = 0; i < it->childCount(); ++i)
121 sz += calcHeight(it->child(i));