From 402279988161b2d065274eda404804029324ec25 Mon Sep 17 00:00:00 2001 From: thalieht Date: Wed, 6 Jun 2018 16:48:17 +0300 Subject: [PATCH] Fix coding style --- src/app/main.cpp | 14 +- .../private/resumedatasavingmanager.cpp | 3 +- src/base/bittorrent/torrenthandle.cpp | 2 +- src/base/scanfoldersmodel.cpp | 2 +- src/gui/about_imp.h | 15 +- src/gui/addnewtorrentdialog.cpp | 8 +- src/gui/advancedsettings.cpp | 18 +- src/gui/advancedsettings.h | 2 +- src/gui/autoexpandabledialog.h | 4 +- src/gui/categoryfiltermodel.cpp | 2 +- src/gui/categoryfiltermodel.h | 2 +- src/gui/categoryfilterproxymodel.h | 2 +- src/gui/categoryfilterwidget.h | 2 +- src/gui/deletionconfirmationdlg.h | 85 ++++---- src/gui/downloadfromurldialog.h | 2 +- src/gui/executionlog.cpp | 38 ++-- src/gui/executionlog.h | 16 +- src/gui/fspathedit.h | 8 +- src/gui/fspathedit_p.h | 6 +- src/gui/hidabletabwidget.h | 8 +- src/gui/loglistwidget.cpp | 4 +- src/gui/loglistwidget.h | 13 +- src/gui/mainwindow.cpp | 36 ++-- src/gui/mainwindow.h | 10 +- src/gui/messageboxraised.cpp | 48 +++-- src/gui/messageboxraised.h | 29 ++- src/gui/optionsdlg.cpp | 39 ++-- src/gui/optionsdlg.h | 12 +- src/gui/previewlistdelegate.h | 5 +- src/gui/programupdater.cpp | 2 +- src/gui/programupdater.h | 8 +- src/gui/properties/downloadedpiecesbar.cpp | 2 +- src/gui/properties/peerlistsortmodel.h | 2 +- src/gui/properties/peerlistwidget.cpp | 10 +- src/gui/properties/peersadditiondlg.cpp | 10 +- src/gui/properties/pieceavailabilitybar.cpp | 2 +- src/gui/properties/piecesbar.cpp | 2 +- src/gui/properties/propertieswidget.cpp | 16 +- src/gui/properties/speedplotview.cpp | 4 +- src/gui/properties/speedwidget.h | 2 +- src/gui/properties/trackerlist.cpp | 2 +- src/gui/properties/trackersadditiondlg.cpp | 10 +- src/gui/scanfoldersdelegate.cpp | 18 +- src/gui/scanfoldersdelegate.h | 19 +- src/gui/shutdownconfirmdlg.cpp | 4 +- src/gui/speedlimitdlg.cpp | 20 +- src/gui/speedlimitdlg.h | 4 +- src/gui/statsdialog.h | 2 +- src/gui/statusbar.h | 2 +- src/gui/tagfiltermodel.cpp | 4 +- src/gui/tagfiltermodel.h | 2 +- src/gui/tagfilterproxymodel.h | 2 +- src/gui/tagfilterwidget.h | 2 +- src/gui/torrentcontentfiltermodel.h | 8 +- src/gui/torrentcontentmodel.cpp | 65 +++--- src/gui/torrentcontentmodel.h | 24 +-- src/gui/torrentcontentmodelfile.cpp | 6 +- src/gui/torrentcontentmodelfile.h | 8 +- src/gui/torrentcontentmodelfolder.cpp | 8 +- src/gui/torrentcontentmodelfolder.h | 20 +- src/gui/torrentcontentmodelitem.cpp | 13 +- src/gui/torrentcontentmodelitem.h | 6 +- src/gui/torrentcontenttreeview.h | 4 +- src/gui/torrentcreatordlg.h | 4 +- src/gui/torrentmodel.cpp | 9 +- src/gui/torrentmodel.h | 14 +- src/gui/trackerlogin.cpp | 6 +- src/gui/trackerlogin.h | 8 +- src/gui/transferlistdelegate.cpp | 195 +++++++++-------- src/gui/transferlistdelegate.h | 18 +- src/gui/transferlistfilterswidget.cpp | 22 +- src/gui/transferlistfilterswidget.h | 41 ++-- src/gui/transferlistsortmodel.cpp | 180 ++++++++-------- src/gui/transferlistsortmodel.h | 12 +- src/gui/transferlistwidget.cpp | 196 +++++++++--------- src/gui/transferlistwidget.h | 22 +- src/gui/updownratiodlg.h | 2 +- src/gui/utils.cpp | 2 +- src/webui/api/torrentscontroller.cpp | 2 +- 79 files changed, 713 insertions(+), 768 deletions(-) diff --git a/src/app/main.cpp b/src/app/main.cpp index 75267ec6a..050bf2a96 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -234,7 +234,7 @@ int main(int argc, char *argv[]) #ifdef DISABLE_GUI if (params.shouldDaemonize) { app.reset(); // Destroy current application - if ((daemon(1, 0) == 0)) { + if (daemon(1, 0) == 0) { app.reset(new Application(appId, argc, argv)); if (app->isRunning()) { // Another instance had time to start. @@ -319,13 +319,13 @@ void sigAbnormalHandler(int signum) #if !defined(DISABLE_GUI) void showSplashScreen() { - QPixmap splash_img(":/icons/skin/splash.png"); - QPainter painter(&splash_img); + QPixmap splashImg(":/icons/skin/splash.png"); + QPainter painter(&splashImg); QString version = QBT_VERSION; painter.setPen(QPen(Qt::white)); painter.setFont(QFont("Arial", 22, QFont::Black)); painter.drawText(224 - painter.fontMetrics().width(version), 270, version); - QSplashScreen *splash = new QSplashScreen(splash_img); + QSplashScreen *splash = new QSplashScreen(splashImg); splash->show(); QTimer::singleShot(1500, splash, &QObject::deleteLater); qApp->processEvents(); @@ -376,7 +376,7 @@ bool userAgreesWithLegalNotice() printf("%s", qUtf8Printable(eula)); char ret = getchar(); // Read pressed key - if (ret == 'y' || ret == 'Y') { + if ((ret == 'y') || (ret == 'Y')) { // Save the answer pref->setAcceptedLegal(true); return true; @@ -386,11 +386,11 @@ bool userAgreesWithLegalNotice() msgBox.setText(QObject::tr("qBittorrent is a file sharing program. When you run a torrent, its data will be made available to others by means of upload. Any content you share is your sole responsibility.\n\nNo further notices will be issued.")); msgBox.setWindowTitle(QObject::tr("Legal notice")); msgBox.addButton(QObject::tr("Cancel"), QMessageBox::RejectRole); - QAbstractButton *agree_button = msgBox.addButton(QObject::tr("I Agree"), QMessageBox::AcceptRole); + QAbstractButton *agreeButton = msgBox.addButton(QObject::tr("I Agree"), QMessageBox::AcceptRole); msgBox.show(); // Need to be shown or to moveToCenter does not work msgBox.move(Utils::Misc::screenCenter(&msgBox)); msgBox.exec(); - if (msgBox.clickedButton() == agree_button) { + if (msgBox.clickedButton() == agreeButton) { // Save the answer pref->setAcceptedLegal(true); return true; diff --git a/src/base/bittorrent/private/resumedatasavingmanager.cpp b/src/base/bittorrent/private/resumedatasavingmanager.cpp index 928d1a3cb..167be4fa8 100644 --- a/src/base/bittorrent/private/resumedatasavingmanager.cpp +++ b/src/base/bittorrent/private/resumedatasavingmanager.cpp @@ -26,12 +26,13 @@ * exception statement from your version. */ +#include "resumedatasavingmanager.h" + #include #include #include "base/logger.h" #include "base/utils/fs.h" -#include "resumedatasavingmanager.h" ResumeDataSavingManager::ResumeDataSavingManager(const QString &resumeFolderPath) : m_resumeDataDir(resumeFolderPath) diff --git a/src/base/bittorrent/torrenthandle.cpp b/src/base/bittorrent/torrenthandle.cpp index 509fa67bd..d478b374d 100644 --- a/src/base/bittorrent/torrenthandle.cpp +++ b/src/base/bittorrent/torrenthandle.cpp @@ -1831,7 +1831,7 @@ void TorrentHandle::manageIncompleteFiles() { const bool isAppendExtensionEnabled = m_session->isAppendExtensionEnabled(); QVector fp = filesProgress(); - if( fp.size() != filesCount() ) { + if (fp.size() != filesCount()) { qDebug() << "skip manageIncompleteFiles because of invalid torrent meta-data or empty file-progress"; return; } diff --git a/src/base/scanfoldersmodel.cpp b/src/base/scanfoldersmodel.cpp index b271c1590..74c9dc952 100644 --- a/src/base/scanfoldersmodel.cpp +++ b/src/base/scanfoldersmodel.cpp @@ -388,7 +388,7 @@ void ScanFoldersModel::addTorrentsToSession(const QStringList &pathList) QString ScanFoldersModel::pathTypeDisplayName(const PathType type) { - switch(type) { + switch (type) { case DOWNLOAD_IN_WATCH_FOLDER: return tr("Monitored folder"); case DEFAULT_LOCATION: diff --git a/src/gui/about_imp.h b/src/gui/about_imp.h index a1bf05f69..b0ac6a548 100644 --- a/src/gui/about_imp.h +++ b/src/gui/about_imp.h @@ -1,6 +1,6 @@ /* - * Bittorrent Client using Qt4 and libtorrent. - * Copyright (C) 2006 Christophe Dumez + * Bittorrent Client using Qt and libtorrent. + * Copyright (C) 2006 Christophe Dumez * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -24,8 +24,6 @@ * modify file(s), you may extend this exception to your version of the file(s), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : chris@qbittorrent.org */ #ifndef ABOUT_H @@ -33,17 +31,18 @@ #include -#include "base/utils/misc.h" #include "base/unicodestrings.h" +#include "base/utils/misc.h" #include "ui_about.h" #include "utils.h" -class about: public QDialog, private Ui::AboutDlg +class AboutDialog : public QDialog, private Ui::AboutDlg { Q_OBJECT public: - about(QWidget *parent) : QDialog(parent) + AboutDialog(QWidget *parent) + : QDialog(parent) { setupUi(this); setAttribute(Qt::WA_DeleteOnClose); @@ -108,4 +107,4 @@ public: } }; -#endif +#endif // ABOUT_H diff --git a/src/gui/addnewtorrentdialog.cpp b/src/gui/addnewtorrentdialog.cpp index 76647f44d..5d525c1d6 100644 --- a/src/gui/addnewtorrentdialog.cpp +++ b/src/gui/addnewtorrentdialog.cpp @@ -536,15 +536,15 @@ void AddNewTorrentDialog::renameSelectedFile() pathItems.prepend(parent.data().toString()); parent = m_contentModel->parent(parent); } - const QString oldPath = pathItems.join("/"); + const QString oldPath = pathItems.join('/'); pathItems.removeLast(); pathItems << newName; - QString newPath = pathItems.join("/"); + QString newPath = pathItems.join('/'); if (Utils::Fs::sameFileNames(oldPath, newPath)) { qDebug("Name did not change"); return; } - if (!newPath.endsWith("/")) newPath += "/"; + if (!newPath.endsWith('/')) newPath += '/'; // Check for overwriting for (int i = 0; i < m_torrentInfo.filesCount(); ++i) { const QString ¤tName = m_torrentInfo.filePath(i); @@ -813,7 +813,7 @@ void AddNewTorrentDialog::setCommentText(const QString &str) const // workaround for the additional space introduced by QScrollArea int lineHeight = m_ui->commentLabel->fontMetrics().lineSpacing(); - int lines = 1 + str.count("\n"); + int lines = 1 + str.count('\n'); int height = lineHeight * lines; m_ui->scrollArea->setMaximumHeight(height); } diff --git a/src/gui/advancedsettings.cpp b/src/gui/advancedsettings.cpp index b5733145e..e1e023942 100644 --- a/src/gui/advancedsettings.cpp +++ b/src/gui/advancedsettings.cpp @@ -33,10 +33,10 @@ #include #include -#include "app/application.h" #include "base/bittorrent/session.h" #include "base/preferences.h" #include "base/unicodestrings.h" +#include "app/application.h" #include "gui/addnewtorrentdialog.h" #include "gui/mainwindow.h" @@ -137,7 +137,7 @@ AdvancedSettings::AdvancedSettings(QWidget *parent) void AdvancedSettings::saveAdvancedSettings() { - Preferences* const pref = Preferences::instance(); + Preferences *const pref = Preferences::instance(); BitTorrent::Session *const session = BitTorrent::Session::instance(); // Disk write cache @@ -201,7 +201,7 @@ void AdvancedSettings::saveAdvancedSettings() session->setAnnounceIP(addr.isNull() ? "" : addr.toString()); // Program notification - MainWindow * const mainWindow = static_cast(QCoreApplication::instance())->mainWindow(); + MainWindow *const mainWindow = static_cast(QCoreApplication::instance())->mainWindow(); mainWindow->setNotificationsEnabled(cb_program_notifications.isChecked()); mainWindow->setTorrentAddedNotificationsEnabled(cb_torrent_added_notifications.isChecked()); // Misc GUI properties @@ -247,16 +247,16 @@ void AdvancedSettings::updateInterfaceAddressCombo() const QString ifaceName = combo_iface.itemData(combo_iface.currentIndex()).toString(); // Empty string for the first element const QString currentAddress = BitTorrent::Session::instance()->networkInterfaceAddress(); - //Clear all items and reinsert them, default to all + // Clear all items and reinsert them, default to all combo_iface_address.clear(); combo_iface_address.addItem(tr("All addresses")); combo_iface_address.setCurrentIndex(0); auto populateCombo = [this, ¤tAddress](const QString &ip, const QAbstractSocket::NetworkLayerProtocol &protocol) { - Q_ASSERT(protocol == QAbstractSocket::IPv4Protocol || protocol == QAbstractSocket::IPv6Protocol); - //Only take ipv4 for now? - if (protocol != QAbstractSocket::IPv4Protocol && protocol != QAbstractSocket::IPv6Protocol) + Q_ASSERT((protocol == QAbstractSocket::IPv4Protocol) || (protocol == QAbstractSocket::IPv6Protocol)); + // Only take ipv4 for now? + if ((protocol != QAbstractSocket::IPv4Protocol) && (protocol != QAbstractSocket::IPv6Protocol)) return; combo_iface_address.addItem(ip); //Try to select the last added one @@ -280,7 +280,7 @@ void AdvancedSettings::updateInterfaceAddressCombo() void AdvancedSettings::loadAdvancedSettings() { - const Preferences* const pref = Preferences::instance(); + const Preferences *const pref = Preferences::instance(); const BitTorrent::Session *const session = BitTorrent::Session::instance(); // add section headers @@ -483,7 +483,7 @@ void AdvancedSettings::loadAdvancedSettings() } template -void AdvancedSettings::addRow(int row, const QString &rowText, T* widget) +void AdvancedSettings::addRow(int row, const QString &rowText, T *widget) { setItem(row, PROPERTY, new QTableWidgetItem(rowText)); setCellWidget(row, VALUE, widget); diff --git a/src/gui/advancedsettings.h b/src/gui/advancedsettings.h index 50c9c1a56..b159d28e9 100644 --- a/src/gui/advancedsettings.h +++ b/src/gui/advancedsettings.h @@ -36,7 +36,7 @@ #include #include -class AdvancedSettings: public QTableWidget +class AdvancedSettings : public QTableWidget { Q_OBJECT diff --git a/src/gui/autoexpandabledialog.h b/src/gui/autoexpandabledialog.h index e12e61d92..f7f46c88c 100644 --- a/src/gui/autoexpandabledialog.h +++ b/src/gui/autoexpandabledialog.h @@ -38,7 +38,7 @@ namespace Ui class AutoExpandableDialog; } -class AutoExpandableDialog: public QDialog +class AutoExpandableDialog : public QDialog { Q_OBJECT @@ -51,7 +51,7 @@ public: bool *ok = nullptr, Qt::InputMethodHints inputMethodHints = Qt::ImhNone); protected: - void showEvent(QShowEvent *e); + void showEvent(QShowEvent *e) override; private: Ui::AutoExpandableDialog *m_ui; diff --git a/src/gui/categoryfiltermodel.cpp b/src/gui/categoryfiltermodel.cpp index 85b4bf30f..cfb104096 100644 --- a/src/gui/categoryfiltermodel.cpp +++ b/src/gui/categoryfiltermodel.cpp @@ -31,8 +31,8 @@ #include #include -#include "base/bittorrent/torrenthandle.h" #include "base/bittorrent/session.h" +#include "base/bittorrent/torrenthandle.h" #include "guiiconprovider.h" class CategoryModelItem diff --git a/src/gui/categoryfiltermodel.h b/src/gui/categoryfiltermodel.h index bf186faae..4b43d9907 100644 --- a/src/gui/categoryfiltermodel.h +++ b/src/gui/categoryfiltermodel.h @@ -40,7 +40,7 @@ namespace BitTorrent class CategoryModelItem; -class CategoryFilterModel: public QAbstractItemModel +class CategoryFilterModel : public QAbstractItemModel { Q_OBJECT diff --git a/src/gui/categoryfilterproxymodel.h b/src/gui/categoryfilterproxymodel.h index 2bdeb95e1..ef6c2e7a5 100644 --- a/src/gui/categoryfilterproxymodel.h +++ b/src/gui/categoryfilterproxymodel.h @@ -32,7 +32,7 @@ #include #include -class CategoryFilterProxyModel: public QSortFilterProxyModel +class CategoryFilterProxyModel : public QSortFilterProxyModel { public: explicit CategoryFilterProxyModel(QObject *parent = nullptr); diff --git a/src/gui/categoryfilterwidget.h b/src/gui/categoryfilterwidget.h index f9387beb2..0c93a5ffb 100644 --- a/src/gui/categoryfilterwidget.h +++ b/src/gui/categoryfilterwidget.h @@ -28,7 +28,7 @@ #include -class CategoryFilterWidget: public QTreeView +class CategoryFilterWidget : public QTreeView { Q_OBJECT Q_DISABLE_COPY(CategoryFilterWidget) diff --git a/src/gui/deletionconfirmationdlg.h b/src/gui/deletionconfirmationdlg.h index dfb958234..df985a96a 100644 --- a/src/gui/deletionconfirmationdlg.h +++ b/src/gui/deletionconfirmationdlg.h @@ -1,6 +1,6 @@ /* * Bittorrent Client using Qt4 and libtorrent. - * Copyright (C) 2006 Christophe Dumez + * Copyright (C) 2006 Christophe Dumez * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -24,8 +24,6 @@ * modify file(s), you may extend this exception to your version of the file(s), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : chris@qbittorrent.org */ #ifndef DELETIONCONFIRMATIONDLG_H @@ -41,52 +39,59 @@ #include "ui_confirmdeletiondlg.h" #include "utils.h" -class DeletionConfirmationDlg : public QDialog, private Ui::confirmDeletionDlg { - Q_OBJECT +class DeletionConfirmationDlg : public QDialog, private Ui::confirmDeletionDlg +{ + Q_OBJECT - public: - DeletionConfirmationDlg(QWidget *parent, const int &size, const QString &name, bool defaultDeleteFiles): QDialog(parent) { - setupUi(this); - if (size == 1) - label->setText(tr("Are you sure you want to delete '%1' from the transfer list?", "Are you sure you want to delete 'ubuntu-linux-iso' from the transfer list?").arg(name.toHtmlEscaped())); - else - label->setText(tr("Are you sure you want to delete these %1 torrents from the transfer list?", "Are you sure you want to delete these 5 torrents from the transfer list?").arg(QString::number(size))); - // Icons - const QSize iconSize = Utils::Gui::largeIconSize(); - lbl_warn->setPixmap(GuiIconProvider::instance()->getIcon("dialog-warning").pixmap(iconSize)); - lbl_warn->setFixedWidth(iconSize.width()); - rememberBtn->setIcon(GuiIconProvider::instance()->getIcon("object-locked")); - rememberBtn->setIconSize(Utils::Gui::mediumIconSize()); +public: + DeletionConfirmationDlg(QWidget *parent, const int &size, const QString &name, bool defaultDeleteFiles) + : QDialog(parent) + { + setupUi(this); + if (size == 1) + label->setText(tr("Are you sure you want to delete '%1' from the transfer list?", "Are you sure you want to delete 'ubuntu-linux-iso' from the transfer list?").arg(name.toHtmlEscaped())); + else + label->setText(tr("Are you sure you want to delete these %1 torrents from the transfer list?", "Are you sure you want to delete these 5 torrents from the transfer list?").arg(QString::number(size))); + // Icons + const QSize iconSize = Utils::Gui::largeIconSize(); + lbl_warn->setPixmap(GuiIconProvider::instance()->getIcon("dialog-warning").pixmap(iconSize)); + lbl_warn->setFixedWidth(iconSize.width()); + rememberBtn->setIcon(GuiIconProvider::instance()->getIcon("object-locked")); + rememberBtn->setIconSize(Utils::Gui::mediumIconSize()); - checkPermDelete->setChecked(defaultDeleteFiles || Preferences::instance()->deleteTorrentFilesAsDefault()); - connect(checkPermDelete, &QCheckBox::clicked, this, &DeletionConfirmationDlg::updateRememberButtonState); - buttonBox->button(QDialogButtonBox::Cancel)->setFocus(); + checkPermDelete->setChecked(defaultDeleteFiles || Preferences::instance()->deleteTorrentFilesAsDefault()); + connect(checkPermDelete, &QCheckBox::clicked, this, &DeletionConfirmationDlg::updateRememberButtonState); + buttonBox->button(QDialogButtonBox::Cancel)->setFocus(); - Utils::Gui::resize(this); - } + Utils::Gui::resize(this); + } - bool shouldDeleteLocalFiles() const { - return checkPermDelete->isChecked(); - } + bool shouldDeleteLocalFiles() const + { + return checkPermDelete->isChecked(); + } - static bool askForDeletionConfirmation(QWidget *parent, bool& deleteLocalFiles, const int& size, const QString& name) { - DeletionConfirmationDlg dlg(parent, size, name, deleteLocalFiles); - if (dlg.exec() == QDialog::Accepted) { - deleteLocalFiles = dlg.shouldDeleteLocalFiles(); - return true; + static bool askForDeletionConfirmation(QWidget *parent, bool &deleteLocalFiles, const int &size, const QString &name) + { + DeletionConfirmationDlg dlg(parent, size, name, deleteLocalFiles); + if (dlg.exec() == QDialog::Accepted) { + deleteLocalFiles = dlg.shouldDeleteLocalFiles(); + return true; + } + return false; } - return false; - } private slots: - void updateRememberButtonState() { - rememberBtn->setEnabled(checkPermDelete->isChecked() != Preferences::instance()->deleteTorrentFilesAsDefault()); - } + void updateRememberButtonState() + { + rememberBtn->setEnabled(checkPermDelete->isChecked() != Preferences::instance()->deleteTorrentFilesAsDefault()); + } - void on_rememberBtn_clicked() { - Preferences::instance()->setDeleteTorrentFilesAsDefault(checkPermDelete->isChecked()); - rememberBtn->setEnabled(false); - } + void on_rememberBtn_clicked() + { + Preferences::instance()->setDeleteTorrentFilesAsDefault(checkPermDelete->isChecked()); + rememberBtn->setEnabled(false); + } }; #endif // DELETIONCONFIRMATIONDLG_H diff --git a/src/gui/downloadfromurldialog.h b/src/gui/downloadfromurldialog.h index 94c61b360..ca430bac5 100644 --- a/src/gui/downloadfromurldialog.h +++ b/src/gui/downloadfromurldialog.h @@ -55,4 +55,4 @@ private: Ui::DownloadFromURLDialog *m_ui; }; -#endif +#endif // DOWNLOADFROMURL_H diff --git a/src/gui/executionlog.cpp b/src/gui/executionlog.cpp index af5ee7773..5909f0f47 100644 --- a/src/gui/executionlog.cpp +++ b/src/gui/executionlog.cpp @@ -1,5 +1,5 @@ /* - * Bittorrent Client using Qt4 and libtorrent. + * Bittorrent Client using Qt and libtorrent. * Copyright (C) 2011 Christophe Dumez * * This program is free software; you can redistribute it and/or @@ -24,40 +24,40 @@ * modify file(s), you may extend this exception to your version of the file(s), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : chris@qbittorrent.org */ -#include -#include -#include +#include "executionlog.h" + #include +#include +#include +#include #include -#include "executionlog.h" -#include "ui_executionlog.h" + #include "guiiconprovider.h" #include "loglistwidget.h" +#include "ui_executionlog.h" ExecutionLog::ExecutionLog(QWidget *parent, const Log::MsgTypes &types) : QWidget(parent) - , ui(new Ui::ExecutionLog) + , m_ui(new Ui::ExecutionLog) , m_peerList(new LogListWidget(MAX_LOG_MESSAGES)) { - ui->setupUi(this); + m_ui->setupUi(this); m_msgList = new LogListWidget(MAX_LOG_MESSAGES, Log::MsgTypes(types)); #ifndef Q_OS_MAC - ui->tabConsole->setTabIcon(0, GuiIconProvider::instance()->getIcon("view-calendar-journal")); - ui->tabConsole->setTabIcon(1, GuiIconProvider::instance()->getIcon("view-filter")); + m_ui->tabConsole->setTabIcon(0, GuiIconProvider::instance()->getIcon("view-calendar-journal")); + m_ui->tabConsole->setTabIcon(1, GuiIconProvider::instance()->getIcon("view-filter")); #endif - ui->tabGeneral->layout()->addWidget(m_msgList); - ui->tabBan->layout()->addWidget(m_peerList); + m_ui->tabGeneral->layout()->addWidget(m_msgList); + m_ui->tabBan->layout()->addWidget(m_peerList); - const Logger* const logger = Logger::instance(); - foreach (const Log::Msg& msg, logger->getMessages()) + const Logger *const logger = Logger::instance(); + foreach (const Log::Msg &msg, logger->getMessages()) addLogMessage(msg); - foreach (const Log::Peer& peer, logger->getPeers()) + foreach (const Log::Peer &peer, logger->getPeers()) addPeerMessage(peer); connect(logger, &Logger::newLogMessage, this, &ExecutionLog::addLogMessage); connect(logger, &Logger::newLogPeer, this, &ExecutionLog::addPeerMessage); @@ -67,7 +67,7 @@ ExecutionLog::~ExecutionLog() { delete m_msgList; delete m_peerList; - delete ui; + delete m_ui; } void ExecutionLog::showMsgTypes(const Log::MsgTypes &types) @@ -99,7 +99,7 @@ void ExecutionLog::addLogMessage(const Log::Msg &msg) m_msgList->appendLine(text, msg.type); } -void ExecutionLog::addPeerMessage(const Log::Peer& peer) +void ExecutionLog::addPeerMessage(const Log::Peer &peer) { QString text; QDateTime time = QDateTime::fromMSecsSinceEpoch(peer.timestamp); diff --git a/src/gui/executionlog.h b/src/gui/executionlog.h index 7422398f8..4715e0a7b 100644 --- a/src/gui/executionlog.h +++ b/src/gui/executionlog.h @@ -1,6 +1,6 @@ /* - * Bittorrent Client using Qt4 and libtorrent. - * Copyright (C) 2011 Christophe Dumez + * Bittorrent Client using Qt and libtorrent. + * Copyright (C) 2011 Christophe Dumez * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -24,8 +24,6 @@ * modify file(s), you may extend this exception to your version of the file(s), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : chris@qbittorrent.org */ #ifndef EXECUTIONLOG_H @@ -34,14 +32,14 @@ #include #include "base/logger.h" -QT_BEGIN_NAMESPACE -namespace Ui { + +namespace Ui +{ class ExecutionLog; } -QT_END_NAMESPACE class LogListWidget; -class ExecutionLog: public QWidget +class ExecutionLog : public QWidget { Q_OBJECT @@ -55,7 +53,7 @@ private slots: void addPeerMessage(const Log::Peer &peer); private: - Ui::ExecutionLog *ui; + Ui::ExecutionLog *m_ui; LogListWidget *m_msgList; LogListWidget *m_peerList; diff --git a/src/gui/fspathedit.h b/src/gui/fspathedit.h index 880c667f8..d7f075f4d 100644 --- a/src/gui/fspathedit.h +++ b/src/gui/fspathedit.h @@ -34,16 +34,16 @@ namespace Private { + class FileComboEdit; class FileEditorWithCompletion; class FileLineEdit; - class FileComboEdit; } /*! * \brief * Widget for editing strings which are paths in filesystem */ -class FileSystemPathEdit: public QWidget +class FileSystemPathEdit : public QWidget { Q_OBJECT Q_ENUMS(Mode) @@ -109,7 +109,7 @@ private: }; /// Widget which uses QLineEdit for path editing -class FileSystemPathLineEdit: public FileSystemPathEdit +class FileSystemPathLineEdit : public FileSystemPathEdit { using base = FileSystemPathEdit; using WidgetType = Private::FileLineEdit; @@ -125,7 +125,7 @@ private: }; /// Widget which uses QComboBox for path editing -class FileSystemPathComboEdit: public FileSystemPathEdit +class FileSystemPathComboEdit : public FileSystemPathEdit { using base = FileSystemPathEdit; using WidgetType = Private::FileComboEdit; diff --git a/src/gui/fspathedit_p.h b/src/gui/fspathedit_p.h index 7edf9455a..b9296e4d7 100644 --- a/src/gui/fspathedit_p.h +++ b/src/gui/fspathedit_p.h @@ -47,7 +47,7 @@ class QStringList; namespace Private { - class FileSystemPathValidator: public QValidator + class FileSystemPathValidator : public QValidator { Q_OBJECT @@ -113,7 +113,7 @@ namespace Private virtual QWidget *widget() = 0; }; - class FileLineEdit: public QLineEdit, public FileEditorWithCompletion + class FileLineEdit : public QLineEdit, public FileEditorWithCompletion { Q_OBJECT Q_DISABLE_COPY(FileLineEdit) @@ -143,7 +143,7 @@ namespace Private QAction *m_warningAction; }; - class FileComboEdit: public QComboBox, public FileEditorWithCompletion + class FileComboEdit : public QComboBox, public FileEditorWithCompletion { Q_OBJECT diff --git a/src/gui/hidabletabwidget.h b/src/gui/hidabletabwidget.h index b6aace6ae..2b2860a56 100644 --- a/src/gui/hidabletabwidget.h +++ b/src/gui/hidabletabwidget.h @@ -1,6 +1,6 @@ /* * Bittorrent Client using Qt and libtorrent. - * Copyright (C) 2006 Christophe Dumez + * Copyright (C) 2006 Christophe Dumez * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -24,15 +24,13 @@ * modify file(s), you may extend this exception to your version of the file(s), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : chris@qbittorrent.org */ #ifndef HIDABLETABWIDGET_H #define HIDABLETABWIDGET_H -#include #include +#include #ifdef Q_OS_MAC #include @@ -48,7 +46,7 @@ public: protected: #ifdef Q_OS_MAC - void paintEvent(QPaintEvent* event) override + void paintEvent(QPaintEvent *event) override { // Hide the pane for macintosh style if (!style()->inherits("QMacStyle")) diff --git a/src/gui/loglistwidget.cpp b/src/gui/loglistwidget.cpp index c93ebe4f6..572fa5fb1 100644 --- a/src/gui/loglistwidget.cpp +++ b/src/gui/loglistwidget.cpp @@ -1,5 +1,5 @@ /* - * Bittorrent Client using Qt4 and libtorrent. + * Bittorrent Client using Qt and libtorrent. * Copyright (C) 2011 Christophe Dumez * * This program is free software; you can redistribute it and/or @@ -100,5 +100,5 @@ void LogListWidget::copySelection() foreach (QListWidgetItem* it, selectedItems()) strings << static_cast(itemWidget(it))->text().remove(htmlTag); - QApplication::clipboard()->setText(strings.join("\n")); + QApplication::clipboard()->setText(strings.join('\n')); } diff --git a/src/gui/loglistwidget.h b/src/gui/loglistwidget.h index 37946538c..c289ccc30 100644 --- a/src/gui/loglistwidget.h +++ b/src/gui/loglistwidget.h @@ -1,6 +1,6 @@ /* - * Bittorrent Client using Qt4 and libtorrent. - * Copyright (C) 2011 Christophe Dumez + * Bittorrent Client using Qt and libtorrent. + * Copyright (C) 2011 Christophe Dumez * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -24,20 +24,17 @@ * modify file(s), you may extend this exception to your version of the file(s), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : chris@qbittorrent.org */ + #ifndef LOGLISTWIDGET_H #define LOGLISTWIDGET_H #include #include "base/logger.h" -QT_BEGIN_NAMESPACE class QKeyEvent; -QT_END_NAMESPACE -class LogListWidget: public QListWidget +class LogListWidget : public QListWidget { Q_OBJECT @@ -53,7 +50,7 @@ protected slots: void copySelection(); protected: - void keyPressEvent(QKeyEvent *event); + void keyPressEvent(QKeyEvent *event) override; private: int m_maxLines; diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index c32ed61c0..91c0fb2d2 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -1,6 +1,6 @@ /* * Bittorrent Client using Qt and libtorrent. - * Copyright (C) 2006 Christophe Dumez + * Copyright (C) 2006 Christophe Dumez * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -24,8 +24,6 @@ * modify file(s), you may extend this exception to your version of the file(s), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : chris@qbittorrent.org */ #include "mainwindow.h" @@ -59,10 +57,6 @@ #include "notifications.h" #endif -#include "about_imp.h" -#include "addnewtorrentdialog.h" -#include "application.h" -#include "autoexpandabledialog.h" #include "base/bittorrent/session.h" #include "base/bittorrent/sessionstatus.h" #include "base/bittorrent/torrenthandle.h" @@ -74,6 +68,10 @@ #include "base/settingsstorage.h" #include "base/utils/fs.h" #include "base/utils/misc.h" +#include "about_imp.h" +#include "addnewtorrentdialog.h" +#include "application.h" +#include "autoexpandabledialog.h" #include "cookiesdialog.h" #include "downloadfromurldialog.h" #include "executionlog.h" @@ -267,7 +265,7 @@ MainWindow::MainWindow(QWidget *parent) connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackersRemoved, m_transferListFiltersWidget, &TransferListFiltersWidget::removeTrackers); connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackerlessStateChanged, m_transferListFiltersWidget, &TransferListFiltersWidget::changeTrackerless); - using Func = void (TransferListFiltersWidget::*)(BitTorrent::TorrentHandle * const, const QString &); + using Func = void (TransferListFiltersWidget::*)(BitTorrent::TorrentHandle *const, const QString &); connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackerSuccess, m_transferListFiltersWidget, static_cast(&TransferListFiltersWidget::trackerSuccess)); connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackerError, m_transferListFiltersWidget, static_cast(&TransferListFiltersWidget::trackerError)); connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackerWarning, m_transferListFiltersWidget, static_cast(&TransferListFiltersWidget::trackerWarning)); @@ -1059,7 +1057,7 @@ void MainWindow::notifyOfUpdate(QString) void MainWindow::toggleVisibility(const QSystemTrayIcon::ActivationReason reason) { switch (reason) { - case QSystemTrayIcon::Trigger: { + case QSystemTrayIcon::Trigger: if (isHidden()) { if (m_uiLocked && !unlockUI()) // Ask for UI lock password return; @@ -1075,9 +1073,7 @@ void MainWindow::toggleVisibility(const QSystemTrayIcon::ActivationReason reason else { hide(); } - break; - } default: break; @@ -1092,7 +1088,7 @@ void MainWindow::on_actionAbout_triggered() if (m_aboutDlg) m_aboutDlg->activateWindow(); else - m_aboutDlg = new about(this); + m_aboutDlg = new AboutDialog(this); } void MainWindow::on_actionStatistics_triggered() @@ -1136,7 +1132,7 @@ void MainWindow::closeEvent(QCloseEvent *e) e->accept(); return; } -#endif +#endif // Q_OS_MAC if (pref->confirmOnExit() && BitTorrent::Session::instance()->hasActiveTorrents()) { if (e->spontaneous() || m_forceExit) { @@ -1144,7 +1140,7 @@ void MainWindow::closeEvent(QCloseEvent *e) show(); QMessageBox confirmBox(QMessageBox::Question, tr("Exiting qBittorrent"), // Split it because the last sentence is used in the Web UI - tr("Some files are currently transferring.") + "\n" + tr("Are you sure you want to quit qBittorrent?"), + tr("Some files are currently transferring.") + '\n' + tr("Are you sure you want to quit qBittorrent?"), QMessageBox::NoButton, this); QPushButton *noBtn = confirmBox.addButton(tr("&No"), QMessageBox::NoRole); confirmBox.addButton(tr("&Yes"), QMessageBox::YesRole); @@ -1355,9 +1351,9 @@ void MainWindow::on_actionOpen_triggered() } // Save last dir to remember it - QStringList topDir = Utils::Fs::fromNativePath(pathsList.at(0)).split("/"); + QStringList topDir = Utils::Fs::fromNativePath(pathsList.at(0)).split('/'); topDir.removeLast(); - pref->setMainLastDir(Utils::Fs::fromNativePath(topDir.join("/"))); + pref->setMainLastDir(Utils::Fs::fromNativePath(topDir.join('/'))); } } @@ -1538,7 +1534,7 @@ void MainWindow::updateGUI() #else // OSes such as Windows do not support html here QString html = tr("DL speed: %1", "e.g: Download speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadDownloadRate, true)); - html += "\n"; + html += '\n'; html += tr("UP speed: %1", "e.g: Upload speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadUploadRate, true)); #endif // Q_OS_UNIX m_systrayIcon->setToolTip(html); // tray icon @@ -1660,7 +1656,7 @@ void MainWindow::createTrayIcon() connect(m_systrayIcon.data(), &QSystemTrayIcon::activated, this, &MainWindow::toggleVisibility); m_systrayIcon->show(); } -#endif +#endif // Q_OS_MAC QMenu *MainWindow::trayIconMenu() { @@ -2006,7 +2002,7 @@ QIcon MainWindow::getSystrayIcon() const // As a failsafe in case the enum is invalid return QIcon(QLatin1String(":/icons/skin/qbittorrent-tray.svg")); } -#endif +#endif // Q_OS_MAC #if defined(Q_OS_WIN) || defined(Q_OS_MAC) void MainWindow::checkProgramUpdate() @@ -2102,4 +2098,4 @@ void MainWindow::pythonDownloadFailure(const QString &url, const QString &error) 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 diff --git a/src/gui/mainwindow.h b/src/gui/mainwindow.h index a06a049d1..08940d2a0 100644 --- a/src/gui/mainwindow.h +++ b/src/gui/mainwindow.h @@ -1,6 +1,6 @@ /* * Bittorrent Client using Qt and libtorrent. - * Copyright (C) 2006 Christophe Dumez + * Copyright (C) 2006 Christophe Dumez * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -24,8 +24,6 @@ * modify file(s), you may extend this exception to your version of the file(s), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : chris@qbittorrent.org */ #ifndef MAINWINDOW_H @@ -48,7 +46,7 @@ class QTimer; class DownloadFromURLDialog; class SearchWidget; class RSSWidget; -class about; +class AboutDialog; class OptionsDialog; class TransferListWidget; class TransferListFiltersWidget; @@ -70,7 +68,7 @@ namespace Ui class MainWindow; } -class MainWindow: public QMainWindow +class MainWindow : public QMainWindow { Q_OBJECT @@ -227,7 +225,7 @@ private: QPointer m_tabs; QPointer m_statusBar; QPointer m_options; - QPointer m_aboutDlg; + QPointer m_aboutDlg; QPointer m_statsDlg; QPointer m_createTorrentDlg; QPointer m_downloadFromURLDialog; diff --git a/src/gui/messageboxraised.cpp b/src/gui/messageboxraised.cpp index 902697628..a4a7a3779 100644 --- a/src/gui/messageboxraised.cpp +++ b/src/gui/messageboxraised.cpp @@ -1,6 +1,6 @@ /* - * Bittorrent Client using Qt4 and libtorrent. - * Copyright (C) 2014 sledgehammer999 + * Bittorrent Client using Qt and libtorrent. + * Copyright (C) 2014 sledgehammer999 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -24,40 +24,46 @@ * modify file(s), you may extend this exception to your version of the file(s), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : hammered999@gmail.com */ #include "messageboxraised.h" MessageBoxRaised::MessageBoxRaised(QMessageBox::Icon icon, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QWidget *parent, Qt::WindowFlags f) - : QMessageBox(icon, title, text, buttons, parent, f) {} + : QMessageBox(icon, title, text, buttons, parent, f) +{ +} -QMessageBox::StandardButton MessageBoxRaised::impl(const QMessageBox::Icon &icon, QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton) { - MessageBoxRaised dlg(icon, title, text, buttons, parent); - dlg.setDefaultButton(defaultButton); - return static_cast(dlg.exec()); +QMessageBox::StandardButton MessageBoxRaised::impl(const QMessageBox::Icon &icon, QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton) +{ + MessageBoxRaised dlg(icon, title, text, buttons, parent); + dlg.setDefaultButton(defaultButton); + return static_cast(dlg.exec()); } -QMessageBox::StandardButton MessageBoxRaised::critical(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton) { - return impl(Critical, parent, title, text, buttons, defaultButton); +QMessageBox::StandardButton MessageBoxRaised::critical(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton) +{ + return impl(Critical, parent, title, text, buttons, defaultButton); } -QMessageBox::StandardButton MessageBoxRaised::information(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton) { - return impl(Information, parent, title, text, buttons, defaultButton); +QMessageBox::StandardButton MessageBoxRaised::information(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton) +{ + return impl(Information, parent, title, text, buttons, defaultButton); } -QMessageBox::StandardButton MessageBoxRaised::question(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton) { - return impl(Question, parent, title, text, buttons, defaultButton); +QMessageBox::StandardButton MessageBoxRaised::question(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton) +{ + return impl(Question, parent, title, text, buttons, defaultButton); } -QMessageBox::StandardButton MessageBoxRaised::warning(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton) { - return impl(Warning, parent, title, text, buttons, defaultButton); +QMessageBox::StandardButton MessageBoxRaised::warning(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton) +{ + return impl(Warning, parent, title, text, buttons, defaultButton); } -void MessageBoxRaised::showEvent(QShowEvent *event) { - QMessageBox::showEvent(event); - activateWindow(); - raise(); +void MessageBoxRaised::showEvent(QShowEvent *event) +{ + QMessageBox::showEvent(event); + activateWindow(); + raise(); } diff --git a/src/gui/messageboxraised.h b/src/gui/messageboxraised.h index 7e12b93cc..b7bf3f7f2 100644 --- a/src/gui/messageboxraised.h +++ b/src/gui/messageboxraised.h @@ -1,6 +1,6 @@ /* - * Bittorrent Client using Qt4 and libtorrent. - * Copyright (C) 2014 sledgehammer999 + * Bittorrent Client using Qt and libtorrent. + * Copyright (C) 2014 sledgehammer999 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -24,8 +24,6 @@ * modify file(s), you may extend this exception to your version of the file(s), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : hammered999@gmail.com */ #ifndef MESSAGEBOXRAISED_H @@ -37,23 +35,22 @@ class MessageBoxRaised : public QMessageBox { Q_OBJECT -private: - MessageBoxRaised(QMessageBox::Icon icon, const QString &title, const QString &text, QMessageBox::StandardButtons buttons = NoButton, QWidget *parent = nullptr, Qt::WindowFlags f = Qt::Dialog|Qt::MSWindowsFixedSizeDialogHint); - MessageBoxRaised(); - MessageBoxRaised(MessageBoxRaised const&); - void operator=(MessageBoxRaised const&); - public: - static QMessageBox::StandardButton critical(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons = QMessageBox::Ok, QMessageBox::StandardButton defaultButton = QMessageBox::NoButton); - static QMessageBox::StandardButton information(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons = QMessageBox::Ok, QMessageBox::StandardButton defaultButton = QMessageBox::NoButton); - static QMessageBox::StandardButton question(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons = QMessageBox::Ok, QMessageBox::StandardButton defaultButton = QMessageBox::NoButton); - static QMessageBox::StandardButton warning(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons = QMessageBox::Ok, QMessageBox::StandardButton defaultButton = QMessageBox::NoButton); + static QMessageBox::StandardButton critical(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons = QMessageBox::Ok, QMessageBox::StandardButton defaultButton = QMessageBox::NoButton); + static QMessageBox::StandardButton information(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons = QMessageBox::Ok, QMessageBox::StandardButton defaultButton = QMessageBox::NoButton); + static QMessageBox::StandardButton question(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons = QMessageBox::Ok, QMessageBox::StandardButton defaultButton = QMessageBox::NoButton); + static QMessageBox::StandardButton warning(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons = QMessageBox::Ok, QMessageBox::StandardButton defaultButton = QMessageBox::NoButton); protected: - void showEvent(QShowEvent *event); + void showEvent(QShowEvent *event) override; private: - static QMessageBox::StandardButton impl(const QMessageBox::Icon &icon, QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons = QMessageBox::Ok, QMessageBox::StandardButton defaultButton = QMessageBox::NoButton); + MessageBoxRaised(QMessageBox::Icon icon, const QString &title, const QString &text, QMessageBox::StandardButtons buttons = NoButton, QWidget *parent = nullptr, Qt::WindowFlags f = Qt::Dialog|Qt::MSWindowsFixedSizeDialogHint); + MessageBoxRaised(); + MessageBoxRaised(MessageBoxRaised const&); + void operator=(MessageBoxRaised const&); + + static QMessageBox::StandardButton impl(const QMessageBox::Icon &icon, QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons = QMessageBox::Ok, QMessageBox::StandardButton defaultButton = QMessageBox::NoButton); }; #endif // MESSAGEBOXRAISED_H diff --git a/src/gui/optionsdlg.cpp b/src/gui/optionsdlg.cpp index 323aae22f..b2bf4c3f9 100644 --- a/src/gui/optionsdlg.cpp +++ b/src/gui/optionsdlg.cpp @@ -1,6 +1,6 @@ /* - * Bittorrent Client using Qt4 and libtorrent. - * Copyright (C) 2006 Christophe Dumez + * Bittorrent Client using Qt and libtorrent. + * Copyright (C) 2006 Christophe Dumez * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -24,8 +24,6 @@ * modify file(s), you may extend this exception to your version of the file(s), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : chris@qbittorrent.org */ #include "optionsdlg.h" @@ -49,7 +47,6 @@ #include #endif -#include "app/application.h" #include "base/bittorrent/session.h" #include "base/global.h" #include "base/net/dnsupdater.h" @@ -65,10 +62,11 @@ #include "base/utils/random.h" #include "addnewtorrentdialog.h" #include "advancedsettings.h" -#include "rss/automatedrssdownloader.h" +#include "app/application.h" #include "banlistoptions.h" #include "ipsubnetwhitelistoptionsdialog.h" #include "guiiconprovider.h" +#include "rss/automatedrssdownloader.h" #include "scanfoldersdelegate.h" #include "utils.h" @@ -401,7 +399,7 @@ OptionsDialog::OptionsDialog(QWidget *parent) connect(m_ui->DNSPasswordTxt, &QLineEdit::textChanged, this, &ThisType::enableApplyButton); connect(m_ui->groupAltWebUI, &QGroupBox::toggled, this, &ThisType::enableApplyButton); connect(m_ui->textWebUIRootFolder, &FileSystemPathLineEdit::selectedPathChanged, this, &ThisType::enableApplyButton); -#endif +#endif // DISABLE_WEBUI // RSS tab connect(m_ui->checkRSSEnable, &QCheckBox::toggled, this, &OptionsDialog::enableApplyButton); @@ -514,7 +512,7 @@ void OptionsDialog::loadSplitterState() void OptionsDialog::saveWindowState() const { - Preferences* const pref = Preferences::instance(); + Preferences *const pref = Preferences::instance(); // window size pref->setPrefSize(size()); @@ -529,7 +527,7 @@ void OptionsDialog::saveWindowState() const void OptionsDialog::saveOptions() { applyButton->setEnabled(false); - Preferences* const pref = Preferences::instance(); + Preferences *const pref = Preferences::instance(); // Load the translation QString locale = getLocale(); if (pref->getLocale() != locale) { @@ -576,7 +574,7 @@ void OptionsDialog::saveOptions() m_ui->checkAssociateMagnetLinks->setEnabled(!m_ui->checkAssociateMagnetLinks->isChecked()); } #endif - Application * const app = static_cast(QCoreApplication::instance()); + Application *const app = static_cast(QCoreApplication::instance()); app->setFileLoggerPath(m_ui->textFileLogPath->selectedPath()); app->setFileLoggerBackup(m_ui->checkFileLogBackup->isChecked()); app->setFileLoggerMaxSize(m_ui->spinFileLogSize->value() * 1024); @@ -652,7 +650,7 @@ void OptionsDialog::saveOptions() pref->setSchedulerDays(static_cast(m_ui->schedule_days->currentIndex())); session->setBandwidthSchedulerEnabled(m_ui->check_schedule->isChecked()); - auto proxyConfigManager = Net::ProxyConfigurationManager::instance(); + auto proxyConfigManager = Net::ProxyConfigurationManager::instance(); Net::ProxyConfiguration proxyConf; proxyConf.type = getProxyType(); proxyConf.ip = getProxyIp(); @@ -769,7 +767,7 @@ void OptionsDialog::loadOptions() QString strValue; bool fileLogBackup = true; bool fileLogDelete = true; - const Preferences* const pref = Preferences::instance(); + const Preferences *const pref = Preferences::instance(); // General preferences setLocale(pref->getLocale()); @@ -807,7 +805,7 @@ void OptionsDialog::loadOptions() m_ui->checkAssociateMagnetLinks->setEnabled(!m_ui->checkAssociateMagnetLinks->isChecked()); #endif - const Application * const app = static_cast(QCoreApplication::instance()); + const Application *const app = static_cast(QCoreApplication::instance()); m_ui->checkFileLog->setChecked(app->isFileLoggerEnabled()); m_ui->textFileLogPath->setSelectedPath(app->fileLoggerPath()); fileLogBackup = app->isFileLoggerBackup(); @@ -1237,7 +1235,7 @@ bool OptionsDialog::closeToTray() const if (!m_ui->checkShowSystray->isChecked()) return false; return m_ui->checkCloseToSystray->isChecked(); } -#endif +#endif // Q_OS_MAC // Return Share ratio qreal OptionsDialog::getMaxRatio() const @@ -1307,7 +1305,7 @@ void OptionsDialog::on_buttonBox_accepted() accept(); } -void OptionsDialog::applySettings(QAbstractButton* button) +void OptionsDialog::applySettings(QAbstractButton *button) { if (button == applyButton) { if (!schedTimesOk()) { @@ -1524,7 +1522,7 @@ int OptionsDialog::getActionOnDblClOnTorrentFn() const void OptionsDialog::on_addScanFolderButton_clicked() { - Preferences* const pref = Preferences::instance(); + Preferences *const pref = Preferences::instance(); const QString dir = QFileDialog::getExistingDirectory(this, tr("Select folder to monitor"), Utils::Fs::toNativePath(Utils::Fs::folderName(pref->getScanDirsLastPath()))); if (!dir.isEmpty()) { @@ -1572,7 +1570,7 @@ void OptionsDialog::handleScanFolderViewSelectionChanged() m_ui->removeScanFolderButton->setEnabled(!m_ui->scanFoldersView->selectionModel()->selectedIndexes().isEmpty()); } -QString OptionsDialog::askForExportDir(const QString& currentExportPath) +QString OptionsDialog::askForExportDir(const QString ¤tExportPath) { QDir currentExportDir(Utils::Fs::expandPathAbs(currentExportPath)); QString dir; @@ -1733,15 +1731,14 @@ QString OptionsDialog::languageToLocalizedString(const QLocale &locale) return QString::fromUtf8(C_LOCALE_CHINESE_TRADITIONAL_HK); default: return QString::fromUtf8(C_LOCALE_CHINESE_TRADITIONAL_TW); - } } case QLocale::Korean: return QString::fromUtf8(C_LOCALE_KOREAN); default: { // Fallback to English - const QString eng_lang = QLocale::languageToString(locale.language()); - qWarning() << "Unrecognized language name: " << eng_lang; - return eng_lang; + const QString engLang = QLocale::languageToString(locale.language()); + qWarning() << "Unrecognized language name: " << engLang; + return engLang; } } } diff --git a/src/gui/optionsdlg.h b/src/gui/optionsdlg.h index a9ca71217..9cab3b5d1 100644 --- a/src/gui/optionsdlg.h +++ b/src/gui/optionsdlg.h @@ -1,6 +1,6 @@ /* - * Bittorrent Client using Qt4 and libtorrent. - * Copyright (C) 2006 Christophe Dumez + * Bittorrent Client using Qt and libtorrent. + * Copyright (C) 2006 Christophe Dumez * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -24,8 +24,6 @@ * modify file(s), you may extend this exception to your version of the file(s), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : chris@qbittorrent.org */ #ifndef OPTIONSDLG_H @@ -57,7 +55,7 @@ namespace Ui class OptionsDialog; } -class OptionsDialog: public QDialog +class OptionsDialog : public QDialog { Q_OBJECT using ThisType = OptionsDialog; @@ -87,7 +85,7 @@ private slots: void enableForceProxy(bool enable); void enableProxy(int index); void on_buttonBox_accepted(); - void closeEvent(QCloseEvent *e); + void closeEvent(QCloseEvent *e) override; void on_buttonBox_rejected(); void applySettings(QAbstractButton *button); void enableApplyButton(); @@ -188,4 +186,4 @@ private: QList removedScanDirs; }; -#endif +#endif // OPTIONSDLG_H diff --git a/src/gui/previewlistdelegate.h b/src/gui/previewlistdelegate.h index baa469d30..f26090c49 100644 --- a/src/gui/previewlistdelegate.h +++ b/src/gui/previewlistdelegate.h @@ -33,11 +33,12 @@ #include #include #include +#include +#include + #ifdef Q_OS_WIN #include #endif -#include -#include #include "base/utils/misc.h" #include "base/utils/string.h" diff --git a/src/gui/programupdater.cpp b/src/gui/programupdater.cpp index 2d39cd984..0e0f69560 100644 --- a/src/gui/programupdater.cpp +++ b/src/gui/programupdater.cpp @@ -1,5 +1,5 @@ /* - * Bittorrent Client using Qt4 and libtorrent. + * Bittorrent Client using Qt and libtorrent. * Copyright (C) 2010 Christophe Dumez * * This program is free software; you can redistribute it and/or diff --git a/src/gui/programupdater.h b/src/gui/programupdater.h index e24641d28..34b8e1762 100644 --- a/src/gui/programupdater.h +++ b/src/gui/programupdater.h @@ -1,6 +1,6 @@ /* - * Bittorrent Client using Qt4 and libtorrent. - * Copyright (C) 2010 Christophe Dumez + * Bittorrent Client using Qt and libtorrent. + * Copyright (C) 2010 Christophe Dumez * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -24,8 +24,6 @@ * modify file(s), you may extend this exception to your version of the file(s), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : chris@qbittorrent.org */ #ifndef PROGRAMUPDATER_H @@ -34,7 +32,7 @@ #include #include -class ProgramUpdater: public QObject +class ProgramUpdater : public QObject { Q_OBJECT diff --git a/src/gui/properties/downloadedpiecesbar.cpp b/src/gui/properties/downloadedpiecesbar.cpp index 44625010c..896ce5f57 100644 --- a/src/gui/properties/downloadedpiecesbar.cpp +++ b/src/gui/properties/downloadedpiecesbar.cpp @@ -101,7 +101,7 @@ QVector DownloadedPiecesBar::bitfieldToFloatVector(const QBitArray &vecin // normalization <0, 1> value /= ratio; - // float precision sometimes gives > 1, because in not possible to store irrational numbers + // float precision sometimes gives > 1, because it's not possible to store irrational numbers value = qMin(value, 1.0f); result[x] = value; diff --git a/src/gui/properties/peerlistsortmodel.h b/src/gui/properties/peerlistsortmodel.h index 83c4f715e..c6fccbb9c 100644 --- a/src/gui/properties/peerlistsortmodel.h +++ b/src/gui/properties/peerlistsortmodel.h @@ -54,7 +54,7 @@ protected: const QString strR = right.data().toString(); const int result = Utils::String::naturalCompare(strL, strR, Qt::CaseInsensitive); return (result < 0); - } + } break; default: return QSortFilterProxyModel::lessThan(left, right); diff --git a/src/gui/properties/peerlistwidget.cpp b/src/gui/properties/peerlistwidget.cpp index e897b4aaf..58c95bd1a 100644 --- a/src/gui/properties/peerlistwidget.cpp +++ b/src/gui/properties/peerlistwidget.cpp @@ -303,12 +303,12 @@ void PeerListWidget::copySelectedPeers() int row = m_proxyModel->mapToSource(index).row(); QString ip = m_listModel->data(m_listModel->index(row, PeerListDelegate::IP_HIDDEN)).toString(); QString myport = m_listModel->data(m_listModel->index(row, PeerListDelegate::PORT)).toString(); - if (ip.indexOf(".") == -1) // IPv6 + if (ip.indexOf('.') == -1) // IPv6 selectedPeers << "[" + ip + "]:" + myport; else // IPv4 selectedPeers << ip + ":" + myport; } - QApplication::clipboard()->setText(selectedPeers.join("\n")); + QApplication::clipboard()->setText(selectedPeers.join('\n')); } void PeerListWidget::clear() @@ -339,7 +339,7 @@ void PeerListWidget::loadPeers(BitTorrent::TorrentHandle *const torrent, bool fo if (!torrent) return; QList peers = torrent->peers(); - QSet oldeersSet = m_peerItems.keys().toSet(); + QSet oldPeersSet = m_peerItems.keys().toSet(); foreach (const BitTorrent::PeerInfo &peer, peers) { BitTorrent::PeerAddress addr = peer.address(); @@ -349,7 +349,7 @@ void PeerListWidget::loadPeers(BitTorrent::TorrentHandle *const torrent, bool fo if (m_peerItems.contains(peerIp)) { // Update existing peer updatePeer(peerIp, torrent, peer); - oldeersSet.remove(peerIp); + oldPeersSet.remove(peerIp); if (forceHostnameResolution && m_resolver) m_resolver->resolve(peerIp); } @@ -363,7 +363,7 @@ void PeerListWidget::loadPeers(BitTorrent::TorrentHandle *const torrent, bool fo } } // Delete peers that are gone - QSetIterator it(oldeersSet); + QSetIterator it(oldPeersSet); while (it.hasNext()) { const QString &ip = it.next(); m_missingFlags.remove(ip); diff --git a/src/gui/properties/peersadditiondlg.cpp b/src/gui/properties/peersadditiondlg.cpp index e1a0609ed..f735b26f9 100644 --- a/src/gui/properties/peersadditiondlg.cpp +++ b/src/gui/properties/peersadditiondlg.cpp @@ -61,7 +61,7 @@ void PeersAdditionDlg::validateInput() QMessageBox::Ok); return; } - foreach (const QString &peer, m_ui->peers_txt->toPlainText().trimmed().split("\n")) { + foreach (const QString &peer, m_ui->peers_txt->toPlainText().trimmed().split('\n')) { BitTorrent::PeerAddress addr = parsePeer(peer); if (!addr.ip.isNull()) { m_peersList.append(addr); @@ -82,10 +82,10 @@ BitTorrent::PeerAddress PeersAdditionDlg::parsePeer(QString peer) BitTorrent::PeerAddress addr; QStringList ipPort; - if (peer[0] == '[' && peer.indexOf("]:") != -1) // IPv6 + if ((peer[0] == '[') && (peer.indexOf("]:") != -1)) // IPv6 ipPort = peer.remove(QChar('[')).split("]:"); - else if (peer.indexOf(":") != -1) // IPv4 - ipPort = peer.split(":"); + else if (peer.indexOf(':') != -1) // IPv4 + ipPort = peer.split(':'); else return addr; @@ -95,7 +95,7 @@ BitTorrent::PeerAddress PeersAdditionDlg::parsePeer(QString peer) bool ok; int port = ipPort[1].toInt(&ok); - if (!ok || port < 1 || port > 65535) + if (!ok || (port < 1) || (port > 65535)) return addr; addr.ip = ip; diff --git a/src/gui/properties/pieceavailabilitybar.cpp b/src/gui/properties/pieceavailabilitybar.cpp index 38a4a6666..dd6411348 100644 --- a/src/gui/properties/pieceavailabilitybar.cpp +++ b/src/gui/properties/pieceavailabilitybar.cpp @@ -109,7 +109,7 @@ QVector PieceAvailabilityBar::intToFloatVector(const QVector &vecin, // normalization <0, 1> value /= ratio * maxElement; - // float precision sometimes gives > 1, because in not possible to store irrational numbers + // float precision sometimes gives > 1, because it's not possible to store irrational numbers value = qMin(value, 1.0f); result[x] = value; diff --git a/src/gui/properties/piecesbar.cpp b/src/gui/properties/piecesbar.cpp index f495f82c1..75298d054 100644 --- a/src/gui/properties/piecesbar.cpp +++ b/src/gui/properties/piecesbar.cpp @@ -50,7 +50,7 @@ namespace { public: PieceIndexToImagePos(const BitTorrent::TorrentInfo &torrentInfo, const QImage &image) - : m_bytesPerPixel {(image.width() > 0 && torrentInfo.totalSize() >= image.width()) + : m_bytesPerPixel {((image.width() > 0) && (torrentInfo.totalSize() >= image.width())) ? torrentInfo.totalSize() / image.width() : -1} , m_torrentInfo {torrentInfo} { diff --git a/src/gui/properties/propertieswidget.cpp b/src/gui/properties/propertieswidget.cpp index df49c23e6..500c3e403 100644 --- a/src/gui/properties/propertieswidget.cpp +++ b/src/gui/properties/propertieswidget.cpp @@ -357,7 +357,7 @@ void PropertiesWidget::readSettings() { const Preferences *const pref = Preferences::instance(); // Restore splitter sizes - QStringList sizesStr = pref->getPropSplitterSizes().split(","); + QStringList sizesStr = pref->getPropSplitterSizes().split(','); if (sizesStr.size() == 2) { m_slideSizes << sizesStr.first().toInt(); m_slideSizes << sizesStr.last().toInt(); @@ -561,7 +561,7 @@ void PropertiesWidget::openFolder(const QModelIndex &index, bool containingFolde if (pathItems.isEmpty()) return; const QDir saveDir(m_torrent->savePath(true)); - const QString relativePath = pathItems.join("/"); + const QString relativePath = pathItems.join('/'); absolutePath = Utils::Fs::expandPath(saveDir.absoluteFilePath(relativePath)); } else { @@ -743,15 +743,15 @@ void PropertiesWidget::renameSelectedFile() pathItems.prepend(parent.data().toString()); parent = m_propListModel->parent(parent); } - const QString oldPath = pathItems.join("/"); + const QString oldPath = pathItems.join('/'); pathItems.removeLast(); pathItems << newName; - QString newPath = pathItems.join("/"); + QString newPath = pathItems.join('/'); if (Utils::Fs::sameFileNames(oldPath, newPath)) { qDebug("Name did not change"); return; } - if (!newPath.endsWith("/")) newPath += "/"; + if (!newPath.endsWith('/')) newPath += '/'; // Check for overwriting for (int i = 0; i < m_torrent->filesCount(); ++i) { const QString ¤tName = m_torrent->filePath(i); @@ -785,9 +785,9 @@ void PropertiesWidget::renameSelectedFile() // Rename folder in torrent files model too m_propListModel->setData(modelIndex, newName); // Remove old folder - const QDir oldFolder(m_torrent->savePath(true) + "/" + oldPath); + const QDir oldFolder(m_torrent->savePath(true) + '/' + oldPath); int timeout = 10; - while (!QDir().rmpath(oldFolder.absolutePath()) && timeout > 0) { + while (!QDir().rmpath(oldFolder.absolutePath()) && (timeout > 0)) { // FIXME: We should not sleep here (freezes the UI for 1 second) QThread::msleep(100); --timeout; @@ -847,7 +847,7 @@ void PropertiesWidget::copySelectedWebSeedsToClipboard() const foreach (QListWidgetItem *item, selectedItems) urlsToCopy << item->text(); - QApplication::clipboard()->setText(urlsToCopy.join("\n")); + QApplication::clipboard()->setText(urlsToCopy.join('\n')); } void PropertiesWidget::editWebSeed() diff --git a/src/gui/properties/speedplotview.cpp b/src/gui/properties/speedplotview.cpp index b1348fa51..f00cd0e91 100644 --- a/src/gui/properties/speedplotview.cpp +++ b/src/gui/properties/speedplotview.cpp @@ -161,7 +161,7 @@ int SpeedPlotView::maxYValue() if (!m_properties[static_cast(id)].enable) continue; - for (int i = int(queue.size()) - 1, j = 0; i >= 0 && j <= m_viewablePointsCount; --i, ++j) + for (int i = static_cast(queue.size()) - 1, j = 0; (i >= 0) && (j <= m_viewablePointsCount); --i, ++j) if (queue[i].y[id] > maxYValue) maxYValue = queue[i].y[id]; } @@ -241,7 +241,7 @@ void SpeedPlotView::paintEvent(QPaintEvent *) continue; QVector points; - for (int i = int(queue.size()) - 1, j = 0; i >= 0 && j <= m_viewablePointsCount; --i, ++j) { + for (int i = static_cast(queue.size()) - 1, j = 0; (i >= 0) && (j <= m_viewablePointsCount); --i, ++j) { int newX = rect.right() - j * xTickSize; int newY = rect.bottom() - queue[i].y[id] * yMultiplier; diff --git a/src/gui/properties/speedwidget.h b/src/gui/properties/speedwidget.h index b82177042..f4d5fb170 100644 --- a/src/gui/properties/speedwidget.h +++ b/src/gui/properties/speedwidget.h @@ -47,7 +47,7 @@ class ComboBoxMenuButton : public QComboBox public: ComboBoxMenuButton(QWidget *parent, QMenu *menu); - virtual void showPopup(); + void showPopup() override; private: QMenu *m_menu; diff --git a/src/gui/properties/trackerlist.cpp b/src/gui/properties/trackerlist.cpp index 8d66d4b62..92378837e 100644 --- a/src/gui/properties/trackerlist.cpp +++ b/src/gui/properties/trackerlist.cpp @@ -411,7 +411,7 @@ void TrackerList::copyTrackerUrl() qDebug() << QString("Copy: ") + trackerURL; urlsToCopy << trackerURL; } - QApplication::clipboard()->setText(urlsToCopy.join("\n")); + QApplication::clipboard()->setText(urlsToCopy.join('\n')); } diff --git a/src/gui/properties/trackersadditiondlg.cpp b/src/gui/properties/trackersadditiondlg.cpp index 9ec5c53fb..546254baf 100644 --- a/src/gui/properties/trackersadditiondlg.cpp +++ b/src/gui/properties/trackersadditiondlg.cpp @@ -59,7 +59,7 @@ TrackersAdditionDlg::~TrackersAdditionDlg() QStringList TrackersAdditionDlg::newTrackers() const { QStringList cleanTrackers; - foreach (QString url, m_ui->trackers_list->toPlainText().split("\n")) { + foreach (QString url, m_ui->trackers_list->toPlainText().split('\n')) { url = url.trimmed(); if (!url.isEmpty()) cleanTrackers << url; @@ -92,7 +92,7 @@ void TrackersAdditionDlg::parseUTorrentList(const QString &, const QString &path // Load from torrent handle QList existingTrackers = m_torrent->trackers(); // Load from current user list - QStringList tmp = m_ui->trackers_list->toPlainText().split("\n"); + QStringList tmp = m_ui->trackers_list->toPlainText().split('\n'); foreach (const QString &userURL, tmp) { BitTorrent::TrackerEntry userTracker(userURL); if (!existingTrackers.contains(userTracker)) @@ -100,7 +100,7 @@ void TrackersAdditionDlg::parseUTorrentList(const QString &, const QString &path } // Add new trackers to the list - if (!m_ui->trackers_list->toPlainText().isEmpty() && !m_ui->trackers_list->toPlainText().endsWith("\n")) + if (!m_ui->trackers_list->toPlainText().isEmpty() && !m_ui->trackers_list->toPlainText().endsWith('\n')) m_ui->trackers_list->insertPlainText("\n"); int nb = 0; while (!listFile.atEnd()) { @@ -108,7 +108,7 @@ void TrackersAdditionDlg::parseUTorrentList(const QString &, const QString &path if (line.isEmpty()) continue; BitTorrent::TrackerEntry newTracker(line); if (!existingTrackers.contains(newTracker)) { - m_ui->trackers_list->insertPlainText(line + "\n"); + m_ui->trackers_list->insertPlainText(line + '\n'); ++nb; } } @@ -125,7 +125,7 @@ void TrackersAdditionDlg::parseUTorrentList(const QString &, const QString &path void TrackersAdditionDlg::getTrackerError(const QString &, const QString &error) { - //To restore the cursor ... + // To restore the cursor ... setCursor(Qt::ArrowCursor); m_ui->uTorrentListButton->setEnabled(true); QMessageBox::warning(this, tr("Download error"), tr("The trackers list could not be downloaded, reason: %1").arg(error), QMessageBox::Ok); diff --git a/src/gui/scanfoldersdelegate.cpp b/src/gui/scanfoldersdelegate.cpp index f7b10ec26..cecee102e 100644 --- a/src/gui/scanfoldersdelegate.cpp +++ b/src/gui/scanfoldersdelegate.cpp @@ -1,6 +1,6 @@ /* * Bittorrent Client using Qt and libtorrent. - * Copyright (C) 2015 sledgehammer999 + * Copyright (C) 2015 sledgehammer999 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -24,21 +24,19 @@ * modify file(s), you may extend this exception to your version of the file(s), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : hammered999@gmail.com */ -#include -#include +#include "scanfoldersdelegate.h" + #include +#include #include -#include #include +#include +#include -#include "base/scanfoldersmodel.h" #include "base/bittorrent/session.h" -#include "scanfoldersdelegate.h" - +#include "base/scanfoldersmodel.h" ScanFoldersDelegate::ScanFoldersDelegate(QObject *parent, QTreeView *foldersView) : QItemDelegate(parent) @@ -60,7 +58,7 @@ QWidget *ScanFoldersDelegate::createEditor(QWidget *parent, const QStyleOptionVi { if (index.column() != ScanFoldersModel::DOWNLOAD) return 0; - QComboBox* editor = new QComboBox(parent); + QComboBox *editor = new QComboBox(parent); editor->setFocusPolicy(Qt::StrongFocus); editor->addItem(ScanFoldersModel::pathTypeDisplayName(ScanFoldersModel::DOWNLOAD_IN_WATCH_FOLDER)); diff --git a/src/gui/scanfoldersdelegate.h b/src/gui/scanfoldersdelegate.h index c9b1af98b..5a925dc32 100644 --- a/src/gui/scanfoldersdelegate.h +++ b/src/gui/scanfoldersdelegate.h @@ -1,6 +1,6 @@ /* * Bittorrent Client using Qt and libtorrent. - * Copyright (C) 2015 sledgehammer999 + * Copyright (C) 2015 sledgehammer999 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -24,8 +24,6 @@ * modify file(s), you may extend this exception to your version of the file(s), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : hammered999@gmail.com */ #ifndef SCANFOLDERSDELEGATE_H @@ -33,12 +31,12 @@ #include -class QPainter; +class QAbstractItemModel; class QModelIndex; +class QPainter; class QStyleOptionViewItem; -class QAbstractItemModel; -class PropertiesWidget; class QTreeView; +class PropertiesWidget; class ScanFoldersDelegate : public QItemDelegate { @@ -51,13 +49,12 @@ private slots: void comboboxIndexChanged(int index); private: - void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const; - void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &) const; - void setEditorData(QWidget *editor, const QModelIndex &index) const; - QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &index) const; + void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override; + void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &) const override; + void setEditorData(QWidget *editor, const QModelIndex &index) const override; + QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &index) const override; QTreeView *m_folderView; }; #endif // SCANFOLDERSDELEGATE_H - diff --git a/src/gui/shutdownconfirmdlg.cpp b/src/gui/shutdownconfirmdlg.cpp index 0cccc3f7a..ac129b115 100644 --- a/src/gui/shutdownconfirmdlg.cpp +++ b/src/gui/shutdownconfirmdlg.cpp @@ -131,12 +131,12 @@ void ShutdownConfirmDlg::initText() break; } - m_msg += "\n"; + m_msg += '\n'; updateText(); } void ShutdownConfirmDlg::updateText() { - QString t = tr("You can cancel the action within %1 seconds.").arg(QString::number(m_timeout)) + "\n"; + QString t = tr("You can cancel the action within %1 seconds.").arg(QString::number(m_timeout)) + '\n'; m_ui->shutdownText->setText(m_msg + t); } diff --git a/src/gui/speedlimitdlg.cpp b/src/gui/speedlimitdlg.cpp index 9f93dc396..02cc0ff7b 100644 --- a/src/gui/speedlimitdlg.cpp +++ b/src/gui/speedlimitdlg.cpp @@ -54,17 +54,17 @@ SpeedLimitDialog::~SpeedLimitDialog() } // -2: if cancel -long SpeedLimitDialog::askSpeedLimit(QWidget *parent, bool *ok, QString title, long default_value, long max_value) +long SpeedLimitDialog::askSpeedLimit(QWidget *parent, bool *ok, QString title, long defaultVal, long maxVal) { SpeedLimitDialog dlg(parent); dlg.setWindowTitle(title); - dlg.setupDialog(max_value / 1024., default_value / 1024.); + dlg.setupDialog(maxVal / 1024., defaultVal / 1024.); if (dlg.exec() == QDialog::Accepted) { *ok = true; int val = dlg.getSpeedLimit(); if (val <= 0) return 0; - return val * 1024; + return (val * 1024); } else { *ok = false; @@ -82,7 +82,7 @@ void SpeedLimitDialog::updateSpinValue(int val) const } else { m_ui->spinBandwidth->setValue(val); - m_ui->spinBandwidth->setSuffix(" " + tr("KiB/s")); + m_ui->spinBandwidth->setSuffix(' ' + tr("KiB/s")); } } @@ -106,17 +106,17 @@ long SpeedLimitDialog::getSpeedLimit() const return -1; } -void SpeedLimitDialog::setupDialog(long max_slider, long val) const +void SpeedLimitDialog::setupDialog(long maxSlider, long val) const { if (val < 0) val = 0; - if (max_slider <= 0) - max_slider = 10000; + if (maxSlider <= 0) + maxSlider = 10000; // This can happen for example if global rate limit is lower // than torrent rate limit. - if (val > max_slider) - max_slider = val; - m_ui->bandwidthSlider->setMaximum(max_slider); + if (val > maxSlider) + maxSlider = val; + m_ui->bandwidthSlider->setMaximum(maxSlider); m_ui->bandwidthSlider->setValue(val); updateSpinValue(val); } diff --git a/src/gui/speedlimitdlg.h b/src/gui/speedlimitdlg.h index 222e5ccc0..285285593 100644 --- a/src/gui/speedlimitdlg.h +++ b/src/gui/speedlimitdlg.h @@ -47,12 +47,12 @@ class SpeedLimitDialog : public QDialog public: explicit SpeedLimitDialog(QWidget *parent); ~SpeedLimitDialog(); - static long askSpeedLimit(QWidget *parent, bool *ok, QString title, long default_value, long max_value=10240000); + static long askSpeedLimit(QWidget *parent, bool *ok, QString title, long defaultVal, long maxVal=10240000); protected slots: void updateSpinValue(int val) const; void updateSliderValue(int val) const; - void setupDialog(long max_slider, long val) const; + void setupDialog(long maxSlider, long val) const; private: long getSpeedLimit() const; diff --git a/src/gui/statsdialog.h b/src/gui/statsdialog.h index 22652ebda..19670754c 100644 --- a/src/gui/statsdialog.h +++ b/src/gui/statsdialog.h @@ -36,7 +36,7 @@ namespace Ui class StatsDialog; } -class StatsDialog: public QDialog +class StatsDialog : public QDialog { Q_OBJECT diff --git a/src/gui/statusbar.h b/src/gui/statusbar.h index 5fe8db8bc..c86c3b3fd 100644 --- a/src/gui/statusbar.h +++ b/src/gui/statusbar.h @@ -39,7 +39,7 @@ namespace BitTorrent struct SessionStatus; } -class StatusBar: public QStatusBar +class StatusBar : public QStatusBar { Q_OBJECT Q_DISABLE_COPY(StatusBar) diff --git a/src/gui/tagfiltermodel.cpp b/src/gui/tagfiltermodel.cpp index 5d9f81bd3..b27161b25 100644 --- a/src/gui/tagfiltermodel.cpp +++ b/src/gui/tagfiltermodel.cpp @@ -113,7 +113,7 @@ bool TagFilterModel::isSpecialItem(const QModelIndex &index) QVariant TagFilterModel::data(const QModelIndex &index, int role) const { - if (!index.isValid() || index.column() != 0) + if (!index.isValid() || (index.column() != 0)) return QVariant(); const int row = index.internalId(); @@ -214,7 +214,7 @@ void TagFilterModel::torrentTagAdded(BitTorrent::TorrentHandle *const torrent, c emit dataChanged(i, i); } -void TagFilterModel::torrentTagRemoved(BitTorrent::TorrentHandle* const torrent, const QString &tag) +void TagFilterModel::torrentTagRemoved(BitTorrent::TorrentHandle *const torrent, const QString &tag) { Q_ASSERT(torrent->tags().count() >= 0); if (torrent->tags().count() == 0) diff --git a/src/gui/tagfiltermodel.h b/src/gui/tagfiltermodel.h index f2f3cc67a..8dbea520d 100644 --- a/src/gui/tagfiltermodel.h +++ b/src/gui/tagfiltermodel.h @@ -42,7 +42,7 @@ namespace BitTorrent class TagModelItem; -class TagFilterModel: public QAbstractListModel +class TagFilterModel : public QAbstractListModel { Q_OBJECT diff --git a/src/gui/tagfilterproxymodel.h b/src/gui/tagfilterproxymodel.h index 60e4174df..6bb83f457 100644 --- a/src/gui/tagfilterproxymodel.h +++ b/src/gui/tagfilterproxymodel.h @@ -32,7 +32,7 @@ #include #include -class TagFilterProxyModel: public QSortFilterProxyModel +class TagFilterProxyModel : public QSortFilterProxyModel { public: explicit TagFilterProxyModel(QObject *parent = nullptr); diff --git a/src/gui/tagfilterwidget.h b/src/gui/tagfilterwidget.h index c24b0d34f..a8e2a6ee8 100644 --- a/src/gui/tagfilterwidget.h +++ b/src/gui/tagfilterwidget.h @@ -31,7 +31,7 @@ #include -class TagFilterWidget: public QTreeView +class TagFilterWidget : public QTreeView { Q_OBJECT diff --git a/src/gui/torrentcontentfiltermodel.h b/src/gui/torrentcontentfiltermodel.h index db7aa1bcf..e79d94cae 100644 --- a/src/gui/torrentcontentfiltermodel.h +++ b/src/gui/torrentcontentfiltermodel.h @@ -35,7 +35,7 @@ class TorrentContentModel; -class TorrentContentFilterModel: public QSortFilterProxyModel +class TorrentContentFilterModel : public QSortFilterProxyModel { Q_OBJECT @@ -46,7 +46,7 @@ public: TorrentContentModel *model() const; TorrentContentModelItem::ItemType itemType(const QModelIndex &index) const; int getFileIndex(const QModelIndex &index) const; - virtual QModelIndex parent(const QModelIndex &child) const; + QModelIndex parent(const QModelIndex &child) const override; public slots: void selectAll(); @@ -56,8 +56,8 @@ signals: void filteredFilesChanged(); protected: - virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; - virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const; + bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override; + bool lessThan(const QModelIndex &left, const QModelIndex &right) const override; private: TorrentContentModel *m_model; diff --git a/src/gui/torrentcontentmodel.cpp b/src/gui/torrentcontentmodel.cpp index 94b2fead6..bdf253918 100644 --- a/src/gui/torrentcontentmodel.cpp +++ b/src/gui/torrentcontentmodel.cpp @@ -1,6 +1,6 @@ /* - * Bittorrent Client using Qt4 and libtorrent. - * Copyright (C) 2006-2012 Christophe Dumez + * Bittorrent Client using Qt and libtorrent. + * Copyright (C) 2006-2012 Christophe Dumez * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -24,8 +24,6 @@ * modify file(s), you may extend this exception to your version of the file(s), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : chris@qbittorrent.org */ #include @@ -48,13 +46,14 @@ #include #endif -#include "guiiconprovider.h" #include "base/utils/misc.h" #include "base/utils/fs.h" +#include "guiiconprovider.h" #include "torrentcontentmodel.h" -#include "torrentcontentmodelitem.h" -#include "torrentcontentmodelfolder.h" #include "torrentcontentmodelfile.h" +#include "torrentcontentmodelfolder.h" +#include "torrentcontentmodelitem.h" + #ifdef Q_OS_MAC #include "macutilities.h" #endif @@ -67,7 +66,7 @@ namespace return cached; } - class UnifiedFileIconProvider: public QFileIconProvider + class UnifiedFileIconProvider : public QFileIconProvider { public: using QFileIconProvider::icon; @@ -99,7 +98,7 @@ namespace PixmapCacheSetup pixmapCacheSetup; - class CachingFileIconProvider: public UnifiedFileIconProvider + class CachingFileIconProvider : public UnifiedFileIconProvider { public: using QFileIconProvider::icon; @@ -123,11 +122,11 @@ namespace protected: virtual QPixmap pixmapForExtension(const QString &ext) const = 0; }; -#endif +#endif // QBT_PIXMAP_CACHE_FOR_FILE_ICONS #if defined(Q_OS_WIN) // See QTBUG-25319 for explanation why this is required - class WinShellFileIconProvider final: public CachingFileIconProvider + class WinShellFileIconProvider final : public CachingFileIconProvider { QPixmap pixmapForExtension(const QString &ext) const override { @@ -174,7 +173,7 @@ namespace return (!testIcon1.isNull() || !testIcon2.isNull()); } - class MimeFileIconProvider: public UnifiedFileIconProvider + class MimeFileIconProvider : public UnifiedFileIconProvider { using QFileIconProvider::icon; @@ -197,7 +196,7 @@ namespace private: QMimeDatabase m_db; }; -#endif +#endif // Q_OS_WIN } TorrentContentModel::TorrentContentModel(QObject *parent) @@ -266,20 +265,20 @@ QVector TorrentContentModel::getFilePriorities() const { QVector prio; prio.reserve(m_filesIndex.size()); - foreach (const TorrentContentModelFile* file, m_filesIndex) + foreach (const TorrentContentModelFile *file, m_filesIndex) prio.push_back(file->priority()); return prio; } bool TorrentContentModel::allFiltered() const { - foreach (const TorrentContentModelFile* fileItem, m_filesIndex) + foreach (const TorrentContentModelFile *fileItem, m_filesIndex) if (fileItem->priority() != prio::IGNORED) return false; return true; } -int TorrentContentModel::columnCount(const QModelIndex& parent) const +int TorrentContentModel::columnCount(const QModelIndex &parent) const { if (parent.isValid()) return static_cast(parent.internalPointer())->columnCount(); @@ -287,7 +286,7 @@ int TorrentContentModel::columnCount(const QModelIndex& parent) const return m_rootItem->columnCount(); } -bool TorrentContentModel::setData(const QModelIndex& index, const QVariant& value, int role) +bool TorrentContentModel::setData(const QModelIndex &index, const QVariant &value, int role) { if (!index.isValid()) return false; @@ -313,7 +312,7 @@ bool TorrentContentModel::setData(const QModelIndex& index, const QVariant& valu if (role == Qt::EditRole) { Q_ASSERT(index.isValid()); - TorrentContentModelItem* item = static_cast(index.internalPointer()); + TorrentContentModelItem *item = static_cast(index.internalPointer()); switch (index.column()) { case TorrentContentModelItem::COL_NAME: item->setName(value.toString()); @@ -331,12 +330,12 @@ bool TorrentContentModel::setData(const QModelIndex& index, const QVariant& valu return false; } -TorrentContentModelItem::ItemType TorrentContentModel::itemType(const QModelIndex& index) const +TorrentContentModelItem::ItemType TorrentContentModel::itemType(const QModelIndex &index) const { return static_cast(index.internalPointer())->itemType(); } -int TorrentContentModel::getFileIndex(const QModelIndex& index) +int TorrentContentModel::getFileIndex(const QModelIndex &index) { TorrentContentModelItem *item = static_cast(index.internalPointer()); if (item->itemType() == TorrentContentModelItem::FileType) @@ -351,7 +350,7 @@ QVariant TorrentContentModel::data(const QModelIndex& index, int role) const if (!index.isValid()) return QVariant(); - TorrentContentModelItem* item = static_cast(index.internalPointer()); + TorrentContentModelItem *item = static_cast(index.internalPointer()); if ((index.column() == TorrentContentModelItem::COL_NAME) && (role == Qt::DecorationRole)) { if (item->itemType() == TorrentContentModelItem::FolderType) @@ -374,7 +373,7 @@ QVariant TorrentContentModel::data(const QModelIndex& index, int role) const return QVariant(); } -Qt::ItemFlags TorrentContentModel::flags(const QModelIndex& index) const +Qt::ItemFlags TorrentContentModel::flags(const QModelIndex &index) const { if (!index.isValid()) return 0; @@ -393,7 +392,7 @@ QVariant TorrentContentModel::headerData(int section, Qt::Orientation orientatio return QVariant(); } -QModelIndex TorrentContentModel::index(int row, int column, const QModelIndex& parent) const +QModelIndex TorrentContentModel::index(int row, int column, const QModelIndex &parent) const { if (parent.isValid() && (parent.column() != 0)) return QModelIndex(); @@ -401,7 +400,7 @@ QModelIndex TorrentContentModel::index(int row, int column, const QModelIndex& p if (column >= TorrentContentModelItem::NB_COL) return QModelIndex(); - TorrentContentModelFolder* parentItem; + TorrentContentModelFolder *parentItem; if (!parent.isValid()) parentItem = m_rootItem; else @@ -411,18 +410,18 @@ QModelIndex TorrentContentModel::index(int row, int column, const QModelIndex& p if (row >= parentItem->childCount()) return QModelIndex(); - TorrentContentModelItem* childItem = parentItem->child(row); + TorrentContentModelItem *childItem = parentItem->child(row); if (childItem) return createIndex(row, column, childItem); return QModelIndex(); } -QModelIndex TorrentContentModel::parent(const QModelIndex& index) const +QModelIndex TorrentContentModel::parent(const QModelIndex &index) const { if (!index.isValid()) return QModelIndex(); - TorrentContentModelItem* childItem = static_cast(index.internalPointer()); + TorrentContentModelItem *childItem = static_cast(index.internalPointer()); if (!childItem) return QModelIndex(); @@ -433,12 +432,12 @@ QModelIndex TorrentContentModel::parent(const QModelIndex& index) const return createIndex(parentItem->row(), 0, parentItem); } -int TorrentContentModel::rowCount(const QModelIndex& parent) const +int TorrentContentModel::rowCount(const QModelIndex &parent) const { if (parent.column() > 0) return 0; - TorrentContentModelFolder* parentItem; + TorrentContentModelFolder *parentItem; if (!parent.isValid()) parentItem = m_rootItem; else @@ -468,15 +467,15 @@ void TorrentContentModel::setupModelData(const BitTorrent::TorrentInfo &info) qDebug("Torrent contains %d files", filesCount); m_filesIndex.reserve(filesCount); - TorrentContentModelFolder* currentParent; + TorrentContentModelFolder *currentParent; // Iterate over files for (int i = 0; i < filesCount; ++i) { currentParent = m_rootItem; QString path = Utils::Fs::fromNativePath(info.filePath(i)); // Iterate of parts of the path to create necessary folders - QStringList pathFolders = path.split("/", QString::SkipEmptyParts); + QStringList pathFolders = path.split('/', QString::SkipEmptyParts); pathFolders.removeLast(); - foreach (const QString& pathPart, pathFolders) { + foreach (const QString &pathPart, pathFolders) { if (pathPart == ".unwanted") continue; TorrentContentModelFolder* newParent = currentParent->childFolderWithName(pathPart); @@ -487,7 +486,7 @@ void TorrentContentModel::setupModelData(const BitTorrent::TorrentInfo &info) currentParent = newParent; } // Actually create the file - TorrentContentModelFile* fileItem = new TorrentContentModelFile(info.fileName(i), info.fileSize(i), currentParent, i); + TorrentContentModelFile *fileItem = new TorrentContentModelFile(info.fileName(i), info.fileSize(i), currentParent, i); currentParent->appendChild(fileItem); m_filesIndex.push_back(fileItem); } diff --git a/src/gui/torrentcontentmodel.h b/src/gui/torrentcontentmodel.h index 60f7f014f..bb1d835ac 100644 --- a/src/gui/torrentcontentmodel.h +++ b/src/gui/torrentcontentmodel.h @@ -1,6 +1,6 @@ /* - * Bittorrent Client using Qt4 and libtorrent. - * Copyright (C) 2006-2012 Christophe Dumez + * Bittorrent Client using Qt and libtorrent. + * Copyright (C) 2006-2012 Christophe Dumez * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -24,8 +24,6 @@ * modify file(s), you may extend this exception to your version of the file(s), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : chris@qbittorrent.org */ #ifndef TORRENTCONTENTMODEL_H @@ -33,8 +31,8 @@ #include #include -#include #include +#include #include "base/bittorrent/torrentinfo.h" #include "torrentcontentmodelitem.h" @@ -42,7 +40,7 @@ class QFileIconProvider; class TorrentContentModelFile; -class TorrentContentModel: public QAbstractItemModel +class TorrentContentModel : public QAbstractItemModel { Q_OBJECT @@ -56,15 +54,15 @@ public: QVector getFilePriorities() const; bool allFiltered() const; int columnCount(const QModelIndex &parent = QModelIndex()) const override; - bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override; - TorrentContentModelItem::ItemType itemType(const QModelIndex& index) const; - int getFileIndex(const QModelIndex& index); - QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; - Qt::ItemFlags flags(const QModelIndex& index) const override; + bool setData(const QModelIndex &index, const QVariant& value, int role = Qt::EditRole) override; + TorrentContentModelItem::ItemType itemType(const QModelIndex &index) const; + int getFileIndex(const QModelIndex &index); + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + Qt::ItemFlags flags(const QModelIndex &index) const override; QVariant headerData(int section, Qt::Orientation orientation, int role) const override; QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override; - QModelIndex parent(const QModelIndex& index) const override; - int rowCount(const QModelIndex& parent = QModelIndex()) const override; + QModelIndex parent(const QModelIndex &index) const override; + int rowCount(const QModelIndex &parent = QModelIndex()) const override; void clear(); void setupModelData(const BitTorrent::TorrentInfo &info); diff --git a/src/gui/torrentcontentmodelfile.cpp b/src/gui/torrentcontentmodelfile.cpp index 62c925428..e3fbbee57 100644 --- a/src/gui/torrentcontentmodelfile.cpp +++ b/src/gui/torrentcontentmodelfile.cpp @@ -1,6 +1,6 @@ /* - * Bittorrent Client using Qt4 and libtorrent. - * Copyright (C) 2006-2012 Christophe Dumez + * Bittorrent Client using Qt and libtorrent. + * Copyright (C) 2006-2012 Christophe Dumez * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -24,8 +24,6 @@ * modify file(s), you may extend this exception to your version of the file(s), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : chris@qbittorrent.org */ #include "torrentcontentmodelfile.h" diff --git a/src/gui/torrentcontentmodelfile.h b/src/gui/torrentcontentmodelfile.h index f6d73e51a..079f43651 100644 --- a/src/gui/torrentcontentmodelfile.h +++ b/src/gui/torrentcontentmodelfile.h @@ -1,6 +1,6 @@ /* - * Bittorrent Client using Qt4 and libtorrent. - * Copyright (C) 2006-2012 Christophe Dumez + * Bittorrent Client using Qt and libtorrent. + * Copyright (C) 2006-2012 Christophe Dumez * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -24,8 +24,6 @@ * modify file(s), you may extend this exception to your version of the file(s), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : chris@qbittorrent.org */ #ifndef TORRENTCONTENTMODELFILE_H @@ -33,7 +31,7 @@ #include "torrentcontentmodelitem.h" -class TorrentContentModelFile: public TorrentContentModelItem +class TorrentContentModelFile : public TorrentContentModelItem { public: TorrentContentModelFile(const QString &fileName, qulonglong fileSize, diff --git a/src/gui/torrentcontentmodelfolder.cpp b/src/gui/torrentcontentmodelfolder.cpp index 63227fef6..404a268bd 100644 --- a/src/gui/torrentcontentmodelfolder.cpp +++ b/src/gui/torrentcontentmodelfolder.cpp @@ -1,6 +1,6 @@ /* - * Bittorrent Client using Qt4 and libtorrent. - * Copyright (C) 2006-2012 Christophe Dumez + * Bittorrent Client using Qt and libtorrent. + * Copyright (C) 2006-2012 Christophe Dumez * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -24,8 +24,6 @@ * modify file(s), you may extend this exception to your version of the file(s), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : chris@qbittorrent.org */ #include "torrentcontentmodelfolder.h" @@ -165,7 +163,7 @@ void TorrentContentModelFolder::recalculateAvailability() qreal tAvailability = 0; qulonglong tSize = 0; bool foundAnyData = false; - foreach (TorrentContentModelItem* child, m_childItems) { + foreach (TorrentContentModelItem *child, m_childItems) { if (child->priority() == prio::IGNORED) continue; diff --git a/src/gui/torrentcontentmodelfolder.h b/src/gui/torrentcontentmodelfolder.h index e136c9a2e..521ec6970 100644 --- a/src/gui/torrentcontentmodelfolder.h +++ b/src/gui/torrentcontentmodelfolder.h @@ -1,6 +1,6 @@ /* - * Bittorrent Client using Qt4 and libtorrent. - * Copyright (C) 2006-2012 Christophe Dumez + * Bittorrent Client using Qt and libtorrent. + * Copyright (C) 2006-2012 Christophe Dumez * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -24,8 +24,6 @@ * modify file(s), you may extend this exception to your version of the file(s), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : chris@qbittorrent.org */ #ifndef TORRENTCONTENTMODELFOLDER_H @@ -33,14 +31,14 @@ #include "torrentcontentmodelitem.h" -class TorrentContentModelFolder: public TorrentContentModelItem +class TorrentContentModelFolder : public TorrentContentModelItem { public: // Folder constructor - TorrentContentModelFolder(const QString& name, TorrentContentModelFolder* parent); + TorrentContentModelFolder(const QString &name, TorrentContentModelFolder *parent); // Invisible root item constructor - TorrentContentModelFolder(const QList& data); + TorrentContentModelFolder(const QList &data); ~TorrentContentModelFolder(); @@ -54,10 +52,10 @@ public: void setPriority(int newPriority, bool updateParent = true) override; void deleteAllChildren(); - const QList& children() const; - void appendChild(TorrentContentModelItem* item); - TorrentContentModelItem* child(int row) const; - TorrentContentModelFolder* childFolderWithName(const QString& name) const; + const QList &children() const; + void appendChild(TorrentContentModelItem *item); + TorrentContentModelItem *child(int row) const; + TorrentContentModelFolder *childFolderWithName(const QString &name) const; int childCount() const; private: diff --git a/src/gui/torrentcontentmodelitem.cpp b/src/gui/torrentcontentmodelitem.cpp index 15a1988db..bc330f702 100644 --- a/src/gui/torrentcontentmodelitem.cpp +++ b/src/gui/torrentcontentmodelitem.cpp @@ -1,6 +1,6 @@ /* - * Bittorrent Client using Qt4 and libtorrent. - * Copyright (C) 2006-2012 Christophe Dumez + * Bittorrent Client using Qt and libtorrent. + * Copyright (C) 2006-2012 Christophe Dumez * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -24,15 +24,15 @@ * modify file(s), you may extend this exception to your version of the file(s), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : chris@qbittorrent.org */ +#include "torrentcontentmodelitem.h" + +#include + #include "base/utils/misc.h" #include "base/utils/fs.h" -#include "torrentcontentmodelitem.h" #include "torrentcontentmodelfolder.h" -#include TorrentContentModelItem::TorrentContentModelItem(TorrentContentModelFolder *parent) : m_parentItem(parent) @@ -138,4 +138,3 @@ TorrentContentModelFolder *TorrentContentModelItem::parent() const { return m_parentItem; } - diff --git a/src/gui/torrentcontentmodelitem.h b/src/gui/torrentcontentmodelitem.h index 115dd76c2..64597bd80 100644 --- a/src/gui/torrentcontentmodelitem.h +++ b/src/gui/torrentcontentmodelitem.h @@ -1,6 +1,6 @@ /* - * Bittorrent Client using Qt4 and libtorrent. - * Copyright (C) 2006-2012 Christophe Dumez + * Bittorrent Client using Qt and libtorrent. + * Copyright (C) 2006-2012 Christophe Dumez * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -24,8 +24,6 @@ * modify file(s), you may extend this exception to your version of the file(s), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : chris@qbittorrent.org */ #ifndef TORRENTCONTENTMODELITEM_H diff --git a/src/gui/torrentcontenttreeview.h b/src/gui/torrentcontenttreeview.h index d5058006d..62c1d4471 100644 --- a/src/gui/torrentcontenttreeview.h +++ b/src/gui/torrentcontenttreeview.h @@ -31,13 +31,13 @@ #include -class TorrentContentTreeView: public QTreeView +class TorrentContentTreeView : public QTreeView { Q_OBJECT public: explicit TorrentContentTreeView(QWidget *parent = nullptr); - void keyPressEvent(QKeyEvent *event); + void keyPressEvent(QKeyEvent *event) override; private: QModelIndex currentNameCell(); diff --git a/src/gui/torrentcreatordlg.h b/src/gui/torrentcreatordlg.h index 7e6580009..a9f678d97 100644 --- a/src/gui/torrentcreatordlg.h +++ b/src/gui/torrentcreatordlg.h @@ -44,7 +44,7 @@ namespace BitTorrent class TorrentCreatorThread; } -class TorrentCreatorDlg: public QDialog +class TorrentCreatorDlg : public QDialog { Q_OBJECT @@ -89,4 +89,4 @@ private: CachedSettingValue m_storeSource; }; -#endif +#endif // TORRENTCREATORDLG_H diff --git a/src/gui/torrentmodel.cpp b/src/gui/torrentmodel.cpp index 585bc250d..4450183d2 100644 --- a/src/gui/torrentmodel.cpp +++ b/src/gui/torrentmodel.cpp @@ -25,20 +25,19 @@ * modify file(s), you may extend this exception to your version of the file(s), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : chris@qbittorrent.org */ -#include +#include "torrentmodel.h" + #include -#include +#include #include +#include #include "base/bittorrent/session.h" #include "base/bittorrent/torrenthandle.h" #include "base/torrentfilter.h" #include "base/utils/fs.h" -#include "torrentmodel.h" static QIcon getIconByState(BitTorrent::TorrentState state); static QColor getColorByState(BitTorrent::TorrentState state); diff --git a/src/gui/torrentmodel.h b/src/gui/torrentmodel.h index e5cc24940..2e8da998f 100644 --- a/src/gui/torrentmodel.h +++ b/src/gui/torrentmodel.h @@ -25,8 +25,6 @@ * modify file(s), you may extend this exception to your version of the file(s), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : chris@qbittorrent.org */ #ifndef TORRENTMODEL_H @@ -85,12 +83,12 @@ public: explicit TorrentModel(QObject *parent = nullptr); - int rowCount(const QModelIndex& index = QModelIndex()) const; - int columnCount(const QModelIndex &parent=QModelIndex()) const; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::DisplayRole); - QVariant headerData(int section, Qt::Orientation orientation, int role) const; - Qt::ItemFlags flags(const QModelIndex &index) const; + int rowCount(const QModelIndex& index = QModelIndex()) const override; + int columnCount(const QModelIndex &parent=QModelIndex()) const override; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::DisplayRole) override; + QVariant headerData(int section, Qt::Orientation orientation, int role) const override; + Qt::ItemFlags flags(const QModelIndex &index) const override; BitTorrent::TorrentHandle *torrentHandle(const QModelIndex &index) const; diff --git a/src/gui/trackerlogin.cpp b/src/gui/trackerlogin.cpp index 717040ec8..e5973c8c7 100644 --- a/src/gui/trackerlogin.cpp +++ b/src/gui/trackerlogin.cpp @@ -1,6 +1,6 @@ /* - * Bittorrent Client using Qt4 and libtorrent. - * Copyright (C) 2006 Christophe Dumez + * Bittorrent Client using Qt and libtorrent. + * Copyright (C) 2006 Christophe Dumez * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -24,8 +24,6 @@ * modify file(s), you may extend this exception to your version of the file(s), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : chris@qbittorrent.org */ #include "trackerlogin.h" diff --git a/src/gui/trackerlogin.h b/src/gui/trackerlogin.h index e43b9e8dc..b4cedc58a 100644 --- a/src/gui/trackerlogin.h +++ b/src/gui/trackerlogin.h @@ -1,6 +1,6 @@ /* - * Bittorrent Client using Qt4 and libtorrent. - * Copyright (C) 2006 Christophe Dumez + * Bittorrent Client using Qt and libtorrent. + * Copyright (C) 2006 Christophe Dumez * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -24,8 +24,6 @@ * modify file(s), you may extend this exception to your version of the file(s), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : chris@qbittorrent.org */ #ifndef TRACKERLOGIN_H @@ -58,4 +56,4 @@ class trackerLogin : public QDialog, private Ui::authentication{ void cancelButtonClicked(); }; -#endif +#endif // TRACKERLOGIN_H diff --git a/src/gui/transferlistdelegate.cpp b/src/gui/transferlistdelegate.cpp index 4263bf098..e21bf181b 100644 --- a/src/gui/transferlistdelegate.cpp +++ b/src/gui/transferlistdelegate.cpp @@ -1,6 +1,6 @@ /* - * Bittorrent Client using Qt4 and libtorrent. - * Copyright (C) 2006 Christophe Dumez + * Bittorrent Client using Qt and libtorrent. + * Copyright (C) 2006 Christophe Dumez * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -24,35 +24,34 @@ * modify file(s), you may extend this exception to your version of the file(s), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : chris@qbittorrent.org */ #include "transferlistdelegate.h" -#include -#include #include +#include #include -#include "base/utils/misc.h" -#include "base/utils/string.h" -#include "torrentmodel.h" -#include "base/bittorrent/session.h" -#include "base/bittorrent/torrenthandle.h" -#include "base/types.h" -#include "base/preferences.h" -#include "base/unicodestrings.h" +#include #ifdef Q_OS_WIN #include #endif +#include "base/bittorrent/session.h" +#include "base/bittorrent/torrenthandle.h" +#include "base/preferences.h" +#include "base/types.h" +#include "base/unicodestrings.h" +#include "base/utils/misc.h" +#include "base/utils/string.h" +#include "torrentmodel.h" + TransferListDelegate::TransferListDelegate(QObject *parent) : QItemDelegate(parent) { } -void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const +void TransferListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { painter->save(); bool isHideState = true; @@ -74,13 +73,13 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem case TorrentModel::TR_COMPLETED: case TorrentModel::TR_SIZE: case TorrentModel::TR_TOTAL_SIZE: { - qlonglong size = index.data().toLongLong(); - if (hideValues && !size) - break; - opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter; - QItemDelegate::drawDisplay(painter, opt, option.rect, Utils::Misc::friendlyUnit(size)); + qlonglong size = index.data().toLongLong(); + if (hideValues && !size) + break; + opt.displayAlignment = (Qt::AlignRight | Qt::AlignVCenter); + QItemDelegate::drawDisplay(painter, opt, option.rect, Utils::Misc::friendlyUnit(size)); + } break; - } case TorrentModel::TR_ETA: { opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter; QItemDelegate::drawDisplay(painter, opt, option.rect, Utils::Misc::userFriendlyDuration(index.data().toLongLong())); @@ -88,124 +87,124 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem } case TorrentModel::TR_SEEDS: case TorrentModel::TR_PEERS: { - qlonglong value = index.data().toLongLong(); - qlonglong total = index.data(Qt::UserRole).toLongLong(); - if (hideValues && (!value && !total)) - break; - QString display = QString::number(value) + " (" + QString::number(total) + ")"; - opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter; - QItemDelegate::drawDisplay(painter, opt, opt.rect, display); + qlonglong value = index.data().toLongLong(); + qlonglong total = index.data(Qt::UserRole).toLongLong(); + if (hideValues && (!value && !total)) + break; + QString display = QString::number(value) + " (" + QString::number(total) + ")"; + opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter; + QItemDelegate::drawDisplay(painter, opt, opt.rect, display); + } break; - } case TorrentModel::TR_STATUS: { - const auto state = index.data().value(); - QString display = getStatusString(state); - QItemDelegate::drawDisplay(painter, opt, opt.rect, display); + const auto state = index.data().value(); + QString display = getStatusString(state); + QItemDelegate::drawDisplay(painter, opt, opt.rect, display); + } break; - } case TorrentModel::TR_UPSPEED: case TorrentModel::TR_DLSPEED: { - const qulonglong speed = index.data().toULongLong(); - if (hideValues && !speed) - break; - opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter; - QItemDelegate::drawDisplay(painter, opt, opt.rect, Utils::Misc::friendlyUnit(speed, true)); + const qulonglong speed = index.data().toULongLong(); + if (hideValues && !speed) + break; + opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter; + QItemDelegate::drawDisplay(painter, opt, opt.rect, Utils::Misc::friendlyUnit(speed, true)); + } break; - } case TorrentModel::TR_UPLIMIT: case TorrentModel::TR_DLLIMIT: { - const qlonglong limit = index.data().toLongLong(); - if (hideValues && !limit) - break; - opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter; - QItemDelegate::drawDisplay(painter, opt, opt.rect, limit > 0 ? Utils::Misc::friendlyUnit(limit, true) : QString::fromUtf8(C_INFINITY)); + const qlonglong limit = index.data().toLongLong(); + if (hideValues && !limit) + break; + opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter; + QItemDelegate::drawDisplay(painter, opt, opt.rect, limit > 0 ? Utils::Misc::friendlyUnit(limit, true) : QString::fromUtf8(C_INFINITY)); + } break; - } case TorrentModel::TR_TIME_ELAPSED: { - const int elapsedTime = index.data().toInt(); - const int seedingTime = index.data(Qt::UserRole).toInt(); - const QString txt = (seedingTime > 0) - ? tr("%1 (seeded for %2)", "e.g. 4m39s (seeded for 3m10s)") - .arg(Utils::Misc::userFriendlyDuration(elapsedTime) - , Utils::Misc::userFriendlyDuration(seedingTime)) - : Utils::Misc::userFriendlyDuration(elapsedTime); - QItemDelegate::drawDisplay(painter, opt, opt.rect, txt); + const int elapsedTime = index.data().toInt(); + const int seedingTime = index.data(Qt::UserRole).toInt(); + const QString txt = (seedingTime > 0) + ? tr("%1 (seeded for %2)", "e.g. 4m39s (seeded for 3m10s)") + .arg(Utils::Misc::userFriendlyDuration(elapsedTime) + , Utils::Misc::userFriendlyDuration(seedingTime)) + : Utils::Misc::userFriendlyDuration(elapsedTime); + QItemDelegate::drawDisplay(painter, opt, opt.rect, txt); + } break; - } case TorrentModel::TR_ADD_DATE: case TorrentModel::TR_SEED_DATE: QItemDelegate::drawDisplay(painter, opt, opt.rect, index.data().toDateTime().toLocalTime().toString(Qt::DefaultLocaleShortDate)); break; case TorrentModel::TR_RATIO_LIMIT: case TorrentModel::TR_RATIO: { - const qreal ratio = index.data().toDouble(); - if (hideValues && (ratio <= 0)) - break; - QString str = ((ratio == -1) || (ratio > BitTorrent::TorrentHandle::MAX_RATIO)) ? QString::fromUtf8(C_INFINITY) : Utils::String::fromDouble(ratio, 2); - opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter; - QItemDelegate::drawDisplay(painter, opt, opt.rect, str); + const qreal ratio = index.data().toDouble(); + if (hideValues && (ratio <= 0)) + break; + QString str = ((ratio == -1) || (ratio > BitTorrent::TorrentHandle::MAX_RATIO)) ? QString::fromUtf8(C_INFINITY) : Utils::String::fromDouble(ratio, 2); + opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter; + QItemDelegate::drawDisplay(painter, opt, opt.rect, str); + } break; - } case TorrentModel::TR_PRIORITY: { - const int priority = index.data().toInt(); - opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter; - if (priority > 0) { - QItemDelegate::paint(painter, opt, index); - } - else { - QItemDelegate::drawDisplay(painter, opt, opt.rect, "*"); + const int priority = index.data().toInt(); + opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter; + if (priority > 0) { + QItemDelegate::paint(painter, opt, index); + } + else { + QItemDelegate::drawDisplay(painter, opt, opt.rect, "*"); + } } break; - } case TorrentModel::TR_PROGRESS: { - QStyleOptionProgressBar newopt; - qreal progress = index.data().toDouble() * 100.; - newopt.rect = opt.rect; - newopt.text = ((progress == 100.0) ? QString("100%") : Utils::String::fromDouble(progress, 1) + "%"); - newopt.progress = static_cast(progress); - newopt.maximum = 100; - newopt.minimum = 0; - newopt.state |= QStyle::State_Enabled; - newopt.textVisible = true; + QStyleOptionProgressBar newopt; + qreal progress = index.data().toDouble() * 100.; + newopt.rect = opt.rect; + newopt.text = ((progress == 100.0) ? QString("100%") : Utils::String::fromDouble(progress, 1) + "%"); + newopt.progress = static_cast(progress); + newopt.maximum = 100; + newopt.minimum = 0; + newopt.state |= QStyle::State_Enabled; + newopt.textVisible = true; #ifndef Q_OS_WIN - QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt, painter); + QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt, painter); #else - // XXX: To avoid having the progress text on the right of the bar - QProxyStyle st("fusion"); - st.drawControl(QStyle::CE_ProgressBar, &newopt, painter, 0); + // XXX: To avoid having the progress text on the right of the bar + QProxyStyle st("fusion"); + st.drawControl(QStyle::CE_ProgressBar, &newopt, painter, 0); #endif + } break; - } case TorrentModel::TR_LAST_ACTIVITY: { - qlonglong elapsed = index.data().toLongLong(); - if (hideValues && ((elapsed < 0) || (elapsed >= MAX_ETA))) - break; + qlonglong elapsed = index.data().toLongLong(); + if (hideValues && ((elapsed < 0) || (elapsed >= MAX_ETA))) + break; - // Show '< 1m ago' when elapsed time is 0 - if (elapsed == 0) - elapsed = 1; + // Show '< 1m ago' when elapsed time is 0 + if (elapsed == 0) + elapsed = 1; - QString elapsedString = (elapsed >= 0) - ? tr("%1 ago", "e.g.: 1h 20m ago").arg(Utils::Misc::userFriendlyDuration(elapsed)) - : Utils::Misc::userFriendlyDuration(elapsed); + QString elapsedString = (elapsed >= 0) + ? tr("%1 ago", "e.g.: 1h 20m ago").arg(Utils::Misc::userFriendlyDuration(elapsed)) + : Utils::Misc::userFriendlyDuration(elapsed); - opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter; - QItemDelegate::drawDisplay(painter, opt, option.rect, elapsedString); + opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter; + QItemDelegate::drawDisplay(painter, opt, option.rect, elapsedString); + } break; - } default: QItemDelegate::paint(painter, option, index); } painter->restore(); } -QWidget* TransferListDelegate::createEditor(QWidget*, const QStyleOptionViewItem &, const QModelIndex &) const +QWidget *TransferListDelegate::createEditor(QWidget *, const QStyleOptionViewItem &, const QModelIndex &) const { // No editor here - return 0; + return nullptr; } -QSize TransferListDelegate::sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const +QSize TransferListDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const { // Reimplementing sizeHint() because the 'name' column contains text+icon. // When that WHOLE column goes out of view(eg user scrolls horizontally) diff --git a/src/gui/transferlistdelegate.h b/src/gui/transferlistdelegate.h index d67c49af0..85587e746 100644 --- a/src/gui/transferlistdelegate.h +++ b/src/gui/transferlistdelegate.h @@ -1,6 +1,6 @@ /* - * Bittorrent Client using Qt4 and libtorrent. - * Copyright (C) 2006 Christophe Dumez + * Bittorrent Client using Qt and libtorrent. + * Copyright (C) 2006 Christophe Dumez * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -24,8 +24,6 @@ * modify file(s), you may extend this exception to your version of the file(s), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : chris@qbittorrent.org */ #ifndef TRANSFERLISTDELEGATE_H @@ -33,11 +31,9 @@ #include -QT_BEGIN_NAMESPACE +class QModelIndex; class QPainter; class QStyleOptionViewItem; -class QModelIndex; -QT_END_NAMESPACE namespace BitTorrent { @@ -45,15 +41,15 @@ namespace BitTorrent } // Defines for download list list columns -class TransferListDelegate: public QItemDelegate +class TransferListDelegate : public QItemDelegate { Q_OBJECT public: TransferListDelegate(QObject *parent); - void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const; - QWidget* createEditor(QWidget*, const QStyleOptionViewItem &, const QModelIndex &) const; - QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const; + void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; + QWidget *createEditor(QWidget *, const QStyleOptionViewItem &, const QModelIndex &) const override; + QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override; private: QString getStatusString(const BitTorrent::TorrentState state) const; diff --git a/src/gui/transferlistfilterswidget.cpp b/src/gui/transferlistfilterswidget.cpp index 423aa9c5b..bbe91aabc 100644 --- a/src/gui/transferlistfilterswidget.cpp +++ b/src/gui/transferlistfilterswidget.cpp @@ -1,6 +1,6 @@ /* - * Bittorrent Client using Qt4 and libtorrent. - * Copyright (C) 2006 Christophe Dumez + * Bittorrent Client using Qt and libtorrent. + * Copyright (C) 2006 Christophe Dumez * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -24,8 +24,6 @@ * modify file(s), you may extend this exception to your version of the file(s), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : chris@qbittorrent.org */ #include "transferlistfilterswidget.h" @@ -37,15 +35,15 @@ #include #include #include -#include #include +#include #include "base/bittorrent/session.h" #include "base/bittorrent/torrenthandle.h" #include "base/bittorrent/trackerentry.h" #include "base/logger.h" -#include "base/net/downloadmanager.h" #include "base/net/downloadhandler.h" +#include "base/net/downloadmanager.h" #include "base/preferences.h" #include "base/torrentfilter.h" #include "base/utils/fs.h" @@ -161,7 +159,7 @@ StatusFiltersWidget::StatusFiltersWidget(QWidget *parent, TransferListWidget *tr errored->setData(Qt::DisplayRole, QVariant(tr("Errored (0)"))); errored->setData(Qt::DecorationRole, QIcon(":/icons/skin/error.png")); - const Preferences* const pref = Preferences::instance(); + const Preferences *const pref = Preferences::instance(); setCurrentRow(pref->getTransSelFilter(), QItemSelectionModel::SelectCurrent); toggleFilter(pref->getStatusFilterState()); } @@ -443,7 +441,7 @@ void TrackerFiltersList::handleFavicoDownload(const QString& url, const QString& } } -void TrackerFiltersList::handleFavicoFailure(const QString& url, const QString& error) +void TrackerFiltersList::handleFavicoFailure(const QString &url, const QString &error) { Q_UNUSED(error) if (url.endsWith(".ico", Qt::CaseInsensitive)) { @@ -514,10 +512,10 @@ QString TrackerFiltersList::trackerFromRow(int row) const { Q_ASSERT(row > 1); const QString &tracker = item(row)->text(); - QStringList parts = tracker.split(" "); + QStringList parts = tracker.split(' '); Q_ASSERT(parts.size() >= 2); parts.removeLast(); // Remove trailing number - return parts.join(" "); + return parts.join(' '); } int TrackerFiltersList::rowFromTracker(const QString &tracker) const @@ -561,7 +559,7 @@ TransferListFiltersWidget::TransferListFiltersWidget(QWidget *parent, TransferLi , m_transferList(transferList) , m_trackerFilters(nullptr) { - Preferences* const pref = Preferences::instance(); + Preferences *const pref = Preferences::instance(); // Construct lists QVBoxLayout *vLayout = new QVBoxLayout(this); @@ -587,7 +585,7 @@ TransferListFiltersWidget::TransferListFiltersWidget(QWidget *parent, TransferLi vLayout->addWidget(scroll); setLayout(vLayout); - QCheckBox * statusLabel = new QCheckBox(tr("Status"), this); + QCheckBox *statusLabel = new QCheckBox(tr("Status"), this); statusLabel->setChecked(pref->getStatusFilterState()); statusLabel->setFont(font); frameLayout->addWidget(statusLabel); diff --git a/src/gui/transferlistfilterswidget.h b/src/gui/transferlistfilterswidget.h index 98b1d6e9f..7b761bfb4 100644 --- a/src/gui/transferlistfilterswidget.h +++ b/src/gui/transferlistfilterswidget.h @@ -1,6 +1,6 @@ /* - * Bittorrent Client using Qt4 and libtorrent. - * Copyright (C) 2006 Christophe Dumez + * Bittorrent Client using Qt and libtorrent. + * Copyright (C) 2006 Christophe Dumez * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -24,21 +24,16 @@ * modify file(s), you may extend this exception to your version of the file(s), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : chris@qbittorrent.org */ #ifndef TRANSFERLISTFILTERSWIDGET_H #define TRANSFERLISTFILTERSWIDGET_H -#include #include +#include -QT_BEGIN_NAMESPACE -class QResizeEvent; class QCheckBox; -QT_END_NAMESPACE - +class QResizeEvent; class TransferListWidget; namespace BitTorrent @@ -47,15 +42,15 @@ namespace BitTorrent class TrackerEntry; } -class FiltersBase: public QListWidget +class FiltersBase : public QListWidget { Q_OBJECT public: FiltersBase(QWidget *parent, TransferListWidget *transferList); - virtual QSize sizeHint() const; - virtual QSize minimumSizeHint() const; + QSize sizeHint() const override; + QSize minimumSizeHint() const override; public slots: void toggleFilter(bool checked); @@ -70,7 +65,7 @@ private slots: virtual void torrentAboutToBeDeleted(BitTorrent::TorrentHandle *const) = 0; }; -class StatusFiltersWidget: public FiltersBase +class StatusFiltersWidget : public FiltersBase { Q_OBJECT @@ -84,13 +79,13 @@ private slots: private: // These 4 methods are virtual slots in the base class. // No need to redeclare them here as slots. - virtual void showMenu(QPoint); - virtual void applyFilter(int row); - virtual void handleNewTorrent(BitTorrent::TorrentHandle *const); - virtual void torrentAboutToBeDeleted(BitTorrent::TorrentHandle *const); + void showMenu(QPoint) override; + void applyFilter(int row) override; + void handleNewTorrent(BitTorrent::TorrentHandle *const) override; + void torrentAboutToBeDeleted(BitTorrent::TorrentHandle *const) override; }; -class TrackerFiltersList: public FiltersBase +class TrackerFiltersList : public FiltersBase { Q_OBJECT @@ -116,10 +111,10 @@ private slots: private: // These 4 methods are virtual slots in the base class. // No need to redeclare them here as slots. - virtual void showMenu(QPoint); - virtual void applyFilter(int row); - virtual void handleNewTorrent(BitTorrent::TorrentHandle *const torrent); - virtual void torrentAboutToBeDeleted(BitTorrent::TorrentHandle *const torrent); + void showMenu(QPoint) override; + void applyFilter(int row) override; + void handleNewTorrent(BitTorrent::TorrentHandle *const torrent) override; + void torrentAboutToBeDeleted(BitTorrent::TorrentHandle *const torrent) override; QString trackerFromRow(int row) const; int rowFromTracker(const QString &tracker) const; QString getHost(const QString &tracker) const; @@ -138,7 +133,7 @@ private: class CategoryFilterWidget; class TagFilterWidget; -class TransferListFiltersWidget: public QFrame +class TransferListFiltersWidget : public QFrame { Q_OBJECT diff --git a/src/gui/transferlistsortmodel.cpp b/src/gui/transferlistsortmodel.cpp index 419e27bd9..7eb5cf21a 100644 --- a/src/gui/transferlistsortmodel.cpp +++ b/src/gui/transferlistsortmodel.cpp @@ -1,6 +1,6 @@ /* - * Bittorrent Client using Qt4 and libtorrent. - * Copyright (C) 2013 Nick Tiskov + * Bittorrent Client using Qt and libtorrent. + * Copyright (C) 2013 Nick Tiskov * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -24,17 +24,17 @@ * modify file(s), you may extend this exception to your version of the file(s), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : daymansmail@gmail.com */ +#include "transferlistsortmodel.h" + #include +#include "base/bittorrent/torrenthandle.h" #include "base/types.h" #include "base/utils/string.h" -#include "base/bittorrent/torrenthandle.h" #include "torrentmodel.h" -#include "transferlistsortmodel.h" + TransferListSortModel::TransferListSortModel(QObject *parent) : QSortFilterProxyModel(parent) @@ -89,125 +89,125 @@ bool TransferListSortModel::lessThan(const QModelIndex &left, const QModelIndex case TorrentModel::TR_CATEGORY: case TorrentModel::TR_TAGS: case TorrentModel::TR_NAME: { - const QVariant vL = left.data(); - const QVariant vR = right.data(); - if (!vL.isValid() || !vR.isValid() || (vL == vR)) - return lowerPositionThan(left, right); + const QVariant vL = left.data(); + const QVariant vR = right.data(); + if (!vL.isValid() || !vR.isValid() || (vL == vR)) + return lowerPositionThan(left, right); - const int result = Utils::String::naturalCompare(vL.toString(), vR.toString(), Qt::CaseInsensitive); - return (result < 0); - } + const int result = Utils::String::naturalCompare(vL.toString(), vR.toString(), Qt::CaseInsensitive); + return (result < 0); + } case TorrentModel::TR_STATUS: { - // QSortFilterProxyModel::lessThan() uses the < operator only for specific QVariant types - // so our custom type is outside that list. - // In this case QSortFilterProxyModel::lessThan() converts other types to QString and - // sorts them. - // Thus we can't use the code in the default label. - const BitTorrent::TorrentState leftValue = left.data().value(); - const BitTorrent::TorrentState rightValue = right.data().value(); - if (leftValue != rightValue) - return leftValue < rightValue; + // QSortFilterProxyModel::lessThan() uses the < operator only for specific QVariant types + // so our custom type is outside that list. + // In this case QSortFilterProxyModel::lessThan() converts other types to QString and + // sorts them. + // Thus we can't use the code in the default label. + const BitTorrent::TorrentState leftValue = left.data().value(); + const BitTorrent::TorrentState rightValue = right.data().value(); + if (leftValue != rightValue) + return leftValue < rightValue; - return lowerPositionThan(left, right); - } + return lowerPositionThan(left, right); + } case TorrentModel::TR_ADD_DATE: case TorrentModel::TR_SEED_DATE: case TorrentModel::TR_SEEN_COMPLETE_DATE: { return dateLessThan(sortColumn(), left, right, true); - } + } case TorrentModel::TR_PRIORITY: { return lowerPositionThan(left, right); - } + } case TorrentModel::TR_SEEDS: case TorrentModel::TR_PEERS: { - const int leftActive = left.data().toInt(); - const int leftTotal = left.data(Qt::UserRole).toInt(); - const int rightActive = right.data().toInt(); - const int rightTotal = right.data(Qt::UserRole).toInt(); - - // Active peers/seeds take precedence over total peers/seeds. - if (leftActive != rightActive) - return (leftActive < rightActive); + const int leftActive = left.data().toInt(); + const int leftTotal = left.data(Qt::UserRole).toInt(); + const int rightActive = right.data().toInt(); + const int rightTotal = right.data(Qt::UserRole).toInt(); - if (leftTotal != rightTotal) - return (leftTotal < rightTotal); + // Active peers/seeds take precedence over total peers/seeds. + if (leftActive != rightActive) + return (leftActive < rightActive); - return lowerPositionThan(left, right); - } + if (leftTotal != rightTotal) + return (leftTotal < rightTotal); - case TorrentModel::TR_ETA: { - const TorrentModel *model = qobject_cast(sourceModel()); - - // Sorting rules prioritized. - // 1. Active torrents at the top - // 2. Seeding torrents at the bottom - // 3. Torrents with invalid ETAs at the bottom - - const bool isActiveL = TorrentFilter::ActiveTorrent.match(model->torrentHandle(model->index(left.row()))); - const bool isActiveR = TorrentFilter::ActiveTorrent.match(model->torrentHandle(model->index(right.row()))); - if (isActiveL != isActiveR) - return isActiveL; - - const int prioL = model->data(model->index(left.row(), TorrentModel::TR_PRIORITY)).toInt(); - const int prioR = model->data(model->index(right.row(), TorrentModel::TR_PRIORITY)).toInt(); - const bool isSeedingL = (prioL < 0); - const bool isSeedingR = (prioR < 0); - if (isSeedingL != isSeedingR) { - const bool isAscendingOrder = (sortOrder() == Qt::AscendingOrder); - if (isSeedingL) - return !isAscendingOrder; - else - return isAscendingOrder; + return lowerPositionThan(left, right); } - const qlonglong etaL = left.data().toLongLong(); - const qlonglong etaR = right.data().toLongLong(); - const bool isInvalidL = ((etaL < 0) || (etaL >= MAX_ETA)); - const bool isInvalidR = ((etaR < 0) || (etaR >= MAX_ETA)); - if (isInvalidL && isInvalidR) { - if (isSeedingL) // Both seeding - return dateLessThan(TorrentModel::TR_SEED_DATE, left, right, true); - else - return (prioL < prioR); - } - else if (!isInvalidL && !isInvalidR) { - return (etaL < etaR); - } - else { - return !isInvalidL; + case TorrentModel::TR_ETA: { + const TorrentModel *model = qobject_cast(sourceModel()); + + // Sorting rules prioritized. + // 1. Active torrents at the top + // 2. Seeding torrents at the bottom + // 3. Torrents with invalid ETAs at the bottom + + const bool isActiveL = TorrentFilter::ActiveTorrent.match(model->torrentHandle(model->index(left.row()))); + const bool isActiveR = TorrentFilter::ActiveTorrent.match(model->torrentHandle(model->index(right.row()))); + if (isActiveL != isActiveR) + return isActiveL; + + const int prioL = model->data(model->index(left.row(), TorrentModel::TR_PRIORITY)).toInt(); + const int prioR = model->data(model->index(right.row(), TorrentModel::TR_PRIORITY)).toInt(); + const bool isSeedingL = (prioL < 0); + const bool isSeedingR = (prioR < 0); + if (isSeedingL != isSeedingR) { + const bool isAscendingOrder = (sortOrder() == Qt::AscendingOrder); + if (isSeedingL) + return !isAscendingOrder; + else + return isAscendingOrder; + } + + const qlonglong etaL = left.data().toLongLong(); + const qlonglong etaR = right.data().toLongLong(); + const bool isInvalidL = ((etaL < 0) || (etaL >= MAX_ETA)); + const bool isInvalidR = ((etaR < 0) || (etaR >= MAX_ETA)); + if (isInvalidL && isInvalidR) { + if (isSeedingL) // Both seeding + return dateLessThan(TorrentModel::TR_SEED_DATE, left, right, true); + else + return (prioL < prioR); + } + else if (!isInvalidL && !isInvalidR) { + return (etaL < etaR); + } + else { + return !isInvalidL; + } } - } case TorrentModel::TR_LAST_ACTIVITY: { - const qlonglong vL = left.data().toLongLong(); - const qlonglong vR = right.data().toLongLong(); + const qlonglong vL = left.data().toLongLong(); + const qlonglong vR = right.data().toLongLong(); - if (vL == -1) return false; - if (vR == -1) return true; + if (vL == -1) return false; + if (vR == -1) return true; - return vL < vR; - } + return vL < vR; + } case TorrentModel::TR_RATIO_LIMIT: { - const qreal vL = left.data().toDouble(); - const qreal vR = right.data().toDouble(); + const qreal vL = left.data().toDouble(); + const qreal vR = right.data().toDouble(); - if (vL == -1) return false; - if (vR == -1) return true; + if (vL == -1) return false; + if (vR == -1) return true; - return vL < vR; - } + return vL < vR; + } default: { if (left.data() != right.data()) return QSortFilterProxyModel::lessThan(left, right); return lowerPositionThan(left, right); - } + } } } diff --git a/src/gui/transferlistsortmodel.h b/src/gui/transferlistsortmodel.h index a4ca13010..e8581b136 100644 --- a/src/gui/transferlistsortmodel.h +++ b/src/gui/transferlistsortmodel.h @@ -1,6 +1,6 @@ /* - * Bittorrent Client using Qt4 and libtorrent. - * Copyright (C) 2013 Nick Tiskov + * Bittorrent Client using Qt and libtorrent. + * Copyright (C) 2013 Nick Tiskov * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -24,8 +24,6 @@ * modify file(s), you may extend this exception to your version of the file(s), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : daymansmail@gmail.com */ #ifndef TRANSFERLISTSORTMODEL_H @@ -36,7 +34,7 @@ class QStringList; -class TransferListSortModel: public QSortFilterProxyModel +class TransferListSortModel : public QSortFilterProxyModel { Q_OBJECT @@ -52,10 +50,10 @@ public: void disableTrackerFilter(); private: - bool lessThan(const QModelIndex &left, const QModelIndex &right) const; + bool lessThan(const QModelIndex &left, const QModelIndex &right) const override; bool lowerPositionThan(const QModelIndex &left, const QModelIndex &right) const; bool dateLessThan(const int dateColumn, const QModelIndex &left, const QModelIndex &right, bool sortInvalidInBottom) const; - bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; + bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override; bool matchFilter(int sourceRow, const QModelIndex &sourceParent) const; private: diff --git a/src/gui/transferlistwidget.cpp b/src/gui/transferlistwidget.cpp index 3b801d78e..b19332b32 100644 --- a/src/gui/transferlistwidget.cpp +++ b/src/gui/transferlistwidget.cpp @@ -1,5 +1,5 @@ /* - * Bittorrent Client using Qt4 and libtorrent. + * Bittorrent Client using Qt and libtorrent. * Copyright (C) 2006 Christophe Dumez * * This program is free software; you can redistribute it and/or @@ -79,7 +79,7 @@ namespace } // Helper for setting style parameters when painting check box primitives. - class CheckBoxIconHelper: public QCheckBox + class CheckBoxIconHelper : public QCheckBox { public: explicit CheckBoxIconHelper(QWidget *parent); @@ -108,7 +108,7 @@ namespace } // Tristate checkbox styled for use in menus. - class MenuCheckBox: public QWidget + class MenuCheckBox : public QWidget { public: MenuCheckBox(const QString &text, const ToggleFn &onToggle, Qt::CheckState initialState); @@ -188,7 +188,7 @@ namespace m_checkBox->click(); } - class CheckBoxMenuItem: public QWidgetAction + class CheckBoxMenuItem : public QWidgetAction { public: CheckBoxMenuItem(const QString &text, const ToggleFn &onToggle, Qt::CheckState initialState, QObject *parent) @@ -206,7 +206,7 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *mainWindow) setUniformRowHeights(true); // Load settings - bool column_loaded = loadSettings(); + bool columnLoaded = loadSettings(); // Create and apply delegate m_listDelegate = new TransferListDelegate(this); @@ -238,7 +238,7 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *mainWindow) header()->setStretchLastSection(false); // Default hidden columns - if (!column_loaded) { + if (!columnLoaded) { setColumnHidden(TorrentModel::TR_ADD_DATE, true); setColumnHidden(TorrentModel::TR_SEED_DATE, true); setColumnHidden(TorrentModel::TR_UPLIMIT, true); @@ -318,7 +318,7 @@ TransferListWidget::~TransferListWidget() qDebug() << Q_FUNC_INFO << "EXIT"; } -TorrentModel* TransferListWidget::getSourceModel() const +TorrentModel *TransferListWidget::getSourceModel() const { return m_listModel; } @@ -358,7 +358,7 @@ void TransferListWidget::torrentDoubleClicked() else action = Preferences::instance()->getActionOnDblClOnTorrentDl(); - switch(action) { + switch (action) { case TOGGLE_PAUSE: if (torrent->isPaused()) torrent->resume(); @@ -531,7 +531,7 @@ void TransferListWidget::copySelectedMagnetURIs() const foreach (BitTorrent::TorrentHandle *const torrent, getSelectedTorrents()) magnet_uris << torrent->toMagnetUri(); - qApp->clipboard()->setText(magnet_uris.join("\n")); + qApp->clipboard()->setText(magnet_uris.join('\n')); } void TransferListWidget::copySelectedNames() const @@ -540,7 +540,7 @@ void TransferListWidget::copySelectedNames() const foreach (BitTorrent::TorrentHandle *const torrent, getSelectedTorrents()) torrent_names << torrent->name(); - qApp->clipboard()->setText(torrent_names.join("\n")); + qApp->clipboard()->setText(torrent_names.join('\n')); } void TransferListWidget::copySelectedHashes() const @@ -703,8 +703,8 @@ void TransferListWidget::displayDLHoSMenu(const QPoint&) hideshowColumn.setTitle(tr("Column visibility")); QList actions; for (int i = 0; i < m_listModel->columnCount(); ++i) { - if (!BitTorrent::Session::instance()->isQueueingSystemEnabled() && i == TorrentModel::TR_PRIORITY) { - actions.append(0); + if (!BitTorrent::Session::instance()->isQueueingSystemEnabled() && (i == TorrentModel::TR_PRIORITY)) { + actions.append(nullptr); continue; } QAction *myAct = hideshowColumn.addAction(m_listModel->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString()); @@ -872,16 +872,16 @@ void TransferListWidget::displayListMenu(const QPoint&) connect(&actionForceStart, &QAction::triggered, this, &TransferListWidget::forceStartSelectedTorrents); QAction actionDelete(GuiIconProvider::instance()->getIcon("edit-delete"), tr("Delete", "Delete the torrent"), nullptr); connect(&actionDelete, &QAction::triggered, this, &TransferListWidget::softDeleteSelectedTorrents); - QAction actionPreview_file(GuiIconProvider::instance()->getIcon("view-preview"), tr("Preview file..."), nullptr); - connect(&actionPreview_file, &QAction::triggered, this, &TransferListWidget::previewSelectedTorrents); - QAction actionSet_max_ratio(QIcon(QLatin1String(":/icons/skin/ratio.png")), tr("Limit share ratio..."), nullptr); - connect(&actionSet_max_ratio, &QAction::triggered, this, &TransferListWidget::setMaxRatioSelectedTorrents); - QAction actionSet_upload_limit(GuiIconProvider::instance()->getIcon("kt-set-max-upload-speed"), tr("Limit upload rate..."), nullptr); - connect(&actionSet_upload_limit, &QAction::triggered, this, &TransferListWidget::setUpLimitSelectedTorrents); - QAction actionSet_download_limit(GuiIconProvider::instance()->getIcon("kt-set-max-download-speed"), tr("Limit download rate..."), nullptr); - connect(&actionSet_download_limit, &QAction::triggered, this, &TransferListWidget::setDlLimitSelectedTorrents); - QAction actionOpen_destination_folder(GuiIconProvider::instance()->getIcon("inode-directory"), tr("Open destination folder"), nullptr); - connect(&actionOpen_destination_folder, &QAction::triggered, this, &TransferListWidget::openSelectedTorrentsFolder); + QAction actionPreviewFile(GuiIconProvider::instance()->getIcon("view-preview"), tr("Preview file..."), nullptr); + connect(&actionPreviewFile, &QAction::triggered, this, &TransferListWidget::previewSelectedTorrents); + QAction actionSetMaxRatio(QIcon(QLatin1String(":/icons/skin/ratio.png")), tr("Limit share ratio..."), nullptr); + connect(&actionSetMaxRatio, &QAction::triggered, this, &TransferListWidget::setMaxRatioSelectedTorrents); + QAction actionSetUploadLimit(GuiIconProvider::instance()->getIcon("kt-set-max-upload-speed"), tr("Limit upload rate..."), nullptr); + connect(&actionSetUploadLimit, &QAction::triggered, this, &TransferListWidget::setUpLimitSelectedTorrents); + QAction actionSetDownloadLimit(GuiIconProvider::instance()->getIcon("kt-set-max-download-speed"), tr("Limit download rate..."), nullptr); + connect(&actionSetDownloadLimit, &QAction::triggered, this, &TransferListWidget::setDlLimitSelectedTorrents); + QAction actionOpenDestinationFolder(GuiIconProvider::instance()->getIcon("inode-directory"), tr("Open destination folder"), nullptr); + connect(&actionOpenDestinationFolder, &QAction::triggered, this, &TransferListWidget::openSelectedTorrentsFolder); QAction actionIncreasePriority(GuiIconProvider::instance()->getIcon("go-up"), tr("Move up", "i.e. move up in the queue"), nullptr); connect(&actionIncreasePriority, &QAction::triggered, this, &TransferListWidget::increasePrioSelectedTorrents); QAction actionDecreasePriority(GuiIconProvider::instance()->getIcon("go-down"), tr("Move down", "i.e. Move down in the queue"), nullptr); @@ -892,27 +892,27 @@ void TransferListWidget::displayListMenu(const QPoint&) connect(&actionBottomPriority, &QAction::triggered, this, &TransferListWidget::bottomPrioSelectedTorrents); QAction actionSetTorrentPath(GuiIconProvider::instance()->getIcon("inode-directory"), tr("Set location..."), nullptr); connect(&actionSetTorrentPath, &QAction::triggered, this, &TransferListWidget::setSelectedTorrentsLocation); - QAction actionForce_recheck(GuiIconProvider::instance()->getIcon("document-edit-verify"), tr("Force recheck"), nullptr); - connect(&actionForce_recheck, &QAction::triggered, this, &TransferListWidget::recheckSelectedTorrents); - QAction actionForce_reannounce(GuiIconProvider::instance()->getIcon("document-edit-verify"), tr("Force reannounce"), nullptr); - connect(&actionForce_reannounce, &QAction::triggered, this, &TransferListWidget::reannounceSelectedTorrents); - QAction actionCopy_magnet_link(GuiIconProvider::instance()->getIcon("kt-magnet"), tr("Copy magnet link"), nullptr); - connect(&actionCopy_magnet_link, &QAction::triggered, this, &TransferListWidget::copySelectedMagnetURIs); - QAction actionCopy_name(GuiIconProvider::instance()->getIcon("edit-copy"), tr("Copy name"), nullptr); - connect(&actionCopy_name, &QAction::triggered, this, &TransferListWidget::copySelectedNames); + QAction actionForceRecheck(GuiIconProvider::instance()->getIcon("document-edit-verify"), tr("Force recheck"), nullptr); + connect(&actionForceRecheck, &QAction::triggered, this, &TransferListWidget::recheckSelectedTorrents); + QAction actionForceReannounce(GuiIconProvider::instance()->getIcon("document-edit-verify"), tr("Force reannounce"), nullptr); + connect(&actionForceReannounce, &QAction::triggered, this, &TransferListWidget::reannounceSelectedTorrents); + QAction actionCopyMagnetLink(GuiIconProvider::instance()->getIcon("kt-magnet"), tr("Copy magnet link"), nullptr); + connect(&actionCopyMagnetLink, &QAction::triggered, this, &TransferListWidget::copySelectedMagnetURIs); + QAction actionCopyName(GuiIconProvider::instance()->getIcon("edit-copy"), tr("Copy name"), nullptr); + connect(&actionCopyName, &QAction::triggered, this, &TransferListWidget::copySelectedNames); QAction actionCopyHash(GuiIconProvider::instance()->getIcon("edit-copy"), tr("Copy hash"), nullptr); connect(&actionCopyHash, &QAction::triggered, this, &TransferListWidget::copySelectedHashes); - QAction actionSuper_seeding_mode(tr("Super seeding mode"), nullptr); - actionSuper_seeding_mode.setCheckable(true); - connect(&actionSuper_seeding_mode, &QAction::triggered, this, &TransferListWidget::toggleSelectedTorrentsSuperSeeding); + QAction actionSuperSeedingMode(tr("Super seeding mode"), nullptr); + actionSuperSeedingMode.setCheckable(true); + connect(&actionSuperSeedingMode, &QAction::triggered, this, &TransferListWidget::toggleSelectedTorrentsSuperSeeding); QAction actionRename(GuiIconProvider::instance()->getIcon("edit-rename"), tr("Rename..."), nullptr); connect(&actionRename, &QAction::triggered, this, &TransferListWidget::renameSelectedTorrent); - QAction actionSequential_download(tr("Download in sequential order"), nullptr); - actionSequential_download.setCheckable(true); - connect(&actionSequential_download, &QAction::triggered, this, &TransferListWidget::toggleSelectedTorrentsSequentialDownload); - QAction actionFirstLastPiece_prio(tr("Download first and last pieces first"), nullptr); - actionFirstLastPiece_prio.setCheckable(true); - connect(&actionFirstLastPiece_prio, &QAction::triggered, this, &TransferListWidget::toggleSelectedFirstLastPiecePrio); + QAction actionSequentialDownload(tr("Download in sequential order"), nullptr); + actionSequentialDownload.setCheckable(true); + connect(&actionSequentialDownload, &QAction::triggered, this, &TransferListWidget::toggleSelectedTorrentsSequentialDownload); + QAction actionFirstLastPiecePrio(tr("Download first and last pieces first"), nullptr); + actionFirstLastPiecePrio.setCheckable(true); + connect(&actionFirstLastPiecePrio, &QAction::triggered, this, &TransferListWidget::toggleSelectedFirstLastPiecePrio); QAction actionAutoTMM(tr("Automatic Torrent Management"), nullptr); actionAutoTMM.setCheckable(true); actionAutoTMM.setToolTip(tr("Automatic mode means that various torrent properties(eg save path) will be decided by the associated category")); @@ -920,12 +920,12 @@ void TransferListWidget::displayListMenu(const QPoint&) // End of actions // Enable/disable pause/start action given the DL state - bool needs_pause = false, needs_start = false, needs_force = false, needs_preview = false; - bool all_same_super_seeding = true; - bool super_seeding_mode = false; - bool all_same_sequential_download_mode = true, all_same_prio_firstlast = true; - bool sequential_download_mode = false, prioritize_first_last = false; - bool one_has_metadata = false, one_not_seed = false; + bool needsPause = false, needsStart = false, needsForce = false, needsPreview = false; + bool allSameSuperSeeding = true; + bool superSeedingMode = false; + bool allSameSequentialDownloadMode = true, allSamePrioFirstlast = true; + bool sequentialDownloadMode = false, prioritizeFirstLast = false; + bool oneHasMetadata = false, oneNotSeed = false; bool allSameCategory = true; bool allSameAutoTMM = true; bool firstAutoTMM = false; @@ -960,57 +960,57 @@ void TransferListWidget::displayListMenu(const QPoint&) allSameAutoTMM = false; if (torrent->hasMetadata()) - one_has_metadata = true; + oneHasMetadata = true; if (!torrent->isSeed()) { - one_not_seed = true; + oneNotSeed = true; if (torrent->hasMetadata()) { if (first) { - sequential_download_mode = torrent->isSequentialDownload(); - prioritize_first_last = torrent->hasFirstLastPiecePriority(); + sequentialDownloadMode = torrent->isSequentialDownload(); + prioritizeFirstLast = torrent->hasFirstLastPiecePriority(); } else { - if (sequential_download_mode != torrent->isSequentialDownload()) - all_same_sequential_download_mode = false; - if (prioritize_first_last != torrent->hasFirstLastPiecePriority()) - all_same_prio_firstlast = false; + if (sequentialDownloadMode != torrent->isSequentialDownload()) + allSameSequentialDownloadMode = false; + if (prioritizeFirstLast != torrent->hasFirstLastPiecePriority()) + allSamePrioFirstlast = false; } } } else { - if (!one_not_seed && all_same_super_seeding && torrent->hasMetadata()) { + if (!oneNotSeed && allSameSuperSeeding && torrent->hasMetadata()) { if (first) { - super_seeding_mode = torrent->superSeeding(); + superSeedingMode = torrent->superSeeding(); } - else if (super_seeding_mode != torrent->superSeeding()) - all_same_super_seeding = false; + else if (superSeedingMode != torrent->superSeeding()) + allSameSuperSeeding = false; } } if (!torrent->isForced()) - needs_force = true; + needsForce = true; else - needs_start = true; + needsStart = true; if (torrent->isPaused()) - needs_start = true; + needsStart = true; else - needs_pause = true; + needsPause = true; if (torrent->hasMetadata()) - needs_preview = true; + needsPreview = true; first = false; - if (one_has_metadata && one_not_seed && !all_same_sequential_download_mode - && !all_same_prio_firstlast && !all_same_super_seeding && !allSameCategory - && needs_start && needs_force && needs_pause && needs_preview && !allSameAutoTMM) { + if (oneHasMetadata && oneNotSeed && !allSameSequentialDownloadMode + && !allSamePrioFirstlast && !allSameSuperSeeding && !allSameCategory + && needsStart && needsForce && needsPause && needsPreview && !allSameAutoTMM) { break; } } QMenu listMenu(this); - if (needs_start) + if (needsStart) listMenu.addAction(&actionStart); - if (needs_pause) + if (needsPause) listMenu.addAction(&actionPause); - if (needs_force) + if (needsForce) listMenu.addAction(&actionForceStart); listMenu.addSeparator(); listMenu.addAction(&actionDelete); @@ -1068,42 +1068,42 @@ void TransferListWidget::displayListMenu(const QPoint&) } listMenu.addSeparator(); - if (one_not_seed) - listMenu.addAction(&actionSet_download_limit); - listMenu.addAction(&actionSet_upload_limit); - listMenu.addAction(&actionSet_max_ratio); - if (!one_not_seed && all_same_super_seeding && one_has_metadata) { - actionSuper_seeding_mode.setChecked(super_seeding_mode); - listMenu.addAction(&actionSuper_seeding_mode); + if (oneNotSeed) + listMenu.addAction(&actionSetDownloadLimit); + listMenu.addAction(&actionSetUploadLimit); + listMenu.addAction(&actionSetMaxRatio); + if (!oneNotSeed && allSameSuperSeeding && oneHasMetadata) { + actionSuperSeedingMode.setChecked(superSeedingMode); + listMenu.addAction(&actionSuperSeedingMode); } listMenu.addSeparator(); - bool added_preview_action = false; - if (needs_preview) { - listMenu.addAction(&actionPreview_file); - added_preview_action = true; + bool addedPreviewAction = false; + if (needsPreview) { + listMenu.addAction(&actionPreviewFile); + addedPreviewAction = true; } - if (one_not_seed && one_has_metadata) { - if (all_same_sequential_download_mode) { - actionSequential_download.setChecked(sequential_download_mode); - listMenu.addAction(&actionSequential_download); - added_preview_action = true; + if (oneNotSeed && oneHasMetadata) { + if (allSameSequentialDownloadMode) { + actionSequentialDownload.setChecked(sequentialDownloadMode); + listMenu.addAction(&actionSequentialDownload); + addedPreviewAction = true; } - if (all_same_prio_firstlast) { - actionFirstLastPiece_prio.setChecked(prioritize_first_last); - listMenu.addAction(&actionFirstLastPiece_prio); - added_preview_action = true; + if (allSamePrioFirstlast) { + actionFirstLastPiecePrio.setChecked(prioritizeFirstLast); + listMenu.addAction(&actionFirstLastPiecePrio); + addedPreviewAction = true; } } - if (added_preview_action) + if (addedPreviewAction) listMenu.addSeparator(); - if (one_has_metadata) { - listMenu.addAction(&actionForce_recheck); - listMenu.addAction(&actionForce_reannounce); + if (oneHasMetadata) { + listMenu.addAction(&actionForceRecheck); + listMenu.addAction(&actionForceReannounce); listMenu.addSeparator(); } - listMenu.addAction(&actionOpen_destination_folder); - if (BitTorrent::Session::instance()->isQueueingSystemEnabled() && one_not_seed) { + listMenu.addAction(&actionOpenDestinationFolder); + if (BitTorrent::Session::instance()->isQueueingSystemEnabled() && oneNotSeed) { listMenu.addSeparator(); QMenu *prioMenu = listMenu.addMenu(tr("Priority")); prioMenu->addAction(&actionTopPriority); @@ -1112,9 +1112,9 @@ void TransferListWidget::displayListMenu(const QPoint&) prioMenu->addAction(&actionBottomPriority); } listMenu.addSeparator(); - listMenu.addAction(&actionCopy_name); + listMenu.addAction(&actionCopyName); listMenu.addAction(&actionCopyHash); - listMenu.addAction(&actionCopy_magnet_link); + listMenu.addAction(&actionCopyMagnetLink); // Call menu QAction *act = nullptr; act = listMenu.exec(QCursor::pos()); @@ -1186,7 +1186,7 @@ void TransferListWidget::applyTrackerFilter(const QStringList &hashes) m_sortFilterModel->setTrackerFilter(hashes); } -void TransferListWidget::applyNameFilter(const QString& name) +void TransferListWidget::applyNameFilter(const QString &name) { m_sortFilterModel->setFilterRegExp(QRegExp(name, Qt::CaseInsensitive, QRegExp::WildcardUnix)); } @@ -1195,7 +1195,7 @@ void TransferListWidget::applyStatusFilter(int f) { m_sortFilterModel->setStatusFilter(static_cast(f)); // Select first item if nothing is selected - if (selectionModel()->selectedRows(0).empty() && m_sortFilterModel->rowCount() > 0) { + if (selectionModel()->selectedRows(0).empty() && (m_sortFilterModel->rowCount() > 0)) { qDebug("Nothing is selected, selecting first row: %s", qUtf8Printable(m_sortFilterModel->index(0, TorrentModel::TR_NAME).data().toString())); selectionModel()->setCurrentIndex(m_sortFilterModel->index(0, TorrentModel::TR_NAME), QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows); } diff --git a/src/gui/transferlistwidget.h b/src/gui/transferlistwidget.h index ef272fd55..a9b3c1963 100644 --- a/src/gui/transferlistwidget.h +++ b/src/gui/transferlistwidget.h @@ -1,6 +1,6 @@ /* - * Bittorrent Client using Qt4 and libtorrent. - * Copyright (C) 2006 Christophe Dumez + * Bittorrent Client using Qt and libtorrent. + * Copyright (C) 2006 Christophe Dumez * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -24,8 +24,6 @@ * modify file(s), you may extend this exception to your version of the file(s), * but you are not obligated to do so. If you do not wish to do so, delete this * exception statement from your version. - * - * Contact : chris@qbittorrent.org */ #ifndef TRANSFERLISTWIDGET_H @@ -39,25 +37,23 @@ namespace BitTorrent class TorrentHandle; } +class QShortcut; +class QSortFilterProxyModel; +class QStandardItemModel; + class MainWindow; class TransferListDelegate; class TransferListSortModel; class TorrentModel; -QT_BEGIN_NAMESPACE -class QShortcut; -class QSortFilterProxyModel; -class QStandardItemModel; -QT_END_NAMESPACE - -class TransferListWidget: public QTreeView +class TransferListWidget : public QTreeView { Q_OBJECT public: TransferListWidget(QWidget *parent, MainWindow *mainWindow); ~TransferListWidget(); - TorrentModel* getSourceModel() const; + TorrentModel *getSourceModel() const; public slots: void setSelectionCategory(QString category); @@ -92,7 +88,7 @@ public slots: void previewSelectedTorrents(); void hidePriorityColumn(bool hide); void displayDLHoSMenu(const QPoint&); - void applyNameFilter(const QString& name); + void applyNameFilter(const QString &name); void applyStatusFilter(int f); void applyCategoryFilter(QString category); void applyTagFilter(const QString &tag); diff --git a/src/gui/updownratiodlg.h b/src/gui/updownratiodlg.h index a4bb6d031..eab601b13 100644 --- a/src/gui/updownratiodlg.h +++ b/src/gui/updownratiodlg.h @@ -51,7 +51,7 @@ public: int seedingTime() const; public slots: - void accept(); + void accept() override; private slots: void handleRatioTypeChanged(); diff --git a/src/gui/utils.cpp b/src/gui/utils.cpp index c01c70f73..e2279687a 100644 --- a/src/gui/utils.cpp +++ b/src/gui/utils.cpp @@ -60,7 +60,7 @@ qreal Utils::Gui::screenScalingFactor(const QWidget *widget) #else return widget->devicePixelRatio(); #endif -#endif +#endif // Q_OS_WIN } QPixmap Utils::Gui::scaledPixmap(const QString &path, const QWidget *widget, const int height) diff --git a/src/webui/api/torrentscontroller.cpp b/src/webui/api/torrentscontroller.cpp index 2e991256f..26dd06829 100644 --- a/src/webui/api/torrentscontroller.cpp +++ b/src/webui/api/torrentscontroller.cpp @@ -49,8 +49,8 @@ #include "base/torrentfilter.h" #include "base/utils/fs.h" #include "base/utils/string.h" -#include "serialize/serialize_torrent.h" #include "apierror.h" +#include "serialize/serialize_torrent.h" // Tracker keys const char KEY_TRACKER_URL[] = "url";