Return a default-constructed QString instead of implicitly converting an empty string literal.

This commit is contained in:
Mat Sutcliffe
2018-12-20 21:47:58 +00:00
parent 6c05c5249d
commit d6b5dca6b2
49 changed files with 128 additions and 127 deletions

View File

@@ -381,14 +381,14 @@ namespace BlackMisc
QString CAircraftModelList::findModelIconPathByModelString(const QString &modelString) const
{
if (modelString.isEmpty()) { return ""; }
if (modelString.isEmpty()) { return {}; }
const CAircraftModel m(findFirstByModelStringOrDefault(modelString, Qt::CaseInsensitive));
return m.getIconPath();
}
QString CAircraftModelList::findModelIconPathByCallsign(const CCallsign &callsign) const
{
if (callsign.isEmpty()) { return ""; }
if (callsign.isEmpty()) { return {}; }
const CAircraftModel m(findFirstByCallsignOrDefault(callsign));
return m.getIconPath();
}
@@ -1175,7 +1175,7 @@ namespace BlackMisc
QString CAircraftModelList::asHtmlSummary() const
{
if (this->isEmpty()) { return ""; }
if (this->isEmpty()) { return {}; }
QString html;
for (const CAircraftModel &model : *this)
{

View File

@@ -34,7 +34,7 @@ namespace BlackMisc
QString CAircraftModelUtilities::createIcaoAirlineAircraftHtmlMatrix(const CAircraftModelList &models)
{
if (models.isEmpty()) { return ""; }
if (models.isEmpty()) { return {}; }
static const QString emptyDesignator = "----";
static const QString colorLiveryDesignator = "-C-";
@@ -124,13 +124,13 @@ namespace BlackMisc
QString CAircraftModelUtilities::createIcaoAirlineAircraftHtmlMatrixFile(const CAircraftModelList &models, const QString &tempDir)
{
Q_ASSERT_X(!tempDir.isEmpty(), Q_FUNC_INFO, "Need directory");
if (models.isEmpty()) { return ""; }
if (models.isEmpty()) { return {}; }
const QString html = createIcaoAirlineAircraftHtmlMatrix(models);
if (html.isEmpty()) { return ""; }
if (html.isEmpty()) { return {}; }
QDir dir(tempDir);
BLACK_VERIFY_X(dir.exists(), Q_FUNC_INFO, "Directory does not exist");
if (!dir.exists()) { return ""; }
if (!dir.exists()) { return {}; }
const QString htmlTemplate = CFileUtils::readFileToString(CDirectoryUtils::htmlTemplateFilePath());
const QString fn("airlineAircraftMatrix.html");

View File

@@ -38,10 +38,10 @@ namespace BlackMisc
{
if (!this->getDbKey().isEmpty() && !this->getDescription().isEmpty())
{
return this->getDbKey() + " " + this->getDescription();
return this->getDbKey() % u' ' % this->getDescription();
}
if (!this->getDbKey().isEmpty()) { return this->getDbKey(); }
return "";
return {};
}
bool CDistributor::matchesKeyOrAlias(const QString &keyOrAlias) const

View File

@@ -48,7 +48,7 @@ namespace BlackMisc
QString CAircraftCfgEntries::getFileDirectory() const
{
if (m_fileName.isEmpty()) { return ""; }
if (m_fileName.isEmpty()) { return {}; }
const QFileInfo fileInfo(m_fileName);
return fileInfo.absolutePath();
}
@@ -166,8 +166,8 @@ namespace BlackMisc
QString CAircraftCfgEntries::getThumbnailFileNameGuess() const
{
if (m_texture.isEmpty()) { return ""; }
if (m_fileName.isEmpty()) { return ""; }
if (m_texture.isEmpty()) { return {}; }
if (m_fileName.isEmpty()) { return {}; }
QString fn = QDir::cleanPath(this->getFileDirectory() + QDir::separator() + "texture." + m_texture + QDir::separator() + "thumbnail.jpg");
return fn;
}
@@ -175,9 +175,9 @@ namespace BlackMisc
QString CAircraftCfgEntries::getThumbnailFileNameChecked() const
{
const QString f(getThumbnailFileNameGuess());
if (f.isEmpty()) { return ""; }
if (f.isEmpty()) { return {}; }
if (QFile(f).exists()) { return f; }
return "";
return {};
}
CVariant CAircraftCfgEntries::propertyByIndex(const BlackMisc::CPropertyIndex &index) const

View File

@@ -389,7 +389,7 @@ namespace BlackMisc
{
if (qv.isNull() || !qv.isValid())
{
return ""; // normal when there is no settings value
return {}; // normal when there is no settings value
}
else if (static_cast<QMetaType::Type>(qv.type()) == QMetaType::QStringList)
{
@@ -401,15 +401,15 @@ namespace BlackMisc
return qv.toString().trimmed();
}
Q_ASSERT(false);
return "";
return {};
}
QString CAircraftCfgParser::getFixedIniLineContent(const QString &line)
{
if (line.isEmpty()) { return ""; }
if (line.isEmpty()) { return {}; }
int index = line.indexOf('=');
if (index < 0) { return ""; }
if (line.length() < index + 1) { return ""; }
if (index < 0) { return {}; }
if (line.length() < index + 1) { return {}; }
QString content(line.midRef(index + 1).trimmed().toString());

View File

@@ -93,7 +93,7 @@ namespace BlackMisc
QString fsxSimObjectsDirFromRegistryImpl()
{
const QString fsxPath = CFsCommonUtil::fsxDirFromRegistry();
if (fsxPath.isEmpty()) { return ""; }
if (fsxPath.isEmpty()) { return {}; }
return CFsCommonUtil::fsxSimObjectsDirFromSimDir(fsxPath);
}
@@ -106,7 +106,7 @@ namespace BlackMisc
QString fsxSimObjectsDirImpl()
{
QString dir(CFsCommonUtil::fsxDir());
if (dir.isEmpty()) { return ""; }
if (dir.isEmpty()) { return {}; }
return CFsCommonUtil::fsxSimObjectsDirFromSimDir(dir);
}
@@ -186,7 +186,7 @@ namespace BlackMisc
QString p3dSimObjectsDirFromRegistryImpl()
{
const QString p3dPath = CFsCommonUtil::p3dDirFromRegistry();
if (p3dPath.isEmpty()) { return ""; }
if (p3dPath.isEmpty()) { return {}; }
return CFsCommonUtil::fsxSimObjectsDirFromSimDir(p3dPath);
}
@@ -199,7 +199,7 @@ namespace BlackMisc
QString p3dSimObjectsDirImpl()
{
QString dir(CFsCommonUtil::p3dDir());
if (dir.isEmpty()) { return ""; }
if (dir.isEmpty()) { return {}; }
return CFsCommonUtil::fsxSimObjectsDirFromSimDir(dir);
}

View File

@@ -73,7 +73,7 @@ namespace BlackMisc
QString CSimConnectUtilities::ipAddress(const QSettings *simConnectSettings)
{
if (!simConnectSettings) { return QString(""); }
if (!simConnectSettings) { return {}; }
return simConnectSettings->value("SimConnect/Address").toString();
}
@@ -167,8 +167,8 @@ namespace BlackMisc
QString CSimConnectUtilities::getSimConnectIniFileDirectory(CSimulatorInfo &simulator)
{
static const QString docDir = QStandardPaths::locate(QStandardPaths::DocumentsLocation, "", QStandardPaths::LocateDirectory);
if (docDir.isEmpty()) { return ""; }
if (!simulator.isSingleSimulator() || !simulator.isFsxP3DFamily()) return "";
if (docDir.isEmpty()) { return {}; }
if (!simulator.isSingleSimulator() || !simulator.isFsxP3DFamily()) return {};
const QString iniDir = CFileUtils::appendFilePaths(docDir, simulator.isP3D() ? "Prepar3D v4 Files" : "Flight Simulator X Files");
if (getSimConnectIniFileDirectories().isEmpty()) { return iniDir; }

View File

@@ -67,9 +67,9 @@ namespace BlackMisc
{
static const BlackMisc::CSettingReadOnly<TModelConverterXBinary> setting(new QObject());
const QString mcx = setting.get();
if (mcx.isEmpty()) return "";
if (mcx.isEmpty()) return {};
const QFile f(mcx);
return (f.exists()) ? mcx : "";
return (f.exists()) ? mcx : QString();
}
} // ns
} // ns