1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-04-02 16:20:23 +00:00

Fix table being sorted twice (at least it appeared that way according to the sample profiler)

- Quoting Qt-4.8: "Note: . Setting the property to true with setSortingEnabled() immediately triggers a call to sortByColumn() with the current sort section and order."
This commit is contained in:
cc9cii 2015-12-05 20:38:09 +11:00
parent f029682057
commit 77394fce99

View File

@ -280,12 +280,6 @@ CSVWorld::Table::Table (const CSMWorld::UniversalId& id,
setSelectionBehavior (QAbstractItemView::SelectRows); setSelectionBehavior (QAbstractItemView::SelectRows);
setSelectionMode (QAbstractItemView::ExtendedSelection); setSelectionMode (QAbstractItemView::ExtendedSelection);
setSortingEnabled (sorting);
if (sorting)
{
sortByColumn (mModel->findColumnIndex(CSMWorld::Columns::ColumnId_Id), Qt::AscendingOrder);
}
int columns = mModel->columnCount(); int columns = mModel->columnCount();
for (int i=0; i<columns; ++i) for (int i=0; i<columns; ++i)
{ {
@ -306,6 +300,13 @@ CSVWorld::Table::Table (const CSMWorld::UniversalId& id,
hideColumn (i); hideColumn (i);
} }
if (sorting)
{
// FIXME: some tables (e.g. CellRef) have this column hidden, which makes it confusing
sortByColumn (mModel->findColumnIndex(CSMWorld::Columns::ColumnId_Id), Qt::AscendingOrder);
}
setSortingEnabled (sorting);
mEditAction = new QAction (tr ("Edit Record"), this); mEditAction = new QAction (tr ("Edit Record"), this);
connect (mEditAction, SIGNAL (triggered()), this, SLOT (editRecord())); connect (mEditAction, SIGNAL (triggered()), this, SLOT (editRecord()));
addAction (mEditAction); addAction (mEditAction);