From ec7d85835fb26ee9c0a9c780907441c312d7ac3f Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Mon, 30 Jul 2018 09:20:25 +0200 Subject: Dive list: implement proper Qt-model semantics for DiveTripModel Previously, each dive-list modifying function would lead to a full model reset. Instead, implement proper Qt-model semantics using beginInsertRows()/endInsertRows(), beginRemoveRows()/ endRemoveRows(), dataChange(). To do so, a DiveListNotifer singleton is generatated, which broadcasts all changes to the dive-list. Signals are sent by the commands and received by the DiveTripModel. Signals are batched by dive-trip. This seems to be an adequate compromise for the two kinds of list-views (tree and list). In the common usecase mostly dives of a single trip are affected. Thus, batching of dives is performed in two positions: - At command-level to batch by trip - In DiveTripModel to feed batches of contiguous elements to Qt's begin*/end*-functions. This is conceptually simple, but rather complex code. To avoid repetition of complex loops, the batching is implemented in templated-functions, which are passed lambda-functions, which are called for each batch. Signed-off-by: Berthold Stoeger --- desktop-widgets/tab-widgets/maintab.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'desktop-widgets/tab-widgets') diff --git a/desktop-widgets/tab-widgets/maintab.cpp b/desktop-widgets/tab-widgets/maintab.cpp index 46217af54..1f4fbc518 100644 --- a/desktop-widgets/tab-widgets/maintab.cpp +++ b/desktop-widgets/tab-widgets/maintab.cpp @@ -809,7 +809,6 @@ void MainTab::acceptChanges() acceptingEdit = false; ui.editDiveSiteButton->setEnabled(!ui.location->text().isEmpty()); emit addDiveFinished(); - MainWindow::instance()->dive_list()->reload(DiveTripModel::CURRENT, true); DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::NOTHING); int scrolledBy = MainWindow::instance()->dive_list()->verticalScrollBar()->sliderPosition(); MainWindow::instance()->dive_list()->verticalScrollBar()->setSliderPosition(scrolledBy); -- cgit v1.2.3-70-g09d2