mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-14 17:23:07 -07:00
Add const to almost all remaining vars and arguments that qualify
This commit is contained in:
parent
bb041c0eca
commit
70f1537d9f
35 changed files with 261 additions and 261 deletions
|
@ -183,7 +183,7 @@ bool ScanFoldersModel::setData(const QModelIndex &index, const QVariant &value,
|
|||
return false;
|
||||
|
||||
if (role == Qt::UserRole) {
|
||||
auto type = static_cast<PathType>(value.toInt());
|
||||
const auto type = static_cast<PathType>(value.toInt());
|
||||
if (type == CUSTOM_LOCATION)
|
||||
return false;
|
||||
|
||||
|
@ -192,7 +192,7 @@ bool ScanFoldersModel::setData(const QModelIndex &index, const QVariant &value,
|
|||
emit dataChanged(index, index);
|
||||
}
|
||||
else if (role == Qt::DisplayRole) {
|
||||
QString path = value.toString();
|
||||
const QString path = value.toString();
|
||||
if (path.isEmpty()) // means we didn't pass CUSTOM_LOCATION type
|
||||
return false;
|
||||
|
||||
|
@ -209,14 +209,14 @@ bool ScanFoldersModel::setData(const QModelIndex &index, const QVariant &value,
|
|||
|
||||
ScanFoldersModel::PathStatus ScanFoldersModel::addPath(const QString &watchPath, const PathType &downloadType, const QString &downloadPath, bool addToFSWatcher)
|
||||
{
|
||||
QDir watchDir(watchPath);
|
||||
const QDir watchDir(watchPath);
|
||||
if (!watchDir.exists()) return DoesNotExist;
|
||||
if (!watchDir.isReadable()) return CannotRead;
|
||||
|
||||
const QString canonicalWatchPath = watchDir.canonicalPath();
|
||||
if (findPathData(canonicalWatchPath) != -1) return AlreadyInList;
|
||||
|
||||
QDir downloadDir(downloadPath);
|
||||
const QDir downloadDir(downloadPath);
|
||||
const QString canonicalDownloadPath = downloadDir.canonicalPath();
|
||||
|
||||
if (!m_fsWatcher) {
|
||||
|
@ -236,12 +236,12 @@ ScanFoldersModel::PathStatus ScanFoldersModel::addPath(const QString &watchPath,
|
|||
|
||||
ScanFoldersModel::PathStatus ScanFoldersModel::updatePath(const QString &watchPath, const PathType &downloadType, const QString &downloadPath)
|
||||
{
|
||||
QDir watchDir(watchPath);
|
||||
const QDir watchDir(watchPath);
|
||||
const QString canonicalWatchPath = watchDir.canonicalPath();
|
||||
int row = findPathData(canonicalWatchPath);
|
||||
const int row = findPathData(canonicalWatchPath);
|
||||
if (row == -1) return DoesNotExist;
|
||||
|
||||
QDir downloadDir(downloadPath);
|
||||
const QDir downloadDir(downloadPath);
|
||||
const QString canonicalDownloadPath = downloadDir.canonicalPath();
|
||||
|
||||
m_pathList.at(row)->downloadType = downloadType;
|
||||
|
@ -256,13 +256,13 @@ void ScanFoldersModel::addToFSWatcher(const QStringList &watchPaths)
|
|||
return; // addPath() wasn't called before this
|
||||
|
||||
for (const QString &path : watchPaths) {
|
||||
QDir watchDir(path);
|
||||
const QDir watchDir(path);
|
||||
const QString canonicalWatchPath = watchDir.canonicalPath();
|
||||
m_fsWatcher->addPath(canonicalWatchPath);
|
||||
}
|
||||
}
|
||||
|
||||
void ScanFoldersModel::removePath(int row, bool removeFromFSWatcher)
|
||||
void ScanFoldersModel::removePath(const int row, const bool removeFromFSWatcher)
|
||||
{
|
||||
Q_ASSERT((row >= 0) && (row < rowCount()));
|
||||
beginRemoveRows(QModelIndex(), row, row);
|
||||
|
@ -272,7 +272,7 @@ void ScanFoldersModel::removePath(int row, bool removeFromFSWatcher)
|
|||
endRemoveRows();
|
||||
}
|
||||
|
||||
bool ScanFoldersModel::removePath(const QString &path, bool removeFromFSWatcher)
|
||||
bool ScanFoldersModel::removePath(const QString &path, const bool removeFromFSWatcher)
|
||||
{
|
||||
const int row = findPathData(path);
|
||||
if (row == -1) return false;
|
||||
|
@ -291,7 +291,7 @@ bool ScanFoldersModel::downloadInWatchFolder(const QString &filePath) const
|
|||
{
|
||||
const int row = findPathData(QFileInfo(filePath).dir().path());
|
||||
Q_ASSERT(row != -1);
|
||||
PathData *data = m_pathList.at(row);
|
||||
const PathData *data = m_pathList.at(row);
|
||||
return (data->downloadType == DOWNLOAD_IN_WATCH_FOLDER);
|
||||
}
|
||||
|
||||
|
@ -299,7 +299,7 @@ bool ScanFoldersModel::downloadInDefaultFolder(const QString &filePath) const
|
|||
{
|
||||
const int row = findPathData(QFileInfo(filePath).dir().path());
|
||||
Q_ASSERT(row != -1);
|
||||
PathData *data = m_pathList.at(row);
|
||||
const PathData *data = m_pathList.at(row);
|
||||
return (data->downloadType == DEFAULT_LOCATION);
|
||||
}
|
||||
|
||||
|
@ -307,7 +307,7 @@ QString ScanFoldersModel::downloadPathTorrentFolder(const QString &filePath) con
|
|||
{
|
||||
const int row = findPathData(QFileInfo(filePath).dir().path());
|
||||
Q_ASSERT(row != -1);
|
||||
PathData *data = m_pathList.at(row);
|
||||
const PathData *data = m_pathList.at(row);
|
||||
if (data->downloadType == CUSTOM_LOCATION)
|
||||
return data->downloadPath;
|
||||
|
||||
|
@ -375,7 +375,7 @@ void ScanFoldersModel::addTorrentsToSession(const QStringList &pathList)
|
|||
}
|
||||
}
|
||||
else {
|
||||
BitTorrent::TorrentInfo torrentInfo = BitTorrent::TorrentInfo::loadFromFile(file);
|
||||
const BitTorrent::TorrentInfo torrentInfo = BitTorrent::TorrentInfo::loadFromFile(file);
|
||||
if (torrentInfo.isValid()) {
|
||||
BitTorrent::Session::instance()->addTorrent(torrentInfo, params);
|
||||
Utils::Fs::forceRemove(file);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue