mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
desktop: store pointer to parent in tab-widgets
Make it possible for the individual tab-widgets to access the parent widget. In principle this could have been done by downcasting the pointer returned by parent(), but this makes it explicit. The goal here is to store information on the selection, current dive, etc. without repeating it in every subwidget. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
cded7ef5fe
commit
8cd191c271
14 changed files with 20 additions and 13 deletions
|
@ -1,6 +1,10 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0
|
// SPDX-License-Identifier: GPL-2.0
|
||||||
#include "TabBase.h"
|
#include "TabBase.h"
|
||||||
|
|
||||||
|
TabBase::TabBase(MainTab *parent) : parent(*parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void TabBase::updateUi(QString)
|
void TabBase::updateUi(QString)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,15 +5,18 @@
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
struct dive;
|
struct dive;
|
||||||
|
class MainTab;
|
||||||
|
|
||||||
class TabBase : public QWidget {
|
class TabBase : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using QWidget::QWidget;
|
TabBase(MainTab *parent);
|
||||||
virtual void updateData(const std::vector<dive *> &selection, dive *currentDive, int currentDC) = 0;
|
virtual void updateData(const std::vector<dive *> &selection, dive *currentDive, int currentDC) = 0;
|
||||||
virtual void clear() = 0;
|
virtual void clear() = 0;
|
||||||
virtual void updateUi(QString titleColor);
|
virtual void updateUi(QString titleColor);
|
||||||
|
protected:
|
||||||
|
MainTab &parent;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -28,7 +28,7 @@ static bool hiddenByDefault(int i)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
TabDiveEquipment::TabDiveEquipment(QWidget *parent) : TabBase(parent),
|
TabDiveEquipment::TabDiveEquipment(MainTab *parent) : TabBase(parent),
|
||||||
cylindersModel(new CylindersModel(false, true, this)),
|
cylindersModel(new CylindersModel(false, true, this)),
|
||||||
weightModel(new WeightModel(this))
|
weightModel(new WeightModel(this))
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,7 +17,7 @@ class CylindersModel;
|
||||||
class TabDiveEquipment : public TabBase {
|
class TabDiveEquipment : public TabBase {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
TabDiveEquipment(QWidget *parent = 0);
|
TabDiveEquipment(MainTab *parent);
|
||||||
~TabDiveEquipment();
|
~TabDiveEquipment();
|
||||||
void updateData(const std::vector<dive *> &selection, dive *currentDive, int currentDC) override;
|
void updateData(const std::vector<dive *> &selection, dive *currentDive, int currentDC) override;
|
||||||
void clear() override;
|
void clear() override;
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include "core/selection.h"
|
#include "core/selection.h"
|
||||||
#include "qt-models/divecomputerextradatamodel.h"
|
#include "qt-models/divecomputerextradatamodel.h"
|
||||||
|
|
||||||
TabDiveExtraInfo::TabDiveExtraInfo(QWidget *parent) :
|
TabDiveExtraInfo::TabDiveExtraInfo(MainTab *parent) :
|
||||||
TabBase(parent),
|
TabBase(parent),
|
||||||
ui(new Ui::TabDiveExtraInfo()),
|
ui(new Ui::TabDiveExtraInfo()),
|
||||||
extraDataModel(new ExtraDataModel(this))
|
extraDataModel(new ExtraDataModel(this))
|
||||||
|
|
|
@ -13,7 +13,7 @@ class ExtraDataModel;
|
||||||
class TabDiveExtraInfo : public TabBase {
|
class TabDiveExtraInfo : public TabBase {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
TabDiveExtraInfo(QWidget *parent = 0);
|
TabDiveExtraInfo(MainTab *parent);
|
||||||
~TabDiveExtraInfo();
|
~TabDiveExtraInfo();
|
||||||
void updateData(const std::vector<dive *> &selection, dive *currentDive, int currentDC) override;
|
void updateData(const std::vector<dive *> &selection, dive *currentDive, int currentDC) override;
|
||||||
void clear() override;
|
void clear() override;
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#define COMBO_CHANGED 0
|
#define COMBO_CHANGED 0
|
||||||
#define TEXT_EDITED 1
|
#define TEXT_EDITED 1
|
||||||
|
|
||||||
TabDiveInformation::TabDiveInformation(QWidget *parent) : TabBase(parent), ui(new Ui::TabDiveInformation())
|
TabDiveInformation::TabDiveInformation(MainTab *parent) : TabBase(parent), ui(new Ui::TabDiveInformation())
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
connect(&diveListNotifier, &DiveListNotifier::divesChanged, this, &TabDiveInformation::divesChanged);
|
connect(&diveListNotifier, &DiveListNotifier::divesChanged, this, &TabDiveInformation::divesChanged);
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace Ui {
|
||||||
class TabDiveInformation : public TabBase {
|
class TabDiveInformation : public TabBase {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
TabDiveInformation(QWidget *parent = 0);
|
TabDiveInformation(MainTab *parent);
|
||||||
~TabDiveInformation();
|
~TabDiveInformation();
|
||||||
void updateData(const std::vector<dive *> &selection, dive *currentDive, int currentDC) override;
|
void updateData(const std::vector<dive *> &selection, dive *currentDive, int currentDC) override;
|
||||||
void clear() override;
|
void clear() override;
|
||||||
|
|
|
@ -20,7 +20,7 @@ struct Completers {
|
||||||
QCompleter *tags;
|
QCompleter *tags;
|
||||||
};
|
};
|
||||||
|
|
||||||
TabDiveNotes::TabDiveNotes(QWidget *parent) : TabBase(parent),
|
TabDiveNotes::TabDiveNotes(MainTab *parent) : TabBase(parent),
|
||||||
ignoreInput(false),
|
ignoreInput(false),
|
||||||
currentTrip(0)
|
currentTrip(0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,7 +16,7 @@ class DivePictureModel;
|
||||||
class TabDiveNotes : public TabBase {
|
class TabDiveNotes : public TabBase {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
TabDiveNotes(QWidget *parent = 0);
|
TabDiveNotes(MainTab *parent);
|
||||||
void updateData(const std::vector<dive *> &selection, dive *currentDive, int currentDC) override;
|
void updateData(const std::vector<dive *> &selection, dive *currentDive, int currentDC) override;
|
||||||
void clear() override;
|
void clear() override;
|
||||||
void closeWarning();
|
void closeWarning();
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#include "../mainwindow.h"
|
#include "../mainwindow.h"
|
||||||
#include "../divelistview.h"
|
#include "../divelistview.h"
|
||||||
|
|
||||||
TabDivePhotos::TabDivePhotos(QWidget *parent)
|
TabDivePhotos::TabDivePhotos(MainTab *parent)
|
||||||
: TabBase(parent),
|
: TabBase(parent),
|
||||||
ui(new Ui::TabDivePhotos()),
|
ui(new Ui::TabDivePhotos()),
|
||||||
divePictureModel(DivePictureModel::instance())
|
divePictureModel(DivePictureModel::instance())
|
||||||
|
|
|
@ -13,7 +13,7 @@ class DivePictureModel;
|
||||||
class TabDivePhotos : public TabBase {
|
class TabDivePhotos : public TabBase {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
TabDivePhotos(QWidget *parent = 0);
|
TabDivePhotos(MainTab *parent);
|
||||||
~TabDivePhotos();
|
~TabDivePhotos();
|
||||||
void updateData(const std::vector<dive *> &selection, dive *currentDive, int currentDC) override;
|
void updateData(const std::vector<dive *> &selection, dive *currentDive, int currentDC) override;
|
||||||
void clear() override;
|
void clear() override;
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
|
|
||||||
TabDiveStatistics::TabDiveStatistics(QWidget *parent) : TabBase(parent), ui(new Ui::TabDiveStatistics())
|
TabDiveStatistics::TabDiveStatistics(MainTab *parent) : TabBase(parent), ui(new Ui::TabDiveStatistics())
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->sacLimits->overrideMaxToolTipText(tr("Highest total SAC of a dive"));
|
ui->sacLimits->overrideMaxToolTipText(tr("Highest total SAC of a dive"));
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace Ui {
|
||||||
class TabDiveStatistics : public TabBase {
|
class TabDiveStatistics : public TabBase {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
TabDiveStatistics(QWidget *parent = 0);
|
TabDiveStatistics(MainTab *parent);
|
||||||
~TabDiveStatistics();
|
~TabDiveStatistics();
|
||||||
void updateData(const std::vector<dive *> &selection, dive *currentDive, int currentDC) override;
|
void updateData(const std::vector<dive *> &selection, dive *currentDive, int currentDC) override;
|
||||||
void clear() override;
|
void clear() override;
|
||||||
|
|
Loading…
Add table
Reference in a new issue