Browse Source

Merge pull request #9217 from Chocobo1/char

Replace single-character string with character literal
adaptive-webui-19844
Mike Tzou 6 years ago committed by GitHub
parent
commit
5d4da09093
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      src/app/application.cpp
  2. 4
      src/app/cmdoptions.cpp
  3. 2
      src/base/bittorrent/magneturi.cpp
  4. 2
      src/base/bittorrent/peerinfo.cpp
  5. 12
      src/base/bittorrent/session.cpp
  6. 2
      src/base/bittorrent/torrentcreatorthread.cpp
  7. 22
      src/base/bittorrent/torrenthandle.cpp
  8. 2
      src/base/bittorrent/tracker.cpp
  9. 2
      src/base/net/dnsupdater.cpp
  10. 8
      src/base/net/smtp.cpp
  11. 12
      src/base/preferences.cpp
  12. 8
      src/base/rss/rss_autodownloadrule.cpp
  13. 6
      src/base/search/searchhandler.cpp
  14. 8
      src/base/search/searchpluginmanager.cpp
  15. 18
      src/base/utils/fs.cpp
  16. 6
      src/base/utils/misc.cpp
  17. 2
      src/gui/addnewtorrentdialog.cpp
  18. 4
      src/gui/mainwindow.cpp
  19. 2
      src/gui/previewlistdelegate.h
  20. 2
      src/gui/properties/peerlistdelegate.h
  21. 8
      src/gui/properties/peerlistwidget.cpp
  22. 2
      src/gui/properties/propertieswidget.cpp
  23. 2
      src/gui/properties/proplistdelegate.cpp
  24. 6
      src/gui/properties/trackerlistwidget.cpp
  25. 4
      src/gui/rss/automatedrssdownloader.cpp
  26. 8
      src/gui/statusbar.cpp
  27. 12
      src/gui/tagfiltermodel.cpp
  28. 4
      src/gui/transferlistdelegate.cpp
  29. 2
      src/gui/transferlistmodel.cpp
  30. 2
      src/gui/utils.cpp
  31. 2
      src/webui/api/synccontroller.cpp
  32. 2
      src/webui/api/torrentscontroller.cpp

10
src/app/application.cpp

@ -99,10 +99,10 @@ namespace @@ -99,10 +99,10 @@ namespace
// just a shortcut
inline SettingsStorage *settings() { return SettingsStorage::instance(); }
const QString LOG_FOLDER("logs");
const char PARAMS_SEPARATOR[] = "|";
const QString LOG_FOLDER = QStringLiteral("logs");
const QChar PARAMS_SEPARATOR = '|';
const QString DEFAULT_PORTABLE_MODE_PROFILE_DIR = QLatin1String("profile");
const QString DEFAULT_PORTABLE_MODE_PROFILE_DIR = QStringLiteral("profile");
const int MIN_FILELOG_SIZE = 1024; // 1KiB
const int MAX_FILELOG_SIZE = 1000 * 1024 * 1024; // 1000MiB
@ -265,7 +265,7 @@ void Application::setFileLoggerAgeType(const int value) @@ -265,7 +265,7 @@ void Application::setFileLoggerAgeType(const int value)
void Application::processMessage(const QString &message)
{
QStringList params = message.split(QLatin1String(PARAMS_SEPARATOR), QString::SkipEmptyParts);
QStringList params = message.split(PARAMS_SEPARATOR, QString::SkipEmptyParts);
// If Application is not running (i.e., other
// components are not ready) store params
if (m_running)
@ -409,7 +409,7 @@ void Application::allTorrentsFinished() @@ -409,7 +409,7 @@ void Application::allTorrentsFinished()
bool Application::sendParams(const QStringList &params)
{
return sendMessage(params.join(QLatin1String(PARAMS_SEPARATOR)));
return sendMessage(params.join(PARAMS_SEPARATOR));
}
// As program parameters, we can get paths or urls.

4
src/app/cmdoptions.cpp

@ -402,7 +402,7 @@ QBtCommandLineParameters parseCommandLine(const QStringList &args) @@ -402,7 +402,7 @@ QBtCommandLineParameters parseCommandLine(const QStringList &args)
const QString &arg = args[i];
if ((arg.startsWith("--") && !arg.endsWith(".torrent"))
|| (arg.startsWith("-") && (arg.size() == 2))) {
|| (arg.startsWith('-') && (arg.size() == 2))) {
// Parse known parameters
if (arg == SHOW_HELP_OPTION) {
result.showHelp = true;
@ -499,7 +499,7 @@ QString wrapText(const QString &text, int initialIndentation = USAGE_TEXT_COLUMN @@ -499,7 +499,7 @@ QString wrapText(const QString &text, int initialIndentation = USAGE_TEXT_COLUMN
foreach (const QString &word, words.mid(1)) {
if (lines.last().length() + word.length() + 1 < currentLineMaxLength) {
lines.last().append(" " + word);
lines.last().append(' ' + word);
}
else {
lines.append(QString(initialIndentation, ' ') + word);

2
src/base/bittorrent/magneturi.cpp

@ -46,7 +46,7 @@ namespace @@ -46,7 +46,7 @@ namespace
rawBc = rawBc.mid(8); // skip bc://bt/
rawBc = QByteArray::fromBase64(rawBc); // Decode base64
// Format is now AA/url_encoded_filename/size_bytes/info_hash/ZZ
QStringList parts = QString(rawBc).split("/");
QStringList parts = QString(rawBc).split('/');
if (parts.size() != 5) return QString();
QString filename = parts.at(1);

2
src/base/bittorrent/peerinfo.cpp

@ -377,7 +377,7 @@ void PeerInfo::determineFlags() @@ -377,7 +377,7 @@ void PeerInfo::determineFlags()
// L = Peer is local
if (fromLSD()) {
m_flags += "L";
m_flags += 'L';
flagsDescriptionList += "L = "
+ tr("peer from LSD");
}

12
src/base/bittorrent/session.cpp

@ -688,7 +688,7 @@ QString Session::torrentTempPath(const TorrentInfo &torrentInfo) const @@ -688,7 +688,7 @@ QString Session::torrentTempPath(const TorrentInfo &torrentInfo) const
if ((torrentInfo.filesCount() > 1) && !torrentInfo.hasRootFolder())
return tempPath()
+ QString::fromStdString(torrentInfo.nativeInfo()->orig_files().name())
+ "/";
+ '/';
return tempPath();
}
@ -793,7 +793,7 @@ bool Session::removeCategory(const QString &name) @@ -793,7 +793,7 @@ bool Session::removeCategory(const QString &name)
bool result = false;
if (isSubcategoriesEnabled()) {
// remove subcategories
const QString test = name + "/";
const QString test = name + '/';
Dict::removeIf(m_categories, [this, &test, &result](const QString &category, const QString &)
{
if (category.startsWith(test)) {
@ -3664,7 +3664,7 @@ void Session::handleTorrentFinished(TorrentHandle *const torrent) @@ -3664,7 +3664,7 @@ void Session::handleTorrentFinished(TorrentHandle *const torrent)
const QString torrentRelpath = torrent->filePath(i);
if (torrentRelpath.endsWith(".torrent", Qt::CaseInsensitive)) {
qDebug("Found possible recursive torrent download.");
const QString torrentFullpath = torrent->savePath(true) + "/" + torrentRelpath;
const QString torrentFullpath = torrent->savePath(true) + '/' + torrentRelpath;
qDebug("Full subtorrent path is %s", qUtf8Printable(torrentFullpath));
TorrentInfo torrentInfo = TorrentInfo::loadFromFile(torrentFullpath);
if (torrentInfo.isValid()) {
@ -3814,7 +3814,7 @@ void Session::recursiveTorrentDownload(const InfoHash &hash) @@ -3814,7 +3814,7 @@ void Session::recursiveTorrentDownload(const InfoHash &hash)
tr("Recursive download of file '%1' embedded in torrent '%2'"
, "Recursive download of 'test.torrent' embedded in torrent 'test2'")
.arg(Utils::Fs::toNativePath(torrentRelpath), torrent->name()));
const QString torrentFullpath = torrent->savePath() + "/" + torrentRelpath;
const QString torrentFullpath = torrent->savePath() + '/' + torrentRelpath;
AddTorrentParams params;
// Passing the save path along to the sub torrent file
@ -4309,7 +4309,7 @@ void Session::handleListenSucceededAlert(libt::listen_succeeded_alert *p) @@ -4309,7 +4309,7 @@ void Session::handleListenSucceededAlert(libt::listen_succeeded_alert *p)
proto = "TCP";
else if (p->sock_type == libt::listen_succeeded_alert::tcp_ssl)
proto = "TCP_SSL";
qDebug() << "Successfully listening on " << proto << p->endpoint.address().to_string(ec).c_str() << "/" << p->endpoint.port();
qDebug() << "Successfully listening on " << proto << p->endpoint.address().to_string(ec).c_str() << '/' << p->endpoint.port();
Logger::instance()->addMessage(
tr("qBittorrent is successfully listening on interface %1 port: %2/%3", "e.g: qBittorrent is successfully listening on interface 192.168.0.1 port: TCP/6881")
.arg(p->endpoint.address().to_string(ec).c_str(), proto, QString::number(p->endpoint.port())), Log::INFO);
@ -4336,7 +4336,7 @@ void Session::handleListenFailedAlert(libt::listen_failed_alert *p) @@ -4336,7 +4336,7 @@ void Session::handleListenFailedAlert(libt::listen_failed_alert *p)
proto = "I2P";
else if (p->sock_type == libt::listen_failed_alert::socks5)
proto = "SOCKS5";
qDebug() << "Failed listening on " << proto << p->endpoint.address().to_string(ec).c_str() << "/" << p->endpoint.port();
qDebug() << "Failed listening on " << proto << p->endpoint.address().to_string(ec).c_str() << '/' << p->endpoint.port();
Logger::instance()->addMessage(
tr("qBittorrent failed listening on interface %1 port: %2/%3. Reason: %4.",
"e.g: qBittorrent failed listening on interface 192.168.0.1 port: TCP/6881. Reason: already in use.")

2
src/base/bittorrent/torrentcreatorthread.cpp

@ -89,7 +89,7 @@ void TorrentCreatorThread::run() @@ -89,7 +89,7 @@ void TorrentCreatorThread::run()
emit updateProgress(0);
try {
const QString parentPath = Utils::Fs::branchPath(m_params.inputPath) + "/";
const QString parentPath = Utils::Fs::branchPath(m_params.inputPath) + '/';
// Adding files to the torrent
libt::file_storage fs;

22
src/base/bittorrent/torrenthandle.cpp

@ -328,7 +328,7 @@ QString TorrentHandle::rootPath(bool actual) const @@ -328,7 +328,7 @@ QString TorrentHandle::rootPath(bool actual) const
return QString();
QString firstFilePath = filePath(0);
const int slashIndex = firstFilePath.indexOf("/");
const int slashIndex = firstFilePath.indexOf('/');
if (slashIndex >= 0)
return QDir(savePath(actual)).absoluteFilePath(firstFilePath.left(slashIndex));
else
@ -556,7 +556,7 @@ bool TorrentHandle::belongsToCategory(const QString &category) const @@ -556,7 +556,7 @@ bool TorrentHandle::belongsToCategory(const QString &category) const
if (m_category == category) return true;
if (m_session->isSubcategoriesEnabled() && m_category.startsWith(category + "/"))
if (m_session->isSubcategoriesEnabled() && m_category.startsWith(category + '/'))
return true;
return false;
@ -1683,12 +1683,12 @@ void TorrentHandle::handleFileRenamedAlert(const libtorrent::file_renamed_alert @@ -1683,12 +1683,12 @@ void TorrentHandle::handleFileRenamedAlert(const libtorrent::file_renamed_alert
// TODO: Check this!
if (filesCount() > 1) {
// Check if folders were renamed
QStringList oldPathParts = m_torrentInfo.origFilePath(p->index).split("/");
QStringList oldPathParts = m_torrentInfo.origFilePath(p->index).split('/');
oldPathParts.removeLast();
QString oldPath = oldPathParts.join("/");
QStringList newPathParts = newName.split("/");
QString oldPath = oldPathParts.join('/');
QStringList newPathParts = newName.split('/');
newPathParts.removeLast();
QString newPath = newPathParts.join("/");
QString newPath = newPathParts.join('/');
if (!newPathParts.isEmpty() && (oldPath != newPath)) {
qDebug("oldPath(%s) != newPath(%s)", qUtf8Printable(oldPath), qUtf8Printable(newPath));
oldPath = QString("%1/%2").arg(savePath(true), oldPath);
@ -2018,7 +2018,7 @@ void TorrentHandle::prioritizeFiles(const QVector<int> &priorities) @@ -2018,7 +2018,7 @@ void TorrentHandle::prioritizeFiles(const QVector<int> &priorities)
// Make sure the file does not already exists
if (QDir(parentAbsPath).dirName() != ".unwanted") {
QString unwantedAbsPath = parentAbsPath + "/.unwanted";
QString newAbsPath = unwantedAbsPath + "/" + Utils::Fs::fileName(filepath);
QString newAbsPath = unwantedAbsPath + '/' + Utils::Fs::fileName(filepath);
qDebug() << "Unwanted path is" << unwantedAbsPath;
if (QFile::exists(newAbsPath)) {
qWarning() << "File" << newAbsPath << "already exists at destination.";
@ -2038,8 +2038,8 @@ void TorrentHandle::prioritizeFiles(const QVector<int> &priorities) @@ -2038,8 +2038,8 @@ void TorrentHandle::prioritizeFiles(const QVector<int> &priorities)
}
#endif
QString parentPath = Utils::Fs::branchPath(filepath);
if (!parentPath.isEmpty() && !parentPath.endsWith("/"))
parentPath += "/";
if (!parentPath.isEmpty() && !parentPath.endsWith('/'))
parentPath += '/';
renameFile(i, parentPath + ".unwanted/" + Utils::Fs::fileName(filepath));
}
}
@ -2056,8 +2056,8 @@ void TorrentHandle::prioritizeFiles(const QVector<int> &priorities) @@ -2056,8 +2056,8 @@ void TorrentHandle::prioritizeFiles(const QVector<int> &priorities)
renameFile(i, QDir(newRelPath).filePath(oldName));
// Remove .unwanted directory if empty
qDebug() << "Attempting to remove .unwanted folder at " << QDir(spath + "/" + newRelPath).absoluteFilePath(".unwanted");
QDir(spath + "/" + newRelPath).rmdir(".unwanted");
qDebug() << "Attempting to remove .unwanted folder at " << QDir(spath + '/' + newRelPath).absoluteFilePath(".unwanted");
QDir(spath + '/' + newRelPath).rmdir(".unwanted");
}
}
}

2
src/base/bittorrent/tracker.cpp

@ -60,7 +60,7 @@ bool Peer::operator==(const Peer &other) const @@ -60,7 +60,7 @@ bool Peer::operator==(const Peer &other) const
QString Peer::uid() const
{
return ip + ":" + QString::number(port);
return ip + ':' + QString::number(port);
}
libtorrent::entry Peer::toEntry(bool noPeerId) const

2
src/base/net/dnsupdater.cpp

@ -181,7 +181,7 @@ void DNSUpdater::processIPUpdateReply(const QString &reply) @@ -181,7 +181,7 @@ void DNSUpdater::processIPUpdateReply(const QString &reply)
{
Logger *const logger = Logger::instance();
qDebug() << Q_FUNC_INFO << reply;
QString code = reply.split(" ").first();
QString code = reply.split(' ').first();
qDebug() << Q_FUNC_INFO << "Code:" << code;
if ((code == "good") || (code == "nochg")) {

8
src/base/net/smtp.cpp

@ -299,7 +299,7 @@ QByteArray Smtp::encodeMimeHeader(const QString &key, const QString &value, QTex @@ -299,7 +299,7 @@ QByteArray Smtp::encodeMimeHeader(const QString &key, const QString &value, QTex
if (firstWord)
line += word;
else
line += " " + word;
line += ' ' + word;
firstWord = false;
}
}
@ -423,7 +423,7 @@ void Smtp::authenticate() @@ -423,7 +423,7 @@ void Smtp::authenticate()
// Skip authentication
logError("The SMTP server does not seem to support any of the authentications modes "
"we support [CRAM-MD5|PLAIN|LOGIN], skipping authentication, "
"knowing it is likely to fail... Server Auth Modes: " + auth.join("|"));
"knowing it is likely to fail... Server Auth Modes: " + auth.join('|'));
m_state = Authenticated;
// At this point the server will not send any response
// So fill the buffer with a fake one to pass the tests
@ -503,7 +503,7 @@ void Smtp::authLogin() @@ -503,7 +503,7 @@ void Smtp::authLogin()
void Smtp::logError(const QString &msg)
{
qDebug() << "Email Notification Error:" << msg;
Logger::instance()->addMessage(tr("Email Notification Error:") + " " + msg, Log::CRITICAL);
Logger::instance()->addMessage(tr("Email Notification Error:") + ' ' + msg, Log::CRITICAL);
}
QString Smtp::getCurrentDateTime() const
@ -529,7 +529,7 @@ QString Smtp::getCurrentDateTime() const @@ -529,7 +529,7 @@ QString Smtp::getCurrentDateTime() const
std::snprintf(buf, sizeof(buf), "%+05d", timeOffset);
QString timeOffsetStr = buf;
QString ret = weekDayStr + ", " + dayStr + " " + monthStr + " " + yearStr + " " + timeStr + " " + timeOffsetStr;
QString ret = weekDayStr + ", " + dayStr + ' ' + monthStr + ' ' + yearStr + ' ' + timeStr + ' ' + timeOffsetStr;
return ret;
}

12
src/base/preferences.cpp

@ -256,7 +256,7 @@ void Preferences::setWinStartup(bool b) @@ -256,7 +256,7 @@ void Preferences::setWinStartup(bool b)
{
QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat);
if (b) {
const QString binPath = "\"" + Utils::Fs::toNativePath(qApp->applicationFilePath()) + "\"";
const QString binPath = '"' + Utils::Fs::toNativePath(qApp->applicationFilePath()) + '"';
settings.setValue("qBittorrent", binPath);
}
else {
@ -500,7 +500,7 @@ void Preferences::setWebUiAuthSubnetWhitelist(QStringList subnets) @@ -500,7 +500,7 @@ void Preferences::setWebUiAuthSubnetWhitelist(QStringList subnets)
QString Preferences::getServerDomains() const
{
return value("Preferences/WebUI/ServerDomains", "*").toString();
return value("Preferences/WebUI/ServerDomains", '*').toString();
}
void Preferences::setServerDomains(const QString &str)
@ -510,7 +510,7 @@ void Preferences::setServerDomains(const QString &str) @@ -510,7 +510,7 @@ void Preferences::setServerDomains(const QString &str)
QString Preferences::getWebUiAddress() const
{
return value("Preferences/WebUI/Address", "*").toString().trimmed();
return value("Preferences/WebUI/Address", '*').toString().trimmed();
}
void Preferences::setWebUiAddress(const QString &addr)
@ -987,7 +987,7 @@ QString Preferences::getPythonPath() @@ -987,7 +987,7 @@ QString Preferences::getPythonPath()
// Fallback: Detect python from default locations
const QStringList dirs = QDir("C:/").entryList(QStringList("Python*"), QDir::Dirs, QDir::Name | QDir::Reversed);
foreach (const QString &dir, dirs) {
const QString path("C:/" + dir + "/");
const QString path("C:/" + dir + '/');
if (QFile::exists(path + "python.exe"))
return path;
}
@ -1058,8 +1058,8 @@ void Preferences::setMagnetLinkAssoc(bool set) @@ -1058,8 +1058,8 @@ void Preferences::setMagnetLinkAssoc(bool set)
// Magnet association
if (set) {
const QString commandStr = "\"" + qApp->applicationFilePath() + "\" \"%1\"";
const QString iconStr = "\"" + qApp->applicationFilePath() + "\",1";
const QString commandStr = '"' + qApp->applicationFilePath() + "\" \"%1\"";
const QString iconStr = '"' + qApp->applicationFilePath() + "\",1";
settings.setValue("magnet/Default", "URL:Magnet link");
settings.setValue("magnet/Content Type", "application/x-magnet");

8
src/base/rss/rss_autodownloadrule.cpp

@ -502,7 +502,7 @@ void AutoDownloadRule::setMustContain(const QString &tokens) @@ -502,7 +502,7 @@ void AutoDownloadRule::setMustContain(const QString &tokens)
if (m_dataPtr->useRegex)
m_dataPtr->mustContain = QStringList() << tokens;
else
m_dataPtr->mustContain = tokens.split("|");
m_dataPtr->mustContain = tokens.split('|');
// Check for single empty string - if so, no condition
if ((m_dataPtr->mustContain.size() == 1) && m_dataPtr->mustContain[0].isEmpty())
@ -516,7 +516,7 @@ void AutoDownloadRule::setMustNotContain(const QString &tokens) @@ -516,7 +516,7 @@ void AutoDownloadRule::setMustNotContain(const QString &tokens)
if (m_dataPtr->useRegex)
m_dataPtr->mustNotContain = QStringList() << tokens;
else
m_dataPtr->mustNotContain = tokens.split("|");
m_dataPtr->mustNotContain = tokens.split('|');
// Check for single empty string - if so, no condition
if ((m_dataPtr->mustNotContain.size() == 1) && m_dataPtr->mustNotContain[0].isEmpty())
@ -605,12 +605,12 @@ int AutoDownloadRule::ignoreDays() const @@ -605,12 +605,12 @@ int AutoDownloadRule::ignoreDays() const
QString AutoDownloadRule::mustContain() const
{
return m_dataPtr->mustContain.join("|");
return m_dataPtr->mustContain.join('|');
}
QString AutoDownloadRule::mustNotContain() const
{
return m_dataPtr->mustNotContain.join("|");
return m_dataPtr->mustNotContain.join('|');
}
bool AutoDownloadRule::useSmartFilter() const

6
src/base/search/searchhandler.cpp

@ -65,13 +65,13 @@ SearchHandler::SearchHandler(const QString &pattern, const QString &category, co @@ -65,13 +65,13 @@ SearchHandler::SearchHandler(const QString &pattern, const QString &category, co
const QStringList params {
Utils::Fs::toNativePath(m_manager->engineLocation() + "/nova2.py"),
m_usedPlugins.join(","),
m_usedPlugins.join(','),
m_category
};
// Launch search
m_searchProcess->setProgram(Utils::ForeignApps::pythonInfo().executableName);
m_searchProcess->setArguments(params + m_pattern.split(" "));
m_searchProcess->setArguments(params + m_pattern.split(' '));
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
connect(m_searchProcess, &QProcess::errorOccurred, this, &SearchHandler::processFailed);
@ -161,7 +161,7 @@ void SearchHandler::processFailed() @@ -161,7 +161,7 @@ void SearchHandler::processFailed()
// file url | file name | file size | nb seeds | nb leechers | Search engine url
bool SearchHandler::parseSearchResult(const QString &line, SearchResult &searchResult)
{
const QStringList parts = line.split("|");
const QStringList parts = line.split('|');
const int nbFields = parts.size();
if (nbFields < (NB_PLUGIN_COLUMNS - 1)) return false; // -1 because desc_link is optional

8
src/base/search/searchpluginmanager.cpp

@ -204,7 +204,7 @@ void SearchPluginManager::installPlugin(const QString &source) @@ -204,7 +204,7 @@ void SearchPluginManager::installPlugin(const QString &source)
path = QUrl(path).toLocalFile();
QString pluginName = Utils::Fs::fileName(path);
pluginName.chop(pluginName.size() - pluginName.lastIndexOf("."));
pluginName.chop(pluginName.size() - pluginName.lastIndexOf('.'));
if (!path.endsWith(".py", Qt::CaseInsensitive))
emit pluginInstallationFailed(pluginName, tr("Unknown search engine plugin file format."));
@ -375,7 +375,7 @@ void SearchPluginManager::pluginDownloaded(const QString &url, QString filePath) @@ -375,7 +375,7 @@ void SearchPluginManager::pluginDownloaded(const QString &url, QString filePath)
filePath = Utils::Fs::fromNativePath(filePath);
QString pluginName = Utils::Fs::fileName(url);
pluginName.chop(pluginName.size() - pluginName.lastIndexOf(".")); // Remove extension
pluginName.chop(pluginName.size() - pluginName.lastIndexOf('.')); // Remove extension
installPlugin_impl(pluginName, filePath);
Utils::Fs::forceRemove(filePath);
}
@ -502,13 +502,13 @@ void SearchPluginManager::parseVersionInfo(const QByteArray &info) @@ -502,13 +502,13 @@ void SearchPluginManager::parseVersionInfo(const QByteArray &info)
foreach (QByteArray line, lines) {
line = line.trimmed();
if (line.isEmpty()) continue;
if (line.startsWith("#")) continue;
if (line.startsWith('#')) continue;
QList<QByteArray> list = line.split(' ');
if (list.size() != 2) continue;
QString pluginName = QString(list.first());
if (!pluginName.endsWith(":")) continue;
if (!pluginName.endsWith(':')) continue;
pluginName.chop(1); // remove trailing ':'
PluginVersion version = PluginVersion::tryParse(list.last(), {});

18
src/base/utils/fs.cpp

@ -78,14 +78,14 @@ QString Utils::Fs::fromNativePath(const QString &path) @@ -78,14 +78,14 @@ QString Utils::Fs::fromNativePath(const QString &path)
QString Utils::Fs::fileExtension(const QString &filename)
{
QString ext = QString(filename).remove(QB_EXT);
const int pointIndex = ext.lastIndexOf(".");
const int pointIndex = ext.lastIndexOf('.');
return (pointIndex >= 0) ? ext.mid(pointIndex + 1) : QString();
}
QString Utils::Fs::fileName(const QString &filePath)
{
QString path = fromNativePath(filePath);
const int slashIndex = path.lastIndexOf("/");
const int slashIndex = path.lastIndexOf('/');
if (slashIndex == -1)
return path;
return path.mid(slashIndex + 1);
@ -94,7 +94,7 @@ QString Utils::Fs::fileName(const QString &filePath) @@ -94,7 +94,7 @@ QString Utils::Fs::fileName(const QString &filePath)
QString Utils::Fs::folderName(const QString &filePath)
{
QString path = fromNativePath(filePath);
const int slashIndex = path.lastIndexOf("/");
const int slashIndex = path.lastIndexOf('/');
if (slashIndex == -1)
return path;
return path.left(slashIndex);
@ -121,13 +121,13 @@ bool Utils::Fs::smartRemoveEmptyFolderTree(const QString &path) @@ -121,13 +121,13 @@ bool Utils::Fs::smartRemoveEmptyFolderTree(const QString &path)
};
// travel from the deepest folder and remove anything unwanted on the way out.
QStringList dirList(path + "/"); // get all sub directories paths
QStringList dirList(path + '/'); // get all sub directories paths
QDirIterator iter(path, (QDir::AllDirs | QDir::NoDotAndDotDot), QDirIterator::Subdirectories);
while (iter.hasNext())
dirList << iter.next() + "/";
dirList << iter.next() + '/';
// sort descending by directory depth
std::sort(dirList.begin(), dirList.end()
, [](const QString &l, const QString &r) { return l.count("/") > r.count("/"); });
, [](const QString &l, const QString &r) { return l.count('/') > r.count('/'); });
for (const QString &p : qAsConst(dirList)) {
// remove unwanted files
@ -139,7 +139,7 @@ bool Utils::Fs::smartRemoveEmptyFolderTree(const QString &path) @@ -139,7 +139,7 @@ bool Utils::Fs::smartRemoveEmptyFolderTree(const QString &path)
QDir dir(p);
QStringList tmpFileList = dir.entryList(QDir::Files);
for (const QString &f : tmpFileList) {
if (f.endsWith("~"))
if (f.endsWith('~'))
forceRemove(p + f);
}
@ -246,9 +246,9 @@ qint64 Utils::Fs::freeDiskSpaceOnPath(const QString &path) @@ -246,9 +246,9 @@ qint64 Utils::Fs::freeDiskSpaceOnPath(const QString &path)
QString Utils::Fs::branchPath(const QString &filePath, QString *removed)
{
QString ret = fromNativePath(filePath);
if (ret.endsWith("/"))
if (ret.endsWith('/'))
ret.chop(1);
const int slashIndex = ret.lastIndexOf("/");
const int slashIndex = ret.lastIndexOf('/');
if (slashIndex >= 0) {
if (removed)
*removed = ret.mid(slashIndex + 1);

6
src/base/utils/misc.cpp

@ -501,7 +501,7 @@ void Utils::Misc::openFolderSelect(const QString &absolutePath) @@ -501,7 +501,7 @@ void Utils::Misc::openFolderSelect(const QString &absolutePath)
const QString path = Utils::Fs::fromNativePath(absolutePath);
// If the item to select doesn't exist, try to open its parent
if (!QFileInfo::exists(path)) {
openPath(path.left(path.lastIndexOf("/")));
openPath(path.left(path.lastIndexOf('/')));
return;
}
#ifdef Q_OS_WIN
@ -540,10 +540,10 @@ void Utils::Misc::openFolderSelect(const QString &absolutePath) @@ -540,10 +540,10 @@ void Utils::Misc::openFolderSelect(const QString &absolutePath)
}
else {
// "caja" manager can't pinpoint the file, see: https://github.com/qbittorrent/qBittorrent/issues/5003
openPath(path.left(path.lastIndexOf("/")));
openPath(path.left(path.lastIndexOf('/')));
}
#else
openPath(path.left(path.lastIndexOf("/")));
openPath(path.left(path.lastIndexOf('/')));
#endif
}

2
src/gui/addnewtorrentdialog.cpp

@ -445,7 +445,7 @@ void AddNewTorrentDialog::updateDiskSpaceLabel() @@ -445,7 +445,7 @@ void AddNewTorrentDialog::updateDiskSpaceLabel()
sizeString += " (";
sizeString += tr("Free space on disk: %1").arg(Utils::Misc::friendlyUnit(Utils::Fs::freeDiskSpaceOnPath(
m_ui->savePath->selectedPath())));
sizeString += ")";
sizeString += ')';
m_ui->labelSize->setText(sizeString);
}

4
src/gui/mainwindow.cpp

@ -2037,7 +2037,7 @@ bool MainWindow::addPythonPathToEnv() @@ -2037,7 +2037,7 @@ bool MainWindow::addPythonPathToEnv()
QString pathEnvar = QString::fromLocal8Bit(qgetenv("PATH").constData());
if (pathEnvar.isNull())
pathEnvar = "";
pathEnvar = pythonPath + ";" + pathEnvar;
pathEnvar = pythonPath + ';' + pathEnvar;
qDebug("New PATH envvar is: %s", qUtf8Printable(pathEnvar));
qputenv("PATH", Utils::Fs::toNativePath(pathEnvar).toLocal8Bit());
return true;
@ -2069,7 +2069,7 @@ void MainWindow::pythonDownloadSuccess(const QString &url, const QString &filePa @@ -2069,7 +2069,7 @@ void MainWindow::pythonDownloadSuccess(const QString &url, const QString &filePa
if (QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA) {
QFile::rename(filePath, filePath + ".exe");
installer.start("\"" + Utils::Fs::toNativePath(filePath) + ".exe\" /passive");
installer.start('"' + Utils::Fs::toNativePath(filePath) + ".exe\" /passive");
}
else {
QFile::rename(filePath, filePath + ".msi");

2
src/gui/previewlistdelegate.h

@ -70,7 +70,7 @@ public: @@ -70,7 +70,7 @@ public:
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.text = ((progress == 100.0) ? QString("100%") : Utils::String::fromDouble(progress, 1) + '%');
newopt.progress = static_cast<int>(progress);
newopt.maximum = 100;
newopt.minimum = 0;

2
src/gui/properties/peerlistdelegate.h

@ -100,7 +100,7 @@ public: @@ -100,7 +100,7 @@ public:
case RELEVANCE: {
qreal progress = index.data().toDouble();
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
QItemDelegate::drawDisplay(painter, opt, opt.rect, Utils::String::fromDouble(progress * 100.0, 1) + "%");
QItemDelegate::drawDisplay(painter, opt, opt.rect, Utils::String::fromDouble(progress * 100.0, 1) + '%');
}
break;
default:

8
src/gui/properties/peerlistwidget.cpp

@ -304,9 +304,9 @@ void PeerListWidget::copySelectedPeers() @@ -304,9 +304,9 @@ void PeerListWidget::copySelectedPeers()
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
selectedPeers << "[" + ip + "]:" + myport;
selectedPeers << '[' + ip + "]:" + myport;
else // IPv4
selectedPeers << ip + ":" + myport;
selectedPeers << ip + ':' + myport;
}
QApplication::clipboard()->setText(selectedPeers.join('\n'));
}
@ -404,8 +404,8 @@ QStandardItem *PeerListWidget::addPeer(const QString &ip, BitTorrent::TorrentHan @@ -404,8 +404,8 @@ QStandardItem *PeerListWidget::addPeer(const QString &ip, BitTorrent::TorrentHan
m_listModel->setData(m_listModel->index(row, PeerListDelegate::TOT_UP), peer.totalUpload());
m_listModel->setData(m_listModel->index(row, PeerListDelegate::RELEVANCE), peer.relevance());
QStringList downloadingFiles(torrent->info().filesForPiece(peer.downloadingPieceIndex()));
m_listModel->setData(m_listModel->index(row, PeerListDelegate::DOWNLOADING_PIECE), downloadingFiles.join(QLatin1String(";")));
m_listModel->setData(m_listModel->index(row, PeerListDelegate::DOWNLOADING_PIECE), downloadingFiles.join(QLatin1String("\n")), Qt::ToolTipRole);
m_listModel->setData(m_listModel->index(row, PeerListDelegate::DOWNLOADING_PIECE), downloadingFiles.join(QLatin1Char(';')));
m_listModel->setData(m_listModel->index(row, PeerListDelegate::DOWNLOADING_PIECE), downloadingFiles.join(QLatin1Char('\n')), Qt::ToolTipRole);
return m_listModel->item(row, PeerListDelegate::IP);
}

2
src/gui/properties/propertieswidget.cpp

@ -474,7 +474,7 @@ void PropertiesWidget::loadDynamicData() @@ -474,7 +474,7 @@ void PropertiesWidget::loadDynamicData()
// Progress
qreal progress = m_torrent->progress() * 100.;
m_ui->labelProgressVal->setText(Utils::String::fromDouble(progress, 1) + "%");
m_ui->labelProgressVal->setText(Utils::String::fromDouble(progress, 1) + '%');
m_downloadedPieces->setProgress(m_torrent->pieces(), m_torrent->downloadingPieces());
}
else {

2
src/gui/properties/proplistdelegate.cpp

@ -87,7 +87,7 @@ void PropListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti @@ -87,7 +87,7 @@ void PropListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
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.text = ((progress == 100.0) ? QString("100%") : Utils::String::fromDouble(progress, 1) + '%');
newopt.progress = int(progress);
newopt.maximum = 100;
newopt.minimum = 0;

6
src/gui/properties/trackerlistwidget.cpp

@ -371,9 +371,9 @@ void TrackerListWidget::loadTrackers() @@ -371,9 +371,9 @@ void TrackerListWidget::loadTrackers()
item->setText(COL_PEERS, QString::number(entry.nativeEntry().scrape_incomplete > 0 ? entry.nativeEntry().scrape_incomplete : 0));
item->setText(COL_DOWNLOADED, QString::number(entry.nativeEntry().scrape_downloaded > 0 ? entry.nativeEntry().scrape_downloaded : 0));
#else
item->setText(COL_SEEDS, "0");
item->setText(COL_PEERS, "0");
item->setText(COL_DOWNLOADED, "0");
item->setText(COL_SEEDS, '0');
item->setText(COL_PEERS, '0');
item->setText(COL_DOWNLOADED, '0');
#endif
item->setTextAlignment(COL_TIER, (Qt::AlignRight | Qt::AlignVCenter));

4
src/gui/rss/automatedrssdownloader.cpp

@ -675,7 +675,7 @@ void AutomatedRssDownloader::updateMustLineValidity() @@ -675,7 +675,7 @@ void AutomatedRssDownloader::updateMustLineValidity()
if (isRegex)
tokens << text;
else
foreach (const QString &token, text.split("|"))
foreach (const QString &token, text.split('|'))
tokens << Utils::String::wildcardToRegex(token);
foreach (const QString &token, tokens) {
@ -713,7 +713,7 @@ void AutomatedRssDownloader::updateMustNotLineValidity() @@ -713,7 +713,7 @@ void AutomatedRssDownloader::updateMustNotLineValidity()
if (isRegex)
tokens << text;
else
foreach (const QString &token, text.split("|"))
foreach (const QString &token, text.split('|'))
tokens << Utils::String::wildcardToRegex(token);
foreach (const QString &token, tokens) {

8
src/gui/statusbar.cpp

@ -209,14 +209,14 @@ void StatusBar::updateSpeedLabels() @@ -209,14 +209,14 @@ void StatusBar::updateSpeedLabels()
QString speedLbl = Utils::Misc::friendlyUnit(sessionStatus.payloadDownloadRate, true);
int speedLimit = BitTorrent::Session::instance()->downloadSpeedLimit();
if (speedLimit)
speedLbl += " [" + Utils::Misc::friendlyUnit(speedLimit, true) + "]";
speedLbl += " (" + Utils::Misc::friendlyUnit(sessionStatus.totalPayloadDownload) + ")";
speedLbl += " [" + Utils::Misc::friendlyUnit(speedLimit, true) + ']';
speedLbl += " (" + Utils::Misc::friendlyUnit(sessionStatus.totalPayloadDownload) + ')';
m_dlSpeedLbl->setText(speedLbl);
speedLimit = BitTorrent::Session::instance()->uploadSpeedLimit();
speedLbl = Utils::Misc::friendlyUnit(sessionStatus.payloadUploadRate, true);
if (speedLimit)
speedLbl += " [" + Utils::Misc::friendlyUnit(speedLimit, true) + "]";
speedLbl += " (" + Utils::Misc::friendlyUnit(sessionStatus.totalPayloadUpload) + ")";
speedLbl += " [" + Utils::Misc::friendlyUnit(speedLimit, true) + ']';
speedLbl += " (" + Utils::Misc::friendlyUnit(sessionStatus.totalPayloadUpload) + ')';
m_upSpeedLbl->setText(speedLbl);
}

12
src/gui/tagfiltermodel.cpp

@ -39,16 +39,16 @@ namespace @@ -39,16 +39,16 @@ namespace
{
QString getSpecialAllTag()
{
static const QString *const ALL_TAG = new QString(" ");
Q_ASSERT(!BitTorrent::Session::isValidTag(*ALL_TAG));
return *ALL_TAG;
const QString ALL_TAG = QLatin1String(" ");
Q_ASSERT(!BitTorrent::Session::isValidTag(ALL_TAG));
return ALL_TAG;
}
QString getSpecialUntaggedTag()
{
static const QString *const UNTAGGED_TAG = new QString(" ");
Q_ASSERT(!BitTorrent::Session::isValidTag(*UNTAGGED_TAG));
return *UNTAGGED_TAG;
const QString UNTAGGED_TAG = QLatin1String(" ");
Q_ASSERT(!BitTorrent::Session::isValidTag(UNTAGGED_TAG));
return UNTAGGED_TAG;
}
}

4
src/gui/transferlistdelegate.cpp

@ -91,7 +91,7 @@ void TransferListDelegate::paint(QPainter *painter, const QStyleOptionViewItem & @@ -91,7 +91,7 @@ void TransferListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
qlonglong total = index.data(Qt::UserRole).toLongLong();
if (hideValues && (!value && !total))
break;
QString display = QString::number(value) + " (" + QString::number(total) + ")";
QString display = QString::number(value) + " (" + QString::number(total) + ')';
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
QItemDelegate::drawDisplay(painter, opt, opt.rect, display);
}
@ -160,7 +160,7 @@ void TransferListDelegate::paint(QPainter *painter, const QStyleOptionViewItem & @@ -160,7 +160,7 @@ void TransferListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
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.text = ((progress == 100.0) ? QString("100%") : Utils::String::fromDouble(progress, 1) + '%');
newopt.progress = static_cast<int>(progress);
newopt.maximum = 100;
newopt.minimum = 0;

2
src/gui/transferlistmodel.cpp

@ -93,7 +93,7 @@ QVariant TransferListModel::headerData(int section, Qt::Orientation orientation, @@ -93,7 +93,7 @@ QVariant TransferListModel::headerData(int section, Qt::Orientation orientation,
if (orientation == Qt::Horizontal) {
if (role == Qt::DisplayRole) {
switch (section) {
case TR_PRIORITY: return "#";
case TR_PRIORITY: return QChar('#');
case TR_NAME: return tr("Name", "i.e: torrent name");
case TR_SIZE: return tr("Size", "i.e: torrent size");
case TR_PROGRESS: return tr("Done", "% Done");

2
src/gui/utils.cpp

@ -73,7 +73,7 @@ QPixmap Utils::Gui::scaledPixmap(const QString &path, const QWidget *widget, con @@ -73,7 +73,7 @@ QPixmap Utils::Gui::scaledPixmap(const QString &path, const QWidget *widget, con
QPixmap Utils::Gui::scaledPixmapSvg(const QString &path, const QWidget *widget, const int baseHeight)
{
const int scaledHeight = baseHeight * Utils::Gui::screenScalingFactor(widget);
const QString normalizedKey = path + "@" + QString::number(scaledHeight);
const QString normalizedKey = path + '@' + QString::number(scaledHeight);
QPixmap pm;
QPixmapCache cache;

2
src/webui/api/synccontroller.cpp

@ -465,7 +465,7 @@ void SyncController::torrentPeersAction() @@ -465,7 +465,7 @@ void SyncController::torrentPeersAction()
peer[KEY_PEER_RELEVANCE] = pi.relevance();
peer[KEY_PEER_FILES] = torrent->info().filesForPiece(pi.downloadingPieceIndex()).join(QLatin1String("\n"));
peers[pi.address().ip.toString() + ":" + QString::number(pi.address().port)] = peer;
peers[pi.address().ip.toString() + ':' + QString::number(pi.address().port)] = peer;
}
data["peers"] = peers;

2
src/webui/api/torrentscontroller.cpp

@ -734,7 +734,7 @@ void TorrentsController::setLocationAction() @@ -734,7 +734,7 @@ void TorrentsController::setLocationAction()
{
checkParams({"hashes", "location"});
const QStringList hashes {params()["hashes"].split("|")};
const QStringList hashes {params()["hashes"].split('|')};
const QString newLocation {params()["location"].trimmed()};
if (newLocation.isEmpty())

Loading…
Cancel
Save