Skip to content

Commit

Permalink
New entries should be added at the top of date groups
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Apr 22, 2023
1 parent 9e760fc commit a337490
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
5 changes: 2 additions & 3 deletions src/gui/history/qgshistoryentrymodel.cpp
Expand Up @@ -299,10 +299,9 @@ void QgsHistoryEntryRootNode::addEntryNode( const QgsHistoryEntry &entry, QgsHis
if ( model )
{
const QModelIndex dateNodeIndex = model->node2index( targetDateNode );
const int previousCount = model->rowCount( dateNodeIndex );
model->beginInsertRows( dateNodeIndex, previousCount, previousCount );
model->beginInsertRows( dateNodeIndex, 0, 0 );
}
targetDateNode->addChild( node );
targetDateNode->insertChild( 0, node );
if ( model )
{
model->endInsertRows();
Expand Down
7 changes: 4 additions & 3 deletions tests/src/python/test_qgshistoryproviderregistry.py
Expand Up @@ -398,11 +398,11 @@ def test_model(self):
self.assertEqual(model.data(date_group_1_index), 'Today')

self.assertEqual(model.rowCount(date_group_1_index), 3)
entry_1_index = model.index(0, 0, date_group_1_index)
entry_1_index = model.index(2, 0, date_group_1_index)
self.assertEqual(model.data(entry_1_index), {'a': 1})
entry_2_index = model.index(1, 0, date_group_1_index)
self.assertEqual(model.data(entry_2_index), {'a': 2})
entry_3_index = model.index(2, 0, date_group_1_index)
entry_3_index = model.index(0, 0, date_group_1_index)
self.assertEqual(model.data(entry_3_index), {'a': 3})

# an entry from yesterday
Expand All @@ -426,8 +426,9 @@ def test_model(self):

self.assertEqual(model.rowCount(yesterday_index), 2)
self.assertEqual(model.data(entry_4_index), {'a': 4})
entry_5_index = model.index(1, 0, yesterday_index)
entry_5_index = model.index(0, 0, yesterday_index)
self.assertEqual(model.data(entry_5_index), {'a': 5})
self.assertEqual(model.data(entry_4_index), {'a': 4})

# an entry from an earlier month
earlier_entry = QgsHistoryEntry(provider.id(), QDateTime(QDate(2020, 6, 3), QTime(12, 13, 14)), {'a': 6})
Expand Down

0 comments on commit a337490

Please sign in to comment.