Autoresize table subview columns (bug #6939)

Use the contents of the first 500 records, clamp the width to [100, 300]
pull/3228/head
Alexei Kotov 2 years ago
parent 5b9acd0bb9
commit aee8150d65

@ -5,6 +5,7 @@
Bug #5057: Weapon swing sound plays at same pitch whether it hits or misses
Bug #5129: Stuttering animation on Centurion Archer
Bug #5977: Fatigueless NPCs' corpse underwater changes animation on game load
Bug #6939: OpenMW-CS: ID columns are too short
Feature #6945: Support S3TC-compressed and BGR/BGRA NiPixelData
0.48.0

@ -96,3 +96,12 @@ CSMWorld::ColumnBase::Display CSVWorld::DragRecordTable::getIndexDisplayType(con
}
return CSMWorld::ColumnBase::Display_None;
}
int CSVWorld::DragRecordTable::sizeHintForColumn(int column) const
{
// Prevent the column width from getting too long or too short
constexpr int minWidth = 100;
constexpr int maxWidth = 300;
int width = QTableView::sizeHintForColumn(column);
return std::clamp(width, minWidth, maxWidth);
}

@ -44,6 +44,8 @@ namespace CSVWorld
void dropEvent(QDropEvent *event) override;
int sizeHintForColumn(int column) const override;
private:
CSMWorld::ColumnBase::Display getIndexDisplayType(const QModelIndex &index) const;

@ -263,6 +263,10 @@ CSVWorld::Table::Table (const CSMWorld::UniversalId& id,
setModel (mProxyModel);
horizontalHeader()->setSectionResizeMode (QHeaderView::Interactive);
// The number is arbitrary but autoresize would be way too slow otherwise.
constexpr int autoResizePrecision = 500;
horizontalHeader()->setResizeContentsPrecision(autoResizePrecision);
resizeColumnsToContents();
verticalHeader()->hide();
setSelectionBehavior (QAbstractItemView::SelectRows);
setSelectionMode (QAbstractItemView::ExtendedSelection);

Loading…
Cancel
Save