mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Provide photos summary on dive list
1) Add an extra column to dive list, just left of Locality field.
2) For each dive, give summary of photos as follows:
   i)   no photos: no icon in that column
   ii)  photos taken during dive: show icon of fish
   iii) photos taken before/after dive: show icon of sun
   iv)  photos taken during as well as before/after dive: show
     icon with both fish and sun
3) Provide information for the sort operation to work on
   this column of the dive list.
Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
			
			
This commit is contained in:
		
							parent
							
								
									2aeb2b8d8b
								
							
						
					
					
						commit
						1fa855e1c0
					
				
					 7 changed files with 62 additions and 5 deletions
				
			
		|  | @ -24,8 +24,8 @@ | |||
| #include "core/metrics.h" | ||||
| #include "core/helpers.h" | ||||
| 
 | ||||
| //                                #  Date  Rtg Dpth  Dur  Tmp Wght Suit  Cyl  Gas  SAC  OTU  CNS  Loc
 | ||||
| static int defaultWidth[] =    {  70, 140, 90,  50,  50,  50,  50,  70,  50,  50,  70,  50,  50, 500}; | ||||
| //                                #  Date  Rtg Dpth  Dur  Tmp Wght Suit  Cyl  Gas  SAC  OTU  CNS  Px  Loc
 | ||||
| static int defaultWidth[] =    {  70, 140, 90,  50,  50,  50,  50,  70,  50,  50,  70,  50,  50,  25, 500}; | ||||
| 
 | ||||
| DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelection(false), sortColumn(0), | ||||
| 	currentOrder(Qt::DescendingOrder), dontEmitDiveChangedSignal(false), selectionSaved(false) | ||||
|  | @ -81,6 +81,9 @@ DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelec | |||
| 		case DiveTripModel::SAC: | ||||
| 			sw = 7*em; | ||||
| 			break; | ||||
| 		case DiveTripModel::PHOTOS: | ||||
| 			sw = 5*em; | ||||
| 			break; | ||||
| 		case DiveTripModel::LOCATION: | ||||
| 			sw = 50*em; | ||||
| 			break; | ||||
|  |  | |||
							
								
								
									
										
											BIN
										
									
								
								icons/duringPhoto.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								icons/duringPhoto.png
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 5.2 KiB | 
							
								
								
									
										
											BIN
										
									
								
								icons/inAndOutPhoto.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								icons/inAndOutPhoto.png
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 5.4 KiB | 
							
								
								
									
										
											BIN
										
									
								
								icons/outsidePhoto.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								icons/outsidePhoto.png
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 3 KiB | 
|  | @ -22,6 +22,7 @@ static QVariant dive_table_alignment(int column) | |||
| 	case DiveTripModel::TOTALWEIGHT: | ||||
| 	case DiveTripModel::SAC: | ||||
| 	case DiveTripModel::OTU: | ||||
| 	case DiveTripModel::PHOTOS: | ||||
| 	case DiveTripModel::MAXCNS: | ||||
| 		// Right align numeric columns
 | ||||
| 		retVal = int(Qt::AlignRight | Qt::AlignVCenter); | ||||
|  | @ -80,6 +81,8 @@ QVariant TripItem::data(int column, int role) const | |||
| QVariant DiveItem::data(int column, int role) const | ||||
| { | ||||
| 	QVariant retVal; | ||||
| 	int iconIndex; | ||||
| 	QString icon_names[4] = {":zero",":duringPhoto", ":outsidePhoto", ":inAndOutPhoto" }; | ||||
| 	struct dive *dive = get_dive_by_uniq_id(diveId); | ||||
| 	if (!dive) | ||||
| 		return QVariant(); | ||||
|  | @ -130,6 +133,9 @@ QVariant DiveItem::data(int column, int role) const | |||
| 		case MAXCNS: | ||||
| 			retVal = dive->maxcns; | ||||
| 			break; | ||||
| 		case PHOTOS: | ||||
| 			retVal = countPhotos(dive); | ||||
| 			break; | ||||
| 		case LOCATION: | ||||
| 			retVal = QString(get_dive_location(dive)); | ||||
| 			break; | ||||
|  | @ -171,6 +177,8 @@ QVariant DiveItem::data(int column, int role) const | |||
| 		case MAXCNS: | ||||
| 			retVal = dive->maxcns; | ||||
| 			break; | ||||
| 		case PHOTOS: | ||||
| 			break; | ||||
| 		case LOCATION: | ||||
| 			retVal = QString(get_dive_location(dive)); | ||||
| 			break; | ||||
|  | @ -182,11 +190,21 @@ QVariant DiveItem::data(int column, int role) const | |||
| 		} | ||||
| 		break; | ||||
| 	case Qt::DecorationRole: | ||||
| 		if (column == LOCATION) | ||||
| 		switch (column) { | ||||
| 		case LOCATION: | ||||
| 			if (dive_has_gps_location(dive)) { | ||||
| 				IconMetrics im = defaultIconMetrics(); | ||||
| 				retVal = QIcon(":satellite").pixmap(im.sz_small, im.sz_small); | ||||
| 				retVal = QIcon(":globe-icon").pixmap(im.sz_small, im.sz_small); | ||||
| 			} | ||||
| 			break; | ||||
| 		case PHOTOS:	// if enabled, show photos icon: fish= photos during dive; sun=photos before/after dive
 | ||||
| 			if (dive->picture_list)	// sun+fish=photos during dive as well as before/after
 | ||||
| 			{ | ||||
| 				IconMetrics im = defaultIconMetrics(); | ||||
| 				retVal = QIcon(icon_names[countPhotos(dive)]).pixmap(im.sz_small, im.sz_small); | ||||
| 			} | ||||
| 			break; | ||||
| 		} | ||||
| 		break; | ||||
| 	case Qt::ToolTipRole: | ||||
| 		switch (column) { | ||||
|  | @ -231,6 +249,9 @@ QVariant DiveItem::data(int column, int role) const | |||
| 		case MAXCNS: | ||||
| 			retVal = tr("Max CNS"); | ||||
| 			break; | ||||
| 		case PHOTOS: | ||||
| 			retVal = tr("Photos before/during/after dive"); | ||||
| 			break; | ||||
| 		case LOCATION: | ||||
| 			retVal = tr("Location"); | ||||
| 			break; | ||||
|  | @ -301,6 +322,25 @@ QString DiveItem::displayDepthWithUnit() const | |||
| 	return get_depth_string(dive->maxdepth, true); | ||||
| } | ||||
| 
 | ||||
| int DiveItem::countPhotos(dive *dive) const | ||||
| { | ||||
| 	int diveDuration = dive->duration.seconds; | ||||
| 	int pic_offset, icon_index = 0; | ||||
| 	struct picture *pic_list = dive->picture_list;	// Point to 1st picture of dive
 | ||||
| 	if (!pic_list) return 0;			// This dive does not contain pictures
 | ||||
| 	do { | ||||
| 		pic_offset = pic_list->offset.seconds; | ||||
| 		if  ((pic_offset < 0) | (pic_offset > diveDuration)) { | ||||
| 			icon_index |= 0x02;	// If picture is before/after the dive
 | ||||
| 		}				//  then set the appropriate bit ...
 | ||||
| 		else { | ||||
| 			icon_index |= 0x01;	// else set the bit for picture during the dive
 | ||||
| 		} | ||||
| 		pic_list = pic_list->next;	// look at next photo
 | ||||
| 	} while (pic_list); | ||||
| 	return icon_index;	// return value: 0=no pictures; 1=pictures during dive;
 | ||||
| }				// 2=pictures before/after; 3=pictures during as well as before/after
 | ||||
| 
 | ||||
| QString DiveItem::displayDuration() const | ||||
| { | ||||
| 	int hrs, mins, fullmins, secs; | ||||
|  | @ -430,6 +470,9 @@ QVariant DiveTripModel::headerData(int section, Qt::Orientation orientation, int | |||
| 		case MAXCNS: | ||||
| 			ret = tr("Max CNS"); | ||||
| 			break; | ||||
| 		case PHOTOS: | ||||
| 			ret = tr("█"); | ||||
| 			break; | ||||
| 		case LOCATION: | ||||
| 			ret = tr("Location"); | ||||
| 			break; | ||||
|  | @ -478,6 +521,9 @@ QVariant DiveTripModel::headerData(int section, Qt::Orientation orientation, int | |||
| 		case MAXCNS: | ||||
| 			ret = tr("Max CNS"); | ||||
| 			break; | ||||
| 		case PHOTOS: | ||||
| 			ret = tr("Photos before/during/after dive"); | ||||
| 			break; | ||||
| 		case LOCATION: | ||||
| 			ret = tr("Location"); | ||||
| 			break; | ||||
|  |  | |||
|  | @ -3,6 +3,7 @@ | |||
| 
 | ||||
| #include "treemodel.h" | ||||
| #include "core/dive.h" | ||||
| #include <string> | ||||
| 
 | ||||
| struct DiveItem : public TreeItem { | ||||
| 	Q_DECLARE_TR_FUNCTIONS(TripItem) | ||||
|  | @ -21,6 +22,7 @@ public: | |||
| 		SAC, | ||||
| 		OTU, | ||||
| 		MAXCNS, | ||||
| 		PHOTOS, | ||||
| 		LOCATION, | ||||
| 		COLUMNS | ||||
| 	}; | ||||
|  | @ -36,7 +38,9 @@ public: | |||
| 	QString displayTemperature() const; | ||||
| 	QString displayWeight() const; | ||||
| 	QString displaySac() const; | ||||
| 	int countPhotos(dive *dive) const; | ||||
| 	int weight() const; | ||||
| 	QString icon_names[4]; | ||||
| }; | ||||
| 
 | ||||
| struct TripItem : public TreeItem { | ||||
|  | @ -63,6 +67,7 @@ public: | |||
| 		SAC, | ||||
| 		OTU, | ||||
| 		MAXCNS, | ||||
| 		PHOTOS, | ||||
| 		LOCATION, | ||||
| 		COLUMNS | ||||
| 	}; | ||||
|  |  | |||
|  | @ -74,7 +74,10 @@ | |||
|         <file alias="filter-hide">icons/go-top.svg</file> | ||||
|         <file alias="filter-close">icons/process-stop.svg</file> | ||||
|         <file alias="edit">icons/edit-circled.svg</file> | ||||
|         <file alias="satellite">icons/Emblem-earth.svg</file> | ||||
|         <file alias="globe-icon">icons/Emblem-earth.svg</file> | ||||
|         <file alias="geocode">icons/geocode.svg</file> | ||||
|         <file alias="duringPhoto">icons/duringPhoto.png</file> | ||||
|         <file alias="outsidePhoto">icons/outsidePhoto.png</file> | ||||
|         <file alias="inAndOutPhoto">icons/inAndOutPhoto.png</file> | ||||
|     </qresource> | ||||
| </RCC> | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue