Fix coding style

This commit is contained in:
thalieht 2018-06-06 16:48:17 +03:00 committed by sledgehammer999
parent b107b745f2
commit ac6426eab1
No known key found for this signature in database
GPG key ID: 6E4A2D025B7CC9A2
79 changed files with 717 additions and 772 deletions

View file

@ -234,7 +234,7 @@ int main(int argc, char *argv[])
#ifdef DISABLE_GUI #ifdef DISABLE_GUI
if (params.shouldDaemonize) { if (params.shouldDaemonize) {
app.reset(); // Destroy current application app.reset(); // Destroy current application
if ((daemon(1, 0) == 0)) { if (daemon(1, 0) == 0) {
app.reset(new Application(appId, argc, argv)); app.reset(new Application(appId, argc, argv));
if (app->isRunning()) { if (app->isRunning()) {
// Another instance had time to start. // Another instance had time to start.
@ -319,13 +319,13 @@ void sigAbnormalHandler(int signum)
#if !defined(DISABLE_GUI) #if !defined(DISABLE_GUI)
void showSplashScreen() void showSplashScreen()
{ {
QPixmap splash_img(":/icons/skin/splash.png"); QPixmap splashImg(":/icons/skin/splash.png");
QPainter painter(&splash_img); QPainter painter(&splashImg);
QString version = QBT_VERSION; QString version = QBT_VERSION;
painter.setPen(QPen(Qt::white)); painter.setPen(QPen(Qt::white));
painter.setFont(QFont("Arial", 22, QFont::Black)); painter.setFont(QFont("Arial", 22, QFont::Black));
painter.drawText(224 - painter.fontMetrics().width(version), 270, version); painter.drawText(224 - painter.fontMetrics().width(version), 270, version);
QSplashScreen *splash = new QSplashScreen(splash_img); QSplashScreen *splash = new QSplashScreen(splashImg);
splash->show(); splash->show();
QTimer::singleShot(1500, splash, &QObject::deleteLater); QTimer::singleShot(1500, splash, &QObject::deleteLater);
qApp->processEvents(); qApp->processEvents();
@ -376,7 +376,7 @@ bool userAgreesWithLegalNotice()
printf("%s", qUtf8Printable(eula)); printf("%s", qUtf8Printable(eula));
char ret = getchar(); // Read pressed key char ret = getchar(); // Read pressed key
if (ret == 'y' || ret == 'Y') { if ((ret == 'y') || (ret == 'Y')) {
// Save the answer // Save the answer
pref->setAcceptedLegal(true); pref->setAcceptedLegal(true);
return true; return true;
@ -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.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.setWindowTitle(QObject::tr("Legal notice"));
msgBox.addButton(QObject::tr("Cancel"), QMessageBox::RejectRole); 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.show(); // Need to be shown or to moveToCenter does not work
msgBox.move(Utils::Misc::screenCenter(&msgBox)); msgBox.move(Utils::Misc::screenCenter(&msgBox));
msgBox.exec(); msgBox.exec();
if (msgBox.clickedButton() == agree_button) { if (msgBox.clickedButton() == agreeButton) {
// Save the answer // Save the answer
pref->setAcceptedLegal(true); pref->setAcceptedLegal(true);
return true; return true;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -101,7 +101,7 @@ QVector<float> DownloadedPiecesBar::bitfieldToFloatVector(const QBitArray &vecin
// normalization <0, 1> // normalization <0, 1>
value /= ratio; 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); value = qMin(value, 1.0f);
result[x] = value; result[x] = value;

View file

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

View file

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

View file

@ -109,7 +109,7 @@ QVector<float> PieceAvailabilityBar::intToFloatVector(const QVector<int> &vecin,
// normalization <0, 1> // normalization <0, 1>
value /= ratio * maxElement; 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); value = qMin(value, 1.0f);
result[x] = value; result[x] = value;

View file

@ -50,7 +50,7 @@ namespace
{ {
public: public:
PieceIndexToImagePos(const BitTorrent::TorrentInfo &torrentInfo, const QImage &image) 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} ? torrentInfo.totalSize() / image.width() : -1}
, m_torrentInfo {torrentInfo} , m_torrentInfo {torrentInfo}
{ {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -131,12 +131,12 @@ void ShutdownConfirmDlg::initText()
break; break;
} }
m_msg += "\n"; m_msg += '\n';
updateText(); updateText();
} }
void ShutdownConfirmDlg::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); m_ui->shutdownText->setText(m_msg + t);
} }

View file

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

View file

@ -47,12 +47,12 @@ class SpeedLimitDialog : public QDialog
public: public:
explicit SpeedLimitDialog(QWidget *parent); explicit SpeedLimitDialog(QWidget *parent);
~SpeedLimitDialog(); ~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: protected slots:
void updateSpinValue(int val) const; void updateSpinValue(int val) const;
void updateSliderValue(int val) const; void updateSliderValue(int val) const;
void setupDialog(long max_slider, long val) const; void setupDialog(long maxSlider, long val) const;
private: private:
long getSpeedLimit() const; long getSpeedLimit() const;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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