mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Mobile: ensure the sort order is always set
This shouldn't be necessary every time we replace the sort model, but it can't hurt, either (famous last words?). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
8b0f4e65d3
commit
2c9bf775b7
1 changed files with 9 additions and 6 deletions
|
@ -17,8 +17,6 @@
|
||||||
CollapsedDiveListSortModel::CollapsedDiveListSortModel()
|
CollapsedDiveListSortModel::CollapsedDiveListSortModel()
|
||||||
{
|
{
|
||||||
setSourceModel(DiveListSortModel::instance());
|
setSourceModel(DiveListSortModel::instance());
|
||||||
setDynamicSortFilter(true);
|
|
||||||
updateFilterState();
|
|
||||||
// make sure that we after changes to the underlying model (and therefore the dive list
|
// make sure that we after changes to the underlying model (and therefore the dive list
|
||||||
// we update the filter state
|
// we update the filter state
|
||||||
connect(DiveListModel::instance(), &DiveListModel::rowsInserted, this, &CollapsedDiveListSortModel::updateFilterState);
|
connect(DiveListModel::instance(), &DiveListModel::rowsInserted, this, &CollapsedDiveListSortModel::updateFilterState);
|
||||||
|
@ -35,6 +33,10 @@ CollapsedDiveListSortModel *CollapsedDiveListSortModel::instance()
|
||||||
void CollapsedDiveListSortModel::setSourceModel(QAbstractItemModel *sourceModel)
|
void CollapsedDiveListSortModel::setSourceModel(QAbstractItemModel *sourceModel)
|
||||||
{
|
{
|
||||||
QSortFilterProxyModel::setSourceModel(sourceModel);
|
QSortFilterProxyModel::setSourceModel(sourceModel);
|
||||||
|
// make sure we sort descending and have the filters correct
|
||||||
|
setDynamicSortFilter(true);
|
||||||
|
setSortRole(DiveListModel::DiveDateRole);
|
||||||
|
sort(0, Qt::DescendingOrder);
|
||||||
updateFilterState();
|
updateFilterState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,10 +177,6 @@ bool CollapsedDiveListSortModel::filterAcceptsRow(int source_row, const QModelIn
|
||||||
DiveListSortModel::DiveListSortModel()
|
DiveListSortModel::DiveListSortModel()
|
||||||
{
|
{
|
||||||
setSourceModel(DiveListModel::instance());
|
setSourceModel(DiveListModel::instance());
|
||||||
setDynamicSortFilter(true);
|
|
||||||
setSortRole(DiveListModel::DiveDateRole);
|
|
||||||
sort(0, Qt::DescendingOrder);
|
|
||||||
updateFilterState();
|
|
||||||
LOG_STP("run_ui diveListModel sorted");
|
LOG_STP("run_ui diveListModel sorted");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,6 +210,11 @@ void DiveListSortModel::updateFilterState()
|
||||||
void DiveListSortModel::setSourceModel(QAbstractItemModel *sourceModel)
|
void DiveListSortModel::setSourceModel(QAbstractItemModel *sourceModel)
|
||||||
{
|
{
|
||||||
QSortFilterProxyModel::setSourceModel(sourceModel);
|
QSortFilterProxyModel::setSourceModel(sourceModel);
|
||||||
|
// make sure we sort descending and have the filters correct
|
||||||
|
setDynamicSortFilter(true);
|
||||||
|
setSortRole(DiveListModel::DiveDateRole);
|
||||||
|
sort(0, Qt::DescendingOrder);
|
||||||
|
updateFilterState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiveListSortModel::setFilter(QString f)
|
void DiveListSortModel::setFilter(QString f)
|
||||||
|
|
Loading…
Add table
Reference in a new issue