mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-01-06 15:04:34 +08:00
Avoid repeating the return type
This commit is contained in:
parent
9959a901fe
commit
8c944bd4e1
@ -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)
|
||||
|
@ -71,7 +71,7 @@ QString AutoExpandableDialog::getText(QWidget *parent, const QString &title, con
|
||||
if (ok)
|
||||
*ok = res;
|
||||
|
||||
if (!res) return QString();
|
||||
if (!res) return {};
|
||||
|
||||
return d.m_ui->textEdit->text();
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ int CategoryFilterModel::columnCount(const QModelIndex &) const
|
||||
|
||||
QVariant CategoryFilterModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid()) return QVariant();
|
||||
if (!index.isValid()) return {};
|
||||
|
||||
auto item = static_cast<CategoryModelItem *>(index.internalPointer());
|
||||
|
||||
@ -224,7 +224,7 @@ QVariant CategoryFilterModel::data(const QModelIndex &index, int role) const
|
||||
return item->torrentsCount();
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
return {};
|
||||
}
|
||||
|
||||
Qt::ItemFlags CategoryFilterModel::flags(const QModelIndex &index) const
|
||||
@ -240,32 +240,32 @@ QVariant CategoryFilterModel::headerData(int section, Qt::Orientation orientatio
|
||||
if (section == 0)
|
||||
return tr("Categories");
|
||||
|
||||
return QVariant();
|
||||
return {};
|
||||
}
|
||||
|
||||
QModelIndex CategoryFilterModel::index(int row, int column, const QModelIndex &parent) const
|
||||
{
|
||||
if (column > 0)
|
||||
return QModelIndex();
|
||||
return {};
|
||||
|
||||
if (parent.isValid() && (parent.column() != 0))
|
||||
return QModelIndex();
|
||||
return {};
|
||||
|
||||
auto parentItem = parent.isValid() ? static_cast<CategoryModelItem *>(parent.internalPointer())
|
||||
: m_rootItem;
|
||||
if (row < parentItem->childCount())
|
||||
return createIndex(row, column, parentItem->childAt(row));
|
||||
|
||||
return QModelIndex();
|
||||
return {};
|
||||
}
|
||||
|
||||
QModelIndex CategoryFilterModel::parent(const QModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QModelIndex();
|
||||
return {};
|
||||
|
||||
auto item = static_cast<CategoryModelItem *>(index.internalPointer());
|
||||
if (!item) return QModelIndex();
|
||||
if (!item) return {};
|
||||
|
||||
return this->index(item->parent());
|
||||
}
|
||||
@ -291,13 +291,13 @@ QModelIndex CategoryFilterModel::index(const QString &categoryName) const
|
||||
|
||||
QString CategoryFilterModel::categoryName(const QModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid()) return QString();
|
||||
if (!index.isValid()) return {};
|
||||
return static_cast<CategoryModelItem *>(index.internalPointer())->fullName();
|
||||
}
|
||||
|
||||
QModelIndex CategoryFilterModel::index(CategoryModelItem *item) const
|
||||
{
|
||||
if (!item || !item->parent()) return QModelIndex();
|
||||
if (!item || !item->parent()) return {};
|
||||
|
||||
return index(item->pos(), 0, index(item->parent()));
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ QVariant CookiesModel::headerData(int section, Qt::Orientation orientation, int
|
||||
}
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
return {};
|
||||
}
|
||||
|
||||
QModelIndex CookiesModel::index(int row, int column, const QModelIndex &parent) const
|
||||
@ -66,7 +66,7 @@ QModelIndex CookiesModel::index(int row, int column, const QModelIndex &parent)
|
||||
if (parent.isValid() // no items with valid parent
|
||||
|| (row < 0) || (row >= m_cookies.size())
|
||||
|| (column < 0) || (column >= NB_COLUMNS))
|
||||
return QModelIndex();
|
||||
return {};
|
||||
|
||||
return createIndex(row, column, &m_cookies[row]);
|
||||
}
|
||||
@ -74,7 +74,7 @@ QModelIndex CookiesModel::index(int row, int column, const QModelIndex &parent)
|
||||
QModelIndex CookiesModel::parent(const QModelIndex &index) const
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
return QModelIndex();
|
||||
return {};
|
||||
}
|
||||
|
||||
int CookiesModel::rowCount(const QModelIndex &parent) const
|
||||
@ -94,7 +94,7 @@ QVariant CookiesModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid() || (index.row() >= m_cookies.size())
|
||||
|| ((role != Qt::DisplayRole) && (role != Qt::EditRole)))
|
||||
return QVariant();
|
||||
return {};
|
||||
|
||||
switch (index.column()) {
|
||||
case COL_DOMAIN:
|
||||
@ -109,7 +109,7 @@ QVariant CookiesModel::data(const QModelIndex &index, int role) const
|
||||
return m_cookies[index.row()].expirationDate();
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
return {};
|
||||
}
|
||||
|
||||
bool CookiesModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||
|
@ -311,7 +311,7 @@ QString Private::FileLineEdit::warningText(FileSystemPathValidator::TestResult r
|
||||
case TestResult::CantWrite:
|
||||
return tr("Does not have write permission in '%1'");
|
||||
default:
|
||||
return QString();
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ QIcon GuiIconProvider::getIcon(const QString &iconId, const QString &fallback) c
|
||||
|
||||
QIcon GuiIconProvider::getFlagIcon(const QString &countryIsoCode) const
|
||||
{
|
||||
if (countryIsoCode.isEmpty()) return QIcon();
|
||||
if (countryIsoCode.isEmpty()) return {};
|
||||
return QIcon(":/icons/flags/" + countryIsoCode.toLower() + ".svg");
|
||||
}
|
||||
|
||||
|
@ -1447,14 +1447,14 @@ QString OptionsDialog::getTorrentExportDir() const
|
||||
{
|
||||
if (m_ui->checkExportDir->isChecked())
|
||||
return Utils::Fs::expandPathAbs(m_ui->textExportDir->selectedPath());
|
||||
return QString();
|
||||
return {};
|
||||
}
|
||||
|
||||
QString OptionsDialog::getFinishedTorrentExportDir() const
|
||||
{
|
||||
if (m_ui->checkExportDirFin->isChecked())
|
||||
return Utils::Fs::expandPathAbs(m_ui->textExportDirFin->selectedPath());
|
||||
return QString();
|
||||
return {};
|
||||
}
|
||||
|
||||
// Return action on double-click on a downloading torrent set in options
|
||||
|
@ -166,6 +166,6 @@ namespace
|
||||
if (xml.isCharacters() && !xml.isWhitespace())
|
||||
return xml.text().toString();
|
||||
|
||||
return QString();
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ QVariant HtmlBrowser::loadResource(int type, const QUrl &name)
|
||||
m_netManager->get(req);
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
return {};
|
||||
}
|
||||
|
||||
return QTextBrowser::loadResource(type, name);
|
||||
|
@ -385,7 +385,7 @@ QString SearchJobWidget::statusText(SearchJobWidget::Status st)
|
||||
case Status::NoResults:
|
||||
return tr("Search returned no results");
|
||||
default:
|
||||
return QString();
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ namespace
|
||||
case SearchJobWidget::Status::NoResults:
|
||||
return QLatin1String("task-attention");
|
||||
default:
|
||||
return QString();
|
||||
return {};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ bool TagFilterModel::isSpecialItem(const QModelIndex &index)
|
||||
QVariant TagFilterModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid() || (index.column() != 0))
|
||||
return QVariant();
|
||||
return {};
|
||||
|
||||
const int row = index.internalId();
|
||||
Q_ASSERT(isValidRow(row));
|
||||
@ -129,7 +129,7 @@ QVariant TagFilterModel::data(const QModelIndex &index, int role) const
|
||||
case Qt::UserRole:
|
||||
return item.torrentsCount();
|
||||
default:
|
||||
return QVariant();
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
@ -145,13 +145,13 @@ QVariant TagFilterModel::headerData(int section, Qt::Orientation orientation, in
|
||||
if ((orientation == Qt::Horizontal) && (role == Qt::DisplayRole))
|
||||
if (section == 0)
|
||||
return tr("Tags");
|
||||
return QVariant();
|
||||
return {};
|
||||
}
|
||||
|
||||
QModelIndex TagFilterModel::index(int row, int, const QModelIndex &) const
|
||||
{
|
||||
if (!isValidRow(row))
|
||||
return QModelIndex();
|
||||
return {};
|
||||
return createIndex(row, 0, row);
|
||||
}
|
||||
|
||||
@ -171,14 +171,14 @@ QModelIndex TagFilterModel::index(const QString &tag) const
|
||||
{
|
||||
const int row = findRow(tag);
|
||||
if (!isValidRow(row))
|
||||
return QModelIndex();
|
||||
return {};
|
||||
return index(row, 0, QModelIndex());
|
||||
}
|
||||
|
||||
QString TagFilterModel::tag(const QModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QString();
|
||||
return {};
|
||||
const int row = index.internalId();
|
||||
Q_ASSERT(isValidRow(row));
|
||||
return m_tagItems[row].tag();
|
||||
|
@ -66,10 +66,10 @@ int TorrentContentFilterModel::getFileIndex(const QModelIndex &index) const
|
||||
|
||||
QModelIndex TorrentContentFilterModel::parent(const QModelIndex &child) const
|
||||
{
|
||||
if (!child.isValid()) return QModelIndex();
|
||||
if (!child.isValid()) return {};
|
||||
|
||||
QModelIndex sourceParent = m_model->parent(mapToSource(child));
|
||||
if (!sourceParent.isValid()) return QModelIndex();
|
||||
if (!sourceParent.isValid()) return {};
|
||||
|
||||
return mapFromSource(sourceParent);
|
||||
}
|
||||
|
@ -113,12 +113,12 @@ namespace
|
||||
const QString ext = info.suffix();
|
||||
if (!ext.isEmpty()) {
|
||||
QPixmap cached;
|
||||
if (QPixmapCache::find(ext, &cached)) return QIcon(cached);
|
||||
if (QPixmapCache::find(ext, &cached)) return {cached};
|
||||
|
||||
const QPixmap pixmap = pixmapForExtension(ext);
|
||||
if (!pixmap.isNull()) {
|
||||
QPixmapCache::insert(ext, pixmap);
|
||||
return QIcon(pixmap);
|
||||
return {pixmap};
|
||||
}
|
||||
}
|
||||
return UnifiedFileIconProvider::icon(info);
|
||||
@ -140,7 +140,7 @@ namespace
|
||||
HRESULT hr = ::SHGetFileInfoW(extWithDot.toStdWString().c_str(),
|
||||
FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(sfi), SHGFI_ICON | SHGFI_USEFILEATTRIBUTES);
|
||||
if (FAILED(hr))
|
||||
return QPixmap();
|
||||
return {};
|
||||
|
||||
QPixmap iconPixmap = QtWin::fromHICON(sfi.hIcon);
|
||||
::DestroyIcon(sfi.hIcon);
|
||||
@ -354,7 +354,7 @@ int TorrentContentModel::getFileIndex(const QModelIndex &index)
|
||||
QVariant TorrentContentModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
return {};
|
||||
|
||||
auto *item = static_cast<TorrentContentModelItem*>(index.internalPointer());
|
||||
|
||||
@ -376,7 +376,7 @@ QVariant TorrentContentModel::data(const QModelIndex &index, int role) const
|
||||
if (role == Qt::DisplayRole)
|
||||
return item->data(index.column());
|
||||
|
||||
return QVariant();
|
||||
return {};
|
||||
}
|
||||
|
||||
Qt::ItemFlags TorrentContentModel::flags(const QModelIndex &index) const
|
||||
@ -395,16 +395,16 @@ QVariant TorrentContentModel::headerData(int section, Qt::Orientation orientatio
|
||||
if ((orientation == Qt::Horizontal) && (role == Qt::DisplayRole))
|
||||
return m_rootItem->data(section);
|
||||
|
||||
return QVariant();
|
||||
return {};
|
||||
}
|
||||
|
||||
QModelIndex TorrentContentModel::index(int row, int column, const QModelIndex &parent) const
|
||||
{
|
||||
if (parent.isValid() && (parent.column() != 0))
|
||||
return QModelIndex();
|
||||
return {};
|
||||
|
||||
if (column >= TorrentContentModelItem::NB_COL)
|
||||
return QModelIndex();
|
||||
return {};
|
||||
|
||||
TorrentContentModelFolder *parentItem;
|
||||
if (!parent.isValid())
|
||||
@ -414,26 +414,26 @@ QModelIndex TorrentContentModel::index(int row, int column, const QModelIndex &p
|
||||
Q_ASSERT(parentItem);
|
||||
|
||||
if (row >= parentItem->childCount())
|
||||
return QModelIndex();
|
||||
return {};
|
||||
|
||||
TorrentContentModelItem *childItem = parentItem->child(row);
|
||||
if (childItem)
|
||||
return createIndex(row, column, childItem);
|
||||
return QModelIndex();
|
||||
return {};
|
||||
}
|
||||
|
||||
QModelIndex TorrentContentModel::parent(const QModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QModelIndex();
|
||||
return {};
|
||||
|
||||
auto *childItem = static_cast<TorrentContentModelItem*>(index.internalPointer());
|
||||
if (!childItem)
|
||||
return QModelIndex();
|
||||
return {};
|
||||
|
||||
TorrentContentModelItem *parentItem = childItem->parent();
|
||||
if (parentItem == m_rootItem)
|
||||
return QModelIndex();
|
||||
return {};
|
||||
|
||||
return createIndex(parentItem->row(), 0, parentItem);
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ QVariant TorrentContentModelItem::data(int column) const
|
||||
return availability();
|
||||
default:
|
||||
Q_ASSERT(false);
|
||||
return QVariant();
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ QModelIndex TorrentContentTreeView::currentNameCell()
|
||||
QModelIndex current = currentIndex();
|
||||
if (!current.isValid()) {
|
||||
Q_ASSERT(false);
|
||||
return QModelIndex();
|
||||
return {};
|
||||
}
|
||||
|
||||
return model()->index(current.row(), TorrentContentModelItem::COL_NAME, current.parent());
|
||||
|
@ -125,7 +125,7 @@ QVariant TransferListModel::headerData(int section, Qt::Orientation orientation,
|
||||
case TR_LAST_ACTIVITY: return tr("Last Activity", "Time passed since a chunk was downloaded/uploaded");
|
||||
case TR_TOTAL_SIZE: return tr("Total Size", "i.e. Size including unwanted data");
|
||||
default:
|
||||
return QVariant();
|
||||
return {};
|
||||
}
|
||||
}
|
||||
else if (role == Qt::TextAlignmentRole) {
|
||||
@ -149,22 +149,22 @@ QVariant TransferListModel::headerData(int section, Qt::Orientation orientation,
|
||||
case TR_RATIO:
|
||||
case TR_PRIORITY:
|
||||
case TR_LAST_ACTIVITY:
|
||||
return QVariant(Qt::AlignRight | Qt::AlignVCenter);
|
||||
return {Qt::AlignRight | Qt::AlignVCenter};
|
||||
default:
|
||||
return QAbstractListModel::headerData(section, orientation, role);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
return {};
|
||||
}
|
||||
|
||||
QVariant TransferListModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid()) return QVariant();
|
||||
if (!index.isValid()) return {};
|
||||
|
||||
BitTorrent::TorrentHandle *const torrent = m_torrents.value(index.row());
|
||||
if (!torrent) return QVariant();
|
||||
if (!torrent) return {};
|
||||
|
||||
if ((role == Qt::DecorationRole) && (index.column() == TR_NAME))
|
||||
return getIconByState(torrent->state());
|
||||
@ -173,7 +173,7 @@ QVariant TransferListModel::data(const QModelIndex &index, int role) const
|
||||
return getColorByState(torrent->state());
|
||||
|
||||
if ((role != Qt::DisplayRole) && (role != Qt::UserRole))
|
||||
return QVariant();
|
||||
return {};
|
||||
|
||||
switch (index.column()) {
|
||||
case TR_NAME:
|
||||
@ -243,7 +243,7 @@ QVariant TransferListModel::data(const QModelIndex &index, int role) const
|
||||
return torrent->totalSize();
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
return {};
|
||||
}
|
||||
|
||||
bool TransferListModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||
@ -366,32 +366,32 @@ QColor getColorByState(BitTorrent::TorrentState state)
|
||||
case BitTorrent::TorrentState::ForcedDownloading:
|
||||
case BitTorrent::TorrentState::DownloadingMetadata:
|
||||
if (!dark)
|
||||
return QColor(34, 139, 34); // Forest Green
|
||||
return {34, 139, 34}; // Forest Green
|
||||
else
|
||||
return QColor(50, 205, 50); // Lime Green
|
||||
return {50, 205, 50}; // Lime Green
|
||||
case BitTorrent::TorrentState::Allocating:
|
||||
case BitTorrent::TorrentState::StalledDownloading:
|
||||
case BitTorrent::TorrentState::StalledUploading:
|
||||
if (!dark)
|
||||
return QColor(0, 0, 0); // Black
|
||||
return {0, 0, 0}; // Black
|
||||
else
|
||||
return QColor(204, 204, 204); // Gray 80
|
||||
return {204, 204, 204}; // Gray 80
|
||||
case BitTorrent::TorrentState::Uploading:
|
||||
case BitTorrent::TorrentState::ForcedUploading:
|
||||
if (!dark)
|
||||
return QColor(65, 105, 225); // Royal Blue
|
||||
return {65, 105, 225}; // Royal Blue
|
||||
else
|
||||
return QColor(99, 184, 255); // Steel Blue 1
|
||||
return {99, 184, 255}; // Steel Blue 1
|
||||
case BitTorrent::TorrentState::PausedDownloading:
|
||||
return QColor(250, 128, 114); // Salmon
|
||||
return {250, 128, 114}; // Salmon
|
||||
case BitTorrent::TorrentState::PausedUploading:
|
||||
if (!dark)
|
||||
return QColor(0, 0, 139); // Dark Blue
|
||||
return {0, 0, 139}; // Dark Blue
|
||||
else
|
||||
return QColor(79, 148, 205); // Steel Blue 3
|
||||
return {79, 148, 205}; // Steel Blue 3
|
||||
case BitTorrent::TorrentState::Error:
|
||||
case BitTorrent::TorrentState::MissingFiles:
|
||||
return QColor(255, 0, 0); // red
|
||||
return {255, 0, 0}; // red
|
||||
case BitTorrent::TorrentState::QueuedDownloading:
|
||||
case BitTorrent::TorrentState::QueuedUploading:
|
||||
case BitTorrent::TorrentState::CheckingDownloading:
|
||||
@ -399,14 +399,14 @@ QColor getColorByState(BitTorrent::TorrentState state)
|
||||
case BitTorrent::TorrentState::CheckingResumeData:
|
||||
case BitTorrent::TorrentState::Moving:
|
||||
if (!dark)
|
||||
return QColor(0, 128, 128); // Teal
|
||||
return {0, 128, 128}; // Teal
|
||||
else
|
||||
return QColor(0, 205, 205); // Cyan 3
|
||||
return {0, 205, 205}; // Cyan 3
|
||||
case BitTorrent::TorrentState::Unknown:
|
||||
return QColor(255, 0, 0); // red
|
||||
return {255, 0, 0}; // red
|
||||
default:
|
||||
Q_ASSERT(false);
|
||||
return QColor(255, 0, 0); // red
|
||||
return {255, 0, 0}; // red
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ namespace
|
||||
QSize CheckBoxIconHelper::sizeHint() const
|
||||
{
|
||||
const int dim = QCheckBox::sizeHint().height();
|
||||
return QSize(dim, dim);
|
||||
return {dim, dim};
|
||||
}
|
||||
|
||||
void CheckBoxIconHelper::initStyleOption(QStyleOptionButton *opt) const
|
||||
@ -812,7 +812,7 @@ QStringList TransferListWidget::askTagsForSelection(const QString &dialogTitle)
|
||||
const QString tagsInput = AutoExpandableDialog::getText(
|
||||
this, dialogTitle, tr("Comma-separated tags:"), QLineEdit::Normal, "", &ok).trimmed();
|
||||
if (!ok || tagsInput.isEmpty())
|
||||
return QStringList();
|
||||
return {};
|
||||
tags = tagsInput.split(',', QString::SkipEmptyParts);
|
||||
for (QString &tag : tags) {
|
||||
tag = tag.trimmed();
|
||||
|
@ -96,7 +96,7 @@ QSize Utils::Gui::smallIconSize(const QWidget *widget)
|
||||
// Get DPI scaled icon size (device-dependent), see QT source
|
||||
// under a 1080p screen is usually 16x16
|
||||
const int s = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize, nullptr, widget);
|
||||
return QSize(s, s);
|
||||
return {s, s};
|
||||
}
|
||||
|
||||
QSize Utils::Gui::mediumIconSize(const QWidget *widget)
|
||||
@ -110,5 +110,5 @@ QSize Utils::Gui::largeIconSize(const QWidget *widget)
|
||||
// Get DPI scaled icon size (device-dependent), see QT source
|
||||
// under a 1080p screen is usually 32x32
|
||||
const int s = QApplication::style()->pixelMetric(QStyle::PM_LargeIconSize, nullptr, widget);
|
||||
return QSize(s, s);
|
||||
return {s, s};
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ namespace
|
||||
inline QUrl urlFromHostHeader(const QString &hostHeader)
|
||||
{
|
||||
if (!hostHeader.contains(QLatin1String("://")))
|
||||
return QUrl(QLatin1String("http://") + hostHeader);
|
||||
return {QLatin1String("http://") + hostHeader};
|
||||
return hostHeader;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user