Skip to content

Commit

Permalink
Apply Thomas Frank's fixes for issue #6774
Browse files Browse the repository at this point in the history
  • Loading branch information
RockinRoel committed Mar 13, 2020
1 parent 9e5a4a9 commit a339785
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/Wt/WTreeView.C
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ WTreeViewNode::WTreeViewNode(WTreeView *view, const WModelIndex& index,
nodeWidget_->bindEmpty("no-expand");
nodeWidget_->bindEmpty("col0");

int selfHeight = 0;
const int selfHeight = index_ == view_->rootIndex() ? 0 : 1;
bool needLoad = view_->isExpanded(index_);

if (index_ != view_->rootIndex() && !needLoad)
Expand All @@ -360,8 +360,6 @@ WTreeViewNode::WTreeViewNode(WTreeView *view, const WModelIndex& index,
updateGraphics(isLast, !view_->model()->hasChildren(index_));
insertColumns(0, view_->columnCount());

selfHeight = 1;

if (view_->selectionBehavior() == SelectRows && view_->isSelected(index_))
renderSelected(true, 0);
}
Expand Down Expand Up @@ -2349,8 +2347,11 @@ int WTreeView::getIndexRow(const WModelIndex& child,
return result;
}

return result + getIndexRow(parent, ancestor,
lowerBound - result, upperBound - result);
if (parent != ancestor)
return result + 1 + getIndexRow(parent, ancestor,
lowerBound - result, upperBound - result);
else
return result;
}
}

Expand Down Expand Up @@ -2895,18 +2896,18 @@ int WTreeView::pageSize() const

void WTreeView::scrollTo(const WModelIndex& index, ScrollHint hint)
{
int row = getIndexRow(index, rootIndex(), 0,
std::numeric_limits<int>::max()) + 1;
const int row = getIndexRow(index, rootIndex(), 0,
std::numeric_limits<int>::max());

WApplication *app = WApplication::instance();

if (app->environment().ajax()) {
if (viewportHeight_ != UNKNOWN_VIEWPORT_HEIGHT) {
if (hint == EnsureVisible) {
if (viewportTop_ + viewportHeight_ < row)
hint = PositionAtTop;
else if (row < viewportTop_)
hint = PositionAtBottom;
if (viewportTop_ + viewportHeight_ <= row)
hint = PositionAtBottom;
else if (row < viewportTop_)
hint = PositionAtTop;
}

switch (hint) {
Expand Down

0 comments on commit a339785

Please sign in to comment.