From 5b14cf7f715bf7f98c8c25f7ba0e7468ec64c845 Mon Sep 17 00:00:00 2001 From: Mat Sutcliffe Date: Sun, 16 Aug 2020 20:01:01 +0100 Subject: [PATCH] Style: renaming methods --- src/blackgui/components/downloadcomponent.cpp | 2 +- .../components/installxswiftbuscomponent.cpp | 16 ++++++++-------- src/blackmisc/network/remotefile.cpp | 6 +++--- src/blackmisc/network/remotefile.h | 4 ++-- src/blackmisc/network/remotefilelist.cpp | 10 +++++----- src/blackmisc/network/remotefilelist.h | 4 ++-- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/blackgui/components/downloadcomponent.cpp b/src/blackgui/components/downloadcomponent.cpp index 253dd1681..4fafe490e 100644 --- a/src/blackgui/components/downloadcomponent.cpp +++ b/src/blackgui/components/downloadcomponent.cpp @@ -190,7 +190,7 @@ namespace BlackGui const CUrl download = remoteFile.getSmartUrl(); 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); return false; } diff --git a/src/blackgui/components/installxswiftbuscomponent.cpp b/src/blackgui/components/installxswiftbuscomponent.cpp index 02dba7469..2df5fa5da 100644 --- a/src/blackgui/components/installxswiftbuscomponent.cpp +++ b/src/blackgui/components/installxswiftbuscomponent.cpp @@ -222,7 +222,7 @@ namespace BlackGui const CUrl download = rf.getSmartUrl(); 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); return; } @@ -287,10 +287,10 @@ namespace BlackGui 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 CRemoteFileList remoteFiles = update.getArtifactsXSwiftBus().asRemoteFiles(); - return remoteFiles.findFirstByMatchingNameOrDefault(fileNameAndSize); + return remoteFiles.findFirstByMatchingBaseNameOrDefault(baseNameAndSize); } QString CInstallXSwiftBusComponent::downloadDir() const @@ -331,7 +331,7 @@ namespace BlackGui const CRemoteFileList remoteFiles = artifacts.asRemoteFiles(); if (!remoteFiles.isEmpty()) { - const QStringList xSwiftBusFiles(remoteFiles.getNamesPlusSize(false)); + const QStringList xSwiftBusFiles(remoteFiles.getBaseNamesPlusSize(false)); m_xSwiftBusArtifacts = artifacts; ui->cb_DownloadFile->addItems(xSwiftBusFiles); @@ -340,17 +340,17 @@ namespace BlackGui if (m_defaultDownloadName.isEmpty()) { const CRemoteFile rf = remoteFiles.findFirstContainingNameOrDefault(CBuildConfig::getVersionString(), Qt::CaseInsensitive); - if (rf.hasName()) { current = rf.getNameAndSize(); } + if (rf.hasName()) { current = rf.getBaseNameAndSize(); } } else { - const CRemoteFile rf = remoteFiles.findFirstByMatchingNameOrDefault(m_defaultDownloadName); - if (rf.hasName()) { current = rf.getNameAndSize(); } + const CRemoteFile rf = remoteFiles.findFirstByMatchingBaseNameOrDefault(m_defaultDownloadName); + if (rf.hasName()) { current = rf.getBaseNameAndSize(); } } ui->cb_DownloadFile->setCurrentText( current.isEmpty() ? - remoteFiles.frontOrDefault().getNameAndSize() : + remoteFiles.frontOrDefault().getBaseNameAndSize() : current ); // latest version } diff --git a/src/blackmisc/network/remotefile.cpp b/src/blackmisc/network/remotefile.cpp index 9d8ee26be..cf4920912 100644 --- a/src/blackmisc/network/remotefile.cpp +++ b/src/blackmisc/network/remotefile.cpp @@ -27,13 +27,13 @@ namespace BlackMisc : m_name(name), m_url(url), m_size(size) { } - QString CRemoteFile::getNameAndSize() const + QString CRemoteFile::getBaseNameAndSize() const { 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 (caseInsensitiveStringCompare(name, this->getBaseName())) { return true; } diff --git a/src/blackmisc/network/remotefile.h b/src/blackmisc/network/remotefile.h index d3a22b427..409a72d09 100644 --- a/src/blackmisc/network/remotefile.h +++ b/src/blackmisc/network/remotefile.h @@ -66,13 +66,13 @@ namespace BlackMisc bool hasName() const { return !m_name.isEmpty(); } //! Name + human readable size - QString getNameAndSize() const; + QString getBaseNameAndSize() const; //! Name void setName(const QString &name) { m_name = name.trimmed(); } //! Matching name? - bool matchesName(const QString &name) const; + bool matchesBaseName(const QString &baseName) const; //! Description const QString &getDescription() const { return m_description; } diff --git a/src/blackmisc/network/remotefilelist.cpp b/src/blackmisc/network/remotefilelist.cpp index 6d5b4176a..e89686fbe 100644 --- a/src/blackmisc/network/remotefilelist.cpp +++ b/src/blackmisc/network/remotefilelist.cpp @@ -35,12 +35,12 @@ namespace BlackMisc return fileNames; } - QStringList CRemoteFileList::getNamesPlusSize(bool sorted) const + QStringList CRemoteFileList::getBaseNamesPlusSize(bool sorted) const { QStringList fileNames; for (const CRemoteFile &rf : *this) { - fileNames.append(rf.getNameAndSize()); + fileNames.append(rf.getBaseNameAndSize()); } if (sorted) { fileNames.sort(); } return fileNames; @@ -62,12 +62,12 @@ namespace BlackMisc 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) { - if (rf.matchesName(name)) { return rf; } + if (rf.matchesBaseName(baseName)) { return rf; } } return CRemoteFile(); } diff --git a/src/blackmisc/network/remotefilelist.h b/src/blackmisc/network/remotefilelist.h index f802ebb68..bb63c9c1e 100644 --- a/src/blackmisc/network/remotefilelist.h +++ b/src/blackmisc/network/remotefilelist.h @@ -45,7 +45,7 @@ namespace BlackMisc QStringList getNames(bool sorted = true) const; //! All file names plus size - QStringList getNamesPlusSize(bool sorted = true) const; + QStringList getBaseNamesPlusSize(bool sorted = true) const; //! First by name of default CRemoteFile findFirstByNameOrDefault(const QString &name) const; @@ -54,7 +54,7 @@ namespace BlackMisc CRemoteFile findFirstContainingNameOrDefault(const QString &name, Qt::CaseSensitivity cs) const; //! 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) CRemoteFileList findExecutableFiles() const;