Skip to content

Commit a337490

Browse files
committedApr 22, 2023
New entries should be added at the top of date groups
1 parent 9e760fc commit a337490

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed
 

‎src/gui/history/qgshistoryentrymodel.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,10 +299,9 @@ void QgsHistoryEntryRootNode::addEntryNode( const QgsHistoryEntry &entry, QgsHis
299299
if ( model )
300300
{
301301
const QModelIndex dateNodeIndex = model->node2index( targetDateNode );
302-
const int previousCount = model->rowCount( dateNodeIndex );
303-
model->beginInsertRows( dateNodeIndex, previousCount, previousCount );
302+
model->beginInsertRows( dateNodeIndex, 0, 0 );
304303
}
305-
targetDateNode->addChild( node );
304+
targetDateNode->insertChild( 0, node );
306305
if ( model )
307306
{
308307
model->endInsertRows();

‎tests/src/python/test_qgshistoryproviderregistry.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -398,11 +398,11 @@ def test_model(self):
398398
self.assertEqual(model.data(date_group_1_index), 'Today')
399399

400400
self.assertEqual(model.rowCount(date_group_1_index), 3)
401-
entry_1_index = model.index(0, 0, date_group_1_index)
401+
entry_1_index = model.index(2, 0, date_group_1_index)
402402
self.assertEqual(model.data(entry_1_index), {'a': 1})
403403
entry_2_index = model.index(1, 0, date_group_1_index)
404404
self.assertEqual(model.data(entry_2_index), {'a': 2})
405-
entry_3_index = model.index(2, 0, date_group_1_index)
405+
entry_3_index = model.index(0, 0, date_group_1_index)
406406
self.assertEqual(model.data(entry_3_index), {'a': 3})
407407

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

427427
self.assertEqual(model.rowCount(yesterday_index), 2)
428428
self.assertEqual(model.data(entry_4_index), {'a': 4})
429-
entry_5_index = model.index(1, 0, yesterday_index)
429+
entry_5_index = model.index(0, 0, yesterday_index)
430430
self.assertEqual(model.data(entry_5_index), {'a': 5})
431+
self.assertEqual(model.data(entry_4_index), {'a': 4})
431432

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

0 commit comments

Comments
 (0)
Please sign in to comment.