mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-01-05 22:57:25 +03:00
Don't use 'else' after return/break
This commit is contained in:
parent
78ab0e4ba9
commit
8a3f942385
15 changed files with 75 additions and 83 deletions
|
@ -89,7 +89,7 @@ namespace
|
||||||
|
|
||||||
if ((USAGE_TEXT_COLUMN - usage.length() - 4) > 0)
|
if ((USAGE_TEXT_COLUMN - usage.length() - 4) > 0)
|
||||||
return res + QString(USAGE_TEXT_COLUMN - usage.length() - 4, ' ');
|
return res + QString(USAGE_TEXT_COLUMN - usage.length() - 4, ' ');
|
||||||
else
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,13 +256,13 @@ namespace
|
||||||
if (parts.size() == 1) {
|
if (parts.size() == 1) {
|
||||||
return TriStateBool(m_defaultValue);
|
return TriStateBool(m_defaultValue);
|
||||||
}
|
}
|
||||||
else if (parts.size() == 2) {
|
if (parts.size() == 2) {
|
||||||
QString val = parts[1];
|
QString val = parts[1];
|
||||||
|
|
||||||
if ((val.toUpper() == QLatin1String("TRUE")) || (val == QLatin1String("1"))) {
|
if ((val.toUpper() == QLatin1String("TRUE")) || (val == QLatin1String("1"))) {
|
||||||
return TriStateBool::True;
|
return TriStateBool::True;
|
||||||
}
|
}
|
||||||
else if ((val.toUpper() == QLatin1String("FALSE")) || (val == QLatin1String("0"))) {
|
if ((val.toUpper() == QLatin1String("FALSE")) || (val == QLatin1String("0"))) {
|
||||||
return TriStateBool::False;
|
return TriStateBool::False;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -281,21 +281,20 @@ namespace
|
||||||
if (val.isEmpty()) {
|
if (val.isEmpty()) {
|
||||||
return TriStateBool(m_defaultValue);
|
return TriStateBool(m_defaultValue);
|
||||||
}
|
}
|
||||||
else if (val == QLatin1String("-1")) {
|
if (val == QLatin1String("-1")) {
|
||||||
return TriStateBool::Undefined;
|
return TriStateBool::Undefined;
|
||||||
}
|
}
|
||||||
else if ((val.toUpper() == QLatin1String("TRUE")) || (val == QLatin1String("1"))) {
|
if ((val.toUpper() == QLatin1String("TRUE")) || (val == QLatin1String("1"))) {
|
||||||
return TriStateBool::True;
|
return TriStateBool::True;
|
||||||
}
|
}
|
||||||
else if ((val.toUpper() == QLatin1String("FALSE")) || (val == QLatin1String("0"))) {
|
if ((val.toUpper() == QLatin1String("FALSE")) || (val == QLatin1String("0"))) {
|
||||||
return TriStateBool::False;
|
return TriStateBool::False;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
qDebug() << QObject::tr("Expected %1 in environment variable '%2', but got '%3'")
|
qDebug() << QObject::tr("Expected %1 in environment variable '%2', but got '%3'")
|
||||||
.arg(QLatin1String("true|false"), envVarName(), val);
|
.arg(QLatin1String("true|false"), envVarName(), val);
|
||||||
return TriStateBool::Undefined;
|
return TriStateBool::Undefined;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
bool m_defaultValue;
|
bool m_defaultValue;
|
||||||
};
|
};
|
||||||
|
|
|
@ -177,9 +177,8 @@ int FilterParserThread::parseDATFilterFile()
|
||||||
memmove(buffer.data(), buffer.data() + start, offset);
|
memmove(buffer.data(), buffer.data() + start, offset);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
++nbLine;
|
++nbLine;
|
||||||
}
|
|
||||||
|
|
||||||
if ((buffer[start] == '#')
|
if ((buffer[start] == '#')
|
||||||
|| ((buffer[start] == '/') && ((start + 1 < dataSize) && (buffer[start + 1] == '/')))) {
|
|| ((buffer[start] == '/') && ((start + 1 < dataSize) && (buffer[start + 1] == '/')))) {
|
||||||
|
@ -325,9 +324,8 @@ int FilterParserThread::parseP2PFilterFile()
|
||||||
memmove(buffer.data(), buffer.data() + start, offset);
|
memmove(buffer.data(), buffer.data() + start, offset);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
++nbLine;
|
++nbLine;
|
||||||
}
|
|
||||||
|
|
||||||
if ((buffer[start] == '#')
|
if ((buffer[start] == '#')
|
||||||
|| ((buffer[start] == '/') && ((start + 1 < dataSize) && (buffer[start + 1] == '/')))) {
|
|| ((buffer[start] == '/') && ((start + 1 < dataSize) && (buffer[start + 1] == '/')))) {
|
||||||
|
|
|
@ -59,11 +59,11 @@ TrackerEntry::Status TrackerEntry::status() const
|
||||||
// true when the tracker hasn't been tried yet.
|
// true when the tracker hasn't been tried yet.
|
||||||
if (m_nativeEntry.verified && m_nativeEntry.is_working())
|
if (m_nativeEntry.verified && m_nativeEntry.is_working())
|
||||||
return Working;
|
return Working;
|
||||||
else if ((m_nativeEntry.fails == 0) && m_nativeEntry.updating)
|
if ((m_nativeEntry.fails == 0) && m_nativeEntry.updating)
|
||||||
return Updating;
|
return Updating;
|
||||||
else if (m_nativeEntry.fails == 0)
|
if (m_nativeEntry.fails == 0)
|
||||||
return NotContacted;
|
return NotContacted;
|
||||||
else
|
|
||||||
return NotWorking;
|
return NotWorking;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -178,7 +178,7 @@ QString GeoIPDatabase::lookup(const QHostAddress &hostAddr) const
|
||||||
if (id == m_nodeCount) {
|
if (id == m_nodeCount) {
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
else if (id > m_nodeCount) {
|
if (id > m_nodeCount) {
|
||||||
QString country = m_countries.value(id);
|
QString country = m_countries.value(id);
|
||||||
if (country.isEmpty()) {
|
if (country.isEmpty()) {
|
||||||
const quint32 offset = id - m_nodeCount - sizeof(DATA_SECTION_SEPARATOR);
|
const quint32 offset = id - m_nodeCount - sizeof(DATA_SECTION_SEPARATOR);
|
||||||
|
@ -191,11 +191,10 @@ QString GeoIPDatabase::lookup(const QHostAddress &hostAddr) const
|
||||||
}
|
}
|
||||||
return country;
|
return country;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
ptr = m_data + (id * m_nodeSize);
|
ptr = m_data + (id * m_nodeSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
@ -205,7 +204,7 @@ if (!metadata.contains(#key)) { \
|
||||||
error = errMsgNotFound.arg(#key); \
|
error = errMsgNotFound.arg(#key); \
|
||||||
return false; \
|
return false; \
|
||||||
} \
|
} \
|
||||||
else if (metadata.value(#key).userType() != QMetaType::type) { \
|
if (metadata.value(#key).userType() != QMetaType::type) { \
|
||||||
error = errMsgInvalid.arg(#key); \
|
error = errMsgInvalid.arg(#key); \
|
||||||
return false; \
|
return false; \
|
||||||
}
|
}
|
||||||
|
|
|
@ -556,23 +556,21 @@ void Parser::parse_impl(const QByteArray &feedData)
|
||||||
foundChannel = true;
|
foundChannel = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
qDebug() << "Skip rss item: " << xml.name();
|
qDebug() << "Skip rss item: " << xml.name();
|
||||||
xml.skipCurrentElement();
|
xml.skipCurrentElement();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (xml.name() == "feed") { // Atom feed
|
if (xml.name() == "feed") { // Atom feed
|
||||||
parseAtomChannel(xml);
|
parseAtomChannel(xml);
|
||||||
foundChannel = true;
|
foundChannel = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
qDebug() << "Skip root item: " << xml.name();
|
qDebug() << "Skip root item: " << xml.name();
|
||||||
xml.skipCurrentElement();
|
xml.skipCurrentElement();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!foundChannel) {
|
if (!foundChannel) {
|
||||||
m_result.error = tr("Invalid RSS feed.");
|
m_result.error = tr("Invalid RSS feed.");
|
||||||
|
|
|
@ -81,8 +81,8 @@ QString Item::joinPath(const QString &path1, const QString &path2)
|
||||||
{
|
{
|
||||||
if (path1.isEmpty())
|
if (path1.isEmpty())
|
||||||
return path2;
|
return path2;
|
||||||
else
|
|
||||||
return path1 + Item::PathSeparator + path2;
|
return (path1 + Item::PathSeparator + path2);
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList Item::expandPath(const QString &path)
|
QStringList Item::expandPath(const QString &path)
|
||||||
|
|
|
@ -174,19 +174,22 @@ bool TorrentFilter::matchState(const BitTorrent::TorrentHandle *const torrent) c
|
||||||
bool TorrentFilter::matchHash(const BitTorrent::TorrentHandle *const torrent) const
|
bool TorrentFilter::matchHash(const BitTorrent::TorrentHandle *const torrent) const
|
||||||
{
|
{
|
||||||
if (m_hashSet == AnyHash) return true;
|
if (m_hashSet == AnyHash) return true;
|
||||||
else return m_hashSet.contains(torrent->hash());
|
|
||||||
|
return m_hashSet.contains(torrent->hash());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TorrentFilter::matchCategory(const BitTorrent::TorrentHandle *const torrent) const
|
bool TorrentFilter::matchCategory(const BitTorrent::TorrentHandle *const torrent) const
|
||||||
{
|
{
|
||||||
if (m_category.isNull()) return true;
|
if (m_category.isNull()) return true;
|
||||||
else return (torrent->belongsToCategory(m_category));
|
|
||||||
|
return (torrent->belongsToCategory(m_category));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TorrentFilter::matchTag(const BitTorrent::TorrentHandle *const torrent) const
|
bool TorrentFilter::matchTag(const BitTorrent::TorrentHandle *const torrent) const
|
||||||
{
|
{
|
||||||
// Empty tag is a special value to indicate we're filtering for untagged torrents.
|
// Empty tag is a special value to indicate we're filtering for untagged torrents.
|
||||||
if (m_tag.isNull()) return true;
|
if (m_tag.isNull()) return true;
|
||||||
else if (m_tag.isEmpty()) return torrent->tags().isEmpty();
|
if (m_tag.isEmpty()) return torrent->tags().isEmpty();
|
||||||
else return (torrent->hasTag(m_tag));
|
|
||||||
|
return (torrent->hasTag(m_tag));
|
||||||
}
|
}
|
||||||
|
|
|
@ -285,8 +285,8 @@ int Utils::Misc::friendlyUnitPrecision(SizeUnit unit)
|
||||||
// friendlyUnit's number of digits after the decimal point
|
// friendlyUnit's number of digits after the decimal point
|
||||||
if (unit == SizeUnit::Byte) return 0;
|
if (unit == SizeUnit::Byte) return 0;
|
||||||
if (unit <= SizeUnit::MebiByte) return 1;
|
if (unit <= SizeUnit::MebiByte) return 1;
|
||||||
else if (unit == SizeUnit::GibiByte) return 2;
|
if (unit == SizeUnit::GibiByte) return 2;
|
||||||
else return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
qlonglong Utils::Misc::sizeInBytes(qreal size, Utils::Misc::SizeUnit unit)
|
qlonglong Utils::Misc::sizeInBytes(qreal size, Utils::Misc::SizeUnit unit)
|
||||||
|
|
|
@ -758,9 +758,8 @@ void MainWindow::tabChanged(int newTab)
|
||||||
m_searchFilterAction->setVisible(true);
|
m_searchFilterAction->setVisible(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
m_searchFilterAction->setVisible(false);
|
m_searchFilterAction->setVisible(false);
|
||||||
}
|
|
||||||
if (m_tabs->currentWidget() == m_searchWidget) {
|
if (m_tabs->currentWidget() == m_searchWidget) {
|
||||||
qDebug("Changed tab to search engine, giving focus to search input");
|
qDebug("Changed tab to search engine, giving focus to search input");
|
||||||
m_searchWidget->giveFocusToSearchInput();
|
m_searchWidget->giveFocusToSearchInput();
|
||||||
|
|
|
@ -1209,7 +1209,7 @@ int OptionsDialog::getMaxConnecs() const
|
||||||
{
|
{
|
||||||
if (!m_ui->checkMaxConnecs->isChecked())
|
if (!m_ui->checkMaxConnecs->isChecked())
|
||||||
return -1;
|
return -1;
|
||||||
else
|
|
||||||
return m_ui->spinMaxConnec->value();
|
return m_ui->spinMaxConnec->value();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1217,7 +1217,7 @@ int OptionsDialog::getMaxConnecsPerTorrent() const
|
||||||
{
|
{
|
||||||
if (!m_ui->checkMaxConnecsPerTorrent->isChecked())
|
if (!m_ui->checkMaxConnecsPerTorrent->isChecked())
|
||||||
return -1;
|
return -1;
|
||||||
else
|
|
||||||
return m_ui->spinMaxConnecPerTorrent->value();
|
return m_ui->spinMaxConnecPerTorrent->value();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1225,7 +1225,7 @@ int OptionsDialog::getMaxUploads() const
|
||||||
{
|
{
|
||||||
if (!m_ui->checkMaxUploads->isChecked())
|
if (!m_ui->checkMaxUploads->isChecked())
|
||||||
return -1;
|
return -1;
|
||||||
else
|
|
||||||
return m_ui->spinMaxUploads->value();
|
return m_ui->spinMaxUploads->value();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1233,7 +1233,7 @@ int OptionsDialog::getMaxUploadsPerTorrent() const
|
||||||
{
|
{
|
||||||
if (!m_ui->checkMaxUploadsPerTorrent->isChecked())
|
if (!m_ui->checkMaxUploadsPerTorrent->isChecked())
|
||||||
return -1;
|
return -1;
|
||||||
else
|
|
||||||
return m_ui->spinMaxUploadsPerTorrent->value();
|
return m_ui->spinMaxUploadsPerTorrent->value();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1645,7 +1645,7 @@ QString OptionsDialog::languageToLocalizedString(const QLocale &locale)
|
||||||
case QLocale::English: {
|
case QLocale::English: {
|
||||||
if (locale.country() == QLocale::Australia)
|
if (locale.country() == QLocale::Australia)
|
||||||
return QString::fromUtf8(C_LOCALE_ENGLISH_AUSTRALIA);
|
return QString::fromUtf8(C_LOCALE_ENGLISH_AUSTRALIA);
|
||||||
else if (locale.country() == QLocale::UnitedKingdom)
|
if (locale.country() == QLocale::UnitedKingdom)
|
||||||
return QString::fromUtf8(C_LOCALE_ENGLISH_UNITEDKINGDOM);
|
return QString::fromUtf8(C_LOCALE_ENGLISH_UNITEDKINGDOM);
|
||||||
return QString::fromUtf8(C_LOCALE_ENGLISH);
|
return QString::fromUtf8(C_LOCALE_ENGLISH);
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,10 +147,9 @@ bool PiecesBar::event(QEvent *e)
|
||||||
showToolTip(static_cast<QHelpEvent *>(e));
|
showToolTip(static_cast<QHelpEvent *>(e));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
return base::event(e);
|
return base::event(e);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void PiecesBar::enterEvent(QEvent *e)
|
void PiecesBar::enterEvent(QEvent *e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -96,13 +96,12 @@ bool TorrentContentFilterModel::lessThan(const QModelIndex &left, const QModelIn
|
||||||
const QString strR = right.data().toString();
|
const QString strR = right.data().toString();
|
||||||
return Utils::String::naturalLessThan<Qt::CaseInsensitive>(strL, strR);
|
return Utils::String::naturalLessThan<Qt::CaseInsensitive>(strL, strR);
|
||||||
}
|
}
|
||||||
else if ((leftType == TorrentContentModelItem::FolderType) && (sortOrder() == Qt::AscendingOrder)) {
|
if ((leftType == TorrentContentModelItem::FolderType) && (sortOrder() == Qt::AscendingOrder)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
return QSortFilterProxyModel::lessThan(left, right);
|
return QSortFilterProxyModel::lessThan(left, right);
|
||||||
};
|
};
|
||||||
|
@ -136,7 +135,6 @@ bool TorrentContentFilterModel::hasFiltered(const QModelIndex &folder) const
|
||||||
if (m_model->hasChildren(childIndex)) {
|
if (m_model->hasChildren(childIndex)) {
|
||||||
if (hasFiltered(childIndex))
|
if (hasFiltered(childIndex))
|
||||||
return true;
|
return true;
|
||||||
else
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
name = childIndex.data().toString();
|
name = childIndex.data().toString();
|
||||||
|
|
|
@ -287,7 +287,7 @@ int TorrentContentModel::columnCount(const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
if (parent.isValid())
|
if (parent.isValid())
|
||||||
return static_cast<TorrentContentModelItem*>(parent.internalPointer())->columnCount();
|
return static_cast<TorrentContentModelItem*>(parent.internalPointer())->columnCount();
|
||||||
else
|
|
||||||
return m_rootItem->columnCount();
|
return m_rootItem->columnCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -361,7 +361,7 @@ QVariant TorrentContentModel::data(const QModelIndex &index, int role) const
|
||||||
if ((index.column() == TorrentContentModelItem::COL_NAME) && (role == Qt::DecorationRole)) {
|
if ((index.column() == TorrentContentModelItem::COL_NAME) && (role == Qt::DecorationRole)) {
|
||||||
if (item->itemType() == TorrentContentModelItem::FolderType)
|
if (item->itemType() == TorrentContentModelItem::FolderType)
|
||||||
return getDirectoryIcon();
|
return getDirectoryIcon();
|
||||||
else
|
|
||||||
return m_fileIconProvider->icon(QFileInfo(item->name()));
|
return m_fileIconProvider->icon(QFileInfo(item->name()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -543,11 +543,11 @@ QStringList TrackerFiltersList::getHashes(int row)
|
||||||
{
|
{
|
||||||
if (row == 1)
|
if (row == 1)
|
||||||
return m_trackers.value("");
|
return m_trackers.value("");
|
||||||
else if (row == 2)
|
if (row == 2)
|
||||||
return m_errors.keys();
|
return m_errors.keys();
|
||||||
else if (row == 3)
|
if (row == 3)
|
||||||
return m_warnings.keys();
|
return m_warnings.keys();
|
||||||
else
|
|
||||||
return m_trackers.value(trackerFromRow(row));
|
return m_trackers.value(trackerFromRow(row));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -160,7 +160,7 @@ bool TransferListSortModel::lessThan(const QModelIndex &left, const QModelIndex
|
||||||
const bool isAscendingOrder = (sortOrder() == Qt::AscendingOrder);
|
const bool isAscendingOrder = (sortOrder() == Qt::AscendingOrder);
|
||||||
if (isSeedingL)
|
if (isSeedingL)
|
||||||
return !isAscendingOrder;
|
return !isAscendingOrder;
|
||||||
else
|
|
||||||
return isAscendingOrder;
|
return isAscendingOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,16 +171,15 @@ bool TransferListSortModel::lessThan(const QModelIndex &left, const QModelIndex
|
||||||
if (isInvalidL && isInvalidR) {
|
if (isInvalidL && isInvalidR) {
|
||||||
if (isSeedingL) // Both seeding
|
if (isSeedingL) // Both seeding
|
||||||
return dateLessThan(TransferListModel::TR_SEED_DATE, left, right, true);
|
return dateLessThan(TransferListModel::TR_SEED_DATE, left, right, true);
|
||||||
else
|
|
||||||
return (prioL < prioR);
|
return (prioL < prioR);
|
||||||
}
|
}
|
||||||
else if (!isInvalidL && !isInvalidR) {
|
if (!isInvalidL && !isInvalidR) {
|
||||||
return (etaL < etaR);
|
return (etaL < etaR);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
return !isInvalidL;
|
return !isInvalidL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
case TransferListModel::TR_LAST_ACTIVITY: {
|
case TransferListModel::TR_LAST_ACTIVITY: {
|
||||||
const int vL = left.data().toInt();
|
const int vL = left.data().toInt();
|
||||||
|
@ -221,7 +220,7 @@ bool TransferListSortModel::lowerPositionThan(const QModelIndex &left, const QMo
|
||||||
if ((queueL > 0) || (queueR > 0)) {
|
if ((queueL > 0) || (queueR > 0)) {
|
||||||
if ((queueL > 0) && (queueR > 0))
|
if ((queueL > 0) && (queueR > 0))
|
||||||
return queueL < queueR;
|
return queueL < queueR;
|
||||||
else
|
|
||||||
return queueL != 0;
|
return queueL != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue