Fix some warnings

This commit is contained in:
thalieht 2018-09-07 14:12:38 +03:00
parent e2b46f01bb
commit 94613c2fa2
29 changed files with 48 additions and 50 deletions

View file

@ -344,7 +344,7 @@ TorrentInfo::PieceRange TorrentInfo::filePieces(int fileIndex) const
static_cast<int>((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());

View file

@ -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;

View file

@ -64,7 +64,7 @@ namespace
setAllCookies(cookies);
}
~NetworkCookieJar()
~NetworkCookieJar() override
{
QDateTime now = QDateTime::currentDateTime();
QList<QNetworkCookie> cookies = allCookies();

View file

@ -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<char *>(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;

View file

@ -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) {

View file

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

View file

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

View file

@ -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;

View file

@ -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()) {

View file

@ -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
{

View file

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

View file

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

View file

@ -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<QTreeWidgetItem*> 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;
}

View file

@ -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()),

View file

@ -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) {

View file

@ -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;

View file

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

View file

@ -47,7 +47,7 @@ class TagFilterModel : public QAbstractListModel
public:
explicit TagFilterModel(QObject *parent = nullptr);
~TagFilterModel();
~TagFilterModel() override;
static bool isSpecialItem(const QModelIndex &index);

View file

@ -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;

View file

@ -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;

View file

@ -46,7 +46,7 @@ class TorrentContentModel : public QAbstractItemModel
public:
TorrentContentModel(QObject *parent = nullptr);
~TorrentContentModel();
~TorrentContentModel() override;
void updateFilesProgress(const QVector<qreal> &fp);
void updateFilesPriorities(const QVector<int> &fprio);

View file

@ -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<TorrentContentModelFolder *>(child);
return 0;
return nullptr;
}
int TorrentContentModelFolder::childCount() const

View file

@ -40,7 +40,7 @@ public:
// Invisible root item constructor
TorrentContentModelFolder(const QList<QVariant> &data);
~TorrentContentModelFolder();
~TorrentContentModelFolder() override;
ItemType itemType() const override;

View file

@ -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:

View file

@ -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;

View file

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

View file

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

View file

@ -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;

View file

@ -52,7 +52,7 @@ class TransferListWidget : public QTreeView
public:
TransferListWidget(QWidget *parent, MainWindow *mainWindow);
~TransferListWidget();
~TransferListWidget() override;
TransferListModel *getSourceModel() const;
public slots: