Skip to content

Commit cb33e94

Browse files
committed
Data Browser: correctly count the number of visible rows
- Start counting by 1, so rowCount() matches the row_bottom. - Use viewport, so we don't have to adjust for the scrollbar. - Discard from the count rows partially visible (more than a half hidden) - Do not update the recordset label in refresh, since it returns a bad number and seems unnecessary. See issues #3180 and #3176.
1 parent 64fbf8f commit cb33e94

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/ExtendedTableWidget.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,13 +1033,13 @@ int ExtendedTableWidget::numVisibleRows() const
10331033
return 0;
10341034

10351035
// Get the row numbers of the rows currently visible at the top and the bottom of the widget
1036-
int row_top = rowAt(0) == -1 ? 0 : rowAt(0);
1037-
int row_bottom = verticalHeader()->visualIndexAt(height()) == -1 ? model()->rowCount() : (verticalHeader()->visualIndexAt(height()) - 1);
1038-
if(horizontalScrollBar()->isVisible()) // Assume the scrollbar covers about one row
1039-
row_bottom--;
1036+
int row_top = rowAt(0) == -1 ? 0 : verticalHeader()->visualIndexAt(0) + 1;
1037+
// Adjust the height so we don't count rows visible only less than a half of the default height
1038+
int adjusted_height = viewport()->height() - (verticalHeader()->defaultSectionSize() / 2);
1039+
int row_bottom = verticalHeader()->visualIndexAt(adjusted_height) == -1 ? model()->rowCount() : (verticalHeader()->visualIndexAt(adjusted_height) + 1);
10401040

10411041
// Calculate the number of visible rows
1042-
return row_bottom - row_top;
1042+
return row_bottom - row_top + 1;
10431043
}
10441044

10451045
std::unordered_set<size_t> ExtendedTableWidget::selectedCols() const

src/TableBrowser.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,6 @@ void TableBrowser::refresh()
553553
// Build query and apply settings
554554
applyModelSettings(storedData, buildQuery(storedData, tablename));
555555
applyViewportSettings(storedData, tablename);
556-
updateRecordsetLabel();
557556
emit updatePlot(ui->dataTable, m_model, &m_settings[tablename], true);
558557
}
559558

0 commit comments

Comments
 (0)