2017-04-27 20:25:32 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								// SPDX-License-Identifier: GPL-2.0
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-29 14:42:57 -03:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifndef DIVEPICTUREMODEL_H
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#define DIVEPICTUREMODEL_H
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-15 17:56:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#include "core/units.h"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-29 14:42:57 -03:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#include <QAbstractTableModel>
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#include <QImage>
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#include <QFuture>
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-10 00:07:46 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								struct PictureEntry {
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-30 21:32:14 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									int diveId;
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-10 00:07:46 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									struct picture *picture;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									QString filename;
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-29 14:42:57 -03:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
									QImage image;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									int offsetSeconds;
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-14 16:19:23 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									duration_t length;
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-29 14:42:57 -03:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								};
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								class DivePictureModel : public QAbstractTableModel {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Q_OBJECT
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								public:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									static DivePictureModel *instance();
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-29 22:13:44 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									int columnCount(const QModelIndex &parent = QModelIndex()) const override;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									int rowCount(const QModelIndex &parent = QModelIndex()) const override;
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-31 07:41:19 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									void updateDivePictures();
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-18 21:57:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									void removePictures(const QVector<QString> &fileUrls);
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-30 21:32:14 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									void updateDivePictureOffset(int diveId, const QString &filename, int offsetSeconds);
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-30 11:36:37 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								signals:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									void picturesRemoved(const QVector<QString> &fileUrls);
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-17 16:17:38 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								public slots:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									void setZoomLevel(int level);
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-15 17:56:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									void updateThumbnail(QString filename, QImage thumbnail, duration_t duration);
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-17 14:49:40 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								private:
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-29 14:42:57 -03:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
									DivePictureModel();
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-19 21:18:39 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									QVector<PictureEntry> pictures;
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-01 12:35:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									int findPictureId(const QString &filename);	// Return -1 if not found
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-17 16:17:38 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									double zoomLevel;	// -1.0: minimum, 0.0: standard, 1.0: maximum
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-11 06:56:46 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									int size;
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-17 16:17:38 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									void updateThumbnails();
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-11 06:56:46 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									void updateZoom();
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-29 14:42:57 -03:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								};
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2015-08-06 10:14:18 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#endif
							 |