mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-02 05:38:06 -06:00
Avoid repeating the return type
This commit is contained in:
@@ -47,10 +47,10 @@ void SpeedMonitor::addSample(const SpeedSample &sample)
|
||||
SpeedSampleAvg SpeedMonitor::average() const
|
||||
{
|
||||
if (m_speedSamples.empty())
|
||||
return SpeedSampleAvg();
|
||||
return {};
|
||||
|
||||
const qreal k = qreal(1.) / m_speedSamples.size();
|
||||
return SpeedSampleAvg(m_sum.download * k, m_sum.upload * k);
|
||||
return {m_sum.download * k, m_sum.upload * k};
|
||||
}
|
||||
|
||||
void SpeedMonitor::reset()
|
||||
|
||||
@@ -4299,11 +4299,11 @@ namespace
|
||||
|
||||
using PCONVERTIFACENAMETOLUID = NETIO_STATUS (WINAPI *)(const WCHAR *, PNET_LUID);
|
||||
const auto ConvertIfaceNameToLuid = Utils::Misc::loadWinAPI<PCONVERTIFACENAMETOLUID>("Iphlpapi.dll", "ConvertInterfaceNameToLuidW");
|
||||
if (!ConvertIfaceNameToLuid) return QString();
|
||||
if (!ConvertIfaceNameToLuid) return {};
|
||||
|
||||
using PCONVERTIFACELUIDTOGUID = NETIO_STATUS (WINAPI *)(const NET_LUID *, GUID *);
|
||||
const auto ConvertIfaceLuidToGuid = Utils::Misc::loadWinAPI<PCONVERTIFACELUIDTOGUID>("Iphlpapi.dll", "ConvertInterfaceLuidToGuid");
|
||||
if (!ConvertIfaceLuidToGuid) return QString();
|
||||
if (!ConvertIfaceLuidToGuid) return {};
|
||||
|
||||
NET_LUID luid;
|
||||
const LONG res = ConvertIfaceNameToLuid(name.toStdWString().c_str(), &luid);
|
||||
@@ -4313,7 +4313,7 @@ namespace
|
||||
return QUuid(guid).toString().toUpper();
|
||||
}
|
||||
|
||||
return QString();
|
||||
return {};
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -297,7 +297,7 @@ QString TorrentHandle::savePath(bool actual) const
|
||||
QString TorrentHandle::rootPath(bool actual) const
|
||||
{
|
||||
if ((filesCount() > 1) && !hasRootFolder())
|
||||
return QString();
|
||||
return {};
|
||||
|
||||
const QString firstFilePath = filePath(0);
|
||||
const int slashIndex = firstFilePath.indexOf('/');
|
||||
@@ -593,7 +593,7 @@ QString TorrentHandle::filePath(int index) const
|
||||
|
||||
QString TorrentHandle::fileName(int index) const
|
||||
{
|
||||
if (!hasMetadata()) return QString();
|
||||
if (!hasMetadata()) return {};
|
||||
return Utils::Fs::fileName(filePath(index));
|
||||
}
|
||||
|
||||
@@ -606,7 +606,7 @@ qlonglong TorrentHandle::fileSize(int index) const
|
||||
// to all files in a torrent
|
||||
QStringList TorrentHandle::absoluteFilePaths() const
|
||||
{
|
||||
if (!hasMetadata()) return QStringList();
|
||||
if (!hasMetadata()) return {};
|
||||
|
||||
const QDir saveDir(savePath(true));
|
||||
QStringList res;
|
||||
@@ -617,7 +617,7 @@ QStringList TorrentHandle::absoluteFilePaths() const
|
||||
|
||||
QStringList TorrentHandle::absoluteFilePathsUnwanted() const
|
||||
{
|
||||
if (!hasMetadata()) return QStringList();
|
||||
if (!hasMetadata()) return {};
|
||||
|
||||
const QDir saveDir(savePath(true));
|
||||
QStringList res;
|
||||
@@ -987,7 +987,7 @@ QDateTime TorrentHandle::lastSeenComplete() const
|
||||
if (m_nativeStatus.last_seen_complete > 0)
|
||||
return QDateTime::fromTime_t(m_nativeStatus.last_seen_complete);
|
||||
else
|
||||
return QDateTime();
|
||||
return {};
|
||||
}
|
||||
|
||||
QDateTime TorrentHandle::completedTime() const
|
||||
@@ -995,7 +995,7 @@ QDateTime TorrentHandle::completedTime() const
|
||||
if (m_nativeStatus.completed_time > 0)
|
||||
return QDateTime::fromTime_t(m_nativeStatus.completed_time);
|
||||
else
|
||||
return QDateTime();
|
||||
return {};
|
||||
}
|
||||
|
||||
int TorrentHandle::timeSinceUpload() const
|
||||
|
||||
@@ -133,32 +133,32 @@ bool TorrentInfo::isValid() const
|
||||
|
||||
InfoHash TorrentInfo::hash() const
|
||||
{
|
||||
if (!isValid()) return InfoHash();
|
||||
if (!isValid()) return {};
|
||||
return m_nativeInfo->info_hash();
|
||||
}
|
||||
|
||||
QString TorrentInfo::name() const
|
||||
{
|
||||
if (!isValid()) return QString();
|
||||
if (!isValid()) return {};
|
||||
return QString::fromStdString(m_nativeInfo->name());
|
||||
}
|
||||
|
||||
QDateTime TorrentInfo::creationDate() const
|
||||
{
|
||||
if (!isValid()) return QDateTime();
|
||||
if (!isValid()) return {};
|
||||
const boost::optional<time_t> t = m_nativeInfo->creation_date();
|
||||
return t ? QDateTime::fromTime_t(*t) : QDateTime();
|
||||
}
|
||||
|
||||
QString TorrentInfo::creator() const
|
||||
{
|
||||
if (!isValid()) return QString();
|
||||
if (!isValid()) return {};
|
||||
return QString::fromStdString(m_nativeInfo->creator());
|
||||
}
|
||||
|
||||
QString TorrentInfo::comment() const
|
||||
{
|
||||
if (!isValid()) return QString();
|
||||
if (!isValid()) return {};
|
||||
return QString::fromStdString(m_nativeInfo->comment());
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ int TorrentInfo::piecesCount() const
|
||||
|
||||
QString TorrentInfo::filePath(const int index) const
|
||||
{
|
||||
if (!isValid()) return QString();
|
||||
if (!isValid()) return {};
|
||||
return Utils::Fs::fromNativePath(QString::fromStdString(m_nativeInfo->files().file_path(index)));
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ QString TorrentInfo::fileName(const int index) const
|
||||
|
||||
QString TorrentInfo::origFilePath(const int index) const
|
||||
{
|
||||
if (!isValid()) return QString();
|
||||
if (!isValid()) return {};
|
||||
return Utils::Fs::fromNativePath(QString::fromStdString(m_nativeInfo->orig_files().file_path(index)));
|
||||
}
|
||||
|
||||
@@ -238,7 +238,7 @@ qlonglong TorrentInfo::fileOffset(const int index) const
|
||||
|
||||
QList<TrackerEntry> TorrentInfo::trackers() const
|
||||
{
|
||||
if (!isValid()) return QList<TrackerEntry>();
|
||||
if (!isValid()) return {};
|
||||
|
||||
QList<TrackerEntry> trackers;
|
||||
for (const libt::announce_entry &tracker : m_nativeInfo->trackers())
|
||||
@@ -249,7 +249,7 @@ QList<TrackerEntry> TorrentInfo::trackers() const
|
||||
|
||||
QList<QUrl> TorrentInfo::urlSeeds() const
|
||||
{
|
||||
if (!isValid()) return QList<QUrl>();
|
||||
if (!isValid()) return {};
|
||||
|
||||
QList<QUrl> urlSeeds;
|
||||
for (const libt::web_seed_entry &webSeed : m_nativeInfo->web_seeds())
|
||||
@@ -261,8 +261,8 @@ QList<QUrl> TorrentInfo::urlSeeds() const
|
||||
|
||||
QByteArray TorrentInfo::metadata() const
|
||||
{
|
||||
if (!isValid()) return QByteArray();
|
||||
return QByteArray(m_nativeInfo->metadata().get(), m_nativeInfo->metadata_size());
|
||||
if (!isValid()) return {};
|
||||
return {m_nativeInfo->metadata().get(), m_nativeInfo->metadata_size()};
|
||||
}
|
||||
|
||||
QStringList TorrentInfo::filesForPiece(const int pieceIndex) const
|
||||
@@ -281,7 +281,7 @@ QStringList TorrentInfo::filesForPiece(const int pieceIndex) const
|
||||
QVector<int> TorrentInfo::fileIndicesForPiece(const int pieceIndex) const
|
||||
{
|
||||
if (!isValid() || (pieceIndex < 0) || (pieceIndex >= piecesCount()))
|
||||
return QVector<int>();
|
||||
return {};
|
||||
|
||||
const std::vector<libt::file_slice> files(
|
||||
nativeInfo()->map_block(pieceIndex, 0, nativeInfo()->piece_size(pieceIndex)));
|
||||
|
||||
@@ -98,7 +98,7 @@ QVector<Log::Msg> Logger::getMessages(int lastKnownId) const
|
||||
return m_messages;
|
||||
|
||||
if (diff <= 0)
|
||||
return QVector<Log::Msg>();
|
||||
return {};
|
||||
|
||||
return m_messages.mid(size - diff);
|
||||
}
|
||||
@@ -114,7 +114,7 @@ QVector<Log::Peer> Logger::getPeers(int lastKnownId) const
|
||||
return m_peers;
|
||||
|
||||
if (diff <= 0)
|
||||
return QVector<Log::Peer>();
|
||||
return {};
|
||||
|
||||
return m_peers.mid(size - diff);
|
||||
}
|
||||
|
||||
@@ -288,11 +288,11 @@ QUrl DNSUpdater::getRegistrationUrl(int service)
|
||||
{
|
||||
switch (service) {
|
||||
case DNS::DYNDNS:
|
||||
return QUrl("https://www.dyndns.com/account/services/hosts/add.html");
|
||||
return {"https://www.dyndns.com/account/services/hosts/add.html"};
|
||||
case DNS::NOIP:
|
||||
return QUrl("https://www.noip.com/remote-access");
|
||||
return {"https://www.noip.com/remote-access"};
|
||||
default:
|
||||
Q_ASSERT(0);
|
||||
}
|
||||
return QUrl();
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ QString GeoIPManager::lookup(const QHostAddress &hostAddr) const
|
||||
if (m_enabled && m_geoIPDatabase)
|
||||
return m_geoIPDatabase->lookup(hostAddr);
|
||||
|
||||
return QString();
|
||||
return {};
|
||||
}
|
||||
|
||||
QString GeoIPManager::CountryName(const QString &countryISOCode)
|
||||
|
||||
@@ -176,7 +176,7 @@ QString GeoIPDatabase::lookup(const QHostAddress &hostAddr) const
|
||||
fromBigEndian(idPtr, 4);
|
||||
|
||||
if (id == m_nodeCount) {
|
||||
return QString();
|
||||
return {};
|
||||
}
|
||||
if (id > m_nodeCount) {
|
||||
QString country = m_countries.value(id);
|
||||
@@ -196,7 +196,7 @@ QString GeoIPDatabase::lookup(const QHostAddress &hostAddr) const
|
||||
}
|
||||
}
|
||||
|
||||
return QString();
|
||||
return {};
|
||||
}
|
||||
|
||||
#define CHECK_METADATA_REQ(key, type) \
|
||||
@@ -304,14 +304,14 @@ QVariantHash GeoIPDatabase::readMetadata() const
|
||||
return metadata.toHash();
|
||||
}
|
||||
|
||||
return QVariantHash();
|
||||
return {};
|
||||
}
|
||||
|
||||
QVariant GeoIPDatabase::readDataField(quint32 &offset) const
|
||||
{
|
||||
DataFieldDescriptor descr;
|
||||
if (!readDataFieldDescriptor(offset, descr))
|
||||
return QVariant();
|
||||
return {};
|
||||
|
||||
quint32 locOffset = offset;
|
||||
bool usePointer = false;
|
||||
@@ -320,7 +320,7 @@ QVariant GeoIPDatabase::readDataField(quint32 &offset) const
|
||||
// convert offset from data section to global
|
||||
locOffset = descr.offset + (m_nodeCount * m_recordSize / 4) + sizeof(DATA_SECTION_SEPARATOR);
|
||||
if (!readDataFieldDescriptor(locOffset, descr))
|
||||
return QVariant();
|
||||
return {};
|
||||
}
|
||||
|
||||
QVariant fieldValue;
|
||||
@@ -459,12 +459,12 @@ QVariant GeoIPDatabase::readMapValue(quint32 &offset, quint32 count) const
|
||||
for (quint32 i = 0; i < count; ++i) {
|
||||
QVariant field = readDataField(offset);
|
||||
if (field.userType() != QMetaType::QString)
|
||||
return QVariant();
|
||||
return {};
|
||||
|
||||
QString key = field.toString();
|
||||
field = readDataField(offset);
|
||||
if (field.userType() == QVariant::Invalid)
|
||||
return QVariant();
|
||||
return {};
|
||||
|
||||
map[key] = field;
|
||||
}
|
||||
@@ -479,7 +479,7 @@ QVariant GeoIPDatabase::readArrayValue(quint32 &offset, quint32 count) const
|
||||
for (quint32 i = 0; i < count; ++i) {
|
||||
QVariant field = readDataField(offset);
|
||||
if (field.userType() == QVariant::Invalid)
|
||||
return QVariant();
|
||||
return {};
|
||||
|
||||
array.append(field);
|
||||
}
|
||||
|
||||
@@ -464,7 +464,7 @@ namespace
|
||||
offset = parts[2].toInt(&ok[0]) * 3600;
|
||||
int offsetMin = parts[3].toInt(&ok[1]);
|
||||
if (!ok[0] || !ok[1] || offsetMin > 59)
|
||||
return QDateTime();
|
||||
return {};
|
||||
offset += offsetMin * 60;
|
||||
negOffset = (parts[1] == QLatin1String("-"));
|
||||
if (negOffset)
|
||||
@@ -494,7 +494,7 @@ namespace
|
||||
for (int i = 0, end = zone.size(); (i < end) && !nonalpha; ++i)
|
||||
nonalpha = !isalpha(zone[i]);
|
||||
if (nonalpha)
|
||||
return QDateTime();
|
||||
return {};
|
||||
// TODO: Attempt to recognize the time zone abbreviation?
|
||||
negOffset = true; // unknown time zone: RFC 2822 treats as '-0000'
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace
|
||||
switch (static_cast<int>(triStateBool)) {
|
||||
case 0: return false;
|
||||
case 1: return true;
|
||||
default: return QJsonValue();
|
||||
default: return {};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ QString computeEpisodeName(const QString &article)
|
||||
|
||||
// See if we can extract an season/episode number or date from the title
|
||||
if (!match.hasMatch())
|
||||
return QString();
|
||||
return {};
|
||||
|
||||
QStringList ret;
|
||||
for (int i = 1; i <= match.lastCapturedIndex(); ++i) {
|
||||
|
||||
@@ -107,7 +107,7 @@ int ScanFoldersModel::columnCount(const QModelIndex &parent) const
|
||||
QVariant ScanFoldersModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid() || (index.row() >= rowCount()))
|
||||
return QVariant();
|
||||
return {};
|
||||
|
||||
const PathData *pathData = m_pathList.at(index.row());
|
||||
QVariant value;
|
||||
@@ -141,7 +141,7 @@ QVariant ScanFoldersModel::data(const QModelIndex &index, int role) const
|
||||
QVariant ScanFoldersModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if ((orientation != Qt::Horizontal) || (role != Qt::DisplayRole) || (section < 0) || (section >= columnCount()))
|
||||
return QVariant();
|
||||
return {};
|
||||
|
||||
QVariant title;
|
||||
|
||||
@@ -311,7 +311,7 @@ QString ScanFoldersModel::downloadPathTorrentFolder(const QString &filePath) con
|
||||
if (data->downloadType == CUSTOM_LOCATION)
|
||||
return data->downloadPath;
|
||||
|
||||
return QString();
|
||||
return {};
|
||||
}
|
||||
|
||||
int ScanFoldersModel::findPathData(const QString &path) const
|
||||
@@ -399,5 +399,5 @@ QString ScanFoldersModel::pathTypeDisplayName(const PathType type)
|
||||
default:
|
||||
qDebug("Invalid PathType: %d", type);
|
||||
};
|
||||
return QString();
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -282,7 +282,7 @@ QString TransactionalSettings::deserialize(const QString &name, QVariantHash &da
|
||||
SettingsPtr settings = Profile::instance().applicationSettings(name);
|
||||
|
||||
if (settings->allKeys().isEmpty())
|
||||
return QString();
|
||||
return {};
|
||||
|
||||
// Copy everything into memory. This means even keys inserted in the file manually
|
||||
// or that we don't touch directly in this code (eg disabled by ifdef). This ensures
|
||||
@@ -314,5 +314,5 @@ QString TransactionalSettings::serialize(const QString &name, const QVariantHash
|
||||
Logger::instance()->addMessage(QObject::tr("An unknown error occurred while trying to write the configuration file."), Log::CRITICAL);
|
||||
break;
|
||||
}
|
||||
return QString();
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -227,7 +227,7 @@ namespace
|
||||
return path;
|
||||
}
|
||||
|
||||
return QString();
|
||||
return {};
|
||||
}
|
||||
#endif // Q_OS_WIN
|
||||
}
|
||||
|
||||
@@ -256,7 +256,7 @@ QPoint Utils::Misc::screenCenter(const QWidget *w)
|
||||
QDesktopWidget *desktop = QApplication::desktop();
|
||||
int scrn = desktop->screenNumber(parent); // fallback to `primaryScreen` when parent is invalid
|
||||
QRect r = desktop->availableGeometry(scrn);
|
||||
return QPoint(r.x() + (r.width() - w->frameSize().width()) / 2, r.y() + (r.height() - w->frameSize().height()) / 2);
|
||||
return {r.x() + (r.width() - w->frameSize().width()) / 2, r.y() + (r.height() - w->frameSize().height()) / 2};
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace Utils
|
||||
QSslKey key {data, QSsl::Rsa};
|
||||
if (!key.isNull())
|
||||
return key;
|
||||
return QSslKey(data, QSsl::Ec);
|
||||
return {data, QSsl::Ec};
|
||||
}
|
||||
|
||||
bool isSSLKeyValid(const QByteArray &data)
|
||||
|
||||
Reference in New Issue
Block a user