mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-02 13:48:05 -06:00
Fix coding style for various things
This commit is contained in:
committed by
sledgehammer999
parent
c62127e9f1
commit
62e71a15a4
@@ -425,7 +425,7 @@ void AdvancedSettings::loadAdvancedSettings()
|
||||
const QString currentInterface = session->networkInterface();
|
||||
bool interfaceExists = currentInterface.isEmpty();
|
||||
int i = 1;
|
||||
foreach (const QNetworkInterface& iface, QNetworkInterface::allInterfaces()) {
|
||||
foreach (const QNetworkInterface &iface, QNetworkInterface::allInterfaces()) {
|
||||
// This line fixes a Qt bug => https://bugreports.qt.io/browse/QTBUG-52633
|
||||
// Tested in Qt 5.6.0. For more info see:
|
||||
// https://github.com/qbittorrent/qBittorrent/issues/5131
|
||||
|
||||
@@ -350,7 +350,7 @@ void FileSystemPathComboEdit::addItem(const QString &text)
|
||||
editWidget<WidgetType>()->addItem(Utils::Fs::toNativePath(text));
|
||||
}
|
||||
|
||||
void FileSystemPathComboEdit::insertItem(int index, const QString& text)
|
||||
void FileSystemPathComboEdit::insertItem(int index, const QString &text)
|
||||
{
|
||||
editWidget<WidgetType>()->insertItem(index, Utils::Fs::toNativePath(text));
|
||||
}
|
||||
|
||||
@@ -305,7 +305,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
spacer->setMinimumWidth(8);
|
||||
m_ui->toolBar->addWidget(spacer);
|
||||
}
|
||||
#endif
|
||||
#endif // Q_OS_MAC
|
||||
|
||||
// Transfer list slots
|
||||
connect(m_ui->actionStart, &QAction::triggered, m_transferListWidget, &TransferListWidget::startSelectedTorrents);
|
||||
@@ -1110,7 +1110,7 @@ void MainWindow::toggleVisibility(const QSystemTrayIcon::ActivationReason reason
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif // Q_OS_MAC
|
||||
|
||||
// Display About Dialog
|
||||
void MainWindow::on_actionAbout_triggered()
|
||||
@@ -1272,7 +1272,7 @@ bool MainWindow::event(QEvent *e)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#endif // Q_OS_MAC
|
||||
|
||||
return QMainWindow::event(e);
|
||||
}
|
||||
@@ -1361,7 +1361,7 @@ void MainWindow::setupDockClickHandler()
|
||||
MacUtils::overrideDockClickHandler(dockClickHandler);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // Q_OS_MAC
|
||||
|
||||
/*****************************************************
|
||||
* *
|
||||
|
||||
@@ -163,7 +163,7 @@ OptionsDialog::OptionsDialog(QWidget *parent)
|
||||
QList<QAbstractButton *> buttons = m_ui->buttonBox->buttons();
|
||||
foreach (QAbstractButton *button, buttons) {
|
||||
if (m_ui->buttonBox->buttonRole(button) == QDialogButtonBox::ApplyRole) {
|
||||
applyButton = button;
|
||||
m_applyButton = button;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -424,13 +424,13 @@ OptionsDialog::OptionsDialog(QWidget *parent)
|
||||
connect(m_ui->btnEditRules, &QPushButton::clicked, this, [this]() { AutomatedRssDownloader(this).exec(); });
|
||||
|
||||
// Disable apply Button
|
||||
applyButton->setEnabled(false);
|
||||
m_applyButton->setEnabled(false);
|
||||
// Tab selection mechanism
|
||||
connect(m_ui->tabSelection, &QListWidget::currentItemChanged, this, &ThisType::changePage);
|
||||
// Load Advanced settings
|
||||
advancedSettings = new AdvancedSettings(m_ui->tabAdvancedPage);
|
||||
m_ui->advPageLayout->addWidget(advancedSettings);
|
||||
connect(advancedSettings, &AdvancedSettings::settingsChanged, this, &ThisType::enableApplyButton);
|
||||
m_advancedSettings = new AdvancedSettings(m_ui->tabAdvancedPage);
|
||||
m_ui->advPageLayout->addWidget(m_advancedSettings);
|
||||
connect(m_advancedSettings, &AdvancedSettings::settingsChanged, this, &ThisType::enableApplyButton);
|
||||
|
||||
m_ui->textFileLogPath->setDialogCaption(tr("Choose a save directory"));
|
||||
m_ui->textFileLogPath->setMode(FileSystemPathEdit::Mode::DirectorySave);
|
||||
@@ -493,7 +493,7 @@ OptionsDialog::~OptionsDialog()
|
||||
|
||||
saveWindowState();
|
||||
|
||||
foreach (const QString &path, addedScanDirs)
|
||||
foreach (const QString &path, m_addedScanDirs)
|
||||
ScanFoldersModel::instance()->removePath(path);
|
||||
ScanFoldersModel::instance()->configure(); // reloads "removed" paths
|
||||
delete m_ui;
|
||||
@@ -541,7 +541,7 @@ void OptionsDialog::saveWindowState() const
|
||||
|
||||
void OptionsDialog::saveOptions()
|
||||
{
|
||||
applyButton->setEnabled(false);
|
||||
m_applyButton->setEnabled(false);
|
||||
Preferences *const pref = Preferences::instance();
|
||||
// Load the translation
|
||||
QString locale = getLocale();
|
||||
@@ -625,11 +625,11 @@ void OptionsDialog::saveOptions()
|
||||
AddNewTorrentDialog::setTopLevel(m_ui->checkAdditionDialogFront->isChecked());
|
||||
session->setAddTorrentPaused(addTorrentsInPause());
|
||||
session->setCreateTorrentSubfolder(m_ui->checkCreateSubfolder->isChecked());
|
||||
ScanFoldersModel::instance()->removeFromFSWatcher(removedScanDirs);
|
||||
ScanFoldersModel::instance()->addToFSWatcher(addedScanDirs);
|
||||
ScanFoldersModel::instance()->removeFromFSWatcher(m_removedScanDirs);
|
||||
ScanFoldersModel::instance()->addToFSWatcher(m_addedScanDirs);
|
||||
ScanFoldersModel::instance()->makePersistent();
|
||||
removedScanDirs.clear();
|
||||
addedScanDirs.clear();
|
||||
m_removedScanDirs.clear();
|
||||
m_addedScanDirs.clear();
|
||||
session->setTorrentExportDirectory(getTorrentExportDir());
|
||||
session->setFinishedTorrentExportDirectory(getFinishedTorrentExportDir());
|
||||
pref->setMailNotificationEnabled(m_ui->groupMailNotification->isChecked());
|
||||
@@ -748,7 +748,7 @@ void OptionsDialog::saveOptions()
|
||||
// End Web UI
|
||||
// End preferences
|
||||
// Save advanced settings
|
||||
advancedSettings->saveAdvancedSettings();
|
||||
m_advancedSettings->saveAdvancedSettings();
|
||||
// Assume that user changed multiple settings
|
||||
// so it's best to save immediately
|
||||
pref->apply();
|
||||
@@ -1240,7 +1240,7 @@ int OptionsDialog::getMaxUploadsPerTorrent() const
|
||||
|
||||
void OptionsDialog::on_buttonBox_accepted()
|
||||
{
|
||||
if (applyButton->isEnabled()) {
|
||||
if (m_applyButton->isEnabled()) {
|
||||
if (!schedTimesOk()) {
|
||||
m_ui->tabSelection->setCurrentRow(TAB_SPEED);
|
||||
return;
|
||||
@@ -1249,7 +1249,7 @@ void OptionsDialog::on_buttonBox_accepted()
|
||||
m_ui->tabSelection->setCurrentRow(TAB_WEBUI);
|
||||
return;
|
||||
}
|
||||
applyButton->setEnabled(false);
|
||||
m_applyButton->setEnabled(false);
|
||||
this->hide();
|
||||
saveOptions();
|
||||
}
|
||||
@@ -1259,7 +1259,7 @@ void OptionsDialog::on_buttonBox_accepted()
|
||||
|
||||
void OptionsDialog::applySettings(QAbstractButton *button)
|
||||
{
|
||||
if (button == applyButton) {
|
||||
if (button == m_applyButton) {
|
||||
if (!schedTimesOk()) {
|
||||
m_ui->tabSelection->setCurrentRow(TAB_SPEED);
|
||||
return;
|
||||
@@ -1291,7 +1291,7 @@ bool OptionsDialog::useAdditionDialog() const
|
||||
|
||||
void OptionsDialog::enableApplyButton()
|
||||
{
|
||||
applyButton->setEnabled(true);
|
||||
m_applyButton->setEnabled(true);
|
||||
}
|
||||
|
||||
void OptionsDialog::toggleComboRatioLimitAct()
|
||||
@@ -1486,7 +1486,7 @@ void OptionsDialog::on_addScanFolderButton_clicked()
|
||||
break;
|
||||
default:
|
||||
pref->setScanDirsLastPath(dir);
|
||||
addedScanDirs << dir;
|
||||
m_addedScanDirs << dir;
|
||||
for (int i = 0; i < ScanFoldersModel::instance()->columnCount(); ++i)
|
||||
m_ui->scanFoldersView->resizeColumnToContents(i);
|
||||
enableApplyButton();
|
||||
@@ -1506,7 +1506,7 @@ void OptionsDialog::on_removeScanFolderButton_clicked()
|
||||
Q_ASSERT(selected.count() == ScanFoldersModel::instance()->columnCount());
|
||||
foreach (const QModelIndex &index, selected) {
|
||||
if (index.column() == ScanFoldersModel::WATCH)
|
||||
removedScanDirs << index.data().toString();
|
||||
m_removedScanDirs << index.data().toString();
|
||||
}
|
||||
ScanFoldersModel::instance()->removePath(selected.first().row(), false);
|
||||
}
|
||||
|
||||
@@ -176,11 +176,10 @@ private:
|
||||
QByteArray m_sslCert, m_sslKey;
|
||||
|
||||
Ui::OptionsDialog *m_ui;
|
||||
QButtonGroup choiceLanguage;
|
||||
QAbstractButton *applyButton;
|
||||
AdvancedSettings *advancedSettings;
|
||||
QList<QString> addedScanDirs;
|
||||
QList<QString> removedScanDirs;
|
||||
QAbstractButton *m_applyButton;
|
||||
AdvancedSettings *m_advancedSettings;
|
||||
QList<QString> m_addedScanDirs;
|
||||
QList<QString> m_removedScanDirs;
|
||||
};
|
||||
|
||||
#endif // OPTIONSDIALOG_H
|
||||
|
||||
@@ -141,7 +141,7 @@ bool ProgramUpdater::isVersionMoreRecent(const QString &remoteVersion) const
|
||||
qDebug() << Q_FUNC_INFO << "local version:" << localVersion << "/" << QBT_VERSION;
|
||||
QStringList remoteParts = remoteVersion.split('.');
|
||||
QStringList localParts = localVersion.split('.');
|
||||
for (int i = 0; i<qMin(remoteParts.size(), localParts.size()); ++i) {
|
||||
for (int i = 0; i < qMin(remoteParts.size(), localParts.size()); ++i) {
|
||||
if (remoteParts[i].toInt() > localParts[i].toInt())
|
||||
return true;
|
||||
if (remoteParts[i].toInt() < localParts[i].toInt())
|
||||
|
||||
@@ -103,7 +103,7 @@ PeerListWidget::PeerListWidget(PropertiesWidget *parent)
|
||||
hideColumn(PeerListDelegate::COUNTRY);
|
||||
// Ensure that at least one column is visible at all times
|
||||
bool atLeastOne = false;
|
||||
for (unsigned int i = 0; i < PeerListDelegate::IP_HIDDEN; ++i) {
|
||||
for (int i = 0; i < PeerListDelegate::IP_HIDDEN; ++i) {
|
||||
if (!isColumnHidden(i)) {
|
||||
atLeastOne = true;
|
||||
break;
|
||||
@@ -114,7 +114,7 @@ PeerListWidget::PeerListWidget(PropertiesWidget *parent)
|
||||
// To also mitigate the above issue, we have to resize each column when
|
||||
// its size is 0, because explicitly 'showing' the column isn't enough
|
||||
// in the above scenario.
|
||||
for (unsigned int i = 0; i < PeerListDelegate::IP_HIDDEN; ++i)
|
||||
for (int i = 0; i < PeerListDelegate::IP_HIDDEN; ++i)
|
||||
if ((columnWidth(i) <= 0) && !isColumnHidden(i))
|
||||
resizeColumnToContents(i);
|
||||
// Context menu
|
||||
@@ -169,7 +169,7 @@ void PeerListWidget::displayToggleColumnsMenu(const QPoint &)
|
||||
actions.append(myAct);
|
||||
}
|
||||
int visibleCols = 0;
|
||||
for (unsigned int i = 0; i < PeerListDelegate::IP_HIDDEN; ++i) {
|
||||
for (int i = 0; i < PeerListDelegate::IP_HIDDEN; ++i) {
|
||||
if (!isColumnHidden(i))
|
||||
++visibleCols;
|
||||
|
||||
@@ -321,7 +321,7 @@ void PeerListWidget::clear()
|
||||
int nbrows = m_listModel->rowCount();
|
||||
if (nbrows > 0) {
|
||||
qDebug("Cleared %d peers", nbrows);
|
||||
m_listModel->removeRows(0, nbrows);
|
||||
m_listModel->removeRows(0, nbrows);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -275,7 +275,7 @@ void PiecesBar::showToolTip(const QHelpEvent *e)
|
||||
DetailedTooltipRenderer renderer(stream, tooltipTitle);
|
||||
|
||||
const bool isFileNameCorrectionNeeded = this->isFileNameCorrectionNeeded();
|
||||
for (int f: files) {
|
||||
for (int f : files) {
|
||||
QString filePath {m_torrent->info().filePath(f)};
|
||||
if (isFileNameCorrectionNeeded)
|
||||
filePath.replace(QLatin1String("/.unwanted"), QString());
|
||||
|
||||
@@ -126,7 +126,7 @@ bool SearchSortModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceP
|
||||
const QAbstractItemModel *const sourceModel = this->sourceModel();
|
||||
if (m_isNameFilterEnabled && !m_searchTerm.isEmpty()) {
|
||||
QString name = sourceModel->data(sourceModel->index(sourceRow, NAME, sourceParent)).toString();
|
||||
for (const QString &word: m_searchTermWords) {
|
||||
for (const QString &word : m_searchTermWords) {
|
||||
int i = name.indexOf(word, 0, Qt::CaseInsensitive);
|
||||
if (i == -1) {
|
||||
return false;
|
||||
|
||||
@@ -146,7 +146,7 @@ namespace
|
||||
#elif defined(Q_OS_MAC)
|
||||
// There is a similar bug on macOS, to be reported to Qt
|
||||
// https://github.com/qbittorrent/qBittorrent/pull/6156#issuecomment-316302615
|
||||
class MacFileIconProvider final: public CachingFileIconProvider
|
||||
class MacFileIconProvider final : public CachingFileIconProvider
|
||||
{
|
||||
QPixmap pixmapForExtension(const QString &ext) const override
|
||||
{
|
||||
@@ -346,7 +346,7 @@ int TorrentContentModel::getFileIndex(const QModelIndex &index)
|
||||
return -1;
|
||||
}
|
||||
|
||||
QVariant TorrentContentModel::data(const QModelIndex& index, int role) const
|
||||
QVariant TorrentContentModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
|
||||
@@ -54,13 +54,13 @@ public:
|
||||
QVector<int> getFilePriorities() const;
|
||||
bool allFiltered() const;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
bool setData(const QModelIndex &index, const QVariant& value, int role = Qt::EditRole) override;
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
|
||||
TorrentContentModelItem::ItemType itemType(const QModelIndex &index) const;
|
||||
int getFileIndex(const QModelIndex &index);
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
||||
QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;
|
||||
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
|
||||
QModelIndex parent(const QModelIndex &index) const override;
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
void clear();
|
||||
|
||||
@@ -404,7 +404,7 @@ void TrackerFiltersList::trackerWarning(const QString &hash, const QString &trac
|
||||
applyFilter(3);
|
||||
}
|
||||
|
||||
void TrackerFiltersList::downloadFavicon(const QString& url)
|
||||
void TrackerFiltersList::downloadFavicon(const QString &url)
|
||||
{
|
||||
if (!m_downloadTrackerFavicon) return;
|
||||
Net::DownloadHandler *h = Net::DownloadManager::instance()->download(
|
||||
@@ -416,7 +416,7 @@ void TrackerFiltersList::downloadFavicon(const QString& url)
|
||||
, &TrackerFiltersList::handleFavicoFailure);
|
||||
}
|
||||
|
||||
void TrackerFiltersList::handleFavicoDownload(const QString& url, const QString& filePath)
|
||||
void TrackerFiltersList::handleFavicoDownload(const QString &url, const QString &filePath)
|
||||
{
|
||||
QString host = url.startsWith(GOOGLE_FAVICON_URL)
|
||||
? url.mid(GOOGLE_FAVICON_URL.size())
|
||||
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
|
||||
explicit TransferListModel(QObject *parent = nullptr);
|
||||
|
||||
int rowCount(const QModelIndex& index = QModelIndex()) const override;
|
||||
int rowCount(const QModelIndex &index = QModelIndex()) const override;
|
||||
int columnCount(const QModelIndex &parent=QModelIndex()) const override;
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
||||
|
||||
@@ -582,7 +582,7 @@ void TransferListWidget::openSelectedTorrentsFolder() const
|
||||
}
|
||||
pathsList.insert(path);
|
||||
}
|
||||
#endif
|
||||
#endif // Q_OS_MAC
|
||||
}
|
||||
|
||||
void TransferListWidget::previewSelectedTorrents()
|
||||
@@ -595,16 +595,16 @@ void TransferListWidget::previewSelectedTorrents()
|
||||
|
||||
void TransferListWidget::setDlLimitSelectedTorrents()
|
||||
{
|
||||
QList<BitTorrent::TorrentHandle *> TorrentsList;
|
||||
QList<BitTorrent::TorrentHandle *> torrentsList;
|
||||
foreach (BitTorrent::TorrentHandle *const torrent, getSelectedTorrents()) {
|
||||
if (torrent->isSeed())
|
||||
continue;
|
||||
TorrentsList += torrent;
|
||||
torrentsList += torrent;
|
||||
}
|
||||
if (TorrentsList.empty()) return;
|
||||
if (torrentsList.empty()) return;
|
||||
|
||||
int oldLimit = TorrentsList.first()->downloadLimit();
|
||||
foreach (BitTorrent::TorrentHandle *const torrent, TorrentsList) {
|
||||
int oldLimit = torrentsList.first()->downloadLimit();
|
||||
foreach (BitTorrent::TorrentHandle *const torrent, torrentsList) {
|
||||
if (torrent->downloadLimit() != oldLimit) {
|
||||
oldLimit = -1;
|
||||
break;
|
||||
@@ -617,7 +617,7 @@ void TransferListWidget::setDlLimitSelectedTorrents()
|
||||
, BitTorrent::Session::instance()->globalDownloadSpeedLimit());
|
||||
if (!ok) return;
|
||||
|
||||
foreach (BitTorrent::TorrentHandle *const torrent, TorrentsList) {
|
||||
foreach (BitTorrent::TorrentHandle *const torrent, torrentsList) {
|
||||
qDebug("Applying download speed limit of %ld Kb/s to torrent %s", (newLimit / 1024l), qUtf8Printable(torrent->hash()));
|
||||
torrent->setDownloadLimit(newLimit);
|
||||
}
|
||||
@@ -625,11 +625,11 @@ void TransferListWidget::setDlLimitSelectedTorrents()
|
||||
|
||||
void TransferListWidget::setUpLimitSelectedTorrents()
|
||||
{
|
||||
QList<BitTorrent::TorrentHandle *> TorrentsList = getSelectedTorrents();
|
||||
if (TorrentsList.empty()) return;
|
||||
QList<BitTorrent::TorrentHandle *> torrentsList = getSelectedTorrents();
|
||||
if (torrentsList.empty()) return;
|
||||
|
||||
int oldLimit = TorrentsList.first()->uploadLimit();
|
||||
foreach (BitTorrent::TorrentHandle *const torrent, TorrentsList) {
|
||||
int oldLimit = torrentsList.first()->uploadLimit();
|
||||
foreach (BitTorrent::TorrentHandle *const torrent, torrentsList) {
|
||||
if (torrent->uploadLimit() != oldLimit) {
|
||||
oldLimit = -1;
|
||||
break;
|
||||
@@ -642,7 +642,7 @@ void TransferListWidget::setUpLimitSelectedTorrents()
|
||||
, BitTorrent::Session::instance()->globalUploadSpeedLimit());
|
||||
if (!ok) return;
|
||||
|
||||
foreach (BitTorrent::TorrentHandle *const torrent, TorrentsList) {
|
||||
foreach (BitTorrent::TorrentHandle *const torrent, torrentsList) {
|
||||
qDebug("Applying upload speed limit of %ld Kb/s to torrent %s", (newLimit / 1024l), qUtf8Printable(torrent->hash()));
|
||||
torrent->setUploadLimit(newLimit);
|
||||
}
|
||||
@@ -1144,7 +1144,7 @@ void TransferListWidget::displayListMenu(const QPoint&)
|
||||
}
|
||||
}
|
||||
|
||||
void TransferListWidget::currentChanged(const QModelIndex& current, const QModelIndex&)
|
||||
void TransferListWidget::currentChanged(const QModelIndex ¤t, const QModelIndex&)
|
||||
{
|
||||
qDebug("CURRENT CHANGED");
|
||||
BitTorrent::TorrentHandle *torrent = nullptr;
|
||||
|
||||
@@ -106,7 +106,7 @@ protected:
|
||||
protected slots:
|
||||
void torrentDoubleClicked();
|
||||
void displayListMenu(const QPoint&);
|
||||
void currentChanged(const QModelIndex& current, const QModelIndex&) override;
|
||||
void currentChanged(const QModelIndex ¤t, const QModelIndex&) override;
|
||||
void toggleSelectedTorrentsSuperSeeding() const;
|
||||
void toggleSelectedTorrentsSequentialDownload() const;
|
||||
void toggleSelectedFirstLastPiecePrio() const;
|
||||
|
||||
Reference in New Issue
Block a user