Browse Source

Merge pull request #9042 from thalieht/codingstyle

Fix coding style final
adaptive-webui-19844
Vladimir Golovnev 7 years ago committed by GitHub
parent
commit
0433d5f074
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      src/app/main.cpp
  2. 3
      src/base/bittorrent/private/resumedatasavingmanager.cpp
  3. 15
      src/gui/about_imp.h
  4. 8
      src/gui/addnewtorrentdialog.cpp
  5. 6
      src/gui/advancedsettings.cpp
  6. 2
      src/gui/autoexpandabledialog.h
  7. 2
      src/gui/categoryfiltermodel.cpp
  8. 23
      src/gui/deletionconfirmationdlg.h
  9. 2
      src/gui/downloadfromurldialog.h
  10. 30
      src/gui/executionlog.cpp
  11. 14
      src/gui/executionlog.h
  12. 2
      src/gui/fspathedit.h
  13. 6
      src/gui/hidabletabwidget.h
  14. 4
      src/gui/loglistwidget.cpp
  15. 11
      src/gui/loglistwidget.h
  16. 34
      src/gui/mainwindow.cpp
  17. 8
      src/gui/mainwindow.h
  18. 28
      src/gui/messageboxraised.cpp
  19. 19
      src/gui/messageboxraised.h
  20. 21
      src/gui/optionsdlg.cpp
  21. 10
      src/gui/optionsdlg.h
  22. 5
      src/gui/previewlistdelegate.h
  23. 2
      src/gui/programupdater.cpp
  24. 6
      src/gui/programupdater.h
  25. 2
      src/gui/properties/downloadedpiecesbar.cpp
  26. 10
      src/gui/properties/peerlistwidget.cpp
  27. 10
      src/gui/properties/peersadditiondlg.cpp
  28. 2
      src/gui/properties/pieceavailabilitybar.cpp
  29. 2
      src/gui/properties/piecesbar.cpp
  30. 16
      src/gui/properties/propertieswidget.cpp
  31. 4
      src/gui/properties/speedplotview.cpp
  32. 2
      src/gui/properties/speedwidget.h
  33. 2
      src/gui/properties/trackerlist.cpp
  34. 8
      src/gui/properties/trackersadditiondlg.cpp
  35. 16
      src/gui/scanfoldersdelegate.cpp
  36. 19
      src/gui/scanfoldersdelegate.h
  37. 4
      src/gui/shutdownconfirmdlg.cpp
  38. 20
      src/gui/speedlimitdlg.cpp
  39. 4
      src/gui/speedlimitdlg.h
  40. 2
      src/gui/tagfiltermodel.cpp
  41. 6
      src/gui/torrentcontentfiltermodel.h
  42. 19
      src/gui/torrentcontentmodel.cpp
  43. 8
      src/gui/torrentcontentmodel.h
  44. 6
      src/gui/torrentcontentmodelfile.cpp
  45. 6
      src/gui/torrentcontentmodelfile.h
  46. 6
      src/gui/torrentcontentmodelfolder.cpp
  47. 6
      src/gui/torrentcontentmodelfolder.h
  48. 13
      src/gui/torrentcontentmodelitem.cpp
  49. 6
      src/gui/torrentcontentmodelitem.h
  50. 2
      src/gui/torrentcontenttreeview.h
  51. 2
      src/gui/torrentcreatordlg.h
  52. 9
      src/gui/torrentmodel.cpp
  53. 14
      src/gui/torrentmodel.h
  54. 6
      src/gui/trackerlogin.cpp
  55. 8
      src/gui/trackerlogin.h
  56. 51
      src/gui/transferlistdelegate.cpp
  57. 16
      src/gui/transferlistdelegate.h
  58. 14
      src/gui/transferlistfilterswidget.cpp
  59. 33
      src/gui/transferlistfilterswidget.h
  60. 12
      src/gui/transferlistsortmodel.cpp
  61. 10
      src/gui/transferlistsortmodel.h
  62. 184
      src/gui/transferlistwidget.cpp
  63. 16
      src/gui/transferlistwidget.h
  64. 2
      src/gui/updownratiodlg.h
  65. 2
      src/gui/utils.cpp
  66. 2
      src/webui/api/torrentscontroller.cpp

14
src/app/main.cpp

@ -234,7 +234,7 @@ int main(int argc, char *argv[]) @@ -234,7 +234,7 @@ int main(int argc, char *argv[])
#ifdef DISABLE_GUI
if (params.shouldDaemonize) {
app.reset(); // Destroy current application
if ((daemon(1, 0) == 0)) {
if (daemon(1, 0) == 0) {
app.reset(new Application(appId, argc, argv));
if (app->isRunning()) {
// Another instance had time to start.
@ -319,13 +319,13 @@ void sigAbnormalHandler(int signum) @@ -319,13 +319,13 @@ void sigAbnormalHandler(int signum)
#if !defined(DISABLE_GUI)
void showSplashScreen()
{
QPixmap splash_img(":/icons/skin/splash.png");
QPainter painter(&splash_img);
QPixmap splashImg(":/icons/skin/splash.png");
QPainter painter(&splashImg);
QString version = QBT_VERSION;
painter.setPen(QPen(Qt::white));
painter.setFont(QFont("Arial", 22, QFont::Black));
painter.drawText(224 - painter.fontMetrics().width(version), 270, version);
QSplashScreen *splash = new QSplashScreen(splash_img);
QSplashScreen *splash = new QSplashScreen(splashImg);
splash->show();
QTimer::singleShot(1500, splash, &QObject::deleteLater);
qApp->processEvents();
@ -376,7 +376,7 @@ bool userAgreesWithLegalNotice() @@ -376,7 +376,7 @@ bool userAgreesWithLegalNotice()
printf("%s", qUtf8Printable(eula));
char ret = getchar(); // Read pressed key
if (ret == 'y' || ret == 'Y') {
if ((ret == 'y') || (ret == 'Y')) {
// Save the answer
pref->setAcceptedLegal(true);
return true;
@ -386,11 +386,11 @@ bool userAgreesWithLegalNotice() @@ -386,11 +386,11 @@ bool userAgreesWithLegalNotice()
msgBox.setText(QObject::tr("qBittorrent is a file sharing program. When you run a torrent, its data will be made available to others by means of upload. Any content you share is your sole responsibility.\n\nNo further notices will be issued."));
msgBox.setWindowTitle(QObject::tr("Legal notice"));
msgBox.addButton(QObject::tr("Cancel"), QMessageBox::RejectRole);
QAbstractButton *agree_button = msgBox.addButton(QObject::tr("I Agree"), QMessageBox::AcceptRole);
QAbstractButton *agreeButton = msgBox.addButton(QObject::tr("I Agree"), QMessageBox::AcceptRole);
msgBox.show(); // Need to be shown or to moveToCenter does not work
msgBox.move(Utils::Misc::screenCenter(&msgBox));
msgBox.exec();
if (msgBox.clickedButton() == agree_button) {
if (msgBox.clickedButton() == agreeButton) {
// Save the answer
pref->setAcceptedLegal(true);
return true;

3
src/base/bittorrent/private/resumedatasavingmanager.cpp

@ -26,12 +26,13 @@ @@ -26,12 +26,13 @@
* exception statement from your version.
*/
#include "resumedatasavingmanager.h"
#include <QDebug>
#include <QSaveFile>
#include "base/logger.h"
#include "base/utils/fs.h"
#include "resumedatasavingmanager.h"
ResumeDataSavingManager::ResumeDataSavingManager(const QString &resumeFolderPath)
: m_resumeDataDir(resumeFolderPath)

15
src/gui/about_imp.h

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2006 Christophe Dumez
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -24,8 +24,6 @@ @@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#ifndef ABOUT_H
@ -33,17 +31,18 @@ @@ -33,17 +31,18 @@
#include <QFile>
#include "base/utils/misc.h"
#include "base/unicodestrings.h"
#include "base/utils/misc.h"
#include "ui_about.h"
#include "utils.h"
class about: public QDialog, private Ui::AboutDlg
class AboutDialog : public QDialog, private Ui::AboutDlg
{
Q_OBJECT
public:
about(QWidget *parent) : QDialog(parent)
AboutDialog(QWidget *parent)
: QDialog(parent)
{
setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
@ -108,4 +107,4 @@ public: @@ -108,4 +107,4 @@ public:
}
};
#endif
#endif // ABOUT_H

8
src/gui/addnewtorrentdialog.cpp

@ -536,15 +536,15 @@ void AddNewTorrentDialog::renameSelectedFile() @@ -536,15 +536,15 @@ void AddNewTorrentDialog::renameSelectedFile()
pathItems.prepend(parent.data().toString());
parent = m_contentModel->parent(parent);
}
const QString oldPath = pathItems.join("/");
const QString oldPath = pathItems.join('/');
pathItems.removeLast();
pathItems << newName;
QString newPath = pathItems.join("/");
QString newPath = pathItems.join('/');
if (Utils::Fs::sameFileNames(oldPath, newPath)) {
qDebug("Name did not change");
return;
}
if (!newPath.endsWith("/")) newPath += "/";
if (!newPath.endsWith('/')) newPath += '/';
// Check for overwriting
for (int i = 0; i < m_torrentInfo.filesCount(); ++i) {
const QString &currentName = m_torrentInfo.filePath(i);
@ -813,7 +813,7 @@ void AddNewTorrentDialog::setCommentText(const QString &str) const @@ -813,7 +813,7 @@ void AddNewTorrentDialog::setCommentText(const QString &str) const
// workaround for the additional space introduced by QScrollArea
int lineHeight = m_ui->commentLabel->fontMetrics().lineSpacing();
int lines = 1 + str.count("\n");
int lines = 1 + str.count('\n');
int height = lineHeight * lines;
m_ui->scrollArea->setMaximumHeight(height);
}

6
src/gui/advancedsettings.cpp

@ -33,10 +33,10 @@ @@ -33,10 +33,10 @@
#include <QHostAddress>
#include <QNetworkInterface>
#include "app/application.h"
#include "base/bittorrent/session.h"
#include "base/preferences.h"
#include "base/unicodestrings.h"
#include "app/application.h"
#include "gui/addnewtorrentdialog.h"
#include "gui/mainwindow.h"
@ -254,9 +254,9 @@ void AdvancedSettings::updateInterfaceAddressCombo() @@ -254,9 +254,9 @@ void AdvancedSettings::updateInterfaceAddressCombo()
auto populateCombo = [this, &currentAddress](const QString &ip, const QAbstractSocket::NetworkLayerProtocol &protocol)
{
Q_ASSERT(protocol == QAbstractSocket::IPv4Protocol || protocol == QAbstractSocket::IPv6Protocol);
Q_ASSERT((protocol == QAbstractSocket::IPv4Protocol) || (protocol == QAbstractSocket::IPv6Protocol));
// Only take ipv4 for now?
if (protocol != QAbstractSocket::IPv4Protocol && protocol != QAbstractSocket::IPv6Protocol)
if ((protocol != QAbstractSocket::IPv4Protocol) && (protocol != QAbstractSocket::IPv6Protocol))
return;
combo_iface_address.addItem(ip);
//Try to select the last added one

2
src/gui/autoexpandabledialog.h

@ -51,7 +51,7 @@ public: @@ -51,7 +51,7 @@ public:
bool *ok = nullptr, Qt::InputMethodHints inputMethodHints = Qt::ImhNone);
protected:
void showEvent(QShowEvent *e);
void showEvent(QShowEvent *e) override;
private:
Ui::AutoExpandableDialog *m_ui;

2
src/gui/categoryfiltermodel.cpp

@ -31,8 +31,8 @@ @@ -31,8 +31,8 @@
#include <QHash>
#include <QIcon>
#include "base/bittorrent/torrenthandle.h"
#include "base/bittorrent/session.h"
#include "base/bittorrent/torrenthandle.h"
#include "guiiconprovider.h"
class CategoryModelItem

23
src/gui/deletionconfirmationdlg.h

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2006 Christophe Dumez
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -24,8 +24,6 @@ @@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#ifndef DELETIONCONFIRMATIONDLG_H
@ -41,11 +39,14 @@ @@ -41,11 +39,14 @@
#include "ui_confirmdeletiondlg.h"
#include "utils.h"
class DeletionConfirmationDlg : public QDialog, private Ui::confirmDeletionDlg {
class DeletionConfirmationDlg : public QDialog, private Ui::confirmDeletionDlg
{
Q_OBJECT
public:
DeletionConfirmationDlg(QWidget *parent, const int &size, const QString &name, bool defaultDeleteFiles): QDialog(parent) {
DeletionConfirmationDlg(QWidget *parent, const int &size, const QString &name, bool defaultDeleteFiles)
: QDialog(parent)
{
setupUi(this);
if (size == 1)
label->setText(tr("Are you sure you want to delete '%1' from the transfer list?", "Are you sure you want to delete 'ubuntu-linux-iso' from the transfer list?").arg(name.toHtmlEscaped()));
@ -65,11 +66,13 @@ class DeletionConfirmationDlg : public QDialog, private Ui::confirmDeletionDlg { @@ -65,11 +66,13 @@ class DeletionConfirmationDlg : public QDialog, private Ui::confirmDeletionDlg {
Utils::Gui::resize(this);
}
bool shouldDeleteLocalFiles() const {
bool shouldDeleteLocalFiles() const
{
return checkPermDelete->isChecked();
}
static bool askForDeletionConfirmation(QWidget *parent, bool& deleteLocalFiles, const int& size, const QString& name) {
static bool askForDeletionConfirmation(QWidget *parent, bool &deleteLocalFiles, const int &size, const QString &name)
{
DeletionConfirmationDlg dlg(parent, size, name, deleteLocalFiles);
if (dlg.exec() == QDialog::Accepted) {
deleteLocalFiles = dlg.shouldDeleteLocalFiles();
@ -79,11 +82,13 @@ class DeletionConfirmationDlg : public QDialog, private Ui::confirmDeletionDlg { @@ -79,11 +82,13 @@ class DeletionConfirmationDlg : public QDialog, private Ui::confirmDeletionDlg {
}
private slots:
void updateRememberButtonState() {
void updateRememberButtonState()
{
rememberBtn->setEnabled(checkPermDelete->isChecked() != Preferences::instance()->deleteTorrentFilesAsDefault());
}
void on_rememberBtn_clicked() {
void on_rememberBtn_clicked()
{
Preferences::instance()->setDeleteTorrentFilesAsDefault(checkPermDelete->isChecked());
rememberBtn->setEnabled(false);
}

2
src/gui/downloadfromurldialog.h

@ -55,4 +55,4 @@ private: @@ -55,4 +55,4 @@ private:
Ui::DownloadFromURLDialog *m_ui;
};
#endif
#endif // DOWNLOADFROMURL_H

30
src/gui/executionlog.cpp

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2011 Christophe Dumez
*
* This program is free software; you can redistribute it and/or
@ -24,35 +24,35 @@ @@ -24,35 +24,35 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#include <QListWidgetItem>
#include <QLabel>
#include <QDateTime>
#include "executionlog.h"
#include <QColor>
#include <QDateTime>
#include <QLabel>
#include <QListWidgetItem>
#include <QPalette>
#include "executionlog.h"
#include "ui_executionlog.h"
#include "guiiconprovider.h"
#include "loglistwidget.h"
#include "ui_executionlog.h"
ExecutionLog::ExecutionLog(QWidget *parent, const Log::MsgTypes &types)
: QWidget(parent)
, ui(new Ui::ExecutionLog)
, m_ui(new Ui::ExecutionLog)
, m_peerList(new LogListWidget(MAX_LOG_MESSAGES))
{
ui->setupUi(this);
m_ui->setupUi(this);
m_msgList = new LogListWidget(MAX_LOG_MESSAGES, Log::MsgTypes(types));
#ifndef Q_OS_MAC
ui->tabConsole->setTabIcon(0, GuiIconProvider::instance()->getIcon("view-calendar-journal"));
ui->tabConsole->setTabIcon(1, GuiIconProvider::instance()->getIcon("view-filter"));
m_ui->tabConsole->setTabIcon(0, GuiIconProvider::instance()->getIcon("view-calendar-journal"));
m_ui->tabConsole->setTabIcon(1, GuiIconProvider::instance()->getIcon("view-filter"));
#endif
ui->tabGeneral->layout()->addWidget(m_msgList);
ui->tabBan->layout()->addWidget(m_peerList);
m_ui->tabGeneral->layout()->addWidget(m_msgList);
m_ui->tabBan->layout()->addWidget(m_peerList);
const Logger *const logger = Logger::instance();
foreach (const Log::Msg &msg, logger->getMessages())
@ -67,7 +67,7 @@ ExecutionLog::~ExecutionLog() @@ -67,7 +67,7 @@ ExecutionLog::~ExecutionLog()
{
delete m_msgList;
delete m_peerList;
delete ui;
delete m_ui;
}
void ExecutionLog::showMsgTypes(const Log::MsgTypes &types)

14
src/gui/executionlog.h

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2011 Christophe Dumez
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2011 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -24,8 +24,6 @@ @@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#ifndef EXECUTIONLOG_H
@ -34,11 +32,11 @@ @@ -34,11 +32,11 @@
#include <QWidget>
#include "base/logger.h"
QT_BEGIN_NAMESPACE
namespace Ui {
namespace Ui
{
class ExecutionLog;
}
QT_END_NAMESPACE
class LogListWidget;
class ExecutionLog : public QWidget
@ -55,7 +53,7 @@ private slots: @@ -55,7 +53,7 @@ private slots:
void addPeerMessage(const Log::Peer &peer);
private:
Ui::ExecutionLog *ui;
Ui::ExecutionLog *m_ui;
LogListWidget *m_msgList;
LogListWidget *m_peerList;

2
src/gui/fspathedit.h

@ -34,9 +34,9 @@ @@ -34,9 +34,9 @@
namespace Private
{
class FileComboEdit;
class FileEditorWithCompletion;
class FileLineEdit;
class FileComboEdit;
}
/*!

6
src/gui/hidabletabwidget.h

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006 Christophe Dumez
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -24,15 +24,13 @@ @@ -24,15 +24,13 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#ifndef HIDABLETABWIDGET_H
#define HIDABLETABWIDGET_H
#include <QTabWidget>
#include <QTabBar>
#include <QTabWidget>
#ifdef Q_OS_MAC
#include <QStyle>

4
src/gui/loglistwidget.cpp

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2011 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
@ -100,5 +100,5 @@ void LogListWidget::copySelection() @@ -100,5 +100,5 @@ void LogListWidget::copySelection()
foreach (QListWidgetItem* it, selectedItems())
strings << static_cast<QLabel*>(itemWidget(it))->text().remove(htmlTag);
QApplication::clipboard()->setText(strings.join("\n"));
QApplication::clipboard()->setText(strings.join('\n'));
}

11
src/gui/loglistwidget.h

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2011 Christophe Dumez
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2011 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -24,18 +24,15 @@ @@ -24,18 +24,15 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#ifndef LOGLISTWIDGET_H
#define LOGLISTWIDGET_H
#include <QListWidget>
#include "base/logger.h"
QT_BEGIN_NAMESPACE
class QKeyEvent;
QT_END_NAMESPACE
class LogListWidget : public QListWidget
{
@ -53,7 +50,7 @@ protected slots: @@ -53,7 +50,7 @@ protected slots:
void copySelection();
protected:
void keyPressEvent(QKeyEvent *event);
void keyPressEvent(QKeyEvent *event) override;
private:
int m_maxLines;

34
src/gui/mainwindow.cpp

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006 Christophe Dumez
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -24,8 +24,6 @@ @@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#include "mainwindow.h"
@ -59,10 +57,6 @@ @@ -59,10 +57,6 @@
#include "notifications.h"
#endif
#include "about_imp.h"
#include "addnewtorrentdialog.h"
#include "application.h"
#include "autoexpandabledialog.h"
#include "base/bittorrent/session.h"
#include "base/bittorrent/sessionstatus.h"
#include "base/bittorrent/torrenthandle.h"
@ -74,6 +68,10 @@ @@ -74,6 +68,10 @@
#include "base/settingsstorage.h"
#include "base/utils/fs.h"
#include "base/utils/misc.h"
#include "about_imp.h"
#include "addnewtorrentdialog.h"
#include "application.h"
#include "autoexpandabledialog.h"
#include "cookiesdialog.h"
#include "downloadfromurldialog.h"
#include "executionlog.h"
@ -1059,7 +1057,7 @@ void MainWindow::notifyOfUpdate(QString) @@ -1059,7 +1057,7 @@ void MainWindow::notifyOfUpdate(QString)
void MainWindow::toggleVisibility(const QSystemTrayIcon::ActivationReason reason)
{
switch (reason) {
case QSystemTrayIcon::Trigger: {
case QSystemTrayIcon::Trigger:
if (isHidden()) {
if (m_uiLocked && !unlockUI()) // Ask for UI lock password
return;
@ -1075,9 +1073,7 @@ void MainWindow::toggleVisibility(const QSystemTrayIcon::ActivationReason reason @@ -1075,9 +1073,7 @@ void MainWindow::toggleVisibility(const QSystemTrayIcon::ActivationReason reason
else {
hide();
}
break;
}
default:
break;
@ -1092,7 +1088,7 @@ void MainWindow::on_actionAbout_triggered() @@ -1092,7 +1088,7 @@ void MainWindow::on_actionAbout_triggered()
if (m_aboutDlg)
m_aboutDlg->activateWindow();
else
m_aboutDlg = new about(this);
m_aboutDlg = new AboutDialog(this);
}
void MainWindow::on_actionStatistics_triggered()
@ -1136,7 +1132,7 @@ void MainWindow::closeEvent(QCloseEvent *e) @@ -1136,7 +1132,7 @@ void MainWindow::closeEvent(QCloseEvent *e)
e->accept();
return;
}
#endif
#endif // Q_OS_MAC
if (pref->confirmOnExit() && BitTorrent::Session::instance()->hasActiveTorrents()) {
if (e->spontaneous() || m_forceExit) {
@ -1144,7 +1140,7 @@ void MainWindow::closeEvent(QCloseEvent *e) @@ -1144,7 +1140,7 @@ void MainWindow::closeEvent(QCloseEvent *e)
show();
QMessageBox confirmBox(QMessageBox::Question, tr("Exiting qBittorrent"),
// Split it because the last sentence is used in the Web UI
tr("Some files are currently transferring.") + "\n" + tr("Are you sure you want to quit qBittorrent?"),
tr("Some files are currently transferring.") + '\n' + tr("Are you sure you want to quit qBittorrent?"),
QMessageBox::NoButton, this);
QPushButton *noBtn = confirmBox.addButton(tr("&No"), QMessageBox::NoRole);
confirmBox.addButton(tr("&Yes"), QMessageBox::YesRole);
@ -1355,9 +1351,9 @@ void MainWindow::on_actionOpen_triggered() @@ -1355,9 +1351,9 @@ void MainWindow::on_actionOpen_triggered()
}
// Save last dir to remember it
QStringList topDir = Utils::Fs::fromNativePath(pathsList.at(0)).split("/");
QStringList topDir = Utils::Fs::fromNativePath(pathsList.at(0)).split('/');
topDir.removeLast();
pref->setMainLastDir(Utils::Fs::fromNativePath(topDir.join("/")));
pref->setMainLastDir(Utils::Fs::fromNativePath(topDir.join('/')));
}
}
@ -1538,7 +1534,7 @@ void MainWindow::updateGUI() @@ -1538,7 +1534,7 @@ void MainWindow::updateGUI()
#else
// OSes such as Windows do not support html here
QString html = tr("DL speed: %1", "e.g: Download speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadDownloadRate, true));
html += "\n";
html += '\n';
html += tr("UP speed: %1", "e.g: Upload speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadUploadRate, true));
#endif // Q_OS_UNIX
m_systrayIcon->setToolTip(html); // tray icon
@ -1660,7 +1656,7 @@ void MainWindow::createTrayIcon() @@ -1660,7 +1656,7 @@ void MainWindow::createTrayIcon()
connect(m_systrayIcon.data(), &QSystemTrayIcon::activated, this, &MainWindow::toggleVisibility);
m_systrayIcon->show();
}
#endif
#endif // Q_OS_MAC
QMenu *MainWindow::trayIconMenu()
{
@ -2006,7 +2002,7 @@ QIcon MainWindow::getSystrayIcon() const @@ -2006,7 +2002,7 @@ QIcon MainWindow::getSystrayIcon() const
// As a failsafe in case the enum is invalid
return QIcon(QLatin1String(":/icons/skin/qbittorrent-tray.svg"));
}
#endif
#endif // Q_OS_MAC
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
void MainWindow::checkProgramUpdate()
@ -2102,4 +2098,4 @@ void MainWindow::pythonDownloadFailure(const QString &url, const QString &error) @@ -2102,4 +2098,4 @@ void MainWindow::pythonDownloadFailure(const QString &url, const QString &error)
QMessageBox::warning(this, tr("Download error"), tr("Python setup could not be downloaded, reason: %1.\nPlease install it manually.").arg(error));
}
#endif
#endif // Q_OS_WIN

8
src/gui/mainwindow.h

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006 Christophe Dumez
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -24,8 +24,6 @@ @@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#ifndef MAINWINDOW_H
@ -48,7 +46,7 @@ class QTimer; @@ -48,7 +46,7 @@ class QTimer;
class DownloadFromURLDialog;
class SearchWidget;
class RSSWidget;
class about;
class AboutDialog;
class OptionsDialog;
class TransferListWidget;
class TransferListFiltersWidget;
@ -227,7 +225,7 @@ private: @@ -227,7 +225,7 @@ private:
QPointer<QTabWidget> m_tabs;
QPointer<StatusBar> m_statusBar;
QPointer<OptionsDialog> m_options;
QPointer<about> m_aboutDlg;
QPointer<AboutDialog> m_aboutDlg;
QPointer<StatsDialog> m_statsDlg;
QPointer<TorrentCreatorDlg> m_createTorrentDlg;
QPointer<DownloadFromURLDialog> m_downloadFromURLDialog;

28
src/gui/messageboxraised.cpp

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2014 sledgehammer999
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2014 sledgehammer999 <sledgehammer999@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -24,39 +24,45 @@ @@ -24,39 +24,45 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : hammered999@gmail.com
*/
#include "messageboxraised.h"
MessageBoxRaised::MessageBoxRaised(QMessageBox::Icon icon, const QString &title, const QString &text,
QMessageBox::StandardButtons buttons, QWidget *parent, Qt::WindowFlags f)
: QMessageBox(icon, title, text, buttons, parent, f) {}
: QMessageBox(icon, title, text, buttons, parent, f)
{
}
QMessageBox::StandardButton MessageBoxRaised::impl(const QMessageBox::Icon &icon, QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton) {
QMessageBox::StandardButton MessageBoxRaised::impl(const QMessageBox::Icon &icon, QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton)
{
MessageBoxRaised dlg(icon, title, text, buttons, parent);
dlg.setDefaultButton(defaultButton);
return static_cast<QMessageBox::StandardButton>(dlg.exec());
}
QMessageBox::StandardButton MessageBoxRaised::critical(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton) {
QMessageBox::StandardButton MessageBoxRaised::critical(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton)
{
return impl(Critical, parent, title, text, buttons, defaultButton);
}
QMessageBox::StandardButton MessageBoxRaised::information(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton) {
QMessageBox::StandardButton MessageBoxRaised::information(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton)
{
return impl(Information, parent, title, text, buttons, defaultButton);
}
QMessageBox::StandardButton MessageBoxRaised::question(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton) {
QMessageBox::StandardButton MessageBoxRaised::question(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton)
{
return impl(Question, parent, title, text, buttons, defaultButton);
}
QMessageBox::StandardButton MessageBoxRaised::warning(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton) {
QMessageBox::StandardButton MessageBoxRaised::warning(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton)
{
return impl(Warning, parent, title, text, buttons, defaultButton);
}
void MessageBoxRaised::showEvent(QShowEvent *event) {
void MessageBoxRaised::showEvent(QShowEvent *event)
{
QMessageBox::showEvent(event);
activateWindow();
raise();

19
src/gui/messageboxraised.h

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2014 sledgehammer999
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2014 sledgehammer999 <sledgehammer999@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -24,8 +24,6 @@ @@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : hammered999@gmail.com
*/
#ifndef MESSAGEBOXRAISED_H
@ -37,12 +35,6 @@ class MessageBoxRaised : public QMessageBox @@ -37,12 +35,6 @@ class MessageBoxRaised : public QMessageBox
{
Q_OBJECT
private:
MessageBoxRaised(QMessageBox::Icon icon, const QString &title, const QString &text, QMessageBox::StandardButtons buttons = NoButton, QWidget *parent = nullptr, Qt::WindowFlags f = Qt::Dialog|Qt::MSWindowsFixedSizeDialogHint);
MessageBoxRaised();
MessageBoxRaised(MessageBoxRaised const&);
void operator=(MessageBoxRaised const&);
public:
static QMessageBox::StandardButton critical(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons = QMessageBox::Ok, QMessageBox::StandardButton defaultButton = QMessageBox::NoButton);
static QMessageBox::StandardButton information(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons = QMessageBox::Ok, QMessageBox::StandardButton defaultButton = QMessageBox::NoButton);
@ -50,9 +42,14 @@ public: @@ -50,9 +42,14 @@ public:
static QMessageBox::StandardButton warning(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons = QMessageBox::Ok, QMessageBox::StandardButton defaultButton = QMessageBox::NoButton);
protected:
void showEvent(QShowEvent *event);
void showEvent(QShowEvent *event) override;
private:
MessageBoxRaised(QMessageBox::Icon icon, const QString &title, const QString &text, QMessageBox::StandardButtons buttons = NoButton, QWidget *parent = nullptr, Qt::WindowFlags f = Qt::Dialog|Qt::MSWindowsFixedSizeDialogHint);
MessageBoxRaised();
MessageBoxRaised(MessageBoxRaised const&);
void operator=(MessageBoxRaised const&);
static QMessageBox::StandardButton impl(const QMessageBox::Icon &icon, QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons = QMessageBox::Ok, QMessageBox::StandardButton defaultButton = QMessageBox::NoButton);
};

21
src/gui/optionsdlg.cpp

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2006 Christophe Dumez
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -24,8 +24,6 @@ @@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#include "optionsdlg.h"
@ -49,7 +47,6 @@ @@ -49,7 +47,6 @@
#include <QSslKey>
#endif
#include "app/application.h"
#include "base/bittorrent/session.h"
#include "base/global.h"
#include "base/net/dnsupdater.h"
@ -65,10 +62,11 @@ @@ -65,10 +62,11 @@
#include "base/utils/random.h"
#include "addnewtorrentdialog.h"
#include "advancedsettings.h"
#include "rss/automatedrssdownloader.h"
#include "app/application.h"
#include "banlistoptions.h"
#include "ipsubnetwhitelistoptionsdialog.h"
#include "guiiconprovider.h"
#include "rss/automatedrssdownloader.h"
#include "scanfoldersdelegate.h"
#include "utils.h"
@ -401,7 +399,7 @@ OptionsDialog::OptionsDialog(QWidget *parent) @@ -401,7 +399,7 @@ OptionsDialog::OptionsDialog(QWidget *parent)
connect(m_ui->DNSPasswordTxt, &QLineEdit::textChanged, this, &ThisType::enableApplyButton);
connect(m_ui->groupAltWebUI, &QGroupBox::toggled, this, &ThisType::enableApplyButton);
connect(m_ui->textWebUIRootFolder, &FileSystemPathLineEdit::selectedPathChanged, this, &ThisType::enableApplyButton);
#endif
#endif // DISABLE_WEBUI
// RSS tab
connect(m_ui->checkRSSEnable, &QCheckBox::toggled, this, &OptionsDialog::enableApplyButton);
@ -1237,7 +1235,7 @@ bool OptionsDialog::closeToTray() const @@ -1237,7 +1235,7 @@ bool OptionsDialog::closeToTray() const
if (!m_ui->checkShowSystray->isChecked()) return false;
return m_ui->checkCloseToSystray->isChecked();
}
#endif
#endif // Q_OS_MAC
// Return Share ratio
qreal OptionsDialog::getMaxRatio() const
@ -1733,15 +1731,14 @@ QString OptionsDialog::languageToLocalizedString(const QLocale &locale) @@ -1733,15 +1731,14 @@ QString OptionsDialog::languageToLocalizedString(const QLocale &locale)
return QString::fromUtf8(C_LOCALE_CHINESE_TRADITIONAL_HK);
default:
return QString::fromUtf8(C_LOCALE_CHINESE_TRADITIONAL_TW);
}
}
case QLocale::Korean: return QString::fromUtf8(C_LOCALE_KOREAN);
default: {
// Fallback to English
const QString eng_lang = QLocale::languageToString(locale.language());
qWarning() << "Unrecognized language name: " << eng_lang;
return eng_lang;
const QString engLang = QLocale::languageToString(locale.language());
qWarning() << "Unrecognized language name: " << engLang;
return engLang;
}
}
}

10
src/gui/optionsdlg.h

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2006 Christophe Dumez
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -24,8 +24,6 @@ @@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#ifndef OPTIONSDLG_H
@ -87,7 +85,7 @@ private slots: @@ -87,7 +85,7 @@ private slots:
void enableForceProxy(bool enable);
void enableProxy(int index);
void on_buttonBox_accepted();
void closeEvent(QCloseEvent *e);
void closeEvent(QCloseEvent *e) override;
void on_buttonBox_rejected();
void applySettings(QAbstractButton *button);
void enableApplyButton();
@ -188,4 +186,4 @@ private: @@ -188,4 +186,4 @@ private:
QList<QString> removedScanDirs;
};
#endif
#endif // OPTIONSDLG_H

5
src/gui/previewlistdelegate.h

@ -33,11 +33,12 @@ @@ -33,11 +33,12 @@
#include <QItemDelegate>
#include <QModelIndex>
#include <QPainter>
#include <QStyleOptionProgressBar>
#include <QStyleOptionViewItem>
#ifdef Q_OS_WIN
#include <QProxyStyle>
#endif
#include <QStyleOptionProgressBar>
#include <QStyleOptionViewItem>
#include "base/utils/misc.h"
#include "base/utils/string.h"

2
src/gui/programupdater.cpp

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2010 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or

6
src/gui/programupdater.h

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2010 Christophe Dumez
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2010 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -24,8 +24,6 @@ @@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#ifndef PROGRAMUPDATER_H

2
src/gui/properties/downloadedpiecesbar.cpp

@ -101,7 +101,7 @@ QVector<float> DownloadedPiecesBar::bitfieldToFloatVector(const QBitArray &vecin @@ -101,7 +101,7 @@ QVector<float> DownloadedPiecesBar::bitfieldToFloatVector(const QBitArray &vecin
// normalization <0, 1>
value /= ratio;
// float precision sometimes gives > 1, because in not possible to store irrational numbers
// float precision sometimes gives > 1, because it's not possible to store irrational numbers
value = qMin(value, 1.0f);
result[x] = value;

10
src/gui/properties/peerlistwidget.cpp

@ -303,12 +303,12 @@ void PeerListWidget::copySelectedPeers() @@ -303,12 +303,12 @@ void PeerListWidget::copySelectedPeers()
int row = m_proxyModel->mapToSource(index).row();
QString ip = m_listModel->data(m_listModel->index(row, PeerListDelegate::IP_HIDDEN)).toString();
QString myport = m_listModel->data(m_listModel->index(row, PeerListDelegate::PORT)).toString();
if (ip.indexOf(".") == -1) // IPv6
if (ip.indexOf('.') == -1) // IPv6
selectedPeers << "[" + ip + "]:" + myport;
else // IPv4
selectedPeers << ip + ":" + myport;
}
QApplication::clipboard()->setText(selectedPeers.join("\n"));
QApplication::clipboard()->setText(selectedPeers.join('\n'));
}
void PeerListWidget::clear()
@ -339,7 +339,7 @@ void PeerListWidget::loadPeers(BitTorrent::TorrentHandle *const torrent, bool fo @@ -339,7 +339,7 @@ void PeerListWidget::loadPeers(BitTorrent::TorrentHandle *const torrent, bool fo
if (!torrent) return;
QList<BitTorrent::PeerInfo> peers = torrent->peers();
QSet<QString> oldeersSet = m_peerItems.keys().toSet();
QSet<QString> oldPeersSet = m_peerItems.keys().toSet();
foreach (const BitTorrent::PeerInfo &peer, peers) {
BitTorrent::PeerAddress addr = peer.address();
@ -349,7 +349,7 @@ void PeerListWidget::loadPeers(BitTorrent::TorrentHandle *const torrent, bool fo @@ -349,7 +349,7 @@ void PeerListWidget::loadPeers(BitTorrent::TorrentHandle *const torrent, bool fo
if (m_peerItems.contains(peerIp)) {
// Update existing peer
updatePeer(peerIp, torrent, peer);
oldeersSet.remove(peerIp);
oldPeersSet.remove(peerIp);
if (forceHostnameResolution && m_resolver)
m_resolver->resolve(peerIp);
}
@ -363,7 +363,7 @@ void PeerListWidget::loadPeers(BitTorrent::TorrentHandle *const torrent, bool fo @@ -363,7 +363,7 @@ void PeerListWidget::loadPeers(BitTorrent::TorrentHandle *const torrent, bool fo
}
}
// Delete peers that are gone
QSetIterator<QString> it(oldeersSet);
QSetIterator<QString> it(oldPeersSet);
while (it.hasNext()) {
const QString &ip = it.next();
m_missingFlags.remove(ip);

10
src/gui/properties/peersadditiondlg.cpp

@ -61,7 +61,7 @@ void PeersAdditionDlg::validateInput() @@ -61,7 +61,7 @@ void PeersAdditionDlg::validateInput()
QMessageBox::Ok);
return;
}
foreach (const QString &peer, m_ui->peers_txt->toPlainText().trimmed().split("\n")) {
foreach (const QString &peer, m_ui->peers_txt->toPlainText().trimmed().split('\n')) {
BitTorrent::PeerAddress addr = parsePeer(peer);
if (!addr.ip.isNull()) {
m_peersList.append(addr);
@ -82,10 +82,10 @@ BitTorrent::PeerAddress PeersAdditionDlg::parsePeer(QString peer) @@ -82,10 +82,10 @@ BitTorrent::PeerAddress PeersAdditionDlg::parsePeer(QString peer)
BitTorrent::PeerAddress addr;
QStringList ipPort;
if (peer[0] == '[' && peer.indexOf("]:") != -1) // IPv6
if ((peer[0] == '[') && (peer.indexOf("]:") != -1)) // IPv6
ipPort = peer.remove(QChar('[')).split("]:");
else if (peer.indexOf(":") != -1) // IPv4
ipPort = peer.split(":");
else if (peer.indexOf(':') != -1) // IPv4
ipPort = peer.split(':');
else
return addr;
@ -95,7 +95,7 @@ BitTorrent::PeerAddress PeersAdditionDlg::parsePeer(QString peer) @@ -95,7 +95,7 @@ BitTorrent::PeerAddress PeersAdditionDlg::parsePeer(QString peer)
bool ok;
int port = ipPort[1].toInt(&ok);
if (!ok || port < 1 || port > 65535)
if (!ok || (port < 1) || (port > 65535))
return addr;
addr.ip = ip;

2
src/gui/properties/pieceavailabilitybar.cpp

@ -109,7 +109,7 @@ QVector<float> PieceAvailabilityBar::intToFloatVector(const QVector<int> &vecin, @@ -109,7 +109,7 @@ QVector<float> PieceAvailabilityBar::intToFloatVector(const QVector<int> &vecin,
// normalization <0, 1>
value /= ratio * maxElement;
// float precision sometimes gives > 1, because in not possible to store irrational numbers
// float precision sometimes gives > 1, because it's not possible to store irrational numbers
value = qMin(value, 1.0f);
result[x] = value;

2
src/gui/properties/piecesbar.cpp

@ -50,7 +50,7 @@ namespace @@ -50,7 +50,7 @@ namespace
{
public:
PieceIndexToImagePos(const BitTorrent::TorrentInfo &torrentInfo, const QImage &image)
: m_bytesPerPixel {(image.width() > 0 && torrentInfo.totalSize() >= image.width())
: m_bytesPerPixel {((image.width() > 0) && (torrentInfo.totalSize() >= image.width()))
? torrentInfo.totalSize() / image.width() : -1}
, m_torrentInfo {torrentInfo}
{

16
src/gui/properties/propertieswidget.cpp

@ -357,7 +357,7 @@ void PropertiesWidget::readSettings() @@ -357,7 +357,7 @@ void PropertiesWidget::readSettings()
{
const Preferences *const pref = Preferences::instance();
// Restore splitter sizes
QStringList sizesStr = pref->getPropSplitterSizes().split(",");
QStringList sizesStr = pref->getPropSplitterSizes().split(',');
if (sizesStr.size() == 2) {
m_slideSizes << sizesStr.first().toInt();
m_slideSizes << sizesStr.last().toInt();
@ -561,7 +561,7 @@ void PropertiesWidget::openFolder(const QModelIndex &index, bool containingFolde @@ -561,7 +561,7 @@ void PropertiesWidget::openFolder(const QModelIndex &index, bool containingFolde
if (pathItems.isEmpty())
return;
const QDir saveDir(m_torrent->savePath(true));
const QString relativePath = pathItems.join("/");
const QString relativePath = pathItems.join('/');
absolutePath = Utils::Fs::expandPath(saveDir.absoluteFilePath(relativePath));
}
else {
@ -743,15 +743,15 @@ void PropertiesWidget::renameSelectedFile() @@ -743,15 +743,15 @@ void PropertiesWidget::renameSelectedFile()
pathItems.prepend(parent.data().toString());
parent = m_propListModel->parent(parent);
}
const QString oldPath = pathItems.join("/");
const QString oldPath = pathItems.join('/');
pathItems.removeLast();
pathItems << newName;
QString newPath = pathItems.join("/");
QString newPath = pathItems.join('/');
if (Utils::Fs::sameFileNames(oldPath, newPath)) {
qDebug("Name did not change");
return;
}
if (!newPath.endsWith("/")) newPath += "/";
if (!newPath.endsWith('/')) newPath += '/';
// Check for overwriting
for (int i = 0; i < m_torrent->filesCount(); ++i) {
const QString &currentName = m_torrent->filePath(i);
@ -785,9 +785,9 @@ void PropertiesWidget::renameSelectedFile() @@ -785,9 +785,9 @@ void PropertiesWidget::renameSelectedFile()
// Rename folder in torrent files model too
m_propListModel->setData(modelIndex, newName);
// Remove old folder
const QDir oldFolder(m_torrent->savePath(true) + "/" + oldPath);
const QDir oldFolder(m_torrent->savePath(true) + '/' + oldPath);
int timeout = 10;
while (!QDir().rmpath(oldFolder.absolutePath()) && timeout > 0) {
while (!QDir().rmpath(oldFolder.absolutePath()) && (timeout > 0)) {
// FIXME: We should not sleep here (freezes the UI for 1 second)
QThread::msleep(100);
--timeout;
@ -847,7 +847,7 @@ void PropertiesWidget::copySelectedWebSeedsToClipboard() const @@ -847,7 +847,7 @@ void PropertiesWidget::copySelectedWebSeedsToClipboard() const
foreach (QListWidgetItem *item, selectedItems)
urlsToCopy << item->text();
QApplication::clipboard()->setText(urlsToCopy.join("\n"));
QApplication::clipboard()->setText(urlsToCopy.join('\n'));
}
void PropertiesWidget::editWebSeed()

4
src/gui/properties/speedplotview.cpp

@ -161,7 +161,7 @@ int SpeedPlotView::maxYValue() @@ -161,7 +161,7 @@ int SpeedPlotView::maxYValue()
if (!m_properties[static_cast<GraphID>(id)].enable)
continue;
for (int i = int(queue.size()) - 1, j = 0; i >= 0 && j <= m_viewablePointsCount; --i, ++j)
for (int i = static_cast<int>(queue.size()) - 1, j = 0; (i >= 0) && (j <= m_viewablePointsCount); --i, ++j)
if (queue[i].y[id] > maxYValue)
maxYValue = queue[i].y[id];
}
@ -241,7 +241,7 @@ void SpeedPlotView::paintEvent(QPaintEvent *) @@ -241,7 +241,7 @@ void SpeedPlotView::paintEvent(QPaintEvent *)
continue;
QVector<QPoint> points;
for (int i = int(queue.size()) - 1, j = 0; i >= 0 && j <= m_viewablePointsCount; --i, ++j) {
for (int i = static_cast<int>(queue.size()) - 1, j = 0; (i >= 0) && (j <= m_viewablePointsCount); --i, ++j) {
int newX = rect.right() - j * xTickSize;
int newY = rect.bottom() - queue[i].y[id] * yMultiplier;

2
src/gui/properties/speedwidget.h

@ -47,7 +47,7 @@ class ComboBoxMenuButton : public QComboBox @@ -47,7 +47,7 @@ class ComboBoxMenuButton : public QComboBox
public:
ComboBoxMenuButton(QWidget *parent, QMenu *menu);
virtual void showPopup();
void showPopup() override;
private:
QMenu *m_menu;

2
src/gui/properties/trackerlist.cpp

@ -411,7 +411,7 @@ void TrackerList::copyTrackerUrl() @@ -411,7 +411,7 @@ void TrackerList::copyTrackerUrl()
qDebug() << QString("Copy: ") + trackerURL;
urlsToCopy << trackerURL;
}
QApplication::clipboard()->setText(urlsToCopy.join("\n"));
QApplication::clipboard()->setText(urlsToCopy.join('\n'));
}

8
src/gui/properties/trackersadditiondlg.cpp

@ -59,7 +59,7 @@ TrackersAdditionDlg::~TrackersAdditionDlg() @@ -59,7 +59,7 @@ TrackersAdditionDlg::~TrackersAdditionDlg()
QStringList TrackersAdditionDlg::newTrackers() const
{
QStringList cleanTrackers;
foreach (QString url, m_ui->trackers_list->toPlainText().split("\n")) {
foreach (QString url, m_ui->trackers_list->toPlainText().split('\n')) {
url = url.trimmed();
if (!url.isEmpty())
cleanTrackers << url;
@ -92,7 +92,7 @@ void TrackersAdditionDlg::parseUTorrentList(const QString &, const QString &path @@ -92,7 +92,7 @@ void TrackersAdditionDlg::parseUTorrentList(const QString &, const QString &path
// Load from torrent handle
QList<BitTorrent::TrackerEntry> existingTrackers = m_torrent->trackers();
// Load from current user list
QStringList tmp = m_ui->trackers_list->toPlainText().split("\n");
QStringList tmp = m_ui->trackers_list->toPlainText().split('\n');
foreach (const QString &userURL, tmp) {
BitTorrent::TrackerEntry userTracker(userURL);
if (!existingTrackers.contains(userTracker))
@ -100,7 +100,7 @@ void TrackersAdditionDlg::parseUTorrentList(const QString &, const QString &path @@ -100,7 +100,7 @@ void TrackersAdditionDlg::parseUTorrentList(const QString &, const QString &path
}
// Add new trackers to the list
if (!m_ui->trackers_list->toPlainText().isEmpty() && !m_ui->trackers_list->toPlainText().endsWith("\n"))
if (!m_ui->trackers_list->toPlainText().isEmpty() && !m_ui->trackers_list->toPlainText().endsWith('\n'))
m_ui->trackers_list->insertPlainText("\n");
int nb = 0;
while (!listFile.atEnd()) {
@ -108,7 +108,7 @@ void TrackersAdditionDlg::parseUTorrentList(const QString &, const QString &path @@ -108,7 +108,7 @@ void TrackersAdditionDlg::parseUTorrentList(const QString &, const QString &path
if (line.isEmpty()) continue;
BitTorrent::TrackerEntry newTracker(line);
if (!existingTrackers.contains(newTracker)) {
m_ui->trackers_list->insertPlainText(line + "\n");
m_ui->trackers_list->insertPlainText(line + '\n');
++nb;
}
}

16
src/gui/scanfoldersdelegate.cpp

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2015 sledgehammer999
* Copyright (C) 2015 sledgehammer999 <sledgehammer999@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -24,21 +24,19 @@ @@ -24,21 +24,19 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : hammered999@gmail.com
*/
#include <QDebug>
#include <QPainter>
#include "scanfoldersdelegate.h"
#include <QComboBox>
#include <QDebug>
#include <QFileDialog>
#include <QTreeView>
#include <QItemSelectionModel>
#include <QPainter>
#include <QTreeView>
#include "base/scanfoldersmodel.h"
#include "base/bittorrent/session.h"
#include "scanfoldersdelegate.h"
#include "base/scanfoldersmodel.h"
ScanFoldersDelegate::ScanFoldersDelegate(QObject *parent, QTreeView *foldersView)
: QItemDelegate(parent)

19
src/gui/scanfoldersdelegate.h

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2015 sledgehammer999
* Copyright (C) 2015 sledgehammer999 <sledgehammer999@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -24,8 +24,6 @@ @@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : hammered999@gmail.com
*/
#ifndef SCANFOLDERSDELEGATE_H
@ -33,12 +31,12 @@ @@ -33,12 +31,12 @@
#include <QItemDelegate>
class QPainter;
class QAbstractItemModel;
class QModelIndex;
class QPainter;
class QStyleOptionViewItem;
class QAbstractItemModel;
class PropertiesWidget;
class QTreeView;
class PropertiesWidget;
class ScanFoldersDelegate : public QItemDelegate
{
@ -51,13 +49,12 @@ private slots: @@ -51,13 +49,12 @@ private slots:
void comboboxIndexChanged(int index);
private:
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &) const;
void setEditorData(QWidget *editor, const QModelIndex &index) const;
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &index) const;
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &) const override;
void setEditorData(QWidget *editor, const QModelIndex &index) const override;
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &index) const override;
QTreeView *m_folderView;
};
#endif // SCANFOLDERSDELEGATE_H

4
src/gui/shutdownconfirmdlg.cpp

@ -131,12 +131,12 @@ void ShutdownConfirmDlg::initText() @@ -131,12 +131,12 @@ void ShutdownConfirmDlg::initText()
break;
}
m_msg += "\n";
m_msg += '\n';
updateText();
}
void ShutdownConfirmDlg::updateText()
{
QString t = tr("You can cancel the action within %1 seconds.").arg(QString::number(m_timeout)) + "\n";
QString t = tr("You can cancel the action within %1 seconds.").arg(QString::number(m_timeout)) + '\n';
m_ui->shutdownText->setText(m_msg + t);
}

20
src/gui/speedlimitdlg.cpp

@ -54,17 +54,17 @@ SpeedLimitDialog::~SpeedLimitDialog() @@ -54,17 +54,17 @@ SpeedLimitDialog::~SpeedLimitDialog()
}
// -2: if cancel
long SpeedLimitDialog::askSpeedLimit(QWidget *parent, bool *ok, QString title, long default_value, long max_value)
long SpeedLimitDialog::askSpeedLimit(QWidget *parent, bool *ok, QString title, long defaultVal, long maxVal)
{
SpeedLimitDialog dlg(parent);
dlg.setWindowTitle(title);
dlg.setupDialog(max_value / 1024., default_value / 1024.);
dlg.setupDialog(maxVal / 1024., defaultVal / 1024.);
if (dlg.exec() == QDialog::Accepted) {
*ok = true;
int val = dlg.getSpeedLimit();
if (val <= 0)
return 0;
return val * 1024;
return (val * 1024);
}
else {
*ok = false;
@ -82,7 +82,7 @@ void SpeedLimitDialog::updateSpinValue(int val) const @@ -82,7 +82,7 @@ void SpeedLimitDialog::updateSpinValue(int val) const
}
else {
m_ui->spinBandwidth->setValue(val);
m_ui->spinBandwidth->setSuffix(" " + tr("KiB/s"));
m_ui->spinBandwidth->setSuffix(' ' + tr("KiB/s"));
}
}
@ -106,17 +106,17 @@ long SpeedLimitDialog::getSpeedLimit() const @@ -106,17 +106,17 @@ long SpeedLimitDialog::getSpeedLimit() const
return -1;
}
void SpeedLimitDialog::setupDialog(long max_slider, long val) const
void SpeedLimitDialog::setupDialog(long maxSlider, long val) const
{
if (val < 0)
val = 0;
if (max_slider <= 0)
max_slider = 10000;
if (maxSlider <= 0)
maxSlider = 10000;
// This can happen for example if global rate limit is lower
// than torrent rate limit.
if (val > max_slider)
max_slider = val;
m_ui->bandwidthSlider->setMaximum(max_slider);
if (val > maxSlider)
maxSlider = val;
m_ui->bandwidthSlider->setMaximum(maxSlider);
m_ui->bandwidthSlider->setValue(val);
updateSpinValue(val);
}

4
src/gui/speedlimitdlg.h

@ -47,12 +47,12 @@ class SpeedLimitDialog : public QDialog @@ -47,12 +47,12 @@ class SpeedLimitDialog : public QDialog
public:
explicit SpeedLimitDialog(QWidget *parent);
~SpeedLimitDialog();
static long askSpeedLimit(QWidget *parent, bool *ok, QString title, long default_value, long max_value=10240000);
static long askSpeedLimit(QWidget *parent, bool *ok, QString title, long defaultVal, long maxVal=10240000);
protected slots:
void updateSpinValue(int val) const;
void updateSliderValue(int val) const;
void setupDialog(long max_slider, long val) const;
void setupDialog(long maxSlider, long val) const;
private:
long getSpeedLimit() const;

2
src/gui/tagfiltermodel.cpp

@ -113,7 +113,7 @@ bool TagFilterModel::isSpecialItem(const QModelIndex &index) @@ -113,7 +113,7 @@ bool TagFilterModel::isSpecialItem(const QModelIndex &index)
QVariant TagFilterModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid() || index.column() != 0)
if (!index.isValid() || (index.column() != 0))
return QVariant();
const int row = index.internalId();

6
src/gui/torrentcontentfiltermodel.h

@ -46,7 +46,7 @@ public: @@ -46,7 +46,7 @@ public:
TorrentContentModel *model() const;
TorrentContentModelItem::ItemType itemType(const QModelIndex &index) const;
int getFileIndex(const QModelIndex &index) const;
virtual QModelIndex parent(const QModelIndex &child) const;
QModelIndex parent(const QModelIndex &child) const override;
public slots:
void selectAll();
@ -56,8 +56,8 @@ signals: @@ -56,8 +56,8 @@ signals:
void filteredFilesChanged();
protected:
virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
private:
TorrentContentModel *m_model;

19
src/gui/torrentcontentmodel.cpp

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2006-2012 Christophe Dumez
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006-2012 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -24,8 +24,6 @@ @@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#include <QDir>
@ -48,13 +46,14 @@ @@ -48,13 +46,14 @@
#include <QPixmapCache>
#endif
#include "guiiconprovider.h"
#include "base/utils/misc.h"
#include "base/utils/fs.h"
#include "guiiconprovider.h"
#include "torrentcontentmodel.h"
#include "torrentcontentmodelitem.h"
#include "torrentcontentmodelfolder.h"
#include "torrentcontentmodelfile.h"
#include "torrentcontentmodelfolder.h"
#include "torrentcontentmodelitem.h"
#ifdef Q_OS_MAC
#include "macutilities.h"
#endif
@ -123,7 +122,7 @@ namespace @@ -123,7 +122,7 @@ namespace
protected:
virtual QPixmap pixmapForExtension(const QString &ext) const = 0;
};
#endif
#endif // QBT_PIXMAP_CACHE_FOR_FILE_ICONS
#if defined(Q_OS_WIN)
// See QTBUG-25319 for explanation why this is required
@ -197,7 +196,7 @@ namespace @@ -197,7 +196,7 @@ namespace
private:
QMimeDatabase m_db;
};
#endif
#endif // Q_OS_WIN
}
TorrentContentModel::TorrentContentModel(QObject *parent)
@ -474,7 +473,7 @@ void TorrentContentModel::setupModelData(const BitTorrent::TorrentInfo &info) @@ -474,7 +473,7 @@ void TorrentContentModel::setupModelData(const BitTorrent::TorrentInfo &info)
currentParent = m_rootItem;
QString path = Utils::Fs::fromNativePath(info.filePath(i));
// Iterate of parts of the path to create necessary folders
QStringList pathFolders = path.split("/", QString::SkipEmptyParts);
QStringList pathFolders = path.split('/', QString::SkipEmptyParts);
pathFolders.removeLast();
foreach (const QString &pathPart, pathFolders) {
if (pathPart == ".unwanted")

8
src/gui/torrentcontentmodel.h

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2006-2012 Christophe Dumez
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006-2012 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -24,8 +24,6 @@ @@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#ifndef TORRENTCONTENTMODEL_H
@ -33,8 +31,8 @@ @@ -33,8 +31,8 @@
#include <QAbstractItemModel>
#include <QModelIndex>
#include <QVector>
#include <QVariant>
#include <QVector>
#include "base/bittorrent/torrentinfo.h"
#include "torrentcontentmodelitem.h"

6
src/gui/torrentcontentmodelfile.cpp

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2006-2012 Christophe Dumez
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006-2012 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -24,8 +24,6 @@ @@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#include "torrentcontentmodelfile.h"

6
src/gui/torrentcontentmodelfile.h

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2006-2012 Christophe Dumez
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006-2012 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -24,8 +24,6 @@ @@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#ifndef TORRENTCONTENTMODELFILE_H

6
src/gui/torrentcontentmodelfolder.cpp

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2006-2012 Christophe Dumez
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006-2012 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -24,8 +24,6 @@ @@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#include "torrentcontentmodelfolder.h"

6
src/gui/torrentcontentmodelfolder.h

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2006-2012 Christophe Dumez
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006-2012 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -24,8 +24,6 @@ @@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#ifndef TORRENTCONTENTMODELFOLDER_H

13
src/gui/torrentcontentmodelitem.cpp

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2006-2012 Christophe Dumez
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006-2012 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -24,15 +24,15 @@ @@ -24,15 +24,15 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#include "torrentcontentmodelitem.h"
#include <QDebug>
#include "base/utils/misc.h"
#include "base/utils/fs.h"
#include "torrentcontentmodelitem.h"
#include "torrentcontentmodelfolder.h"
#include <QDebug>
TorrentContentModelItem::TorrentContentModelItem(TorrentContentModelFolder *parent)
: m_parentItem(parent)
@ -138,4 +138,3 @@ TorrentContentModelFolder *TorrentContentModelItem::parent() const @@ -138,4 +138,3 @@ TorrentContentModelFolder *TorrentContentModelItem::parent() const
{
return m_parentItem;
}

6
src/gui/torrentcontentmodelitem.h

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2006-2012 Christophe Dumez
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006-2012 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -24,8 +24,6 @@ @@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#ifndef TORRENTCONTENTMODELITEM_H

2
src/gui/torrentcontenttreeview.h

@ -37,7 +37,7 @@ class TorrentContentTreeView: public QTreeView @@ -37,7 +37,7 @@ class TorrentContentTreeView: public QTreeView
public:
explicit TorrentContentTreeView(QWidget *parent = nullptr);
void keyPressEvent(QKeyEvent *event);
void keyPressEvent(QKeyEvent *event) override;
private:
QModelIndex currentNameCell();

2
src/gui/torrentcreatordlg.h

@ -89,4 +89,4 @@ private: @@ -89,4 +89,4 @@ private:
CachedSettingValue<QString> m_storeSource;
};
#endif
#endif // TORRENTCREATORDLG_H

9
src/gui/torrentmodel.cpp

@ -25,20 +25,19 @@ @@ -25,20 +25,19 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#include <QDebug>
#include "torrentmodel.h"
#include <QApplication>
#include <QPalette>
#include <QDebug>
#include <QIcon>
#include <QPalette>
#include "base/bittorrent/session.h"
#include "base/bittorrent/torrenthandle.h"
#include "base/torrentfilter.h"
#include "base/utils/fs.h"
#include "torrentmodel.h"
static QIcon getIconByState(BitTorrent::TorrentState state);
static QColor getColorByState(BitTorrent::TorrentState state);

14
src/gui/torrentmodel.h

@ -25,8 +25,6 @@ @@ -25,8 +25,6 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#ifndef TORRENTMODEL_H
@ -85,12 +83,12 @@ public: @@ -85,12 +83,12 @@ public:
explicit TorrentModel(QObject *parent = nullptr);
int rowCount(const QModelIndex& index = QModelIndex()) const;
int columnCount(const QModelIndex &parent=QModelIndex()) const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::DisplayRole);
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
Qt::ItemFlags flags(const QModelIndex &index) const;
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 = Qt::DisplayRole) override;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
Qt::ItemFlags flags(const QModelIndex &index) const override;
BitTorrent::TorrentHandle *torrentHandle(const QModelIndex &index) const;

6
src/gui/trackerlogin.cpp

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2006 Christophe Dumez
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -24,8 +24,6 @@ @@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#include "trackerlogin.h"

8
src/gui/trackerlogin.h

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2006 Christophe Dumez
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -24,8 +24,6 @@ @@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#ifndef TRACKERLOGIN_H
@ -58,4 +56,4 @@ class trackerLogin : public QDialog, private Ui::authentication{ @@ -58,4 +56,4 @@ class trackerLogin : public QDialog, private Ui::authentication{
void cancelButtonClicked();
};
#endif
#endif // TRACKERLOGIN_H

51
src/gui/transferlistdelegate.cpp

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2006 Christophe Dumez
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -24,29 +24,28 @@ @@ -24,29 +24,28 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#include "transferlistdelegate.h"
#include <QModelIndex>
#include <QStyleOptionViewItem>
#include <QApplication>
#include <QModelIndex>
#include <QPainter>
#include "base/utils/misc.h"
#include "base/utils/string.h"
#include "torrentmodel.h"
#include "base/bittorrent/session.h"
#include "base/bittorrent/torrenthandle.h"
#include "base/types.h"
#include "base/preferences.h"
#include "base/unicodestrings.h"
#include <QStyleOptionViewItem>
#ifdef Q_OS_WIN
#include <QProxyStyle>
#endif
#include "base/bittorrent/session.h"
#include "base/bittorrent/torrenthandle.h"
#include "base/preferences.h"
#include "base/types.h"
#include "base/unicodestrings.h"
#include "base/utils/misc.h"
#include "base/utils/string.h"
#include "torrentmodel.h"
TransferListDelegate::TransferListDelegate(QObject *parent)
: QItemDelegate(parent)
{
@ -77,10 +76,10 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem @@ -77,10 +76,10 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem
qlonglong size = index.data().toLongLong();
if (hideValues && !size)
break;
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
opt.displayAlignment = (Qt::AlignRight | Qt::AlignVCenter);
QItemDelegate::drawDisplay(painter, opt, option.rect, Utils::Misc::friendlyUnit(size));
break;
}
break;
case TorrentModel::TR_ETA: {
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
QItemDelegate::drawDisplay(painter, opt, option.rect, Utils::Misc::userFriendlyDuration(index.data().toLongLong()));
@ -95,14 +94,14 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem @@ -95,14 +94,14 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem
QString display = QString::number(value) + " (" + QString::number(total) + ")";
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
QItemDelegate::drawDisplay(painter, opt, opt.rect, display);
break;
}
break;
case TorrentModel::TR_STATUS: {
const auto state = index.data().value<BitTorrent::TorrentState>();
QString display = getStatusString(state);
QItemDelegate::drawDisplay(painter, opt, opt.rect, display);
break;
}
break;
case TorrentModel::TR_UPSPEED:
case TorrentModel::TR_DLSPEED: {
const qulonglong speed = index.data().toULongLong();
@ -110,8 +109,8 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem @@ -110,8 +109,8 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem
break;
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
QItemDelegate::drawDisplay(painter, opt, opt.rect, Utils::Misc::friendlyUnit(speed, true));
break;
}
break;
case TorrentModel::TR_UPLIMIT:
case TorrentModel::TR_DLLIMIT: {
const qlonglong limit = index.data().toLongLong();
@ -119,8 +118,8 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem @@ -119,8 +118,8 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem
break;
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
QItemDelegate::drawDisplay(painter, opt, opt.rect, limit > 0 ? Utils::Misc::friendlyUnit(limit, true) : QString::fromUtf8(C_INFINITY));
break;
}
break;
case TorrentModel::TR_TIME_ELAPSED: {
const int elapsedTime = index.data().toInt();
const int seedingTime = index.data(Qt::UserRole).toInt();
@ -130,8 +129,8 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem @@ -130,8 +129,8 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem
, Utils::Misc::userFriendlyDuration(seedingTime))
: Utils::Misc::userFriendlyDuration(elapsedTime);
QItemDelegate::drawDisplay(painter, opt, opt.rect, txt);
break;
}
break;
case TorrentModel::TR_ADD_DATE:
case TorrentModel::TR_SEED_DATE:
QItemDelegate::drawDisplay(painter, opt, opt.rect, index.data().toDateTime().toLocalTime().toString(Qt::DefaultLocaleShortDate));
@ -144,8 +143,8 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem @@ -144,8 +143,8 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem
QString str = ((ratio == -1) || (ratio > BitTorrent::TorrentHandle::MAX_RATIO)) ? QString::fromUtf8(C_INFINITY) : Utils::String::fromDouble(ratio, 2);
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
QItemDelegate::drawDisplay(painter, opt, opt.rect, str);
break;
}
break;
case TorrentModel::TR_PRIORITY: {
const int priority = index.data().toInt();
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
@ -155,8 +154,8 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem @@ -155,8 +154,8 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem
else {
QItemDelegate::drawDisplay(painter, opt, opt.rect, "*");
}
break;
}
break;
case TorrentModel::TR_PROGRESS: {
QStyleOptionProgressBar newopt;
qreal progress = index.data().toDouble() * 100.;
@ -174,8 +173,8 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem @@ -174,8 +173,8 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem
QProxyStyle st("fusion");
st.drawControl(QStyle::CE_ProgressBar, &newopt, painter, 0);
#endif
break;
}
break;
case TorrentModel::TR_LAST_ACTIVITY: {
qlonglong elapsed = index.data().toLongLong();
if (hideValues && ((elapsed < 0) || (elapsed >= MAX_ETA)))
@ -191,8 +190,8 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem @@ -191,8 +190,8 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
QItemDelegate::drawDisplay(painter, opt, option.rect, elapsedString);
break;
}
break;
default:
QItemDelegate::paint(painter, option, index);
}
@ -202,7 +201,7 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem @@ -202,7 +201,7 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem
QWidget *TransferListDelegate::createEditor(QWidget *, const QStyleOptionViewItem &, const QModelIndex &) const
{
// No editor here
return 0;
return nullptr;
}
QSize TransferListDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const

16
src/gui/transferlistdelegate.h

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2006 Christophe Dumez
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -24,8 +24,6 @@ @@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#ifndef TRANSFERLISTDELEGATE_H
@ -33,11 +31,9 @@ @@ -33,11 +31,9 @@
#include <QItemDelegate>
QT_BEGIN_NAMESPACE
class QModelIndex;
class QPainter;
class QStyleOptionViewItem;
class QModelIndex;
QT_END_NAMESPACE
namespace BitTorrent
{
@ -51,9 +47,9 @@ class TransferListDelegate: public QItemDelegate @@ -51,9 +47,9 @@ class TransferListDelegate: public QItemDelegate
public:
TransferListDelegate(QObject *parent);
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const;
QWidget* createEditor(QWidget*, const QStyleOptionViewItem &, const QModelIndex &) const;
QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const;
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
QWidget *createEditor(QWidget *, const QStyleOptionViewItem &, const QModelIndex &) const override;
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
private:
QString getStatusString(const BitTorrent::TorrentState state) const;

14
src/gui/transferlistfilterswidget.cpp

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2006 Christophe Dumez
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -24,8 +24,6 @@ @@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#include "transferlistfilterswidget.h"
@ -37,15 +35,15 @@ @@ -37,15 +35,15 @@
#include <QMenu>
#include <QMessageBox>
#include <QScrollArea>
#include <QVBoxLayout>
#include <QUrl>
#include <QVBoxLayout>
#include "base/bittorrent/session.h"
#include "base/bittorrent/torrenthandle.h"
#include "base/bittorrent/trackerentry.h"
#include "base/logger.h"
#include "base/net/downloadmanager.h"
#include "base/net/downloadhandler.h"
#include "base/net/downloadmanager.h"
#include "base/preferences.h"
#include "base/torrentfilter.h"
#include "base/utils/fs.h"
@ -514,10 +512,10 @@ QString TrackerFiltersList::trackerFromRow(int row) const @@ -514,10 +512,10 @@ QString TrackerFiltersList::trackerFromRow(int row) const
{
Q_ASSERT(row > 1);
const QString &tracker = item(row)->text();
QStringList parts = tracker.split(" ");
QStringList parts = tracker.split(' ');
Q_ASSERT(parts.size() >= 2);
parts.removeLast(); // Remove trailing number
return parts.join(" ");
return parts.join(' ');
}
int TrackerFiltersList::rowFromTracker(const QString &tracker) const

33
src/gui/transferlistfilterswidget.h

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2006 Christophe Dumez
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -24,21 +24,16 @@ @@ -24,21 +24,16 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#ifndef TRANSFERLISTFILTERSWIDGET_H
#define TRANSFERLISTFILTERSWIDGET_H
#include <QListWidget>
#include <QFrame>
#include <QListWidget>
QT_BEGIN_NAMESPACE
class QResizeEvent;
class QCheckBox;
QT_END_NAMESPACE
class QResizeEvent;
class TransferListWidget;
namespace BitTorrent
@ -54,8 +49,8 @@ class FiltersBase: public QListWidget @@ -54,8 +49,8 @@ class FiltersBase: public QListWidget
public:
FiltersBase(QWidget *parent, TransferListWidget *transferList);
virtual QSize sizeHint() const;
virtual QSize minimumSizeHint() const;
QSize sizeHint() const override;
QSize minimumSizeHint() const override;
public slots:
void toggleFilter(bool checked);
@ -84,10 +79,10 @@ private slots: @@ -84,10 +79,10 @@ private slots:
private:
// These 4 methods are virtual slots in the base class.
// No need to redeclare them here as slots.
virtual void showMenu(QPoint);
virtual void applyFilter(int row);
virtual void handleNewTorrent(BitTorrent::TorrentHandle *const);
virtual void torrentAboutToBeDeleted(BitTorrent::TorrentHandle *const);
void showMenu(QPoint) override;
void applyFilter(int row) override;
void handleNewTorrent(BitTorrent::TorrentHandle *const) override;
void torrentAboutToBeDeleted(BitTorrent::TorrentHandle *const) override;
};
class TrackerFiltersList : public FiltersBase
@ -116,10 +111,10 @@ private slots: @@ -116,10 +111,10 @@ private slots:
private:
// These 4 methods are virtual slots in the base class.
// No need to redeclare them here as slots.
virtual void showMenu(QPoint);
virtual void applyFilter(int row);
virtual void handleNewTorrent(BitTorrent::TorrentHandle *const torrent);
virtual void torrentAboutToBeDeleted(BitTorrent::TorrentHandle *const torrent);
void showMenu(QPoint) override;
void applyFilter(int row) override;
void handleNewTorrent(BitTorrent::TorrentHandle *const torrent) override;
void torrentAboutToBeDeleted(BitTorrent::TorrentHandle *const torrent) override;
QString trackerFromRow(int row) const;
int rowFromTracker(const QString &tracker) const;
QString getHost(const QString &tracker) const;

12
src/gui/transferlistsortmodel.cpp

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2013 Nick Tiskov
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2013 Nick Tiskov <daymansmail@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -24,17 +24,17 @@ @@ -24,17 +24,17 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : daymansmail@gmail.com
*/
#include "transferlistsortmodel.h"
#include <QStringList>
#include "base/bittorrent/torrenthandle.h"
#include "base/types.h"
#include "base/utils/string.h"
#include "base/bittorrent/torrenthandle.h"
#include "torrentmodel.h"
#include "transferlistsortmodel.h"
TransferListSortModel::TransferListSortModel(QObject *parent)
: QSortFilterProxyModel(parent)

10
src/gui/transferlistsortmodel.h

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2013 Nick Tiskov
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2013 Nick Tiskov <daymansmail@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -24,8 +24,6 @@ @@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : daymansmail@gmail.com
*/
#ifndef TRANSFERLISTSORTMODEL_H
@ -52,10 +50,10 @@ public: @@ -52,10 +50,10 @@ public:
void disableTrackerFilter();
private:
bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
bool lowerPositionThan(const QModelIndex &left, const QModelIndex &right) const;
bool dateLessThan(const int dateColumn, const QModelIndex &left, const QModelIndex &right, bool sortInvalidInBottom) const;
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
bool matchFilter(int sourceRow, const QModelIndex &sourceParent) const;
private:

184
src/gui/transferlistwidget.cpp

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
@ -206,7 +206,7 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *mainWindow) @@ -206,7 +206,7 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *mainWindow)
setUniformRowHeights(true);
// Load settings
bool column_loaded = loadSettings();
bool columnLoaded = loadSettings();
// Create and apply delegate
m_listDelegate = new TransferListDelegate(this);
@ -238,7 +238,7 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *mainWindow) @@ -238,7 +238,7 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *mainWindow)
header()->setStretchLastSection(false);
// Default hidden columns
if (!column_loaded) {
if (!columnLoaded) {
setColumnHidden(TorrentModel::TR_ADD_DATE, true);
setColumnHidden(TorrentModel::TR_SEED_DATE, true);
setColumnHidden(TorrentModel::TR_UPLIMIT, true);
@ -531,7 +531,7 @@ void TransferListWidget::copySelectedMagnetURIs() const @@ -531,7 +531,7 @@ void TransferListWidget::copySelectedMagnetURIs() const
foreach (BitTorrent::TorrentHandle *const torrent, getSelectedTorrents())
magnet_uris << torrent->toMagnetUri();
qApp->clipboard()->setText(magnet_uris.join("\n"));
qApp->clipboard()->setText(magnet_uris.join('\n'));
}
void TransferListWidget::copySelectedNames() const
@ -540,7 +540,7 @@ void TransferListWidget::copySelectedNames() const @@ -540,7 +540,7 @@ void TransferListWidget::copySelectedNames() const
foreach (BitTorrent::TorrentHandle *const torrent, getSelectedTorrents())
torrent_names << torrent->name();
qApp->clipboard()->setText(torrent_names.join("\n"));
qApp->clipboard()->setText(torrent_names.join('\n'));
}
void TransferListWidget::copySelectedHashes() const
@ -703,8 +703,8 @@ void TransferListWidget::displayDLHoSMenu(const QPoint&) @@ -703,8 +703,8 @@ void TransferListWidget::displayDLHoSMenu(const QPoint&)
hideshowColumn.setTitle(tr("Column visibility"));
QList<QAction*> actions;
for (int i = 0; i < m_listModel->columnCount(); ++i) {
if (!BitTorrent::Session::instance()->isQueueingSystemEnabled() && i == TorrentModel::TR_PRIORITY) {
actions.append(0);
if (!BitTorrent::Session::instance()->isQueueingSystemEnabled() && (i == TorrentModel::TR_PRIORITY)) {
actions.append(nullptr);
continue;
}
QAction *myAct = hideshowColumn.addAction(m_listModel->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString());
@ -872,16 +872,16 @@ void TransferListWidget::displayListMenu(const QPoint&) @@ -872,16 +872,16 @@ void TransferListWidget::displayListMenu(const QPoint&)
connect(&actionForceStart, &QAction::triggered, this, &TransferListWidget::forceStartSelectedTorrents);
QAction actionDelete(GuiIconProvider::instance()->getIcon("edit-delete"), tr("Delete", "Delete the torrent"), nullptr);
connect(&actionDelete, &QAction::triggered, this, &TransferListWidget::softDeleteSelectedTorrents);
QAction actionPreview_file(GuiIconProvider::instance()->getIcon("view-preview"), tr("Preview file..."), nullptr);
connect(&actionPreview_file, &QAction::triggered, this, &TransferListWidget::previewSelectedTorrents);
QAction actionSet_max_ratio(QIcon(QLatin1String(":/icons/skin/ratio.png")), tr("Limit share ratio..."), nullptr);
connect(&actionSet_max_ratio, &QAction::triggered, this, &TransferListWidget::setMaxRatioSelectedTorrents);
QAction actionSet_upload_limit(GuiIconProvider::instance()->getIcon("kt-set-max-upload-speed"), tr("Limit upload rate..."), nullptr);
connect(&actionSet_upload_limit, &QAction::triggered, this, &TransferListWidget::setUpLimitSelectedTorrents);
QAction actionSet_download_limit(GuiIconProvider::instance()->getIcon("kt-set-max-download-speed"), tr("Limit download rate..."), nullptr);
connect(&actionSet_download_limit, &QAction::triggered, this, &TransferListWidget::setDlLimitSelectedTorrents);
QAction actionOpen_destination_folder(GuiIconProvider::instance()->getIcon("inode-directory"), tr("Open destination folder"), nullptr);
connect(&actionOpen_destination_folder, &QAction::triggered, this, &TransferListWidget::openSelectedTorrentsFolder);
QAction actionPreviewFile(GuiIconProvider::instance()->getIcon("view-preview"), tr("Preview file..."), nullptr);
connect(&actionPreviewFile, &QAction::triggered, this, &TransferListWidget::previewSelectedTorrents);
QAction actionSetMaxRatio(QIcon(QLatin1String(":/icons/skin/ratio.png")), tr("Limit share ratio..."), nullptr);
connect(&actionSetMaxRatio, &QAction::triggered, this, &TransferListWidget::setMaxRatioSelectedTorrents);
QAction actionSetUploadLimit(GuiIconProvider::instance()->getIcon("kt-set-max-upload-speed"), tr("Limit upload rate..."), nullptr);
connect(&actionSetUploadLimit, &QAction::triggered, this, &TransferListWidget::setUpLimitSelectedTorrents);
QAction actionSetDownloadLimit(GuiIconProvider::instance()->getIcon("kt-set-max-download-speed"), tr("Limit download rate..."), nullptr);
connect(&actionSetDownloadLimit, &QAction::triggered, this, &TransferListWidget::setDlLimitSelectedTorrents);
QAction actionOpenDestinationFolder(GuiIconProvider::instance()->getIcon("inode-directory"), tr("Open destination folder"), nullptr);
connect(&actionOpenDestinationFolder, &QAction::triggered, this, &TransferListWidget::openSelectedTorrentsFolder);
QAction actionIncreasePriority(GuiIconProvider::instance()->getIcon("go-up"), tr("Move up", "i.e. move up in the queue"), nullptr);
connect(&actionIncreasePriority, &QAction::triggered, this, &TransferListWidget::increasePrioSelectedTorrents);
QAction actionDecreasePriority(GuiIconProvider::instance()->getIcon("go-down"), tr("Move down", "i.e. Move down in the queue"), nullptr);
@ -892,27 +892,27 @@ void TransferListWidget::displayListMenu(const QPoint&) @@ -892,27 +892,27 @@ void TransferListWidget::displayListMenu(const QPoint&)
connect(&actionBottomPriority, &QAction::triggered, this, &TransferListWidget::bottomPrioSelectedTorrents);
QAction actionSetTorrentPath(GuiIconProvider::instance()->getIcon("inode-directory"), tr("Set location..."), nullptr);
connect(&actionSetTorrentPath, &QAction::triggered, this, &TransferListWidget::setSelectedTorrentsLocation);
QAction actionForce_recheck(GuiIconProvider::instance()->getIcon("document-edit-verify"), tr("Force recheck"), nullptr);
connect(&actionForce_recheck, &QAction::triggered, this, &TransferListWidget::recheckSelectedTorrents);
QAction actionForce_reannounce(GuiIconProvider::instance()->getIcon("document-edit-verify"), tr("Force reannounce"), nullptr);
connect(&actionForce_reannounce, &QAction::triggered, this, &TransferListWidget::reannounceSelectedTorrents);
QAction actionCopy_magnet_link(GuiIconProvider::instance()->getIcon("kt-magnet"), tr("Copy magnet link"), nullptr);
connect(&actionCopy_magnet_link, &QAction::triggered, this, &TransferListWidget::copySelectedMagnetURIs);
QAction actionCopy_name(GuiIconProvider::instance()->getIcon("edit-copy"), tr("Copy name"), nullptr);
connect(&actionCopy_name, &QAction::triggered, this, &TransferListWidget::copySelectedNames);
QAction actionForceRecheck(GuiIconProvider::instance()->getIcon("document-edit-verify"), tr("Force recheck"), nullptr);
connect(&actionForceRecheck, &QAction::triggered, this, &TransferListWidget::recheckSelectedTorrents);
QAction actionForceReannounce(GuiIconProvider::instance()->getIcon("document-edit-verify"), tr("Force reannounce"), nullptr);
connect(&actionForceReannounce, &QAction::triggered, this, &TransferListWidget::reannounceSelectedTorrents);
QAction actionCopyMagnetLink(GuiIconProvider::instance()->getIcon("kt-magnet"), tr("Copy magnet link"), nullptr);
connect(&actionCopyMagnetLink, &QAction::triggered, this, &TransferListWidget::copySelectedMagnetURIs);
QAction actionCopyName(GuiIconProvider::instance()->getIcon("edit-copy"), tr("Copy name"), nullptr);
connect(&actionCopyName, &QAction::triggered, this, &TransferListWidget::copySelectedNames);
QAction actionCopyHash(GuiIconProvider::instance()->getIcon("edit-copy"), tr("Copy hash"), nullptr);
connect(&actionCopyHash, &QAction::triggered, this, &TransferListWidget::copySelectedHashes);
QAction actionSuper_seeding_mode(tr("Super seeding mode"), nullptr);
actionSuper_seeding_mode.setCheckable(true);
connect(&actionSuper_seeding_mode, &QAction::triggered, this, &TransferListWidget::toggleSelectedTorrentsSuperSeeding);
QAction actionSuperSeedingMode(tr("Super seeding mode"), nullptr);
actionSuperSeedingMode.setCheckable(true);
connect(&actionSuperSeedingMode, &QAction::triggered, this, &TransferListWidget::toggleSelectedTorrentsSuperSeeding);
QAction actionRename(GuiIconProvider::instance()->getIcon("edit-rename"), tr("Rename..."), nullptr);
connect(&actionRename, &QAction::triggered, this, &TransferListWidget::renameSelectedTorrent);
QAction actionSequential_download(tr("Download in sequential order"), nullptr);
actionSequential_download.setCheckable(true);
connect(&actionSequential_download, &QAction::triggered, this, &TransferListWidget::toggleSelectedTorrentsSequentialDownload);
QAction actionFirstLastPiece_prio(tr("Download first and last pieces first"), nullptr);
actionFirstLastPiece_prio.setCheckable(true);
connect(&actionFirstLastPiece_prio, &QAction::triggered, this, &TransferListWidget::toggleSelectedFirstLastPiecePrio);
QAction actionSequentialDownload(tr("Download in sequential order"), nullptr);
actionSequentialDownload.setCheckable(true);
connect(&actionSequentialDownload, &QAction::triggered, this, &TransferListWidget::toggleSelectedTorrentsSequentialDownload);
QAction actionFirstLastPiecePrio(tr("Download first and last pieces first"), nullptr);
actionFirstLastPiecePrio.setCheckable(true);
connect(&actionFirstLastPiecePrio, &QAction::triggered, this, &TransferListWidget::toggleSelectedFirstLastPiecePrio);
QAction actionAutoTMM(tr("Automatic Torrent Management"), nullptr);
actionAutoTMM.setCheckable(true);
actionAutoTMM.setToolTip(tr("Automatic mode means that various torrent properties(eg save path) will be decided by the associated category"));
@ -920,12 +920,12 @@ void TransferListWidget::displayListMenu(const QPoint&) @@ -920,12 +920,12 @@ void TransferListWidget::displayListMenu(const QPoint&)
// End of actions
// Enable/disable pause/start action given the DL state
bool needs_pause = false, needs_start = false, needs_force = false, needs_preview = false;
bool all_same_super_seeding = true;
bool super_seeding_mode = false;
bool all_same_sequential_download_mode = true, all_same_prio_firstlast = true;
bool sequential_download_mode = false, prioritize_first_last = false;
bool one_has_metadata = false, one_not_seed = false;
bool needsPause = false, needsStart = false, needsForce = false, needsPreview = false;
bool allSameSuperSeeding = true;
bool superSeedingMode = false;
bool allSameSequentialDownloadMode = true, allSamePrioFirstlast = true;
bool sequentialDownloadMode = false, prioritizeFirstLast = false;
bool oneHasMetadata = false, oneNotSeed = false;
bool allSameCategory = true;
bool allSameAutoTMM = true;
bool firstAutoTMM = false;
@ -960,57 +960,57 @@ void TransferListWidget::displayListMenu(const QPoint&) @@ -960,57 +960,57 @@ void TransferListWidget::displayListMenu(const QPoint&)
allSameAutoTMM = false;
if (torrent->hasMetadata())
one_has_metadata = true;
oneHasMetadata = true;
if (!torrent->isSeed()) {
one_not_seed = true;
oneNotSeed = true;
if (torrent->hasMetadata()) {
if (first) {
sequential_download_mode = torrent->isSequentialDownload();
prioritize_first_last = torrent->hasFirstLastPiecePriority();
sequentialDownloadMode = torrent->isSequentialDownload();
prioritizeFirstLast = torrent->hasFirstLastPiecePriority();
}
else {
if (sequential_download_mode != torrent->isSequentialDownload())
all_same_sequential_download_mode = false;
if (prioritize_first_last != torrent->hasFirstLastPiecePriority())
all_same_prio_firstlast = false;
if (sequentialDownloadMode != torrent->isSequentialDownload())
allSameSequentialDownloadMode = false;
if (prioritizeFirstLast != torrent->hasFirstLastPiecePriority())
allSamePrioFirstlast = false;
}
}
}
else {
if (!one_not_seed && all_same_super_seeding && torrent->hasMetadata()) {
if (!oneNotSeed && allSameSuperSeeding && torrent->hasMetadata()) {
if (first) {
super_seeding_mode = torrent->superSeeding();
superSeedingMode = torrent->superSeeding();
}
else if (super_seeding_mode != torrent->superSeeding())
all_same_super_seeding = false;
else if (superSeedingMode != torrent->superSeeding())
allSameSuperSeeding = false;
}
}
if (!torrent->isForced())
needs_force = true;
needsForce = true;
else
needs_start = true;
needsStart = true;
if (torrent->isPaused())
needs_start = true;
needsStart = true;
else
needs_pause = true;
needsPause = true;
if (torrent->hasMetadata())
needs_preview = true;
needsPreview = true;
first = false;
if (one_has_metadata && one_not_seed && !all_same_sequential_download_mode
&& !all_same_prio_firstlast && !all_same_super_seeding && !allSameCategory
&& needs_start && needs_force && needs_pause && needs_preview && !allSameAutoTMM) {
if (oneHasMetadata && oneNotSeed && !allSameSequentialDownloadMode
&& !allSamePrioFirstlast && !allSameSuperSeeding && !allSameCategory
&& needsStart && needsForce && needsPause && needsPreview && !allSameAutoTMM) {
break;
}
}
QMenu listMenu(this);
if (needs_start)
if (needsStart)
listMenu.addAction(&actionStart);
if (needs_pause)
if (needsPause)
listMenu.addAction(&actionPause);
if (needs_force)
if (needsForce)
listMenu.addAction(&actionForceStart);
listMenu.addSeparator();
listMenu.addAction(&actionDelete);
@ -1068,42 +1068,42 @@ void TransferListWidget::displayListMenu(const QPoint&) @@ -1068,42 +1068,42 @@ void TransferListWidget::displayListMenu(const QPoint&)
}
listMenu.addSeparator();
if (one_not_seed)
listMenu.addAction(&actionSet_download_limit);
listMenu.addAction(&actionSet_upload_limit);
listMenu.addAction(&actionSet_max_ratio);
if (!one_not_seed && all_same_super_seeding && one_has_metadata) {
actionSuper_seeding_mode.setChecked(super_seeding_mode);
listMenu.addAction(&actionSuper_seeding_mode);
if (oneNotSeed)
listMenu.addAction(&actionSetDownloadLimit);
listMenu.addAction(&actionSetUploadLimit);
listMenu.addAction(&actionSetMaxRatio);
if (!oneNotSeed && allSameSuperSeeding && oneHasMetadata) {
actionSuperSeedingMode.setChecked(superSeedingMode);
listMenu.addAction(&actionSuperSeedingMode);
}
listMenu.addSeparator();
bool added_preview_action = false;
if (needs_preview) {
listMenu.addAction(&actionPreview_file);
added_preview_action = true;
bool addedPreviewAction = false;
if (needsPreview) {
listMenu.addAction(&actionPreviewFile);
addedPreviewAction = true;
}
if (one_not_seed && one_has_metadata) {
if (all_same_sequential_download_mode) {
actionSequential_download.setChecked(sequential_download_mode);
listMenu.addAction(&actionSequential_download);
added_preview_action = true;
if (oneNotSeed && oneHasMetadata) {
if (allSameSequentialDownloadMode) {
actionSequentialDownload.setChecked(sequentialDownloadMode);
listMenu.addAction(&actionSequentialDownload);
addedPreviewAction = true;
}
if (all_same_prio_firstlast) {
actionFirstLastPiece_prio.setChecked(prioritize_first_last);
listMenu.addAction(&actionFirstLastPiece_prio);
added_preview_action = true;
if (allSamePrioFirstlast) {
actionFirstLastPiecePrio.setChecked(prioritizeFirstLast);
listMenu.addAction(&actionFirstLastPiecePrio);
addedPreviewAction = true;
}
}
if (added_preview_action)
if (addedPreviewAction)
listMenu.addSeparator();
if (one_has_metadata) {
listMenu.addAction(&actionForce_recheck);
listMenu.addAction(&actionForce_reannounce);
if (oneHasMetadata) {
listMenu.addAction(&actionForceRecheck);
listMenu.addAction(&actionForceReannounce);
listMenu.addSeparator();
}
listMenu.addAction(&actionOpen_destination_folder);
if (BitTorrent::Session::instance()->isQueueingSystemEnabled() && one_not_seed) {
listMenu.addAction(&actionOpenDestinationFolder);
if (BitTorrent::Session::instance()->isQueueingSystemEnabled() && oneNotSeed) {
listMenu.addSeparator();
QMenu *prioMenu = listMenu.addMenu(tr("Priority"));
prioMenu->addAction(&actionTopPriority);
@ -1112,9 +1112,9 @@ void TransferListWidget::displayListMenu(const QPoint&) @@ -1112,9 +1112,9 @@ void TransferListWidget::displayListMenu(const QPoint&)
prioMenu->addAction(&actionBottomPriority);
}
listMenu.addSeparator();
listMenu.addAction(&actionCopy_name);
listMenu.addAction(&actionCopyName);
listMenu.addAction(&actionCopyHash);
listMenu.addAction(&actionCopy_magnet_link);
listMenu.addAction(&actionCopyMagnetLink);
// Call menu
QAction *act = nullptr;
act = listMenu.exec(QCursor::pos());
@ -1195,7 +1195,7 @@ void TransferListWidget::applyStatusFilter(int f) @@ -1195,7 +1195,7 @@ void TransferListWidget::applyStatusFilter(int f)
{
m_sortFilterModel->setStatusFilter(static_cast<TorrentFilter::Type>(f));
// Select first item if nothing is selected
if (selectionModel()->selectedRows(0).empty() && m_sortFilterModel->rowCount() > 0) {
if (selectionModel()->selectedRows(0).empty() && (m_sortFilterModel->rowCount() > 0)) {
qDebug("Nothing is selected, selecting first row: %s", qUtf8Printable(m_sortFilterModel->index(0, TorrentModel::TR_NAME).data().toString()));
selectionModel()->setCurrentIndex(m_sortFilterModel->index(0, TorrentModel::TR_NAME), QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
}

16
src/gui/transferlistwidget.h

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2006 Christophe Dumez
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -24,8 +24,6 @@ @@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#ifndef TRANSFERLISTWIDGET_H
@ -39,17 +37,15 @@ namespace BitTorrent @@ -39,17 +37,15 @@ namespace BitTorrent
class TorrentHandle;
}
class QShortcut;
class QSortFilterProxyModel;
class QStandardItemModel;
class MainWindow;
class TransferListDelegate;
class TransferListSortModel;
class TorrentModel;
QT_BEGIN_NAMESPACE
class QShortcut;
class QSortFilterProxyModel;
class QStandardItemModel;
QT_END_NAMESPACE
class TransferListWidget : public QTreeView
{
Q_OBJECT

2
src/gui/updownratiodlg.h

@ -51,7 +51,7 @@ public: @@ -51,7 +51,7 @@ public:
int seedingTime() const;
public slots:
void accept();
void accept() override;
private slots:
void handleRatioTypeChanged();

2
src/gui/utils.cpp

@ -60,7 +60,7 @@ qreal Utils::Gui::screenScalingFactor(const QWidget *widget) @@ -60,7 +60,7 @@ qreal Utils::Gui::screenScalingFactor(const QWidget *widget)
#else
return widget->devicePixelRatio();
#endif
#endif
#endif // Q_OS_WIN
}
QPixmap Utils::Gui::scaledPixmap(const QString &path, const QWidget *widget, const int height)

2
src/webui/api/torrentscontroller.cpp

@ -49,8 +49,8 @@ @@ -49,8 +49,8 @@
#include "base/torrentfilter.h"
#include "base/utils/fs.h"
#include "base/utils/string.h"
#include "serialize/serialize_torrent.h"
#include "apierror.h"
#include "serialize/serialize_torrent.h"
// Tracker keys
const char KEY_TRACKER_URL[] = "url";

Loading…
Cancel
Save