summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/tab-widgets/maintab.h
blob: 4bff215ce8baa1a302f28d95d7b3b236b7a48405 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// SPDX-License-Identifier: GPL-2.0
/*
 * maintab.h
 *
 * header file for the main tab of Subsurface
 *
 */
#ifndef MAINTAB_H
#define MAINTAB_H

#include <QTabWidget>
#include <QDialog>
#include <QMap>
#include <QUuid>

#include "ui_maintab.h"
#include "qt-models/completionmodels.h"
#include "qt-models/divelocationmodel.h"
#include "core/dive.h"
#include "core/subsurface-qt/DiveListNotifier.h"

class WeightModel;
class CylindersModel;
class ExtraDataModel;
class DivePictureModel;
class QCompleter;

struct Completers {
	QCompleter *divemaster;
	QCompleter *buddy;
	QCompleter *suit;
	QCompleter *tags;
};

class TabBase;
class MainTab : public QTabWidget {
	Q_OBJECT
public:
	enum EditMode {
		NONE,
		DIVE,
		TRIP,
		ADD,
		MANUALLY_ADDED_DIVE,
		IGNORE
	};

	MainTab(QWidget *parent = 0);
	~MainTab();
	void clearTabs();
	void clearEquipment();
	void reload();
	void initialUiSetup();
	bool isEditing();
	void updateCoordinatesText(qreal lat, qreal lon);
	void refreshDisplayedDiveSite();
	void nextInputField(QKeyEvent *event);
	void showAndTriggerEditSelective(struct dive_components what);

signals:
	void addDiveFinished();
	void diveSiteChanged();
public
slots:
	void divesEdited(const QVector<dive *> &dives, DiveField field);
	void addCylinder_clicked();
	void addWeight_clicked();
	void updateDiveInfo(bool clear = false);
	void updateNotes(const struct dive *d);
	void updateMode(struct dive *d);
	void updateDateTime(struct dive *d);
	void updateDiveSite(struct dive *d);
	void updateDepthDuration();
	void acceptChanges();
	void rejectChanges();
	void on_location_diveSiteSelected();
	void on_divemaster_textChanged();
	void on_buddy_textChanged();
	void on_suit_editingFinished();
	void on_diveTripLocation_textEdited(const QString& text);
	void on_notes_textChanged();
	void on_notes_editingFinished();
	void on_airtemp_editingFinished();
	void on_duration_textChanged(const QString &text);
	void on_depth_textChanged(const QString &text);
	void divetype_Changed(int);
	void on_watertemp_editingFinished();
	void on_dateEdit_dateChanged(const QDate &date);
	void on_timeEdit_timeChanged(const QTime & time);
	void on_rating_valueChanged(int value);
	void on_visibility_valueChanged(int value);
	void on_tagWidget_textChanged();
	void editCylinderWidget(const QModelIndex &index);
	void editWeightWidget(const QModelIndex &index);
	void addDiveStarted();
	void addMessageAction(QAction *action);
	void hideMessage();
	void closeMessage();
	void displayMessage(QString str);
	void enableEdition(EditMode newEditMode = NONE);
	void toggleTriggeredColumn();
	void updateTextLabels(bool showUnits = true);
	void escDetected(void);
	EditMode getEditMode() const;
private:
	Ui::MainTab ui;
	WeightModel *weightModel;
	CylindersModel *cylindersModel;
	EditMode editMode;
	BuddyCompletionModel buddyModel;
	DiveMasterCompletionModel diveMasterModel;
	SuitCompletionModel suitModel;
	TagCompletionModel tagModel;
	Completers completers;
	bool modified;
	bool copyPaste;
	bool lastSelectedDive;
	int lastTabSelectedDive;
	int lastTabSelectedDiveTrip;
	void resetPallete();
	void copyTagsToDisplayedDive();
	void saveTags(const QVector<dive *> &selectedDives);
	void saveTaggedStrings(const QVector<dive *> &selectedDives);
	int diffTaggedStrings(QString currentString, QString displayedString, QStringList &addedList, QStringList &removedList);
	void markChangedWidget(QWidget *w);
	dive_trip_t *currentTrip;
	dive_trip_t displayedTrip;
	bool acceptingEdit;
	QList<TabBase*> extraWidgets;
};

#endif // MAINTAB_H