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. 2
      src/base/bittorrent/torrenthandle.cpp
  4. 2
      src/base/scanfoldersmodel.cpp
  5. 15
      src/gui/about_imp.h
  6. 8
      src/gui/addnewtorrentdialog.cpp
  7. 18
      src/gui/advancedsettings.cpp
  8. 2
      src/gui/advancedsettings.h
  9. 4
      src/gui/autoexpandabledialog.h
  10. 2
      src/gui/categoryfiltermodel.cpp
  11. 2
      src/gui/categoryfiltermodel.h
  12. 2
      src/gui/categoryfilterproxymodel.h
  13. 2
      src/gui/categoryfilterwidget.h
  14. 85
      src/gui/deletionconfirmationdlg.h
  15. 2
      src/gui/downloadfromurldialog.h
  16. 38
      src/gui/executionlog.cpp
  17. 16
      src/gui/executionlog.h
  18. 8
      src/gui/fspathedit.h
  19. 6
      src/gui/fspathedit_p.h
  20. 8
      src/gui/hidabletabwidget.h
  21. 4
      src/gui/loglistwidget.cpp
  22. 13
      src/gui/loglistwidget.h
  23. 36
      src/gui/mainwindow.cpp
  24. 10
      src/gui/mainwindow.h
  25. 48
      src/gui/messageboxraised.cpp
  26. 29
      src/gui/messageboxraised.h
  27. 39
      src/gui/optionsdlg.cpp
  28. 12
      src/gui/optionsdlg.h
  29. 5
      src/gui/previewlistdelegate.h
  30. 2
      src/gui/programupdater.cpp
  31. 8
      src/gui/programupdater.h
  32. 2
      src/gui/properties/downloadedpiecesbar.cpp
  33. 2
      src/gui/properties/peerlistsortmodel.h
  34. 10
      src/gui/properties/peerlistwidget.cpp
  35. 10
      src/gui/properties/peersadditiondlg.cpp
  36. 2
      src/gui/properties/pieceavailabilitybar.cpp
  37. 2
      src/gui/properties/piecesbar.cpp
  38. 16
      src/gui/properties/propertieswidget.cpp
  39. 4
      src/gui/properties/speedplotview.cpp
  40. 2
      src/gui/properties/speedwidget.h
  41. 2
      src/gui/properties/trackerlist.cpp
  42. 10
      src/gui/properties/trackersadditiondlg.cpp
  43. 18
      src/gui/scanfoldersdelegate.cpp
  44. 19
      src/gui/scanfoldersdelegate.h
  45. 4
      src/gui/shutdownconfirmdlg.cpp
  46. 20
      src/gui/speedlimitdlg.cpp
  47. 4
      src/gui/speedlimitdlg.h
  48. 2
      src/gui/statsdialog.h
  49. 2
      src/gui/statusbar.h
  50. 4
      src/gui/tagfiltermodel.cpp
  51. 2
      src/gui/tagfiltermodel.h
  52. 2
      src/gui/tagfilterproxymodel.h
  53. 2
      src/gui/tagfilterwidget.h
  54. 8
      src/gui/torrentcontentfiltermodel.h
  55. 65
      src/gui/torrentcontentmodel.cpp
  56. 24
      src/gui/torrentcontentmodel.h
  57. 6
      src/gui/torrentcontentmodelfile.cpp
  58. 8
      src/gui/torrentcontentmodelfile.h
  59. 8
      src/gui/torrentcontentmodelfolder.cpp
  60. 20
      src/gui/torrentcontentmodelfolder.h
  61. 13
      src/gui/torrentcontentmodelitem.cpp
  62. 6
      src/gui/torrentcontentmodelitem.h
  63. 4
      src/gui/torrentcontenttreeview.h
  64. 4
      src/gui/torrentcreatordlg.h
  65. 9
      src/gui/torrentmodel.cpp
  66. 14
      src/gui/torrentmodel.h
  67. 6
      src/gui/trackerlogin.cpp
  68. 8
      src/gui/trackerlogin.h
  69. 195
      src/gui/transferlistdelegate.cpp
  70. 18
      src/gui/transferlistdelegate.h
  71. 22
      src/gui/transferlistfilterswidget.cpp
  72. 41
      src/gui/transferlistfilterswidget.h
  73. 180
      src/gui/transferlistsortmodel.cpp
  74. 12
      src/gui/transferlistsortmodel.h
  75. 196
      src/gui/transferlistwidget.cpp
  76. 22
      src/gui/transferlistwidget.h
  77. 2
      src/gui/updownratiodlg.h
  78. 2
      src/gui/utils.cpp
  79. 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)

2
src/base/bittorrent/torrenthandle.cpp

@ -1831,7 +1831,7 @@ void TorrentHandle::manageIncompleteFiles() @@ -1831,7 +1831,7 @@ void TorrentHandle::manageIncompleteFiles()
{
const bool isAppendExtensionEnabled = m_session->isAppendExtensionEnabled();
QVector<qreal> fp = filesProgress();
if( fp.size() != filesCount() ) {
if (fp.size() != filesCount()) {
qDebug() << "skip manageIncompleteFiles because of invalid torrent meta-data or empty file-progress";
return;
}

2
src/base/scanfoldersmodel.cpp

@ -388,7 +388,7 @@ void ScanFoldersModel::addTorrentsToSession(const QStringList &pathList) @@ -388,7 +388,7 @@ void ScanFoldersModel::addTorrentsToSession(const QStringList &pathList)
QString ScanFoldersModel::pathTypeDisplayName(const PathType type)
{
switch(type) {
switch (type) {
case DOWNLOAD_IN_WATCH_FOLDER:
return tr("Monitored folder");
case DEFAULT_LOCATION:

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);
}

18
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"
@ -137,7 +137,7 @@ AdvancedSettings::AdvancedSettings(QWidget *parent) @@ -137,7 +137,7 @@ AdvancedSettings::AdvancedSettings(QWidget *parent)
void AdvancedSettings::saveAdvancedSettings()
{
Preferences* const pref = Preferences::instance();
Preferences *const pref = Preferences::instance();
BitTorrent::Session *const session = BitTorrent::Session::instance();
// Disk write cache
@ -201,7 +201,7 @@ void AdvancedSettings::saveAdvancedSettings() @@ -201,7 +201,7 @@ void AdvancedSettings::saveAdvancedSettings()
session->setAnnounceIP(addr.isNull() ? "" : addr.toString());
// Program notification
MainWindow * const mainWindow = static_cast<Application*>(QCoreApplication::instance())->mainWindow();
MainWindow *const mainWindow = static_cast<Application*>(QCoreApplication::instance())->mainWindow();
mainWindow->setNotificationsEnabled(cb_program_notifications.isChecked());
mainWindow->setTorrentAddedNotificationsEnabled(cb_torrent_added_notifications.isChecked());
// Misc GUI properties
@ -247,16 +247,16 @@ void AdvancedSettings::updateInterfaceAddressCombo() @@ -247,16 +247,16 @@ void AdvancedSettings::updateInterfaceAddressCombo()
const QString ifaceName = combo_iface.itemData(combo_iface.currentIndex()).toString(); // Empty string for the first element
const QString currentAddress = BitTorrent::Session::instance()->networkInterfaceAddress();
//Clear all items and reinsert them, default to all
// Clear all items and reinsert them, default to all
combo_iface_address.clear();
combo_iface_address.addItem(tr("All addresses"));
combo_iface_address.setCurrentIndex(0);
auto populateCombo = [this, &currentAddress](const QString &ip, const QAbstractSocket::NetworkLayerProtocol &protocol)
{
Q_ASSERT(protocol == QAbstractSocket::IPv4Protocol || protocol == QAbstractSocket::IPv6Protocol);
//Only take ipv4 for now?
if (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))
return;
combo_iface_address.addItem(ip);
//Try to select the last added one
@ -280,7 +280,7 @@ void AdvancedSettings::updateInterfaceAddressCombo() @@ -280,7 +280,7 @@ void AdvancedSettings::updateInterfaceAddressCombo()
void AdvancedSettings::loadAdvancedSettings()
{
const Preferences* const pref = Preferences::instance();
const Preferences *const pref = Preferences::instance();
const BitTorrent::Session *const session = BitTorrent::Session::instance();
// add section headers
@ -483,7 +483,7 @@ void AdvancedSettings::loadAdvancedSettings() @@ -483,7 +483,7 @@ void AdvancedSettings::loadAdvancedSettings()
}
template <typename T>
void AdvancedSettings::addRow(int row, const QString &rowText, T* widget)
void AdvancedSettings::addRow(int row, const QString &rowText, T *widget)
{
setItem(row, PROPERTY, new QTableWidgetItem(rowText));
setCellWidget(row, VALUE, widget);

2
src/gui/advancedsettings.h

@ -36,7 +36,7 @@ @@ -36,7 +36,7 @@
#include <QSpinBox>
#include <QTableWidget>
class AdvancedSettings: public QTableWidget
class AdvancedSettings : public QTableWidget
{
Q_OBJECT

4
src/gui/autoexpandabledialog.h

@ -38,7 +38,7 @@ namespace Ui @@ -38,7 +38,7 @@ namespace Ui
class AutoExpandableDialog;
}
class AutoExpandableDialog: public QDialog
class AutoExpandableDialog : public QDialog
{
Q_OBJECT
@ -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

2
src/gui/categoryfiltermodel.h

@ -40,7 +40,7 @@ namespace BitTorrent @@ -40,7 +40,7 @@ namespace BitTorrent
class CategoryModelItem;
class CategoryFilterModel: public QAbstractItemModel
class CategoryFilterModel : public QAbstractItemModel
{
Q_OBJECT

2
src/gui/categoryfilterproxymodel.h

@ -32,7 +32,7 @@ @@ -32,7 +32,7 @@
#include <QSortFilterProxyModel>
#include <QString>
class CategoryFilterProxyModel: public QSortFilterProxyModel
class CategoryFilterProxyModel : public QSortFilterProxyModel
{
public:
explicit CategoryFilterProxyModel(QObject *parent = nullptr);

2
src/gui/categoryfilterwidget.h

@ -28,7 +28,7 @@ @@ -28,7 +28,7 @@
#include <QTreeView>
class CategoryFilterWidget: public QTreeView
class CategoryFilterWidget : public QTreeView
{
Q_OBJECT
Q_DISABLE_COPY(CategoryFilterWidget)

85
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,52 +39,59 @@ @@ -41,52 +39,59 @@
#include "ui_confirmdeletiondlg.h"
#include "utils.h"
class DeletionConfirmationDlg : public QDialog, private Ui::confirmDeletionDlg {
Q_OBJECT
class DeletionConfirmationDlg : public QDialog, private Ui::confirmDeletionDlg
{
Q_OBJECT
public:
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()));
else
label->setText(tr("Are you sure you want to delete these %1 torrents from the transfer list?", "Are you sure you want to delete these 5 torrents from the transfer list?").arg(QString::number(size)));
// Icons
const QSize iconSize = Utils::Gui::largeIconSize();
lbl_warn->setPixmap(GuiIconProvider::instance()->getIcon("dialog-warning").pixmap(iconSize));
lbl_warn->setFixedWidth(iconSize.width());
rememberBtn->setIcon(GuiIconProvider::instance()->getIcon("object-locked"));
rememberBtn->setIconSize(Utils::Gui::mediumIconSize());
public:
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()));
else
label->setText(tr("Are you sure you want to delete these %1 torrents from the transfer list?", "Are you sure you want to delete these 5 torrents from the transfer list?").arg(QString::number(size)));
// Icons
const QSize iconSize = Utils::Gui::largeIconSize();
lbl_warn->setPixmap(GuiIconProvider::instance()->getIcon("dialog-warning").pixmap(iconSize));
lbl_warn->setFixedWidth(iconSize.width());
rememberBtn->setIcon(GuiIconProvider::instance()->getIcon("object-locked"));
rememberBtn->setIconSize(Utils::Gui::mediumIconSize());
checkPermDelete->setChecked(defaultDeleteFiles || Preferences::instance()->deleteTorrentFilesAsDefault());
connect(checkPermDelete, &QCheckBox::clicked, this, &DeletionConfirmationDlg::updateRememberButtonState);
buttonBox->button(QDialogButtonBox::Cancel)->setFocus();
checkPermDelete->setChecked(defaultDeleteFiles || Preferences::instance()->deleteTorrentFilesAsDefault());
connect(checkPermDelete, &QCheckBox::clicked, this, &DeletionConfirmationDlg::updateRememberButtonState);
buttonBox->button(QDialogButtonBox::Cancel)->setFocus();
Utils::Gui::resize(this);
}
Utils::Gui::resize(this);
}
bool shouldDeleteLocalFiles() const {
return checkPermDelete->isChecked();
}
bool shouldDeleteLocalFiles() const
{
return checkPermDelete->isChecked();
}
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();
return true;
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();
return true;
}
return false;
}
return false;
}
private slots:
void updateRememberButtonState() {
rememberBtn->setEnabled(checkPermDelete->isChecked() != Preferences::instance()->deleteTorrentFilesAsDefault());
}
void updateRememberButtonState()
{
rememberBtn->setEnabled(checkPermDelete->isChecked() != Preferences::instance()->deleteTorrentFilesAsDefault());
}
void on_rememberBtn_clicked() {
Preferences::instance()->setDeleteTorrentFilesAsDefault(checkPermDelete->isChecked());
rememberBtn->setEnabled(false);
}
void on_rememberBtn_clicked()
{
Preferences::instance()->setDeleteTorrentFilesAsDefault(checkPermDelete->isChecked());
rememberBtn->setEnabled(false);
}
};
#endif // DELETIONCONFIRMATIONDLG_H

2
src/gui/downloadfromurldialog.h

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

38
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,40 +24,40 @@ @@ -24,40 +24,40 @@
* 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())
const Logger *const logger = Logger::instance();
foreach (const Log::Msg &msg, logger->getMessages())
addLogMessage(msg);
foreach (const Log::Peer& peer, logger->getPeers())
foreach (const Log::Peer &peer, logger->getPeers())
addPeerMessage(peer);
connect(logger, &Logger::newLogMessage, this, &ExecutionLog::addLogMessage);
connect(logger, &Logger::newLogPeer, this, &ExecutionLog::addPeerMessage);
@ -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)
@ -99,7 +99,7 @@ void ExecutionLog::addLogMessage(const Log::Msg &msg) @@ -99,7 +99,7 @@ void ExecutionLog::addLogMessage(const Log::Msg &msg)
m_msgList->appendLine(text, msg.type);
}
void ExecutionLog::addPeerMessage(const Log::Peer& peer)
void ExecutionLog::addPeerMessage(const Log::Peer &peer)
{
QString text;
QDateTime time = QDateTime::fromMSecsSinceEpoch(peer.timestamp);

16
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,14 +32,14 @@ @@ -34,14 +32,14 @@
#include <QWidget>
#include "base/logger.h"
QT_BEGIN_NAMESPACE
namespace Ui {
namespace Ui
{
class ExecutionLog;
}
QT_END_NAMESPACE
class LogListWidget;
class ExecutionLog: public QWidget
class ExecutionLog : public QWidget
{
Q_OBJECT
@ -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;

8
src/gui/fspathedit.h

@ -34,16 +34,16 @@ @@ -34,16 +34,16 @@
namespace Private
{
class FileComboEdit;
class FileEditorWithCompletion;
class FileLineEdit;
class FileComboEdit;
}
/*!
* \brief
* Widget for editing strings which are paths in filesystem
*/
class FileSystemPathEdit: public QWidget
class FileSystemPathEdit : public QWidget
{
Q_OBJECT
Q_ENUMS(Mode)
@ -109,7 +109,7 @@ private: @@ -109,7 +109,7 @@ private:
};
/// Widget which uses QLineEdit for path editing
class FileSystemPathLineEdit: public FileSystemPathEdit
class FileSystemPathLineEdit : public FileSystemPathEdit
{
using base = FileSystemPathEdit;
using WidgetType = Private::FileLineEdit;
@ -125,7 +125,7 @@ private: @@ -125,7 +125,7 @@ private:
};
/// Widget which uses QComboBox for path editing
class FileSystemPathComboEdit: public FileSystemPathEdit
class FileSystemPathComboEdit : public FileSystemPathEdit
{
using base = FileSystemPathEdit;
using WidgetType = Private::FileComboEdit;

6
src/gui/fspathedit_p.h

@ -47,7 +47,7 @@ class QStringList; @@ -47,7 +47,7 @@ class QStringList;
namespace Private
{
class FileSystemPathValidator: public QValidator
class FileSystemPathValidator : public QValidator
{
Q_OBJECT
@ -113,7 +113,7 @@ namespace Private @@ -113,7 +113,7 @@ namespace Private
virtual QWidget *widget() = 0;
};
class FileLineEdit: public QLineEdit, public FileEditorWithCompletion
class FileLineEdit : public QLineEdit, public FileEditorWithCompletion
{
Q_OBJECT
Q_DISABLE_COPY(FileLineEdit)
@ -143,7 +143,7 @@ namespace Private @@ -143,7 +143,7 @@ namespace Private
QAction *m_warningAction;
};
class FileComboEdit: public QComboBox, public FileEditorWithCompletion
class FileComboEdit : public QComboBox, public FileEditorWithCompletion
{
Q_OBJECT

8
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>
@ -48,7 +46,7 @@ public: @@ -48,7 +46,7 @@ public:
protected:
#ifdef Q_OS_MAC
void paintEvent(QPaintEvent* event) override
void paintEvent(QPaintEvent *event) override
{
// Hide the pane for macintosh style
if (!style()->inherits("QMacStyle"))

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'));
}

13
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,20 +24,17 @@ @@ -24,20 +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 : 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
class LogListWidget : public QListWidget
{
Q_OBJECT
@ -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;

36
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"
@ -267,7 +265,7 @@ MainWindow::MainWindow(QWidget *parent) @@ -267,7 +265,7 @@ MainWindow::MainWindow(QWidget *parent)
connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackersRemoved, m_transferListFiltersWidget, &TransferListFiltersWidget::removeTrackers);
connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackerlessStateChanged, m_transferListFiltersWidget, &TransferListFiltersWidget::changeTrackerless);
using Func = void (TransferListFiltersWidget::*)(BitTorrent::TorrentHandle * const, const QString &);
using Func = void (TransferListFiltersWidget::*)(BitTorrent::TorrentHandle *const, const QString &);
connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackerSuccess, m_transferListFiltersWidget, static_cast<Func>(&TransferListFiltersWidget::trackerSuccess));
connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackerError, m_transferListFiltersWidget, static_cast<Func>(&TransferListFiltersWidget::trackerError));
connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackerWarning, m_transferListFiltersWidget, static_cast<Func>(&TransferListFiltersWidget::trackerWarning));
@ -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

10
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;
@ -70,7 +68,7 @@ namespace Ui @@ -70,7 +68,7 @@ namespace Ui
class MainWindow;
}
class MainWindow: public QMainWindow
class MainWindow : public QMainWindow
{
Q_OBJECT
@ -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;

48
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,40 +24,46 @@ @@ -24,40 +24,46 @@
* 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) {
MessageBoxRaised dlg(icon, title, text, buttons, parent);
dlg.setDefaultButton(defaultButton);
return static_cast<QMessageBox::StandardButton>(dlg.exec());
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) {
return impl(Critical, parent, title, text, buttons, 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) {
return impl(Information, parent, title, text, buttons, 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) {
return impl(Question, parent, title, text, buttons, 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) {
return impl(Warning, parent, title, text, buttons, 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) {
QMessageBox::showEvent(event);
activateWindow();
raise();
void MessageBoxRaised::showEvent(QShowEvent *event)
{
QMessageBox::showEvent(event);
activateWindow();
raise();
}

29
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,23 +35,22 @@ class MessageBoxRaised : public QMessageBox @@ -37,23 +35,22 @@ 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);
static QMessageBox::StandardButton question(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons = QMessageBox::Ok, QMessageBox::StandardButton defaultButton = QMessageBox::NoButton);
static QMessageBox::StandardButton warning(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons = QMessageBox::Ok, QMessageBox::StandardButton defaultButton = QMessageBox::NoButton);
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);
static QMessageBox::StandardButton question(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons = QMessageBox::Ok, QMessageBox::StandardButton defaultButton = QMessageBox::NoButton);
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:
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);
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);
};
#endif // MESSAGEBOXRAISED_H

39
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);
@ -514,7 +512,7 @@ void OptionsDialog::loadSplitterState() @@ -514,7 +512,7 @@ void OptionsDialog::loadSplitterState()
void OptionsDialog::saveWindowState() const
{
Preferences* const pref = Preferences::instance();
Preferences *const pref = Preferences::instance();
// window size
pref->setPrefSize(size());
@ -529,7 +527,7 @@ void OptionsDialog::saveWindowState() const @@ -529,7 +527,7 @@ void OptionsDialog::saveWindowState() const
void OptionsDialog::saveOptions()
{
applyButton->setEnabled(false);
Preferences* const pref = Preferences::instance();
Preferences *const pref = Preferences::instance();
// Load the translation
QString locale = getLocale();
if (pref->getLocale() != locale) {
@ -576,7 +574,7 @@ void OptionsDialog::saveOptions() @@ -576,7 +574,7 @@ void OptionsDialog::saveOptions()
m_ui->checkAssociateMagnetLinks->setEnabled(!m_ui->checkAssociateMagnetLinks->isChecked());
}
#endif
Application * const app = static_cast<Application*>(QCoreApplication::instance());
Application *const app = static_cast<Application*>(QCoreApplication::instance());
app->setFileLoggerPath(m_ui->textFileLogPath->selectedPath());
app->setFileLoggerBackup(m_ui->checkFileLogBackup->isChecked());
app->setFileLoggerMaxSize(m_ui->spinFileLogSize->value() * 1024);
@ -652,7 +650,7 @@ void OptionsDialog::saveOptions() @@ -652,7 +650,7 @@ void OptionsDialog::saveOptions()
pref->setSchedulerDays(static_cast<SchedulerDays>(m_ui->schedule_days->currentIndex()));
session->setBandwidthSchedulerEnabled(m_ui->check_schedule->isChecked());
auto proxyConfigManager = Net::ProxyConfigurationManager::instance();
auto proxyConfigManager = Net::ProxyConfigurationManager::instance();
Net::ProxyConfiguration proxyConf;
proxyConf.type = getProxyType();
proxyConf.ip = getProxyIp();
@ -769,7 +767,7 @@ void OptionsDialog::loadOptions() @@ -769,7 +767,7 @@ void OptionsDialog::loadOptions()
QString strValue;
bool fileLogBackup = true;
bool fileLogDelete = true;
const Preferences* const pref = Preferences::instance();
const Preferences *const pref = Preferences::instance();
// General preferences
setLocale(pref->getLocale());
@ -807,7 +805,7 @@ void OptionsDialog::loadOptions() @@ -807,7 +805,7 @@ void OptionsDialog::loadOptions()
m_ui->checkAssociateMagnetLinks->setEnabled(!m_ui->checkAssociateMagnetLinks->isChecked());
#endif
const Application * const app = static_cast<Application*>(QCoreApplication::instance());
const Application *const app = static_cast<Application*>(QCoreApplication::instance());
m_ui->checkFileLog->setChecked(app->isFileLoggerEnabled());
m_ui->textFileLogPath->setSelectedPath(app->fileLoggerPath());
fileLogBackup = app->isFileLoggerBackup();
@ -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
@ -1307,7 +1305,7 @@ void OptionsDialog::on_buttonBox_accepted() @@ -1307,7 +1305,7 @@ void OptionsDialog::on_buttonBox_accepted()
accept();
}
void OptionsDialog::applySettings(QAbstractButton* button)
void OptionsDialog::applySettings(QAbstractButton *button)
{
if (button == applyButton) {
if (!schedTimesOk()) {
@ -1524,7 +1522,7 @@ int OptionsDialog::getActionOnDblClOnTorrentFn() const @@ -1524,7 +1522,7 @@ int OptionsDialog::getActionOnDblClOnTorrentFn() const
void OptionsDialog::on_addScanFolderButton_clicked()
{
Preferences* const pref = Preferences::instance();
Preferences *const pref = Preferences::instance();
const QString dir = QFileDialog::getExistingDirectory(this, tr("Select folder to monitor"),
Utils::Fs::toNativePath(Utils::Fs::folderName(pref->getScanDirsLastPath())));
if (!dir.isEmpty()) {
@ -1572,7 +1570,7 @@ void OptionsDialog::handleScanFolderViewSelectionChanged() @@ -1572,7 +1570,7 @@ void OptionsDialog::handleScanFolderViewSelectionChanged()
m_ui->removeScanFolderButton->setEnabled(!m_ui->scanFoldersView->selectionModel()->selectedIndexes().isEmpty());
}
QString OptionsDialog::askForExportDir(const QString& currentExportPath)
QString OptionsDialog::askForExportDir(const QString &currentExportPath)
{
QDir currentExportDir(Utils::Fs::expandPathAbs(currentExportPath));
QString dir;
@ -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;
}
}
}

12
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
@ -57,7 +55,7 @@ namespace Ui @@ -57,7 +55,7 @@ namespace Ui
class OptionsDialog;
}
class OptionsDialog: public QDialog
class OptionsDialog : public QDialog
{
Q_OBJECT
using ThisType = OptionsDialog;
@ -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

8
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
@ -34,7 +32,7 @@ @@ -34,7 +32,7 @@
#include <QObject>
#include <QUrl>
class ProgramUpdater: public QObject
class ProgramUpdater : public QObject
{
Q_OBJECT

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;

2
src/gui/properties/peerlistsortmodel.h

@ -54,7 +54,7 @@ protected: @@ -54,7 +54,7 @@ protected:
const QString strR = right.data().toString();
const int result = Utils::String::naturalCompare(strL, strR, Qt::CaseInsensitive);
return (result < 0);
}
}
break;
default:
return QSortFilterProxyModel::lessThan(left, right);

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'));
}

10
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;
}
}
@ -125,7 +125,7 @@ void TrackersAdditionDlg::parseUTorrentList(const QString &, const QString &path @@ -125,7 +125,7 @@ void TrackersAdditionDlg::parseUTorrentList(const QString &, const QString &path
void TrackersAdditionDlg::getTrackerError(const QString &, const QString &error)
{
//To restore the cursor ...
// To restore the cursor ...
setCursor(Qt::ArrowCursor);
m_ui->uTorrentListButton->setEnabled(true);
QMessageBox::warning(this, tr("Download error"), tr("The trackers list could not be downloaded, reason: %1").arg(error), QMessageBox::Ok);

18
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)
@ -60,7 +58,7 @@ QWidget *ScanFoldersDelegate::createEditor(QWidget *parent, const QStyleOptionVi @@ -60,7 +58,7 @@ QWidget *ScanFoldersDelegate::createEditor(QWidget *parent, const QStyleOptionVi
{
if (index.column() != ScanFoldersModel::DOWNLOAD) return 0;
QComboBox* editor = new QComboBox(parent);
QComboBox *editor = new QComboBox(parent);
editor->setFocusPolicy(Qt::StrongFocus);
editor->addItem(ScanFoldersModel::pathTypeDisplayName(ScanFoldersModel::DOWNLOAD_IN_WATCH_FOLDER));

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/statsdialog.h

@ -36,7 +36,7 @@ namespace Ui @@ -36,7 +36,7 @@ namespace Ui
class StatsDialog;
}
class StatsDialog: public QDialog
class StatsDialog : public QDialog
{
Q_OBJECT

2
src/gui/statusbar.h

@ -39,7 +39,7 @@ namespace BitTorrent @@ -39,7 +39,7 @@ namespace BitTorrent
struct SessionStatus;
}
class StatusBar: public QStatusBar
class StatusBar : public QStatusBar
{
Q_OBJECT
Q_DISABLE_COPY(StatusBar)

4
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();
@ -214,7 +214,7 @@ void TagFilterModel::torrentTagAdded(BitTorrent::TorrentHandle *const torrent, c @@ -214,7 +214,7 @@ void TagFilterModel::torrentTagAdded(BitTorrent::TorrentHandle *const torrent, c
emit dataChanged(i, i);
}
void TagFilterModel::torrentTagRemoved(BitTorrent::TorrentHandle* const torrent, const QString &tag)
void TagFilterModel::torrentTagRemoved(BitTorrent::TorrentHandle *const torrent, const QString &tag)
{
Q_ASSERT(torrent->tags().count() >= 0);
if (torrent->tags().count() == 0)

2
src/gui/tagfiltermodel.h

@ -42,7 +42,7 @@ namespace BitTorrent @@ -42,7 +42,7 @@ namespace BitTorrent
class TagModelItem;
class TagFilterModel: public QAbstractListModel
class TagFilterModel : public QAbstractListModel
{
Q_OBJECT

2
src/gui/tagfilterproxymodel.h

@ -32,7 +32,7 @@ @@ -32,7 +32,7 @@
#include <QSortFilterProxyModel>
#include <QString>
class TagFilterProxyModel: public QSortFilterProxyModel
class TagFilterProxyModel : public QSortFilterProxyModel
{
public:
explicit TagFilterProxyModel(QObject *parent = nullptr);

2
src/gui/tagfilterwidget.h

@ -31,7 +31,7 @@ @@ -31,7 +31,7 @@
#include <QTreeView>
class TagFilterWidget: public QTreeView
class TagFilterWidget : public QTreeView
{
Q_OBJECT

8
src/gui/torrentcontentfiltermodel.h

@ -35,7 +35,7 @@ @@ -35,7 +35,7 @@
class TorrentContentModel;
class TorrentContentFilterModel: public QSortFilterProxyModel
class TorrentContentFilterModel : public QSortFilterProxyModel
{
Q_OBJECT
@ -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;

65
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
@ -67,7 +66,7 @@ namespace @@ -67,7 +66,7 @@ namespace
return cached;
}
class UnifiedFileIconProvider: public QFileIconProvider
class UnifiedFileIconProvider : public QFileIconProvider
{
public:
using QFileIconProvider::icon;
@ -99,7 +98,7 @@ namespace @@ -99,7 +98,7 @@ namespace
PixmapCacheSetup pixmapCacheSetup;
class CachingFileIconProvider: public UnifiedFileIconProvider
class CachingFileIconProvider : public UnifiedFileIconProvider
{
public:
using QFileIconProvider::icon;
@ -123,11 +122,11 @@ namespace @@ -123,11 +122,11 @@ 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
class WinShellFileIconProvider final: public CachingFileIconProvider
class WinShellFileIconProvider final : public CachingFileIconProvider
{
QPixmap pixmapForExtension(const QString &ext) const override
{
@ -174,7 +173,7 @@ namespace @@ -174,7 +173,7 @@ namespace
return (!testIcon1.isNull() || !testIcon2.isNull());
}
class MimeFileIconProvider: public UnifiedFileIconProvider
class MimeFileIconProvider : public UnifiedFileIconProvider
{
using QFileIconProvider::icon;
@ -197,7 +196,7 @@ namespace @@ -197,7 +196,7 @@ namespace
private:
QMimeDatabase m_db;
};
#endif
#endif // Q_OS_WIN
}
TorrentContentModel::TorrentContentModel(QObject *parent)
@ -266,20 +265,20 @@ QVector<int> TorrentContentModel::getFilePriorities() const @@ -266,20 +265,20 @@ QVector<int> TorrentContentModel::getFilePriorities() const
{
QVector<int> prio;
prio.reserve(m_filesIndex.size());
foreach (const TorrentContentModelFile* file, m_filesIndex)
foreach (const TorrentContentModelFile *file, m_filesIndex)
prio.push_back(file->priority());
return prio;
}
bool TorrentContentModel::allFiltered() const
{
foreach (const TorrentContentModelFile* fileItem, m_filesIndex)
foreach (const TorrentContentModelFile *fileItem, m_filesIndex)
if (fileItem->priority() != prio::IGNORED)
return false;
return true;
}
int TorrentContentModel::columnCount(const QModelIndex& parent) const
int TorrentContentModel::columnCount(const QModelIndex &parent) const
{
if (parent.isValid())
return static_cast<TorrentContentModelItem*>(parent.internalPointer())->columnCount();
@ -287,7 +286,7 @@ int TorrentContentModel::columnCount(const QModelIndex& parent) const @@ -287,7 +286,7 @@ int TorrentContentModel::columnCount(const QModelIndex& parent) const
return m_rootItem->columnCount();
}
bool TorrentContentModel::setData(const QModelIndex& index, const QVariant& value, int role)
bool TorrentContentModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
if (!index.isValid())
return false;
@ -313,7 +312,7 @@ bool TorrentContentModel::setData(const QModelIndex& index, const QVariant& valu @@ -313,7 +312,7 @@ bool TorrentContentModel::setData(const QModelIndex& index, const QVariant& valu
if (role == Qt::EditRole) {
Q_ASSERT(index.isValid());
TorrentContentModelItem* item = static_cast<TorrentContentModelItem*>(index.internalPointer());
TorrentContentModelItem *item = static_cast<TorrentContentModelItem*>(index.internalPointer());
switch (index.column()) {
case TorrentContentModelItem::COL_NAME:
item->setName(value.toString());
@ -331,12 +330,12 @@ bool TorrentContentModel::setData(const QModelIndex& index, const QVariant& valu @@ -331,12 +330,12 @@ bool TorrentContentModel::setData(const QModelIndex& index, const QVariant& valu
return false;
}
TorrentContentModelItem::ItemType TorrentContentModel::itemType(const QModelIndex& index) const
TorrentContentModelItem::ItemType TorrentContentModel::itemType(const QModelIndex &index) const
{
return static_cast<const TorrentContentModelItem*>(index.internalPointer())->itemType();
}
int TorrentContentModel::getFileIndex(const QModelIndex& index)
int TorrentContentModel::getFileIndex(const QModelIndex &index)
{
TorrentContentModelItem *item = static_cast<TorrentContentModelItem*>(index.internalPointer());
if (item->itemType() == TorrentContentModelItem::FileType)
@ -351,7 +350,7 @@ QVariant TorrentContentModel::data(const QModelIndex& index, int role) const @@ -351,7 +350,7 @@ QVariant TorrentContentModel::data(const QModelIndex& index, int role) const
if (!index.isValid())
return QVariant();
TorrentContentModelItem* item = static_cast<TorrentContentModelItem*>(index.internalPointer());
TorrentContentModelItem *item = static_cast<TorrentContentModelItem*>(index.internalPointer());
if ((index.column() == TorrentContentModelItem::COL_NAME) && (role == Qt::DecorationRole)) {
if (item->itemType() == TorrentContentModelItem::FolderType)
@ -374,7 +373,7 @@ QVariant TorrentContentModel::data(const QModelIndex& index, int role) const @@ -374,7 +373,7 @@ QVariant TorrentContentModel::data(const QModelIndex& index, int role) const
return QVariant();
}
Qt::ItemFlags TorrentContentModel::flags(const QModelIndex& index) const
Qt::ItemFlags TorrentContentModel::flags(const QModelIndex &index) const
{
if (!index.isValid())
return 0;
@ -393,7 +392,7 @@ QVariant TorrentContentModel::headerData(int section, Qt::Orientation orientatio @@ -393,7 +392,7 @@ QVariant TorrentContentModel::headerData(int section, Qt::Orientation orientatio
return QVariant();
}
QModelIndex TorrentContentModel::index(int row, int column, const QModelIndex& parent) const
QModelIndex TorrentContentModel::index(int row, int column, const QModelIndex &parent) const
{
if (parent.isValid() && (parent.column() != 0))
return QModelIndex();
@ -401,7 +400,7 @@ QModelIndex TorrentContentModel::index(int row, int column, const QModelIndex& p @@ -401,7 +400,7 @@ QModelIndex TorrentContentModel::index(int row, int column, const QModelIndex& p
if (column >= TorrentContentModelItem::NB_COL)
return QModelIndex();
TorrentContentModelFolder* parentItem;
TorrentContentModelFolder *parentItem;
if (!parent.isValid())
parentItem = m_rootItem;
else
@ -411,18 +410,18 @@ QModelIndex TorrentContentModel::index(int row, int column, const QModelIndex& p @@ -411,18 +410,18 @@ QModelIndex TorrentContentModel::index(int row, int column, const QModelIndex& p
if (row >= parentItem->childCount())
return QModelIndex();
TorrentContentModelItem* childItem = parentItem->child(row);
TorrentContentModelItem *childItem = parentItem->child(row);
if (childItem)
return createIndex(row, column, childItem);
return QModelIndex();
}
QModelIndex TorrentContentModel::parent(const QModelIndex& index) const
QModelIndex TorrentContentModel::parent(const QModelIndex &index) const
{
if (!index.isValid())
return QModelIndex();
TorrentContentModelItem* childItem = static_cast<TorrentContentModelItem*>(index.internalPointer());
TorrentContentModelItem *childItem = static_cast<TorrentContentModelItem*>(index.internalPointer());
if (!childItem)
return QModelIndex();
@ -433,12 +432,12 @@ QModelIndex TorrentContentModel::parent(const QModelIndex& index) const @@ -433,12 +432,12 @@ QModelIndex TorrentContentModel::parent(const QModelIndex& index) const
return createIndex(parentItem->row(), 0, parentItem);
}
int TorrentContentModel::rowCount(const QModelIndex& parent) const
int TorrentContentModel::rowCount(const QModelIndex &parent) const
{
if (parent.column() > 0)
return 0;
TorrentContentModelFolder* parentItem;
TorrentContentModelFolder *parentItem;
if (!parent.isValid())
parentItem = m_rootItem;
else
@ -468,15 +467,15 @@ void TorrentContentModel::setupModelData(const BitTorrent::TorrentInfo &info) @@ -468,15 +467,15 @@ void TorrentContentModel::setupModelData(const BitTorrent::TorrentInfo &info)
qDebug("Torrent contains %d files", filesCount);
m_filesIndex.reserve(filesCount);
TorrentContentModelFolder* currentParent;
TorrentContentModelFolder *currentParent;
// Iterate over files
for (int i = 0; i < filesCount; ++i) {
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) {
foreach (const QString &pathPart, pathFolders) {
if (pathPart == ".unwanted")
continue;
TorrentContentModelFolder* newParent = currentParent->childFolderWithName(pathPart);
@ -487,7 +486,7 @@ void TorrentContentModel::setupModelData(const BitTorrent::TorrentInfo &info) @@ -487,7 +486,7 @@ void TorrentContentModel::setupModelData(const BitTorrent::TorrentInfo &info)
currentParent = newParent;
}
// Actually create the file
TorrentContentModelFile* fileItem = new TorrentContentModelFile(info.fileName(i), info.fileSize(i), currentParent, i);
TorrentContentModelFile *fileItem = new TorrentContentModelFile(info.fileName(i), info.fileSize(i), currentParent, i);
currentParent->appendChild(fileItem);
m_filesIndex.push_back(fileItem);
}

24
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"
@ -42,7 +40,7 @@ @@ -42,7 +40,7 @@
class QFileIconProvider;
class TorrentContentModelFile;
class TorrentContentModel: public QAbstractItemModel
class TorrentContentModel : public QAbstractItemModel
{
Q_OBJECT
@ -56,15 +54,15 @@ public: @@ -56,15 +54,15 @@ public:
QVector<int> getFilePriorities() const;
bool allFiltered() const;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
TorrentContentModelItem::ItemType itemType(const QModelIndex& index) const;
int getFileIndex(const QModelIndex& index);
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
Qt::ItemFlags flags(const QModelIndex& index) const override;
bool setData(const QModelIndex &index, const QVariant& value, int role = Qt::EditRole) override;
TorrentContentModelItem::ItemType itemType(const QModelIndex &index) const;
int getFileIndex(const QModelIndex &index);
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
Qt::ItemFlags flags(const QModelIndex &index) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;
QModelIndex parent(const QModelIndex& index) const override;
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
QModelIndex parent(const QModelIndex &index) const override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
void clear();
void setupModelData(const BitTorrent::TorrentInfo &info);

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"

8
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
@ -33,7 +31,7 @@ @@ -33,7 +31,7 @@
#include "torrentcontentmodelitem.h"
class TorrentContentModelFile: public TorrentContentModelItem
class TorrentContentModelFile : public TorrentContentModelItem
{
public:
TorrentContentModelFile(const QString &fileName, qulonglong fileSize,

8
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"
@ -165,7 +163,7 @@ void TorrentContentModelFolder::recalculateAvailability() @@ -165,7 +163,7 @@ void TorrentContentModelFolder::recalculateAvailability()
qreal tAvailability = 0;
qulonglong tSize = 0;
bool foundAnyData = false;
foreach (TorrentContentModelItem* child, m_childItems) {
foreach (TorrentContentModelItem *child, m_childItems) {
if (child->priority() == prio::IGNORED)
continue;

20
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
@ -33,14 +31,14 @@ @@ -33,14 +31,14 @@
#include "torrentcontentmodelitem.h"
class TorrentContentModelFolder: public TorrentContentModelItem
class TorrentContentModelFolder : public TorrentContentModelItem
{
public:
// Folder constructor
TorrentContentModelFolder(const QString& name, TorrentContentModelFolder* parent);
TorrentContentModelFolder(const QString &name, TorrentContentModelFolder *parent);
// Invisible root item constructor
TorrentContentModelFolder(const QList<QVariant>& data);
TorrentContentModelFolder(const QList<QVariant> &data);
~TorrentContentModelFolder();
@ -54,10 +52,10 @@ public: @@ -54,10 +52,10 @@ public:
void setPriority(int newPriority, bool updateParent = true) override;
void deleteAllChildren();
const QList<TorrentContentModelItem*>& children() const;
void appendChild(TorrentContentModelItem* item);
TorrentContentModelItem* child(int row) const;
TorrentContentModelFolder* childFolderWithName(const QString& name) const;
const QList<TorrentContentModelItem*> &children() const;
void appendChild(TorrentContentModelItem *item);
TorrentContentModelItem *child(int row) const;
TorrentContentModelFolder *childFolderWithName(const QString &name) const;
int childCount() const;
private:

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

4
src/gui/torrentcontenttreeview.h

@ -31,13 +31,13 @@ @@ -31,13 +31,13 @@
#include <QTreeView>
class TorrentContentTreeView: public QTreeView
class TorrentContentTreeView : public QTreeView
{
Q_OBJECT
public:
explicit TorrentContentTreeView(QWidget *parent = nullptr);
void keyPressEvent(QKeyEvent *event);
void keyPressEvent(QKeyEvent *event) override;
private:
QModelIndex currentNameCell();

4
src/gui/torrentcreatordlg.h

@ -44,7 +44,7 @@ namespace BitTorrent @@ -44,7 +44,7 @@ namespace BitTorrent
class TorrentCreatorThread;
}
class TorrentCreatorDlg: public QDialog
class TorrentCreatorDlg : public QDialog
{
Q_OBJECT
@ -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

195
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,35 +24,34 @@ @@ -24,35 +24,34 @@
* 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)
{
}
void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const
void TransferListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
painter->save();
bool isHideState = true;
@ -74,13 +73,13 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem @@ -74,13 +73,13 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem
case TorrentModel::TR_COMPLETED:
case TorrentModel::TR_SIZE:
case TorrentModel::TR_TOTAL_SIZE: {
qlonglong size = index.data().toLongLong();
if (hideValues && !size)
break;
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
QItemDelegate::drawDisplay(painter, opt, option.rect, Utils::Misc::friendlyUnit(size));
qlonglong size = index.data().toLongLong();
if (hideValues && !size)
break;
opt.displayAlignment = (Qt::AlignRight | Qt::AlignVCenter);
QItemDelegate::drawDisplay(painter, opt, option.rect, Utils::Misc::friendlyUnit(size));
}
break;
}
case TorrentModel::TR_ETA: {
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
QItemDelegate::drawDisplay(painter, opt, option.rect, Utils::Misc::userFriendlyDuration(index.data().toLongLong()));
@ -88,124 +87,124 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem @@ -88,124 +87,124 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem
}
case TorrentModel::TR_SEEDS:
case TorrentModel::TR_PEERS: {
qlonglong value = index.data().toLongLong();
qlonglong total = index.data(Qt::UserRole).toLongLong();
if (hideValues && (!value && !total))
break;
QString display = QString::number(value) + " (" + QString::number(total) + ")";
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
QItemDelegate::drawDisplay(painter, opt, opt.rect, display);
qlonglong value = index.data().toLongLong();
qlonglong total = index.data(Qt::UserRole).toLongLong();
if (hideValues && (!value && !total))
break;
QString display = QString::number(value) + " (" + QString::number(total) + ")";
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
QItemDelegate::drawDisplay(painter, opt, opt.rect, display);
}
break;
}
case TorrentModel::TR_STATUS: {
const auto state = index.data().value<BitTorrent::TorrentState>();
QString display = getStatusString(state);
QItemDelegate::drawDisplay(painter, opt, opt.rect, display);
const auto state = index.data().value<BitTorrent::TorrentState>();
QString display = getStatusString(state);
QItemDelegate::drawDisplay(painter, opt, opt.rect, display);
}
break;
}
case TorrentModel::TR_UPSPEED:
case TorrentModel::TR_DLSPEED: {
const qulonglong speed = index.data().toULongLong();
if (hideValues && !speed)
break;
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
QItemDelegate::drawDisplay(painter, opt, opt.rect, Utils::Misc::friendlyUnit(speed, true));
const qulonglong speed = index.data().toULongLong();
if (hideValues && !speed)
break;
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
QItemDelegate::drawDisplay(painter, opt, opt.rect, Utils::Misc::friendlyUnit(speed, true));
}
break;
}
case TorrentModel::TR_UPLIMIT:
case TorrentModel::TR_DLLIMIT: {
const qlonglong limit = index.data().toLongLong();
if (hideValues && !limit)
break;
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
QItemDelegate::drawDisplay(painter, opt, opt.rect, limit > 0 ? Utils::Misc::friendlyUnit(limit, true) : QString::fromUtf8(C_INFINITY));
const qlonglong limit = index.data().toLongLong();
if (hideValues && !limit)
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;
}
case TorrentModel::TR_TIME_ELAPSED: {
const int elapsedTime = index.data().toInt();
const int seedingTime = index.data(Qt::UserRole).toInt();
const QString txt = (seedingTime > 0)
? tr("%1 (seeded for %2)", "e.g. 4m39s (seeded for 3m10s)")
.arg(Utils::Misc::userFriendlyDuration(elapsedTime)
, Utils::Misc::userFriendlyDuration(seedingTime))
: Utils::Misc::userFriendlyDuration(elapsedTime);
QItemDelegate::drawDisplay(painter, opt, opt.rect, txt);
const int elapsedTime = index.data().toInt();
const int seedingTime = index.data(Qt::UserRole).toInt();
const QString txt = (seedingTime > 0)
? tr("%1 (seeded for %2)", "e.g. 4m39s (seeded for 3m10s)")
.arg(Utils::Misc::userFriendlyDuration(elapsedTime)
, Utils::Misc::userFriendlyDuration(seedingTime))
: Utils::Misc::userFriendlyDuration(elapsedTime);
QItemDelegate::drawDisplay(painter, opt, opt.rect, txt);
}
break;
}
case TorrentModel::TR_ADD_DATE:
case TorrentModel::TR_SEED_DATE:
QItemDelegate::drawDisplay(painter, opt, opt.rect, index.data().toDateTime().toLocalTime().toString(Qt::DefaultLocaleShortDate));
break;
case TorrentModel::TR_RATIO_LIMIT:
case TorrentModel::TR_RATIO: {
const qreal ratio = index.data().toDouble();
if (hideValues && (ratio <= 0))
break;
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);
const qreal ratio = index.data().toDouble();
if (hideValues && (ratio <= 0))
break;
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;
}
case TorrentModel::TR_PRIORITY: {
const int priority = index.data().toInt();
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
if (priority > 0) {
QItemDelegate::paint(painter, opt, index);
}
else {
QItemDelegate::drawDisplay(painter, opt, opt.rect, "*");
const int priority = index.data().toInt();
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
if (priority > 0) {
QItemDelegate::paint(painter, opt, index);
}
else {
QItemDelegate::drawDisplay(painter, opt, opt.rect, "*");
}
}
break;
}
case TorrentModel::TR_PROGRESS: {
QStyleOptionProgressBar newopt;
qreal progress = index.data().toDouble() * 100.;
newopt.rect = opt.rect;
newopt.text = ((progress == 100.0) ? QString("100%") : Utils::String::fromDouble(progress, 1) + "%");
newopt.progress = static_cast<int>(progress);
newopt.maximum = 100;
newopt.minimum = 0;
newopt.state |= QStyle::State_Enabled;
newopt.textVisible = true;
QStyleOptionProgressBar newopt;
qreal progress = index.data().toDouble() * 100.;
newopt.rect = opt.rect;
newopt.text = ((progress == 100.0) ? QString("100%") : Utils::String::fromDouble(progress, 1) + "%");
newopt.progress = static_cast<int>(progress);
newopt.maximum = 100;
newopt.minimum = 0;
newopt.state |= QStyle::State_Enabled;
newopt.textVisible = true;
#ifndef Q_OS_WIN
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt, painter);
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt, painter);
#else
// XXX: To avoid having the progress text on the right of the bar
QProxyStyle st("fusion");
st.drawControl(QStyle::CE_ProgressBar, &newopt, painter, 0);
// XXX: To avoid having the progress text on the right of the bar
QProxyStyle st("fusion");
st.drawControl(QStyle::CE_ProgressBar, &newopt, painter, 0);
#endif
}
break;
}
case TorrentModel::TR_LAST_ACTIVITY: {
qlonglong elapsed = index.data().toLongLong();
if (hideValues && ((elapsed < 0) || (elapsed >= MAX_ETA)))
break;
qlonglong elapsed = index.data().toLongLong();
if (hideValues && ((elapsed < 0) || (elapsed >= MAX_ETA)))
break;
// Show '< 1m ago' when elapsed time is 0
if (elapsed == 0)
elapsed = 1;
// Show '< 1m ago' when elapsed time is 0
if (elapsed == 0)
elapsed = 1;
QString elapsedString = (elapsed >= 0)
? tr("%1 ago", "e.g.: 1h 20m ago").arg(Utils::Misc::userFriendlyDuration(elapsed))
: Utils::Misc::userFriendlyDuration(elapsed);
QString elapsedString = (elapsed >= 0)
? tr("%1 ago", "e.g.: 1h 20m ago").arg(Utils::Misc::userFriendlyDuration(elapsed))
: Utils::Misc::userFriendlyDuration(elapsed);
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
QItemDelegate::drawDisplay(painter, opt, option.rect, elapsedString);
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
QItemDelegate::drawDisplay(painter, opt, option.rect, elapsedString);
}
break;
}
default:
QItemDelegate::paint(painter, option, index);
}
painter->restore();
}
QWidget* TransferListDelegate::createEditor(QWidget*, const QStyleOptionViewItem &, const QModelIndex &) const
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
QSize TransferListDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
// Reimplementing sizeHint() because the 'name' column contains text+icon.
// When that WHOLE column goes out of view(eg user scrolls horizontally)

18
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
{
@ -45,15 +41,15 @@ namespace BitTorrent @@ -45,15 +41,15 @@ namespace BitTorrent
}
// Defines for download list list columns
class TransferListDelegate: public QItemDelegate
class TransferListDelegate : public QItemDelegate
{
Q_OBJECT
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;

22
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"
@ -161,7 +159,7 @@ StatusFiltersWidget::StatusFiltersWidget(QWidget *parent, TransferListWidget *tr @@ -161,7 +159,7 @@ StatusFiltersWidget::StatusFiltersWidget(QWidget *parent, TransferListWidget *tr
errored->setData(Qt::DisplayRole, QVariant(tr("Errored (0)")));
errored->setData(Qt::DecorationRole, QIcon(":/icons/skin/error.png"));
const Preferences* const pref = Preferences::instance();
const Preferences *const pref = Preferences::instance();
setCurrentRow(pref->getTransSelFilter(), QItemSelectionModel::SelectCurrent);
toggleFilter(pref->getStatusFilterState());
}
@ -443,7 +441,7 @@ void TrackerFiltersList::handleFavicoDownload(const QString& url, const QString& @@ -443,7 +441,7 @@ void TrackerFiltersList::handleFavicoDownload(const QString& url, const QString&
}
}
void TrackerFiltersList::handleFavicoFailure(const QString& url, const QString& error)
void TrackerFiltersList::handleFavicoFailure(const QString &url, const QString &error)
{
Q_UNUSED(error)
if (url.endsWith(".ico", Qt::CaseInsensitive)) {
@ -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
@ -561,7 +559,7 @@ TransferListFiltersWidget::TransferListFiltersWidget(QWidget *parent, TransferLi @@ -561,7 +559,7 @@ TransferListFiltersWidget::TransferListFiltersWidget(QWidget *parent, TransferLi
, m_transferList(transferList)
, m_trackerFilters(nullptr)
{
Preferences* const pref = Preferences::instance();
Preferences *const pref = Preferences::instance();
// Construct lists
QVBoxLayout *vLayout = new QVBoxLayout(this);
@ -587,7 +585,7 @@ TransferListFiltersWidget::TransferListFiltersWidget(QWidget *parent, TransferLi @@ -587,7 +585,7 @@ TransferListFiltersWidget::TransferListFiltersWidget(QWidget *parent, TransferLi
vLayout->addWidget(scroll);
setLayout(vLayout);
QCheckBox * statusLabel = new QCheckBox(tr("Status"), this);
QCheckBox *statusLabel = new QCheckBox(tr("Status"), this);
statusLabel->setChecked(pref->getStatusFilterState());
statusLabel->setFont(font);
frameLayout->addWidget(statusLabel);

41
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
@ -47,15 +42,15 @@ namespace BitTorrent @@ -47,15 +42,15 @@ namespace BitTorrent
class TrackerEntry;
}
class FiltersBase: public QListWidget
class FiltersBase : public QListWidget
{
Q_OBJECT
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);
@ -70,7 +65,7 @@ private slots: @@ -70,7 +65,7 @@ private slots:
virtual void torrentAboutToBeDeleted(BitTorrent::TorrentHandle *const) = 0;
};
class StatusFiltersWidget: public FiltersBase
class StatusFiltersWidget : public FiltersBase
{
Q_OBJECT
@ -84,13 +79,13 @@ private slots: @@ -84,13 +79,13 @@ 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
class TrackerFiltersList : public FiltersBase
{
Q_OBJECT
@ -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;
@ -138,7 +133,7 @@ private: @@ -138,7 +133,7 @@ private:
class CategoryFilterWidget;
class TagFilterWidget;
class TransferListFiltersWidget: public QFrame
class TransferListFiltersWidget : public QFrame
{
Q_OBJECT

180
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)
@ -89,125 +89,125 @@ bool TransferListSortModel::lessThan(const QModelIndex &left, const QModelIndex @@ -89,125 +89,125 @@ bool TransferListSortModel::lessThan(const QModelIndex &left, const QModelIndex
case TorrentModel::TR_CATEGORY:
case TorrentModel::TR_TAGS:
case TorrentModel::TR_NAME: {
const QVariant vL = left.data();
const QVariant vR = right.data();
if (!vL.isValid() || !vR.isValid() || (vL == vR))
return lowerPositionThan(left, right);
const QVariant vL = left.data();
const QVariant vR = right.data();
if (!vL.isValid() || !vR.isValid() || (vL == vR))
return lowerPositionThan(left, right);
const int result = Utils::String::naturalCompare(vL.toString(), vR.toString(), Qt::CaseInsensitive);
return (result < 0);
}
const int result = Utils::String::naturalCompare(vL.toString(), vR.toString(), Qt::CaseInsensitive);
return (result < 0);
}
case TorrentModel::TR_STATUS: {
// QSortFilterProxyModel::lessThan() uses the < operator only for specific QVariant types
// so our custom type is outside that list.
// In this case QSortFilterProxyModel::lessThan() converts other types to QString and
// sorts them.
// Thus we can't use the code in the default label.
const BitTorrent::TorrentState leftValue = left.data().value<BitTorrent::TorrentState>();
const BitTorrent::TorrentState rightValue = right.data().value<BitTorrent::TorrentState>();
if (leftValue != rightValue)
return leftValue < rightValue;
// QSortFilterProxyModel::lessThan() uses the < operator only for specific QVariant types
// so our custom type is outside that list.
// In this case QSortFilterProxyModel::lessThan() converts other types to QString and
// sorts them.
// Thus we can't use the code in the default label.
const BitTorrent::TorrentState leftValue = left.data().value<BitTorrent::TorrentState>();
const BitTorrent::TorrentState rightValue = right.data().value<BitTorrent::TorrentState>();
if (leftValue != rightValue)
return leftValue < rightValue;
return lowerPositionThan(left, right);
}
return lowerPositionThan(left, right);
}
case TorrentModel::TR_ADD_DATE:
case TorrentModel::TR_SEED_DATE:
case TorrentModel::TR_SEEN_COMPLETE_DATE: {
return dateLessThan(sortColumn(), left, right, true);
}
}
case TorrentModel::TR_PRIORITY: {
return lowerPositionThan(left, right);
}
}
case TorrentModel::TR_SEEDS:
case TorrentModel::TR_PEERS: {
const int leftActive = left.data().toInt();
const int leftTotal = left.data(Qt::UserRole).toInt();
const int rightActive = right.data().toInt();
const int rightTotal = right.data(Qt::UserRole).toInt();
// Active peers/seeds take precedence over total peers/seeds.
if (leftActive != rightActive)
return (leftActive < rightActive);
const int leftActive = left.data().toInt();
const int leftTotal = left.data(Qt::UserRole).toInt();
const int rightActive = right.data().toInt();
const int rightTotal = right.data(Qt::UserRole).toInt();
if (leftTotal != rightTotal)
return (leftTotal < rightTotal);
// Active peers/seeds take precedence over total peers/seeds.
if (leftActive != rightActive)
return (leftActive < rightActive);
return lowerPositionThan(left, right);
}
if (leftTotal != rightTotal)
return (leftTotal < rightTotal);
case TorrentModel::TR_ETA: {
const TorrentModel *model = qobject_cast<TorrentModel *>(sourceModel());
// Sorting rules prioritized.
// 1. Active torrents at the top
// 2. Seeding torrents at the bottom
// 3. Torrents with invalid ETAs at the bottom
const bool isActiveL = TorrentFilter::ActiveTorrent.match(model->torrentHandle(model->index(left.row())));
const bool isActiveR = TorrentFilter::ActiveTorrent.match(model->torrentHandle(model->index(right.row())));
if (isActiveL != isActiveR)
return isActiveL;
const int prioL = model->data(model->index(left.row(), TorrentModel::TR_PRIORITY)).toInt();
const int prioR = model->data(model->index(right.row(), TorrentModel::TR_PRIORITY)).toInt();
const bool isSeedingL = (prioL < 0);
const bool isSeedingR = (prioR < 0);
if (isSeedingL != isSeedingR) {
const bool isAscendingOrder = (sortOrder() == Qt::AscendingOrder);
if (isSeedingL)
return !isAscendingOrder;
else
return isAscendingOrder;
return lowerPositionThan(left, right);
}
const qlonglong etaL = left.data().toLongLong();
const qlonglong etaR = right.data().toLongLong();
const bool isInvalidL = ((etaL < 0) || (etaL >= MAX_ETA));
const bool isInvalidR = ((etaR < 0) || (etaR >= MAX_ETA));
if (isInvalidL && isInvalidR) {
if (isSeedingL) // Both seeding
return dateLessThan(TorrentModel::TR_SEED_DATE, left, right, true);
else
return (prioL < prioR);
}
else if (!isInvalidL && !isInvalidR) {
return (etaL < etaR);
}
else {
return !isInvalidL;
case TorrentModel::TR_ETA: {
const TorrentModel *model = qobject_cast<TorrentModel *>(sourceModel());
// Sorting rules prioritized.
// 1. Active torrents at the top
// 2. Seeding torrents at the bottom
// 3. Torrents with invalid ETAs at the bottom
const bool isActiveL = TorrentFilter::ActiveTorrent.match(model->torrentHandle(model->index(left.row())));
const bool isActiveR = TorrentFilter::ActiveTorrent.match(model->torrentHandle(model->index(right.row())));
if (isActiveL != isActiveR)
return isActiveL;
const int prioL = model->data(model->index(left.row(), TorrentModel::TR_PRIORITY)).toInt();
const int prioR = model->data(model->index(right.row(), TorrentModel::TR_PRIORITY)).toInt();
const bool isSeedingL = (prioL < 0);
const bool isSeedingR = (prioR < 0);
if (isSeedingL != isSeedingR) {
const bool isAscendingOrder = (sortOrder() == Qt::AscendingOrder);
if (isSeedingL)
return !isAscendingOrder;
else
return isAscendingOrder;
}
const qlonglong etaL = left.data().toLongLong();
const qlonglong etaR = right.data().toLongLong();
const bool isInvalidL = ((etaL < 0) || (etaL >= MAX_ETA));
const bool isInvalidR = ((etaR < 0) || (etaR >= MAX_ETA));
if (isInvalidL && isInvalidR) {
if (isSeedingL) // Both seeding
return dateLessThan(TorrentModel::TR_SEED_DATE, left, right, true);
else
return (prioL < prioR);
}
else if (!isInvalidL && !isInvalidR) {
return (etaL < etaR);
}
else {
return !isInvalidL;
}
}
}
case TorrentModel::TR_LAST_ACTIVITY: {
const qlonglong vL = left.data().toLongLong();
const qlonglong vR = right.data().toLongLong();
const qlonglong vL = left.data().toLongLong();
const qlonglong vR = right.data().toLongLong();
if (vL == -1) return false;
if (vR == -1) return true;
if (vL == -1) return false;
if (vR == -1) return true;
return vL < vR;
}
return vL < vR;
}
case TorrentModel::TR_RATIO_LIMIT: {
const qreal vL = left.data().toDouble();
const qreal vR = right.data().toDouble();
const qreal vL = left.data().toDouble();
const qreal vR = right.data().toDouble();
if (vL == -1) return false;
if (vR == -1) return true;
if (vL == -1) return false;
if (vR == -1) return true;
return vL < vR;
}
return vL < vR;
}
default: {
if (left.data() != right.data())
return QSortFilterProxyModel::lessThan(left, right);
return lowerPositionThan(left, right);
}
}
}
}

12
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
@ -36,7 +34,7 @@ @@ -36,7 +34,7 @@
class QStringList;
class TransferListSortModel: public QSortFilterProxyModel
class TransferListSortModel : public QSortFilterProxyModel
{
Q_OBJECT
@ -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:

196
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
@ -79,7 +79,7 @@ namespace @@ -79,7 +79,7 @@ namespace
}
// Helper for setting style parameters when painting check box primitives.
class CheckBoxIconHelper: public QCheckBox
class CheckBoxIconHelper : public QCheckBox
{
public:
explicit CheckBoxIconHelper(QWidget *parent);
@ -108,7 +108,7 @@ namespace @@ -108,7 +108,7 @@ namespace
}
// Tristate checkbox styled for use in menus.
class MenuCheckBox: public QWidget
class MenuCheckBox : public QWidget
{
public:
MenuCheckBox(const QString &text, const ToggleFn &onToggle, Qt::CheckState initialState);
@ -188,7 +188,7 @@ namespace @@ -188,7 +188,7 @@ namespace
m_checkBox->click();
}
class CheckBoxMenuItem: public QWidgetAction
class CheckBoxMenuItem : public QWidgetAction
{
public:
CheckBoxMenuItem(const QString &text, const ToggleFn &onToggle, Qt::CheckState initialState, QObject *parent)
@ -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);
@ -318,7 +318,7 @@ TransferListWidget::~TransferListWidget() @@ -318,7 +318,7 @@ TransferListWidget::~TransferListWidget()
qDebug() << Q_FUNC_INFO << "EXIT";
}
TorrentModel* TransferListWidget::getSourceModel() const
TorrentModel *TransferListWidget::getSourceModel() const
{
return m_listModel;
}
@ -358,7 +358,7 @@ void TransferListWidget::torrentDoubleClicked() @@ -358,7 +358,7 @@ void TransferListWidget::torrentDoubleClicked()
else
action = Preferences::instance()->getActionOnDblClOnTorrentDl();
switch(action) {
switch (action) {
case TOGGLE_PAUSE:
if (torrent->isPaused())
torrent->resume();
@ -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());
@ -1186,7 +1186,7 @@ void TransferListWidget::applyTrackerFilter(const QStringList &hashes) @@ -1186,7 +1186,7 @@ void TransferListWidget::applyTrackerFilter(const QStringList &hashes)
m_sortFilterModel->setTrackerFilter(hashes);
}
void TransferListWidget::applyNameFilter(const QString& name)
void TransferListWidget::applyNameFilter(const QString &name)
{
m_sortFilterModel->setFilterRegExp(QRegExp(name, Qt::CaseInsensitive, QRegExp::WildcardUnix));
}
@ -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);
}

22
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,25 +37,23 @@ namespace BitTorrent @@ -39,25 +37,23 @@ 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
class TransferListWidget : public QTreeView
{
Q_OBJECT
public:
TransferListWidget(QWidget *parent, MainWindow *mainWindow);
~TransferListWidget();
TorrentModel* getSourceModel() const;
TorrentModel *getSourceModel() const;
public slots:
void setSelectionCategory(QString category);
@ -92,7 +88,7 @@ public slots: @@ -92,7 +88,7 @@ public slots:
void previewSelectedTorrents();
void hidePriorityColumn(bool hide);
void displayDLHoSMenu(const QPoint&);
void applyNameFilter(const QString& name);
void applyNameFilter(const QString &name);
void applyStatusFilter(int f);
void applyCategoryFilter(QString category);
void applyTagFilter(const QString &tag);

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