mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Correct the usage of std::string and QString
QStrings shouldn't be == "" to check for empty string, use .isEmpty() QStrings shouldn't be != "" to check for non empty, use .size() std::string shouldn't be cleared with = "", use .clear() Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
		
							parent
							
								
									3b7624ff46
								
							
						
					
					
						commit
						cf848e5233
					
				
					 5 changed files with 18 additions and 18 deletions
				
			
		|  | @ -372,7 +372,7 @@ int parseTemperatureToMkelvin(const QString &text) | ||||||
| 	int mkelvin; | 	int mkelvin; | ||||||
| 	QString numOnly = text; | 	QString numOnly = text; | ||||||
| 	numOnly.replace(",", ".").remove(QRegExp("[^-0-9.]")); | 	numOnly.replace(",", ".").remove(QRegExp("[^-0-9.]")); | ||||||
| 	if (numOnly == "") | 	if (numOnly.isEmpty()) | ||||||
| 		return 0; | 		return 0; | ||||||
| 	double number = numOnly.toDouble(); | 	double number = numOnly.toDouble(); | ||||||
| 	switch (prefs.units.temperature) { | 	switch (prefs.units.temperature) { | ||||||
|  |  | ||||||
|  | @ -525,15 +525,15 @@ int EXIFInfo::parseFromEXIFSegment(const unsigned char *buf, unsigned len) | ||||||
| void EXIFInfo::clear() | void EXIFInfo::clear() | ||||||
| { | { | ||||||
| 	// Strings
 | 	// Strings
 | ||||||
| 	ImageDescription = ""; | 	ImageDescription.clear(); | ||||||
| 	Make = ""; | 	Make.clear(); | ||||||
| 	Model = ""; | 	Model.clear(); | ||||||
| 	Software = ""; | 	Software.clear(); | ||||||
| 	DateTime = ""; | 	DateTime.clear(); | ||||||
| 	DateTimeOriginal = ""; | 	DateTimeOriginal.clear(); | ||||||
| 	DateTimeDigitized = ""; | 	DateTimeDigitized.clear(); | ||||||
| 	SubSecTimeOriginal = ""; | 	SubSecTimeOriginal.clear(); | ||||||
| 	Copyright = ""; | 	Copyright.clear(); | ||||||
| 
 | 
 | ||||||
| 	// Shorts / unsigned / double
 | 	// Shorts / unsigned / double
 | ||||||
| 	ByteAlign = 0; | 	ByteAlign = 0; | ||||||
|  |  | ||||||
|  | @ -48,11 +48,11 @@ GlobeGPS::GlobeGPS(QWidget *parent) : MarbleWidget(parent), | ||||||
| 	QDir marble; | 	QDir marble; | ||||||
| 	if (!list.contains("earth/googlesat/googlesat.dgml")) { | 	if (!list.contains("earth/googlesat/googlesat.dgml")) { | ||||||
| 		subsurfaceDataPath = getSubsurfaceDataPath("marbledata"); | 		subsurfaceDataPath = getSubsurfaceDataPath("marbledata"); | ||||||
| 		if (subsurfaceDataPath != "") { | 		if (subsurfaceDataPath.size()) { | ||||||
| 			MarbleDirs::setMarbleDataPath(subsurfaceDataPath); | 			MarbleDirs::setMarbleDataPath(subsurfaceDataPath); | ||||||
| 		} else { | 		} else { | ||||||
| 			subsurfaceDataPath = getSubsurfaceDataPath("data"); | 			subsurfaceDataPath = getSubsurfaceDataPath("data"); | ||||||
| 			if (subsurfaceDataPath != "") | 			if (subsurfaceDataPath.size()) | ||||||
| 				MarbleDirs::setMarbleDataPath(subsurfaceDataPath); | 				MarbleDirs::setMarbleDataPath(subsurfaceDataPath); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -30,7 +30,7 @@ UserManual::UserManual(QWidget *parent) : QMainWindow(parent), | ||||||
| 
 | 
 | ||||||
| 	ui->webView->page()->setLinkDelegationPolicy(QWebPage::DelegateExternalLinks); | 	ui->webView->page()->setLinkDelegationPolicy(QWebPage::DelegateExternalLinks); | ||||||
| 	QString searchPath = getSubsurfaceDataPath("Documentation"); | 	QString searchPath = getSubsurfaceDataPath("Documentation"); | ||||||
| 	if (searchPath != "") { | 	if (searchPath.size()) { | ||||||
| 		QUrl url(searchPath.append("/user-manual.html")); | 		QUrl url(searchPath.append("/user-manual.html")); | ||||||
| 		ui->webView->setUrl(url); | 		ui->webView->setUrl(url); | ||||||
| 	} else { | 	} else { | ||||||
|  |  | ||||||
							
								
								
									
										10
									
								
								qthelper.cpp
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								qthelper.cpp
									
										
									
									
									
								
							|  | @ -66,17 +66,17 @@ const DiveComputerNode *DiveComputerList::get(QString m) | ||||||
| 
 | 
 | ||||||
| void DiveComputerList::addDC(QString m, uint32_t d, QString n, QString s, QString f) | void DiveComputerList::addDC(QString m, uint32_t d, QString n, QString s, QString f) | ||||||
| { | { | ||||||
| 	if (m == "" || d == 0) | 	if (m.isEmpty() || d == 0) | ||||||
| 		return; | 		return; | ||||||
| 	const DiveComputerNode *existNode = this->getExact(m, d); | 	const DiveComputerNode *existNode = this->getExact(m, d); | ||||||
| 	DiveComputerNode newNode(m, d, s, f, n); | 	DiveComputerNode newNode(m, d, s, f, n); | ||||||
| 	if (existNode) { | 	if (existNode) { | ||||||
| 		if (newNode.changesValues(*existNode)) { | 		if (newNode.changesValues(*existNode)) { | ||||||
| 			if (n != "" && existNode->nickName != n) | 			if (n.size() && existNode->nickName != n) | ||||||
| 				qDebug("new nickname %s for DC model %s deviceId 0x%x", n.toUtf8().data(), m.toUtf8().data(), d); | 				qDebug("new nickname %s for DC model %s deviceId 0x%x", n.toUtf8().data(), m.toUtf8().data(), d); | ||||||
| 			if (f != "" && existNode->firmware != f) | 			if (f.size() && existNode->firmware != f) | ||||||
| 				qDebug("new firmware version %s for DC model %s deviceId 0x%x", f.toUtf8().data(), m.toUtf8().data(), d); | 				qDebug("new firmware version %s for DC model %s deviceId 0x%x", f.toUtf8().data(), m.toUtf8().data(), d); | ||||||
| 			if (s != "" && existNode->serialNumber != s) | 			if (s.size() && existNode->serialNumber != s) | ||||||
| 				qDebug("new serial number %s for DC model %s deviceId 0x%x", s.toUtf8().data(), m.toUtf8().data(), d); | 				qDebug("new serial number %s for DC model %s deviceId 0x%x", s.toUtf8().data(), m.toUtf8().data(), d); | ||||||
| 		} else { | 		} else { | ||||||
| 			return; | 			return; | ||||||
|  | @ -127,7 +127,7 @@ bool parseGpsText(const QString &gps_text, double *latitude, double *longitude) | ||||||
| 	trHemisphere[3] = MainWindow::instance()->information()->trHemisphere("W"); | 	trHemisphere[3] = MainWindow::instance()->information()->trHemisphere("W"); | ||||||
| 	QString regExp; | 	QString regExp; | ||||||
| 	/* an empty string is interpreted as 0.0,0.0 and therefore "no gps location" */ | 	/* an empty string is interpreted as 0.0,0.0 and therefore "no gps location" */ | ||||||
| 	if (gps_text.trimmed() == "") { | 	if (gps_text.trimmed().isEmpty()) { | ||||||
| 		*latitude = 0.0; | 		*latitude = 0.0; | ||||||
| 		*longitude = 0.0; | 		*longitude = 0.0; | ||||||
| 		return true; | 		return true; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue