diff --git a/CHANGELOG.md b/CHANGELOG.md index aacb98999d..302fe9a2e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/apps/opencs/view/world/dragrecordtable.cpp b/apps/opencs/view/world/dragrecordtable.cpp index 58041af9fc..8466e88b17 100644 --- a/apps/opencs/view/world/dragrecordtable.cpp +++ b/apps/opencs/view/world/dragrecordtable.cpp @@ -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); +} diff --git a/apps/opencs/view/world/dragrecordtable.hpp b/apps/opencs/view/world/dragrecordtable.hpp index 4b986f759a..b8a108b143 100644 --- a/apps/opencs/view/world/dragrecordtable.hpp +++ b/apps/opencs/view/world/dragrecordtable.hpp @@ -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; diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index 8e2bc4250b..6a89d08a73 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -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);