Skip to content

Commit

Permalink
gui: Fix column auto resize in variable list when filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
calc84maniac committed Aug 25, 2024
1 parent 6cec423 commit 15a9a98
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion gui/qt/vartablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,12 @@ void VarTableModel::refresh() {
newInsertEnd = std::find_if_not(newIter, newVars.end(), [=](const calc_var_t &var) { return varLess(var, oldIter->info); });
}
if (newIter != newInsertEnd) {
beginInsertRows(QModelIndex(), row, row + (newInsertEnd - newIter - 1));
int lastRow = row + (newInsertEnd - newIter - 1);
beginInsertRows(QModelIndex(), row, lastRow);
oldIter = vars.insert(oldIter, newIter, newInsertEnd);
endInsertRows();
// Handle header resize because it doesn't care about inserted rows
emit dataChanged(index(row, 0), index(lastRow, VAR_NUM_COLS - 1), { Qt::SizeHintRole });
oldIter += (newInsertEnd - newIter);
newIter = newInsertEnd;
} else {
Expand Down Expand Up @@ -294,6 +297,11 @@ void VarTableSortFilterModel::setTypeFilter(int type) {
if (type != typeFilter) {
typeFilter = type;
invalidateFilter();
// Handle header resize because it doesn't care about inserted rows
int rows = rowCount(), cols = columnCount();
if (rows > 0 && cols > 0) {
emit dataChanged(index(0, 0), index(rows - 1, cols - 1), { Qt::SizeHintRole });
}
}
}

Expand Down

0 comments on commit 15a9a98

Please sign in to comment.