diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-03-09 22:32:16 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-04-12 18:19:07 +0300 |
commit | dd12bdaf94c1ebc5d32598151aa96da12e61c146 (patch) | |
tree | ce03750531ebcabdda7c656c28b6c9e9e73032f7 /desktop-widgets/tab-widgets | |
parent | 992ad2fa2784d38c5dfe3cce4e35e00d27a5f533 (diff) | |
download | subsurface-dd12bdaf94c1ebc5d32598151aa96da12e61c146.tar.gz |
Dive site: add dive site list tab
Add a very simple tab-widget presenting the list of known dive sites.
The table is rendered using our custom "TableView".
The (mis)uses the "LocationInformationModel". It moves the items
to be displayed (delete, name, description, number of dives) to the
front and makes the others hidden.
Moreover, it was necessary to limit the geo-tag decoration role to
the name to avoid having the icon next to each column.
Make the trash-can icon active and the name and description editable.
This is modelled after the cylinders-table code.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/tab-widgets')
-rw-r--r-- | desktop-widgets/tab-widgets/TabDiveSite.cpp | 24 | ||||
-rw-r--r-- | desktop-widgets/tab-widgets/TabDiveSite.h | 18 | ||||
-rw-r--r-- | desktop-widgets/tab-widgets/TabDiveSite.ui | 32 | ||||
-rw-r--r-- | desktop-widgets/tab-widgets/maintab.cpp | 5 |
4 files changed, 77 insertions, 2 deletions
diff --git a/desktop-widgets/tab-widgets/TabDiveSite.cpp b/desktop-widgets/tab-widgets/TabDiveSite.cpp new file mode 100644 index 000000000..81736bc77 --- /dev/null +++ b/desktop-widgets/tab-widgets/TabDiveSite.cpp @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "TabDiveSite.h" +#include "qt-models/divelocationmodel.h" + +#include <qt-models/divecomputerextradatamodel.h> + +TabDiveSite::TabDiveSite(QWidget *parent) : TabBase(parent) +{ + ui.setupUi(this); + ui.diveSites->setTitle(tr("Dive sites")); + ui.diveSites->setModel(LocationInformationModel::instance()); + + // Show only the first few columns + for (int i = LocationInformationModel::COORDS; i < LocationInformationModel::COLUMNS; ++i) + ui.diveSites->view()->setColumnHidden(i, true); +} + +void TabDiveSite::updateData() +{ +} + +void TabDiveSite::clear() +{ +} diff --git a/desktop-widgets/tab-widgets/TabDiveSite.h b/desktop-widgets/tab-widgets/TabDiveSite.h new file mode 100644 index 000000000..60b3abd76 --- /dev/null +++ b/desktop-widgets/tab-widgets/TabDiveSite.h @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: GPL-2.0 +#ifndef TAB_DIVE_SITE_H +#define TAB_DIVE_SITE_H + +#include "TabBase.h" +#include "ui_TabDiveSite.h" + +class TabDiveSite : public TabBase { + Q_OBJECT +public: + TabDiveSite(QWidget *parent = 0); + void updateData() override; + void clear() override; +private: + Ui::TabDiveSite ui; +}; + +#endif diff --git a/desktop-widgets/tab-widgets/TabDiveSite.ui b/desktop-widgets/tab-widgets/TabDiveSite.ui new file mode 100644 index 000000000..1d52555e3 --- /dev/null +++ b/desktop-widgets/tab-widgets/TabDiveSite.ui @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>TabDiveSite</class> + <widget class="QWidget" name="TabDiveSite"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Dive sites</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="TableView" name="diveSites" native="true"/> + </item> + </layout> + </widget> + <customwidgets> + <customwidget> + <class>TableView</class> + <extends>QWidget</extends> + <header>desktop-widgets/tableview.h</header> + <container>1</container> + </customwidget> + </customwidgets> + <resources/> + <connections/> +</ui> diff --git a/desktop-widgets/tab-widgets/maintab.cpp b/desktop-widgets/tab-widgets/maintab.cpp index d0e131f1e..a8dd87cb4 100644 --- a/desktop-widgets/tab-widgets/maintab.cpp +++ b/desktop-widgets/tab-widgets/maintab.cpp @@ -33,6 +33,7 @@ #include "TabDiveInformation.h" #include "TabDivePhotos.h" #include "TabDiveStatistics.h" +#include "TabDiveSite.h" #include <QCompleter> #include <QSettings> @@ -62,6 +63,8 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), ui.tabWidget->addTab(extraWidgets.last(), tr("Media")); extraWidgets << new TabDiveExtraInfo(); ui.tabWidget->addTab(extraWidgets.last(), tr("Extra Info")); + extraWidgets << new TabDiveSite(); + ui.tabWidget->addTab(extraWidgets.last(), tr("Dive sites")); ui.dateEdit->setDisplayFormat(prefs.date_format); ui.timeEdit->setDisplayFormat(prefs.time_format); @@ -205,8 +208,6 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), acceptingEdit = false; ui.diveTripLocation->hide(); - - } MainTab::~MainTab() |