Style: renaming methods

This commit is contained in:
Mat Sutcliffe
2020-08-16 20:01:01 +01:00
parent d43a55f087
commit 5b14cf7f71
6 changed files with 21 additions and 21 deletions

View File

@@ -190,7 +190,7 @@ namespace BlackGui
const CUrl download = remoteFile.getSmartUrl(); const CUrl download = remoteFile.getSmartUrl();
if (download.isEmpty()) if (download.isEmpty())
{ {
const CStatusMessage msg = CStatusMessage(this, CLogCategory::validation()).error(u"No download URL for file name '%1'") << remoteFile.getNameAndSize(); const CStatusMessage msg = CStatusMessage(this, CLogCategory::validation()).error(u"No download URL for file name '%1'") << remoteFile.getBaseNameAndSize();
this->showOverlayMessage(msg, CDownloadComponent::OverlayMsgTimeoutMs); this->showOverlayMessage(msg, CDownloadComponent::OverlayMsgTimeoutMs);
return false; return false;
} }

View File

@@ -222,7 +222,7 @@ namespace BlackGui
const CUrl download = rf.getSmartUrl(); const CUrl download = rf.getSmartUrl();
if (download.isEmpty()) if (download.isEmpty())
{ {
const CStatusMessage msg = CStatusMessage(this, CLogCategory::validation()).error(u"No download URL for file name '%1'") << rf.getNameAndSize(); const CStatusMessage msg = CStatusMessage(this, CLogCategory::validation()).error(u"No download URL for file name '%1'") << rf.getBaseNameAndSize();
this->showOverlayMessage(msg, CInstallXSwiftBusComponent::OverlayMsgTimeoutMs); this->showOverlayMessage(msg, CInstallXSwiftBusComponent::OverlayMsgTimeoutMs);
return; return;
} }
@@ -287,10 +287,10 @@ namespace BlackGui
CRemoteFile CInstallXSwiftBusComponent::getRemoteFileSelected() const CRemoteFile CInstallXSwiftBusComponent::getRemoteFileSelected() const
{ {
const QString fileNameAndSize = ui->cb_DownloadFile->currentText(); const QString baseNameAndSize = ui->cb_DownloadFile->currentText();
const CUpdateInfo update = m_updates.get(); const CUpdateInfo update = m_updates.get();
const CRemoteFileList remoteFiles = update.getArtifactsXSwiftBus().asRemoteFiles(); const CRemoteFileList remoteFiles = update.getArtifactsXSwiftBus().asRemoteFiles();
return remoteFiles.findFirstByMatchingNameOrDefault(fileNameAndSize); return remoteFiles.findFirstByMatchingBaseNameOrDefault(baseNameAndSize);
} }
QString CInstallXSwiftBusComponent::downloadDir() const QString CInstallXSwiftBusComponent::downloadDir() const
@@ -331,7 +331,7 @@ namespace BlackGui
const CRemoteFileList remoteFiles = artifacts.asRemoteFiles(); const CRemoteFileList remoteFiles = artifacts.asRemoteFiles();
if (!remoteFiles.isEmpty()) if (!remoteFiles.isEmpty())
{ {
const QStringList xSwiftBusFiles(remoteFiles.getNamesPlusSize(false)); const QStringList xSwiftBusFiles(remoteFiles.getBaseNamesPlusSize(false));
m_xSwiftBusArtifacts = artifacts; m_xSwiftBusArtifacts = artifacts;
ui->cb_DownloadFile->addItems(xSwiftBusFiles); ui->cb_DownloadFile->addItems(xSwiftBusFiles);
@@ -340,17 +340,17 @@ namespace BlackGui
if (m_defaultDownloadName.isEmpty()) if (m_defaultDownloadName.isEmpty())
{ {
const CRemoteFile rf = remoteFiles.findFirstContainingNameOrDefault(CBuildConfig::getVersionString(), Qt::CaseInsensitive); const CRemoteFile rf = remoteFiles.findFirstContainingNameOrDefault(CBuildConfig::getVersionString(), Qt::CaseInsensitive);
if (rf.hasName()) { current = rf.getNameAndSize(); } if (rf.hasName()) { current = rf.getBaseNameAndSize(); }
} }
else else
{ {
const CRemoteFile rf = remoteFiles.findFirstByMatchingNameOrDefault(m_defaultDownloadName); const CRemoteFile rf = remoteFiles.findFirstByMatchingBaseNameOrDefault(m_defaultDownloadName);
if (rf.hasName()) { current = rf.getNameAndSize(); } if (rf.hasName()) { current = rf.getBaseNameAndSize(); }
} }
ui->cb_DownloadFile->setCurrentText( ui->cb_DownloadFile->setCurrentText(
current.isEmpty() ? current.isEmpty() ?
remoteFiles.frontOrDefault().getNameAndSize() : remoteFiles.frontOrDefault().getBaseNameAndSize() :
current current
); // latest version ); // latest version
} }

View File

@@ -27,13 +27,13 @@ namespace BlackMisc
: m_name(name), m_url(url), m_size(size) : m_name(name), m_url(url), m_size(size)
{ } { }
QString CRemoteFile::getNameAndSize() const QString CRemoteFile::getBaseNameAndSize() const
{ {
if (!this->hasName()) { return {}; } if (!this->hasName()) { return {}; }
return QStringLiteral("%1 (%2)").arg(this->getName(), this->getSizeHumanReadable()); return QStringLiteral("%1 (%2)").arg(this->getBaseName(), this->getSizeHumanReadable());
} }
bool CRemoteFile::matchesName(const QString &name) const bool CRemoteFile::matchesBaseName(const QString &name) const
{ {
if (name.isEmpty()) { return false; } if (name.isEmpty()) { return false; }
if (caseInsensitiveStringCompare(name, this->getBaseName())) { return true; } if (caseInsensitiveStringCompare(name, this->getBaseName())) { return true; }

View File

@@ -66,13 +66,13 @@ namespace BlackMisc
bool hasName() const { return !m_name.isEmpty(); } bool hasName() const { return !m_name.isEmpty(); }
//! Name + human readable size //! Name + human readable size
QString getNameAndSize() const; QString getBaseNameAndSize() const;
//! Name //! Name
void setName(const QString &name) { m_name = name.trimmed(); } void setName(const QString &name) { m_name = name.trimmed(); }
//! Matching name? //! Matching name?
bool matchesName(const QString &name) const; bool matchesBaseName(const QString &baseName) const;
//! Description //! Description
const QString &getDescription() const { return m_description; } const QString &getDescription() const { return m_description; }

View File

@@ -35,12 +35,12 @@ namespace BlackMisc
return fileNames; return fileNames;
} }
QStringList CRemoteFileList::getNamesPlusSize(bool sorted) const QStringList CRemoteFileList::getBaseNamesPlusSize(bool sorted) const
{ {
QStringList fileNames; QStringList fileNames;
for (const CRemoteFile &rf : *this) for (const CRemoteFile &rf : *this)
{ {
fileNames.append(rf.getNameAndSize()); fileNames.append(rf.getBaseNameAndSize());
} }
if (sorted) { fileNames.sort(); } if (sorted) { fileNames.sort(); }
return fileNames; return fileNames;
@@ -62,12 +62,12 @@ namespace BlackMisc
return CRemoteFile(); return CRemoteFile();
} }
CRemoteFile CRemoteFileList::findFirstByMatchingNameOrDefault(const QString &name) const CRemoteFile CRemoteFileList::findFirstByMatchingBaseNameOrDefault(const QString &baseName) const
{ {
if (name.isEmpty()) { return CRemoteFile(); } if (baseName.isEmpty()) { return CRemoteFile(); }
for (const CRemoteFile &rf : *this) for (const CRemoteFile &rf : *this)
{ {
if (rf.matchesName(name)) { return rf; } if (rf.matchesBaseName(baseName)) { return rf; }
} }
return CRemoteFile(); return CRemoteFile();
} }

View File

@@ -45,7 +45,7 @@ namespace BlackMisc
QStringList getNames(bool sorted = true) const; QStringList getNames(bool sorted = true) const;
//! All file names plus size //! All file names plus size
QStringList getNamesPlusSize(bool sorted = true) const; QStringList getBaseNamesPlusSize(bool sorted = true) const;
//! First by name of default //! First by name of default
CRemoteFile findFirstByNameOrDefault(const QString &name) const; CRemoteFile findFirstByNameOrDefault(const QString &name) const;
@@ -54,7 +54,7 @@ namespace BlackMisc
CRemoteFile findFirstContainingNameOrDefault(const QString &name, Qt::CaseSensitivity cs) const; CRemoteFile findFirstContainingNameOrDefault(const QString &name, Qt::CaseSensitivity cs) const;
//! Find first matching name of default //! Find first matching name of default
CRemoteFile findFirstByMatchingNameOrDefault(const QString &name) const; CRemoteFile findFirstByMatchingBaseNameOrDefault(const QString &name) const;
//! Find all executable files (decided by appendix) //! Find all executable files (decided by appendix)
CRemoteFileList findExecutableFiles() const; CRemoteFileList findExecutableFiles() const;