diff --git a/src/base/bittorrent/torrentinfo.cpp b/src/base/bittorrent/torrentinfo.cpp index a47501b03..a5a38d888 100644 --- a/src/base/bittorrent/torrentinfo.cpp +++ b/src/base/bittorrent/torrentinfo.cpp @@ -344,7 +344,7 @@ TorrentInfo::PieceRange TorrentInfo::filePieces(int fileIndex) const static_cast((firstOffset + fileSize - 1) / pieceLength())); } -void TorrentInfo::renameFile(uint index, const QString &newPath) +void TorrentInfo::renameFile(const int index, const QString &newPath) { if (!isValid()) return; nativeInfo()->rename_file(index, Utils::Fs::toNativePath(newPath).toStdString()); diff --git a/src/base/bittorrent/torrentinfo.h b/src/base/bittorrent/torrentinfo.h index 8030f042c..d3b11f283 100644 --- a/src/base/bittorrent/torrentinfo.h +++ b/src/base/bittorrent/torrentinfo.h @@ -102,7 +102,7 @@ namespace BitTorrent PieceRange filePieces(const QString &file) const; PieceRange filePieces(int fileIndex) const; - void renameFile(uint index, const QString &newPath); + void renameFile(int index, const QString &newPath); QString rootFolder() const; bool hasRootFolder() const; diff --git a/src/base/net/downloadmanager.cpp b/src/base/net/downloadmanager.cpp index 92a038a7f..66a74bcc1 100644 --- a/src/base/net/downloadmanager.cpp +++ b/src/base/net/downloadmanager.cpp @@ -64,7 +64,7 @@ namespace setAllCookies(cookies); } - ~NetworkCookieJar() + ~NetworkCookieJar() override { QDateTime now = QDateTime::currentDateTime(); QList cookies = allCookies(); diff --git a/src/base/net/private/geoipdatabase.cpp b/src/base/net/private/geoipdatabase.cpp index ba1af9a7e..3319c911c 100644 --- a/src/base/net/private/geoipdatabase.cpp +++ b/src/base/net/private/geoipdatabase.cpp @@ -92,12 +92,12 @@ GeoIPDatabase *GeoIPDatabase::load(const QString &filename, QString &error) QFile file(filename); if (file.size() > MAX_FILE_SIZE) { error = tr("Unsupported database file size."); - return 0; + return nullptr; } if (!file.open(QFile::ReadOnly)) { error = file.errorString(); - return 0; + return nullptr; } db = new GeoIPDatabase(file.size()); @@ -105,13 +105,13 @@ GeoIPDatabase *GeoIPDatabase::load(const QString &filename, QString &error) if (file.read(reinterpret_cast(db->m_data), db->m_size) != db->m_size) { error = file.errorString(); delete db; - return 0; + return nullptr; } if (!db->parseMetadata(db->readMetadata(), error) || !db->loadDB(error)) { delete db; - return 0; + return nullptr; } return db; @@ -122,7 +122,7 @@ GeoIPDatabase *GeoIPDatabase::load(const QByteArray &data, QString &error) GeoIPDatabase *db = nullptr; if (data.size() > MAX_FILE_SIZE) { error = tr("Unsupported database file size."); - return 0; + return nullptr; } db = new GeoIPDatabase(data.size()); @@ -131,7 +131,7 @@ GeoIPDatabase *GeoIPDatabase::load(const QByteArray &data, QString &error) if (!db->parseMetadata(db->readMetadata(), error) || !db->loadDB(error)) { delete db; - return 0; + return nullptr; } return db; diff --git a/src/gui/addnewtorrentdialog.cpp b/src/gui/addnewtorrentdialog.cpp index cb6cdf420..dd6fd9d7e 100644 --- a/src/gui/addnewtorrentdialog.cpp +++ b/src/gui/addnewtorrentdialog.cpp @@ -426,7 +426,7 @@ int AddNewTorrentDialog::indexOfSavePath(const QString &savePath) void AddNewTorrentDialog::updateDiskSpaceLabel() { // Determine torrent size - qulonglong torrentSize = 0; + qlonglong torrentSize = 0; if (m_hasMetadata) { if (m_contentModel) { diff --git a/src/gui/categoryfiltermodel.cpp b/src/gui/categoryfiltermodel.cpp index cfb104096..118fd0421 100644 --- a/src/gui/categoryfiltermodel.cpp +++ b/src/gui/categoryfiltermodel.cpp @@ -228,7 +228,7 @@ QVariant CategoryFilterModel::data(const QModelIndex &index, int role) const Qt::ItemFlags CategoryFilterModel::flags(const QModelIndex &index) const { - if (!index.isValid()) return 0; + if (!index.isValid()) return Qt::NoItemFlags; return Qt::ItemIsEnabled | Qt::ItemIsSelectable; } diff --git a/src/gui/cookiesmodel.cpp b/src/gui/cookiesmodel.cpp index 1d9f8b119..810274d4e 100644 --- a/src/gui/cookiesmodel.cpp +++ b/src/gui/cookiesmodel.cpp @@ -172,7 +172,7 @@ bool CookiesModel::removeRows(int row, int count, const QModelIndex &parent) Qt::ItemFlags CookiesModel::flags(const QModelIndex &index) const { - if (!index.isValid()) return 0; + if (!index.isValid()) return Qt::NoItemFlags; return Qt::ItemIsEditable | QAbstractItemModel::flags(index); } diff --git a/src/gui/guiiconprovider.h b/src/gui/guiiconprovider.h index 5f6c58657..f7942685b 100644 --- a/src/gui/guiiconprovider.h +++ b/src/gui/guiiconprovider.h @@ -53,7 +53,7 @@ private slots: private: explicit GuiIconProvider(QObject *parent = nullptr); - ~GuiIconProvider(); + ~GuiIconProvider() override; #if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) bool m_useSystemTheme; diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 10fbb4b65..3a4228550 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -1036,7 +1036,7 @@ void MainWindow::on_actionCloseWindow_triggered() QWidget *MainWindow::currentTabWidget() const { if (isMinimized() || !isVisible()) - return 0; + return nullptr; if (m_tabs->currentIndex() == 0) return m_transferListWidget; return m_tabs->currentWidget(); @@ -1437,7 +1437,7 @@ void MainWindow::loadPreferences(bool configureSession) #else const bool newSystrayIntegration = pref->systrayIntegration(); m_ui->actionLock->setVisible(newSystrayIntegration); - if (newSystrayIntegration != (m_systrayIcon != 0)) { + if (newSystrayIntegration != (m_systrayIcon != nullptr)) { if (newSystrayIntegration) { // create the trayicon if (!QSystemTrayIcon::isSystemTrayAvailable()) { diff --git a/src/gui/properties/peerlistdelegate.h b/src/gui/properties/peerlistdelegate.h index 93f7f88f5..e0baca12c 100644 --- a/src/gui/properties/peerlistdelegate.h +++ b/src/gui/properties/peerlistdelegate.h @@ -63,7 +63,7 @@ public: PeerListDelegate(QObject *parent) : QItemDelegate(parent) {} - ~PeerListDelegate() {} + ~PeerListDelegate() override {} void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override { diff --git a/src/gui/properties/peerlistwidget.cpp b/src/gui/properties/peerlistwidget.cpp index 8f579ed7e..41cef9b06 100644 --- a/src/gui/properties/peerlistwidget.cpp +++ b/src/gui/properties/peerlistwidget.cpp @@ -441,7 +441,7 @@ void PeerListWidget::updatePeer(const QString &ip, BitTorrent::TorrentHandle *co void PeerListWidget::handleResolved(const QString &ip, const QString &hostname) { - QStandardItem *item = m_peerItems.value(ip, 0); + QStandardItem *item = m_peerItems.value(ip, nullptr); if (item) { qDebug("Resolved %s -> %s", qUtf8Printable(ip), qUtf8Printable(hostname)); item->setData(hostname, Qt::DisplayRole); diff --git a/src/gui/properties/peerlistwidget.h b/src/gui/properties/peerlistwidget.h index 8053e8859..2dc7de4cb 100644 --- a/src/gui/properties/peerlistwidget.h +++ b/src/gui/properties/peerlistwidget.h @@ -61,7 +61,7 @@ class PeerListWidget : public QTreeView public: explicit PeerListWidget(PropertiesWidget *parent); - ~PeerListWidget(); + ~PeerListWidget() override; void loadPeers(BitTorrent::TorrentHandle *const torrent, bool forceHostnameResolution = false); QStandardItem *addPeer(const QString &ip, BitTorrent::TorrentHandle *const torrent, const BitTorrent::PeerInfo &peer); diff --git a/src/gui/properties/trackerlistwidget.cpp b/src/gui/properties/trackerlistwidget.cpp index 8b6e1e1db..986412ae4 100644 --- a/src/gui/properties/trackerlistwidget.cpp +++ b/src/gui/properties/trackerlistwidget.cpp @@ -73,7 +73,7 @@ TrackerListWidget::TrackerListWidget(PropertiesWidget *properties) // To also mitigate the above issue, we have to resize each column when // its size is 0, because explicitly 'showing' the column isn't enough // in the above scenario. - for (unsigned int i = 0; i < COL_COUNT; ++i) + for (int i = 0; i < COL_COUNT; ++i) if ((columnWidth(i) <= 0) && !isColumnHidden(i)) resizeColumnToContents(i); // Context menu @@ -150,9 +150,9 @@ QList TrackerListWidget::getSelectedTrackerItems() const void TrackerListWidget::setRowColor(int row, QColor color) { - unsigned int nbColumns = columnCount(); + const int nbColumns = columnCount(); QTreeWidgetItem *item = topLevelItem(row); - for (unsigned int i = 0; i < nbColumns; ++i) + for (int i = 0; i < nbColumns; ++i) item->setData(i, Qt::ForegroundRole, color); } @@ -333,7 +333,7 @@ void TrackerListWidget::loadTrackers() QStringList oldTrackerURLs = m_trackerItems.keys(); foreach (const BitTorrent::TrackerEntry &entry, torrent->trackers()) { QString trackerURL = entry.url(); - QTreeWidgetItem *item = m_trackerItems.value(trackerURL, 0); + QTreeWidgetItem *item = m_trackerItems.value(trackerURL, nullptr); if (!item) { item = new QTreeWidgetItem(); item->setText(COL_URL, trackerURL); @@ -604,7 +604,7 @@ QStringList TrackerListWidget::headerLabels() int TrackerListWidget::visibleColumnsCount() const { int visibleCols = 0; - for (unsigned int i = 0; i < COL_COUNT; ++i) { + for (int i = 0; i < COL_COUNT; ++i) { if (!isColumnHidden(i)) ++visibleCols; } diff --git a/src/gui/scanfoldersdelegate.cpp b/src/gui/scanfoldersdelegate.cpp index f691d9df3..4c712ef43 100644 --- a/src/gui/scanfoldersdelegate.cpp +++ b/src/gui/scanfoldersdelegate.cpp @@ -54,7 +54,7 @@ void ScanFoldersDelegate::setEditorData(QWidget *editor, const QModelIndex &inde QWidget *ScanFoldersDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &index) const { - if (index.column() != ScanFoldersModel::DOWNLOAD) return 0; + if (index.column() != ScanFoldersModel::DOWNLOAD) return nullptr; QComboBox *editor = new QComboBox(parent); @@ -96,7 +96,7 @@ void ScanFoldersDelegate::setModelData(QWidget *editor, QAbstractItemModel *mode model->setData( index, QFileDialog::getExistingDirectory( - 0, tr("Select save location"), + nullptr, tr("Select save location"), index.data(Qt::UserRole).toInt() == ScanFoldersModel::CUSTOM_LOCATION ? index.data().toString() : BitTorrent::Session::instance()->defaultSavePath()), diff --git a/src/gui/search/pluginselectdialog.cpp b/src/gui/search/pluginselectdialog.cpp index 6f6a26b9c..e2dcd9915 100644 --- a/src/gui/search/pluginselectdialog.cpp +++ b/src/gui/search/pluginselectdialog.cpp @@ -258,7 +258,7 @@ QTreeWidgetItem *PluginSelectDialog::findItemWithID(QString id) return item; } - return 0; + return nullptr; } void PluginSelectDialog::loadSupportedSearchPlugins() @@ -361,7 +361,7 @@ void PluginSelectDialog::askForPluginUrl() void PluginSelectDialog::askForLocalPlugin() { QStringList pathsList = QFileDialog::getOpenFileNames( - 0, tr("Select search plugins"), QDir::homePath(), + nullptr, tr("Select search plugins"), QDir::homePath(), tr("qBittorrent search plugin") + QLatin1String(" (*.py)") ); foreach (QString path, pathsList) { diff --git a/src/gui/search/searchjobwidget.cpp b/src/gui/search/searchjobwidget.cpp index 3974685cc..da7bb3b1d 100644 --- a/src/gui/search/searchjobwidget.cpp +++ b/src/gui/search/searchjobwidget.cpp @@ -103,7 +103,7 @@ SearchJobWidget::SearchJobWidget(SearchHandler *searchHandler, QWidget *parent) // Ensure that at least one column is visible at all times bool atLeastOne = false; - for (unsigned int i = 0; i < SearchSortModel::DL_LINK; ++i) { + for (int i = 0; i < SearchSortModel::DL_LINK; ++i) { if (!m_ui->resultsBrowser->isColumnHidden(i)) { atLeastOne = true; break; @@ -114,7 +114,7 @@ SearchJobWidget::SearchJobWidget(SearchHandler *searchHandler, QWidget *parent) // To also mitigate the above issue, we have to resize each column when // its size is 0, because explicitly 'showing' the column isn't enough // in the above scenario. - for (unsigned int i = 0; i < SearchSortModel::DL_LINK; ++i) + for (int i = 0; i < SearchSortModel::DL_LINK; ++i) if ((m_ui->resultsBrowser->columnWidth(i) <= 0) && !m_ui->resultsBrowser->isColumnHidden(i)) m_ui->resultsBrowser->resizeColumnToContents(i); @@ -412,7 +412,7 @@ void SearchJobWidget::displayToggleColumnsMenu(const QPoint&) actions.append(myAct); } int visibleCols = 0; - for (unsigned int i = 0; i < SearchSortModel::DL_LINK; ++i) { + for (int i = 0; i < SearchSortModel::DL_LINK; ++i) { if (!m_ui->resultsBrowser->isColumnHidden(i)) ++visibleCols; diff --git a/src/gui/tagfiltermodel.cpp b/src/gui/tagfiltermodel.cpp index 8dcb6181d..8ffb934b8 100644 --- a/src/gui/tagfiltermodel.cpp +++ b/src/gui/tagfiltermodel.cpp @@ -135,7 +135,7 @@ QVariant TagFilterModel::data(const QModelIndex &index, int role) const Qt::ItemFlags TagFilterModel::flags(const QModelIndex &index) const { if (!index.isValid()) - return 0; + return Qt::NoItemFlags; return Qt::ItemIsEnabled | Qt::ItemIsSelectable; } diff --git a/src/gui/tagfiltermodel.h b/src/gui/tagfiltermodel.h index 4d02035ce..c1efaf76f 100644 --- a/src/gui/tagfiltermodel.h +++ b/src/gui/tagfiltermodel.h @@ -47,7 +47,7 @@ class TagFilterModel : public QAbstractListModel public: explicit TagFilterModel(QObject *parent = nullptr); - ~TagFilterModel(); + ~TagFilterModel() override; static bool isSpecialItem(const QModelIndex &index); diff --git a/src/gui/torrentcontentfiltermodel.h b/src/gui/torrentcontentfiltermodel.h index e79d94cae..72a701f65 100644 --- a/src/gui/torrentcontentfiltermodel.h +++ b/src/gui/torrentcontentfiltermodel.h @@ -41,7 +41,7 @@ class TorrentContentFilterModel : public QSortFilterProxyModel public: TorrentContentFilterModel(QObject *parent = nullptr); - virtual ~TorrentContentFilterModel(); + ~TorrentContentFilterModel() override; TorrentContentModel *model() const; TorrentContentModelItem::ItemType itemType(const QModelIndex &index) const; diff --git a/src/gui/torrentcontentmodel.cpp b/src/gui/torrentcontentmodel.cpp index c6c4ce69b..01bc66c30 100644 --- a/src/gui/torrentcontentmodel.cpp +++ b/src/gui/torrentcontentmodel.cpp @@ -377,7 +377,7 @@ QVariant TorrentContentModel::data(const QModelIndex& index, int role) const Qt::ItemFlags TorrentContentModel::flags(const QModelIndex &index) const { if (!index.isValid()) - return 0; + return Qt::NoItemFlags; if (itemType(index) == TorrentContentModelItem::FolderType) return Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsTristate; diff --git a/src/gui/torrentcontentmodel.h b/src/gui/torrentcontentmodel.h index bb1d835ac..3a151cffa 100644 --- a/src/gui/torrentcontentmodel.h +++ b/src/gui/torrentcontentmodel.h @@ -46,7 +46,7 @@ class TorrentContentModel : public QAbstractItemModel public: TorrentContentModel(QObject *parent = nullptr); - ~TorrentContentModel(); + ~TorrentContentModel() override; void updateFilesProgress(const QVector &fp); void updateFilesPriorities(const QVector &fprio); diff --git a/src/gui/torrentcontentmodelfolder.cpp b/src/gui/torrentcontentmodelfolder.cpp index 404a268bd..727de5162 100644 --- a/src/gui/torrentcontentmodelfolder.cpp +++ b/src/gui/torrentcontentmodelfolder.cpp @@ -80,7 +80,7 @@ void TorrentContentModelFolder::appendChild(TorrentContentModelItem *item) TorrentContentModelItem *TorrentContentModelFolder::child(int row) const { - return m_childItems.value(row, 0); + return m_childItems.value(row, nullptr); } TorrentContentModelFolder *TorrentContentModelFolder::childFolderWithName(const QString &name) const @@ -88,7 +88,7 @@ TorrentContentModelFolder *TorrentContentModelFolder::childFolderWithName(const foreach (TorrentContentModelItem *child, m_childItems) if ((child->itemType() == FolderType) && (child->name() == name)) return static_cast(child); - return 0; + return nullptr; } int TorrentContentModelFolder::childCount() const diff --git a/src/gui/torrentcontentmodelfolder.h b/src/gui/torrentcontentmodelfolder.h index 521ec6970..940a2629a 100644 --- a/src/gui/torrentcontentmodelfolder.h +++ b/src/gui/torrentcontentmodelfolder.h @@ -40,7 +40,7 @@ public: // Invisible root item constructor TorrentContentModelFolder(const QList &data); - ~TorrentContentModelFolder(); + ~TorrentContentModelFolder() override; ItemType itemType() const override; diff --git a/src/gui/torrentcreatordialog.h b/src/gui/torrentcreatordialog.h index 62a340f35..1362c0f62 100644 --- a/src/gui/torrentcreatordialog.h +++ b/src/gui/torrentcreatordialog.h @@ -50,7 +50,7 @@ class TorrentCreatorDialog : public QDialog public: TorrentCreatorDialog(QWidget *parent = nullptr, const QString &defaultPath = QString()); - ~TorrentCreatorDialog(); + ~TorrentCreatorDialog() override; void updateInputPath(const QString &path); private slots: diff --git a/src/gui/transferlistdelegate.cpp b/src/gui/transferlistdelegate.cpp index 5e8f0b756..4500d1df4 100644 --- a/src/gui/transferlistdelegate.cpp +++ b/src/gui/transferlistdelegate.cpp @@ -104,7 +104,7 @@ void TransferListDelegate::paint(QPainter *painter, const QStyleOptionViewItem & break; case TransferListModel::TR_UPSPEED: case TransferListModel::TR_DLSPEED: { - const qulonglong speed = index.data().toULongLong(); + const int speed = index.data().toInt(); if (hideValues && !speed) break; opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter; diff --git a/src/gui/transferlistfilterswidget.h b/src/gui/transferlistfilterswidget.h index 2aa102371..bbea12e7f 100644 --- a/src/gui/transferlistfilterswidget.h +++ b/src/gui/transferlistfilterswidget.h @@ -71,7 +71,7 @@ class StatusFilterWidget : public BaseFilterWidget public: StatusFilterWidget(QWidget *parent, TransferListWidget *transferList); - ~StatusFilterWidget(); + ~StatusFilterWidget() override; private slots: void updateTorrentNumbers(); @@ -91,7 +91,7 @@ class TrackerFiltersList : public BaseFilterWidget public: TrackerFiltersList(QWidget *parent, TransferListWidget *transferList); - ~TrackerFiltersList(); + ~TrackerFiltersList() override; // Redefine addItem() to make sure the list stays sorted void addItem(const QString &tracker, const QString &hash); diff --git a/src/gui/transferlistmodel.cpp b/src/gui/transferlistmodel.cpp index f7766c814..3c5304257 100644 --- a/src/gui/transferlistmodel.cpp +++ b/src/gui/transferlistmodel.cpp @@ -240,8 +240,6 @@ QVariant TransferListModel::data(const QModelIndex &index, int role) const return torrent->timeSinceActivity(); case TR_TOTAL_SIZE: return torrent->totalSize(); - default: - return QVariant(); } return QVariant(); @@ -283,7 +281,7 @@ void TransferListModel::addTorrent(BitTorrent::TorrentHandle *const torrent) Qt::ItemFlags TransferListModel::flags(const QModelIndex &index) const { - if (!index.isValid()) return 0; + if (!index.isValid()) return Qt::NoItemFlags; // Explicitly mark as editable return QAbstractListModel::flags(index) | Qt::ItemIsEditable; @@ -291,7 +289,7 @@ Qt::ItemFlags TransferListModel::flags(const QModelIndex &index) const BitTorrent::TorrentHandle *TransferListModel::torrentHandle(const QModelIndex &index) const { - if (!index.isValid()) return 0; + if (!index.isValid()) return nullptr; return m_torrents.value(index.row()); } diff --git a/src/gui/transferlistwidget.cpp b/src/gui/transferlistwidget.cpp index bcd81d8c8..13349987c 100644 --- a/src/gui/transferlistwidget.cpp +++ b/src/gui/transferlistwidget.cpp @@ -260,7 +260,7 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *mainWindow) //Ensure that at least one column is visible at all times bool atLeastOne = false; - for (unsigned int i = 0; i < TransferListModel::NB_COLUMNS; ++i) { + for (int i = 0; i < TransferListModel::NB_COLUMNS; ++i) { if (!isColumnHidden(i)) { atLeastOne = true; break; @@ -272,7 +272,7 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *mainWindow) //When adding/removing columns between versions some may //end up being size 0 when the new version is launched with //a conf file from the previous version. - for (unsigned int i = 0; i < TransferListModel::NB_COLUMNS; ++i) + for (int i = 0; i < TransferListModel::NB_COLUMNS; ++i) if ((columnWidth(i) <= 0) && (!isColumnHidden(i))) resizeColumnToContents(i); @@ -713,7 +713,7 @@ void TransferListWidget::displayDLHoSMenu(const QPoint&) actions.append(myAct); } int visibleCols = 0; - for (unsigned int i = 0; i < TransferListModel::NB_COLUMNS; ++i) { + for (int i = 0; i < TransferListModel::NB_COLUMNS; ++i) { if (!isColumnHidden(i)) ++visibleCols; diff --git a/src/gui/transferlistwidget.h b/src/gui/transferlistwidget.h index 987db2f8d..97e7d7573 100644 --- a/src/gui/transferlistwidget.h +++ b/src/gui/transferlistwidget.h @@ -52,7 +52,7 @@ class TransferListWidget : public QTreeView public: TransferListWidget(QWidget *parent, MainWindow *mainWindow); - ~TransferListWidget(); + ~TransferListWidget() override; TransferListModel *getSourceModel() const; public slots: