| 
									
										
										
										
											2017-04-27 20:26:05 +02:00
										 |  |  | // SPDX-License-Identifier: GPL-2.0
 | 
					
						
							| 
									
										
										
										
											2013-04-13 20:44:02 -07:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * divelistview.h | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * header file for the dive list of Subsurface | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2013-04-12 08:24:07 +01:00
										 |  |  | #ifndef DIVELISTVIEW_H
 | 
					
						
							|  |  |  | #define DIVELISTVIEW_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*! A view subclass for use with dives
 | 
					
						
							|  |  |  |   Note: calling this a list view might be misleading? | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <QTreeView>
 | 
					
						
							| 
									
										
										
										
											2014-02-09 18:18:54 +01:00
										 |  |  | #include <QLineEdit>
 | 
					
						
							| 
									
										
										
										
											2015-04-24 17:10:55 +02:00
										 |  |  | #include <QNetworkAccessManager>
 | 
					
						
							| 
									
										
										
										
											2016-04-04 22:02:03 -07:00
										 |  |  | #include "qt-models/divetripmodel.h"
 | 
					
						
							| 
									
										
										
										
											2019-02-24 22:26:08 +01:00
										 |  |  | #include "core/subsurface-qt/DiveListNotifier.h"
 | 
					
						
							| 
									
										
										
										
											2013-04-12 08:24:07 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 |  |  | class DiveListView : public QTreeView { | 
					
						
							| 
									
										
										
										
											2013-05-14 08:18:26 -03:00
										 |  |  | 	Q_OBJECT | 
					
						
							| 
									
										
										
										
											2013-04-12 08:24:07 +01:00
										 |  |  | public: | 
					
						
							|  |  |  | 	DiveListView(QWidget *parent = 0); | 
					
						
							| 
									
										
										
										
											2013-11-08 20:30:17 -02:00
										 |  |  | 	~DiveListView(); | 
					
						
							| 
									
										
										
										
											2017-01-28 12:16:45 +01:00
										 |  |  | 	void mouseDoubleClickEvent(QMouseEvent * event); | 
					
						
							| 
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 |  |  | 	void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected); | 
					
						
							|  |  |  | 	void currentChanged(const QModelIndex ¤t, const QModelIndex &previous); | 
					
						
							| 
									
										
										
										
											2018-11-04 17:54:38 +01:00
										 |  |  | 	void setSortOrder(int i, Qt::SortOrder order); // Call to set sort order
 | 
					
						
							|  |  |  | 	void reload(); // Call to reload model data
 | 
					
						
							| 
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 |  |  | 	bool eventFilter(QObject *, QEvent *); | 
					
						
							| 
									
										
										
										
											2013-06-05 15:41:52 +09:00
										 |  |  | 	void unselectDives(); | 
					
						
							| 
									
										
										
										
											2019-11-28 15:49:49 +01:00
										 |  |  | 	void selectDive(QModelIndex index, bool scrollto = false); | 
					
						
							|  |  |  | 	void selectDive(int dive_table_idx, bool scrollto = false); | 
					
						
							| 
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 |  |  | 	void selectDives(const QList<int> &newDiveSelection); | 
					
						
							| 
									
										
										
										
											2013-06-06 09:06:42 +09:00
										 |  |  | 	void contextMenuEvent(QContextMenuEvent *event); | 
					
						
							| 
									
										
										
										
											2019-05-31 16:09:14 +02:00
										 |  |  | 	QList<dive_trip *> selectedTrips(); | 
					
						
							| 
									
										
										
										
											2018-06-09 16:24:39 +02:00
										 |  |  | 	static QString lastUsedImageDir(); | 
					
						
							| 
									
										
										
										
											2018-06-10 16:40:23 +02:00
										 |  |  | 	static void updateLastUsedImageDir(const QString &s); | 
					
						
							| 
									
										
										
										
											2019-06-23 12:46:42 +02:00
										 |  |  | signals: | 
					
						
							|  |  |  | 	void divesSelected(); | 
					
						
							| 
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 |  |  | public | 
					
						
							|  |  |  | slots: | 
					
						
							| 
									
										
										
										
											2013-05-26 10:12:45 -07:00
										 |  |  | 	void toggleColumnVisibilityByIndex(); | 
					
						
							|  |  |  | 	void reloadHeaderActions(); | 
					
						
							| 
									
										
										
										
											2018-11-04 17:54:38 +01:00
										 |  |  | 	void sortIndicatorChanged(int index, Qt::SortOrder order); | 
					
						
							| 
									
										
										
										
											2013-06-06 09:06:42 +09:00
										 |  |  | 	void removeFromTrip(); | 
					
						
							| 
									
										
										
										
											2013-06-06 10:37:18 +09:00
										 |  |  | 	void deleteDive(); | 
					
						
							| 
									
										
										
										
											2013-12-06 17:40:59 -08:00
										 |  |  | 	void markDiveInvalid(); | 
					
						
							| 
									
										
										
										
											2018-09-29 22:13:44 +02:00
										 |  |  | 	void rowsInserted(const QModelIndex &parent, int start, int end) override; | 
					
						
							|  |  |  | 	void reset() override; | 
					
						
							| 
									
										
										
										
											2013-06-26 19:16:40 -10:00
										 |  |  | 	void mergeTripAbove(); | 
					
						
							|  |  |  | 	void mergeTripBelow(); | 
					
						
							| 
									
										
										
										
											2013-11-15 11:32:19 +09:00
										 |  |  | 	void newTripAbove(); | 
					
						
							| 
									
										
										
										
											2013-11-17 15:36:57 -08:00
										 |  |  | 	void addToTripAbove(); | 
					
						
							| 
									
										
										
										
											2014-03-20 07:42:20 +01:00
										 |  |  | 	void addToTripBelow(); | 
					
						
							| 
									
										
										
										
											2013-09-23 21:57:28 -07:00
										 |  |  | 	void mergeDives(); | 
					
						
							| 
									
										
										
										
											2015-10-01 21:17:37 -04:00
										 |  |  | 	void splitDives(); | 
					
						
							| 
									
										
										
										
											2014-05-20 06:11:32 +09:00
										 |  |  | 	void renumberDives(); | 
					
						
							| 
									
										
										
										
											2013-11-18 14:53:05 +01:00
										 |  |  | 	void shiftTimes(); | 
					
						
							| 
									
										
										
										
											2014-01-27 14:44:26 +01:00
										 |  |  | 	void loadImages(); | 
					
						
							| 
									
										
										
										
											2015-04-24 17:10:55 +02:00
										 |  |  | 	void loadWebImages(); | 
					
						
							| 
									
										
										
										
											2019-06-23 11:13:41 +02:00
										 |  |  | 	void diveSelectionChanged(const QVector<QModelIndex> &indexes); | 
					
						
							| 
									
										
										
										
											2018-08-14 09:12:21 -04:00
										 |  |  | 	void currentDiveChanged(QModelIndex index); | 
					
						
							| 
									
										
										
										
											2019-02-24 22:26:08 +01:00
										 |  |  | 	void tripChanged(dive_trip *trip, TripField); | 
					
						
							| 
									
										
										
										
											2013-05-13 22:14:59 -03:00
										 |  |  | private: | 
					
						
							| 
									
										
										
										
											2019-11-28 00:14:14 +01:00
										 |  |  | 	void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags flags) override; | 
					
						
							|  |  |  | 	void selectAll() override; | 
					
						
							|  |  |  | 	void selectionChangeDone(); | 
					
						
							| 
									
										
										
										
											2018-12-27 10:06:11 +01:00
										 |  |  | 	DiveTripModelBase::Layout currentLayout; | 
					
						
							| 
									
										
										
										
											2013-06-06 09:06:42 +09:00
										 |  |  | 	QModelIndex contextMenuIndex; | 
					
						
							| 
									
										
										
										
											2018-07-25 20:40:47 +02:00
										 |  |  | 	// Remember the initial column widths, to avoid writing unchanged widths to the settings
 | 
					
						
							|  |  |  | 	QVector<int> initialColumnWidths; | 
					
						
							| 
									
										
										
										
											2013-11-26 15:44:18 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-27 10:06:11 +01:00
										 |  |  | 	void resetModel();	// Call after model changed
 | 
					
						
							| 
									
										
										
										
											2013-06-26 19:16:40 -10:00
										 |  |  | 	void merge_trip(const QModelIndex &a, const int offset); | 
					
						
							| 
									
										
										
										
											2018-07-26 18:03:07 +02:00
										 |  |  | 	void setColumnWidths(); | 
					
						
							| 
									
										
										
										
											2018-07-25 21:23:19 +02:00
										 |  |  | 	void calculateInitialColumnWidth(int col); | 
					
						
							| 
									
										
										
										
											2019-11-28 21:55:26 +01:00
										 |  |  | 	std::vector<int> backupExpandedRows(); | 
					
						
							|  |  |  | 	void restoreExpandedRows(const std::vector<int> &); | 
					
						
							| 
									
										
										
										
											2013-11-13 16:59:56 -02:00
										 |  |  | 	int lastVisibleColumn(); | 
					
						
							| 
									
										
										
										
											2019-05-31 16:09:14 +02:00
										 |  |  | 	void selectTrip(dive_trip *trip); | 
					
						
							| 
									
										
										
										
											2014-02-12 16:46:17 +01:00
										 |  |  | 	void updateLastImageTimeOffset(int offset); | 
					
						
							|  |  |  | 	int lastImageTimeOffset(); | 
					
						
							| 
									
										
										
										
											2014-08-21 14:20:03 -05:00
										 |  |  | 	void addToTrip(int delta); | 
					
						
							| 
									
										
										
										
											2015-04-24 17:10:55 +02:00
										 |  |  | 	void matchImagesToDives(QStringList fileNames); | 
					
						
							|  |  |  | 	void loadImageFromURL(QUrl url); | 
					
						
							|  |  |  | 	QNetworkAccessManager manager; | 
					
						
							| 
									
										
										
										
											2013-04-12 08:24:07 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif // DIVELISTVIEW_H
 |