mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Map Short Names - display shortened names on the map.
Only the last component of the Site Name is displayed, otherwise the full name is displayed. Site Name components are separated using slash (/) characters. For example, if the full dive-site name is "Japan / Izu Peninsula / Atami / Chinsen-Aft" then only "Chinsen-Aft" is displayed on the Map. Signed-off-by: Michael WERLE <micha@michaelwerle.com>
This commit is contained in:
		
							parent
							
								
									c897edc13e
								
							
						
					
					
						commit
						3dbba5ae69
					
				
					 1 changed files with 20 additions and 2 deletions
				
			
		| 
						 | 
					@ -10,6 +10,24 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define MIN_DISTANCE_BETWEEN_DIVE_SITES_M 50.0
 | 
					#define MIN_DISTANCE_BETWEEN_DIVE_SITES_M 50.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// MKW If "Map Short Names" preference is set, only return the last component
 | 
				
			||||||
 | 
					// of the full dive site name.
 | 
				
			||||||
 | 
					// Example:
 | 
				
			||||||
 | 
					// Japan/Izu Peninsula/Atami/Chinsen-Aft
 | 
				
			||||||
 | 
					//    Short name: Chinsen-Aft
 | 
				
			||||||
 | 
					static QString siteMapDisplayName(const char *sitename)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						const char Separator = '/';
 | 
				
			||||||
 | 
						QString fullname(sitename);
 | 
				
			||||||
 | 
						QString name = fullname.section(Separator, -1).trimmed();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (name.isEmpty()) {
 | 
				
			||||||
 | 
							name = fullname;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return name;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
MapLocation::MapLocation(struct dive_site *dsIn, QGeoCoordinate coordIn, QString nameIn, bool selectedIn) :
 | 
					MapLocation::MapLocation(struct dive_site *dsIn, QGeoCoordinate coordIn, QString nameIn, bool selectedIn) :
 | 
				
			||||||
    divesite(dsIn), coordinate(coordIn), name(nameIn), selected(selectedIn)
 | 
					    divesite(dsIn), coordinate(coordIn), name(nameIn), selected(selectedIn)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -159,7 +177,7 @@ void MapLocationModel::reload(QObject *map)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if (!diveSiteMode && hasSelectedDive(ds) && !m_selectedDs.contains(ds))
 | 
							if (!diveSiteMode && hasSelectedDive(ds) && !m_selectedDs.contains(ds))
 | 
				
			||||||
			m_selectedDs.append(ds);
 | 
								m_selectedDs.append(ds);
 | 
				
			||||||
		QString name(ds->name);
 | 
							QString name = siteMapDisplayName(ds->name);
 | 
				
			||||||
		if (!diveSiteMode) {
 | 
							if (!diveSiteMode) {
 | 
				
			||||||
			// don't add dive locations with the same name, unless they are
 | 
								// don't add dive locations with the same name, unless they are
 | 
				
			||||||
			// at least MIN_DISTANCE_BETWEEN_DIVE_SITES_M apart
 | 
								// at least MIN_DISTANCE_BETWEEN_DIVE_SITES_M apart
 | 
				
			||||||
| 
						 | 
					@ -223,7 +241,7 @@ void MapLocationModel::diveSiteChanged(struct dive_site *ds, int field)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	case LocationInformationModel::NAME:
 | 
						case LocationInformationModel::NAME:
 | 
				
			||||||
		m_mapLocations[row]->name = ds->name;
 | 
							m_mapLocations[row]->name = siteMapDisplayName(ds->name);
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	default:
 | 
						default:
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue