Skip to content

Commit

Permalink
plugins/TableView: Improve data table vertical scrolling
Browse files Browse the repository at this point in the history
Make the verticall scrolling of table view more pleasant to the eyes by:

- resizing columns of visible rows only

- ensuring that the first displayed column in the table view stay the
  same after resizing column to contents.
  • Loading branch information
anlambert committed Nov 22, 2024
1 parent c112776 commit 167e92c
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions plugins/view/TableView/NavigableTableView.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2019-2021 The Talipot developers
* Copyright (C) 2019-2024 The Talipot developers
*
* Talipot is a fork of Tulip, created by David Auber
* and the Tulip development Team from LaBRI, University of Bordeaux
Expand Down Expand Up @@ -76,10 +76,8 @@ int NavigableTableView::sizeHintForColumn(int col) const {

int hint = 0;

if (bottom == -1 || (bottom + 10) >= model()->rowCount()) {
if (bottom < 0) {
bottom = model()->rowCount() - 1;
} else {
bottom += 10;
}

for (int row = top; row <= bottom; ++row) {
Expand Down Expand Up @@ -111,10 +109,8 @@ void NavigableTableView::resizeTableRows() {
int top = qMax(0, verticalHeader()->visualIndexAt(0));
int bottom = verticalHeader()->visualIndexAt(viewport()->height());

if (bottom == -1 || (bottom + 10) >= model()->rowCount()) {
if (bottom < 0) {
bottom = model()->rowCount() - 1;
} else {
bottom += 10;
}

int left = qMax(0, horizontalHeader()->visualIndexAt(0));
Expand All @@ -131,4 +127,6 @@ void NavigableTableView::resizeTableRows() {
for (int i = left; i <= right; ++i) {
resizeColumnToContents(i);
}

scrollContentsBy(-columnViewportPosition(left), 0);
}

0 comments on commit 167e92c

Please sign in to comment.