mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-05 09:45:44 +08:00
Style: renaming methods
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user