From e99c4c90592c9dba17d5cbb9a99d0bf458fb53d2 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Tue, 12 Mar 2019 17:28:43 +0100 Subject: Dive site: introduce proxy model DiveSiteSortedModel The LocationInformationModel used to sort its entries and was completely rebuilt after every change. This makes it rather complex to support incremental changes. Instead, keep LocationInformationModel sorted by UUID so that indexes are consistent with indices in the core dive site table. Implement sorting by other columns than name and enable sorting in the dive site view. Finally, don't cache the list of dive site names for the mobile app, since that would also need some rather convoluted methods of keeping the list up to date. Calculate it on the fly. Signed-off-by: Berthold Stoeger --- desktop-widgets/tab-widgets/TabDiveSite.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'desktop-widgets/tab-widgets/TabDiveSite.cpp') diff --git a/desktop-widgets/tab-widgets/TabDiveSite.cpp b/desktop-widgets/tab-widgets/TabDiveSite.cpp index 81736bc77..5e2831c93 100644 --- a/desktop-widgets/tab-widgets/TabDiveSite.cpp +++ b/desktop-widgets/tab-widgets/TabDiveSite.cpp @@ -8,7 +8,10 @@ TabDiveSite::TabDiveSite(QWidget *parent) : TabBase(parent) { ui.setupUi(this); ui.diveSites->setTitle(tr("Dive sites")); - ui.diveSites->setModel(LocationInformationModel::instance()); + ui.diveSites->setModel(&model); + // Default: sort by name + ui.diveSites->view()->sortByColumn(LocationInformationModel::NAME, Qt::AscendingOrder); + ui.diveSites->view()->setSortingEnabled(true); // Show only the first few columns for (int i = LocationInformationModel::COORDS; i < LocationInformationModel::COLUMNS; ++i) -- cgit v1.2.3-70-g09d2