From a7f493366ac78cfdb426dd77ad272ae9d360da49 Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Fri, 15 Mar 2024 15:35:17 -0400 Subject: Scroll back after creating new entry and saving. --- mapman/src/groupview.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'mapman/src') diff --git a/mapman/src/groupview.cpp b/mapman/src/groupview.cpp index 721917f..136607b 100644 --- a/mapman/src/groupview.cpp +++ b/mapman/src/groupview.cpp @@ -144,6 +144,7 @@ void group_view::add_group() }; l->new_group(g); refresh_list(); + tv->scrollTo(mf->index(mf->rowCount() - 1, 0)); } void group_view::rem_group() @@ -209,6 +210,7 @@ void group_view::refresh_list() m->setHorizontalHeaderLabels({"Title", "Author(s)", "Dimension", "id"}); tv->setColumnHidden(3, true); auto gids = l->groups(); + auto idx = QModelIndex(); for (auto gid : gids) { map_group_t g = l->get_group(gid); @@ -219,7 +221,12 @@ void group_view::refresh_list() i->setData(QVariant((qlonglong)gid), Qt::ItemDataRole::DisplayRole); m->appendRow({t, a, d, i}); if (gid == curgid) - tv->setCurrentIndex(t->index()); + idx = mf->mapFromSource(t->index()); + } + if (idx.isValid()) + { + tv->setCurrentIndex(idx); + tv->scrollTo(idx); } tv->resizeColumnsToContents(); } -- cgit v1.2.3