mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-31 12:48:04 -06:00
Fix coding style
This commit is contained in:
committed by
sledgehammer999
parent
976e2450ec
commit
c99ac99a99
@@ -26,9 +26,10 @@
|
||||
* exception statement from your version.
|
||||
*/
|
||||
|
||||
#include <QHash>
|
||||
#include "infohash.h"
|
||||
|
||||
#include <QHash>
|
||||
|
||||
using namespace BitTorrent;
|
||||
|
||||
InfoHash::InfoHash()
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
#ifndef BITTORRENT_INFOHASH_H
|
||||
#define BITTORRENT_INFOHASH_H
|
||||
|
||||
#include <QString>
|
||||
#include <libtorrent/sha1_hash.hpp>
|
||||
#include <QString>
|
||||
|
||||
namespace BitTorrent
|
||||
{
|
||||
|
||||
@@ -407,24 +407,24 @@ int FilterParserThread::parseP2PFilterFile()
|
||||
int FilterParserThread::getlineInStream(QDataStream &stream, std::string &name, char delim)
|
||||
{
|
||||
char c;
|
||||
int total_read = 0;
|
||||
int totalRead = 0;
|
||||
int read;
|
||||
do {
|
||||
read = stream.readRawData(&c, 1);
|
||||
total_read += read;
|
||||
totalRead += read;
|
||||
if (read > 0) {
|
||||
if (c != delim) {
|
||||
name += c;
|
||||
}
|
||||
else {
|
||||
// Delim found
|
||||
return total_read;
|
||||
return totalRead;
|
||||
}
|
||||
}
|
||||
}
|
||||
while(read > 0);
|
||||
while (read > 0);
|
||||
|
||||
return total_read;
|
||||
return totalRead;
|
||||
}
|
||||
|
||||
// Parser for PeerGuardian ip filter in p2p format
|
||||
@@ -455,7 +455,7 @@ int FilterParserThread::parseP2BFilterFile()
|
||||
unsigned int start, end;
|
||||
|
||||
std::string name;
|
||||
while(getlineInStream(stream, name, '\0') && !m_abort) {
|
||||
while (getlineInStream(stream, name, '\0') && !m_abort) {
|
||||
if (!stream.readRawData(reinterpret_cast<char*>(&start), sizeof(start))
|
||||
|| !stream.readRawData(reinterpret_cast<char*>(&end), sizeof(end))) {
|
||||
LogMsg(tr("Parsing Error: The filter file is not a valid PeerGuardian P2B file."), Log::CRITICAL);
|
||||
|
||||
@@ -28,7 +28,6 @@ private:
|
||||
void save() const;
|
||||
void load();
|
||||
|
||||
private:
|
||||
BitTorrent::Session *m_session;
|
||||
// Will overflow at 15.9 EiB
|
||||
quint64 m_alltimeUL;
|
||||
|
||||
@@ -26,11 +26,12 @@
|
||||
* exception statement from your version.
|
||||
*/
|
||||
|
||||
#include "trackerentry.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "base/utils/misc.h"
|
||||
#include "base/utils/string.h"
|
||||
#include "trackerentry.h"
|
||||
|
||||
using namespace BitTorrent;
|
||||
|
||||
|
||||
@@ -27,9 +27,10 @@
|
||||
* exception statement from your version.
|
||||
*/
|
||||
|
||||
#include <QString>
|
||||
#include "iconprovider.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
IconProvider::IconProvider(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
|
||||
@@ -257,8 +257,8 @@ void Preferences::setWinStartup(bool b)
|
||||
{
|
||||
QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat);
|
||||
if (b) {
|
||||
const QString bin_path = "\"" + Utils::Fs::toNativePath(qApp->applicationFilePath()) + "\"";
|
||||
settings.setValue("qBittorrent", bin_path);
|
||||
const QString binPath = "\"" + Utils::Fs::toNativePath(qApp->applicationFilePath()) + "\"";
|
||||
settings.setValue("qBittorrent", binPath);
|
||||
}
|
||||
else {
|
||||
settings.remove("qBittorrent");
|
||||
@@ -555,24 +555,24 @@ void Preferences::setWebUiUsername(const QString &username)
|
||||
|
||||
QString Preferences::getWebUiPassword() const
|
||||
{
|
||||
QString pass_ha1 = value("Preferences/WebUI/Password_ha1").toString();
|
||||
if (pass_ha1.isEmpty()) {
|
||||
QString passHa1 = value("Preferences/WebUI/Password_ha1").toString();
|
||||
if (passHa1.isEmpty()) {
|
||||
QCryptographicHash md5(QCryptographicHash::Md5);
|
||||
md5.addData("adminadmin");
|
||||
pass_ha1 = md5.result().toHex();
|
||||
passHa1 = md5.result().toHex();
|
||||
}
|
||||
return pass_ha1;
|
||||
return passHa1;
|
||||
}
|
||||
|
||||
void Preferences::setWebUiPassword(const QString &new_password)
|
||||
void Preferences::setWebUiPassword(const QString &newPassword)
|
||||
{
|
||||
// Do not overwrite current password with its hash
|
||||
if (new_password == getWebUiPassword())
|
||||
if (newPassword == getWebUiPassword())
|
||||
return;
|
||||
|
||||
// Encode to md5 and save
|
||||
QCryptographicHash md5(QCryptographicHash::Md5);
|
||||
md5.addData(new_password.toLocal8Bit());
|
||||
md5.addData(newPassword.toLocal8Bit());
|
||||
|
||||
setValue("Preferences/WebUI/Password_ha1", md5.result().toHex());
|
||||
}
|
||||
@@ -1041,9 +1041,9 @@ void Preferences::setTorrentFileAssoc(bool set)
|
||||
|
||||
// .Torrent association
|
||||
if (set) {
|
||||
QString old_progid = settings.value(".torrent/Default").toString();
|
||||
if (!old_progid.isEmpty() && (old_progid != "qBittorrent"))
|
||||
settings.setValue(".torrent/OpenWithProgids/" + old_progid, "");
|
||||
QString oldProgId = settings.value(".torrent/Default").toString();
|
||||
if (!oldProgId.isEmpty() && (oldProgId != "qBittorrent"))
|
||||
settings.setValue(".torrent/OpenWithProgids/" + oldProgId, "");
|
||||
settings.setValue(".torrent/Default", "qBittorrent");
|
||||
}
|
||||
else if (isTorrentFileAssocSet()) {
|
||||
@@ -1059,15 +1059,15 @@ void Preferences::setMagnetLinkAssoc(bool set)
|
||||
|
||||
// Magnet association
|
||||
if (set) {
|
||||
const QString command_str = "\"" + qApp->applicationFilePath() + "\" \"%1\"";
|
||||
const QString icon_str = "\"" + 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");
|
||||
settings.setValue("magnet/URL Protocol", "");
|
||||
settings.setValue("magnet/DefaultIcon/Default", Utils::Fs::toNativePath(icon_str));
|
||||
settings.setValue("magnet/DefaultIcon/Default", Utils::Fs::toNativePath(iconStr));
|
||||
settings.setValue("magnet/shell/Default", "open");
|
||||
settings.setValue("magnet/shell/open/command/Default", Utils::Fs::toNativePath(command_str));
|
||||
settings.setValue("magnet/shell/open/command/Default", Utils::Fs::toNativePath(commandStr));
|
||||
}
|
||||
else if (isMagnetLinkAssocSet()) {
|
||||
settings.remove("magnet");
|
||||
|
||||
@@ -192,7 +192,7 @@ public:
|
||||
QString getWebUiUsername() const;
|
||||
void setWebUiUsername(const QString &username);
|
||||
QString getWebUiPassword() const;
|
||||
void setWebUiPassword(const QString &new_password);
|
||||
void setWebUiPassword(const QString &newPassword);
|
||||
|
||||
// WebUI security
|
||||
bool isWebUiClickjackingProtectionEnabled() const;
|
||||
|
||||
@@ -25,7 +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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "profile_p.h"
|
||||
|
||||
@@ -25,7 +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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef QBT_PROFILE_H
|
||||
|
||||
@@ -104,7 +104,6 @@ private:
|
||||
QString downloadPathTorrentFolder(const QString &filePath) const;
|
||||
int findPathData(const QString &path) const;
|
||||
|
||||
private:
|
||||
static ScanFoldersModel *m_instance;
|
||||
struct PathData;
|
||||
|
||||
|
||||
@@ -26,9 +26,10 @@
|
||||
* exception statement from your version.
|
||||
*/
|
||||
|
||||
#include "bittorrent/torrenthandle.h"
|
||||
#include "torrentfilter.h"
|
||||
|
||||
#include "bittorrent/torrenthandle.h"
|
||||
|
||||
const QString TorrentFilter::AnyCategory;
|
||||
const QStringSet TorrentFilter::AnyHash = (QStringSet() << QString());
|
||||
const QString TorrentFilter::AnyTag;
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
*/
|
||||
|
||||
#include "bytearray.h"
|
||||
|
||||
#include <QList>
|
||||
|
||||
QList<QByteArray> Utils::ByteArray::splitToViews(const QByteArray &in, const QByteArray &sep, const QString::SplitBehavior behavior)
|
||||
|
||||
@@ -210,7 +210,7 @@ bool Utils::Fs::sameFiles(const QString &path1, const QString &path2)
|
||||
if (!f2.open(QIODevice::ReadOnly)) return false;
|
||||
|
||||
const int readSize = 1024 * 1024; // 1 MiB
|
||||
while(!f1.atEnd() && !f2.atEnd()) {
|
||||
while (!f1.atEnd() && !f2.atEnd()) {
|
||||
if (f1.read(readSize) != f2.read(readSize))
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -299,55 +299,50 @@ qlonglong Utils::Misc::sizeInBytes(qreal size, Utils::Misc::SizeUnit unit)
|
||||
|
||||
bool Utils::Misc::isPreviewable(const QString &extension)
|
||||
{
|
||||
static QSet<QString> multimedia_extensions;
|
||||
if (multimedia_extensions.empty()) {
|
||||
multimedia_extensions.insert("3GP");
|
||||
multimedia_extensions.insert("AAC");
|
||||
multimedia_extensions.insert("AC3");
|
||||
multimedia_extensions.insert("AIF");
|
||||
multimedia_extensions.insert("AIFC");
|
||||
multimedia_extensions.insert("AIFF");
|
||||
multimedia_extensions.insert("ASF");
|
||||
multimedia_extensions.insert("AU");
|
||||
multimedia_extensions.insert("AVI");
|
||||
multimedia_extensions.insert("FLAC");
|
||||
multimedia_extensions.insert("FLV");
|
||||
multimedia_extensions.insert("M3U");
|
||||
multimedia_extensions.insert("M4A");
|
||||
multimedia_extensions.insert("M4P");
|
||||
multimedia_extensions.insert("M4V");
|
||||
multimedia_extensions.insert("MID");
|
||||
multimedia_extensions.insert("MKV");
|
||||
multimedia_extensions.insert("MOV");
|
||||
multimedia_extensions.insert("MP2");
|
||||
multimedia_extensions.insert("MP3");
|
||||
multimedia_extensions.insert("MP4");
|
||||
multimedia_extensions.insert("MPC");
|
||||
multimedia_extensions.insert("MPE");
|
||||
multimedia_extensions.insert("MPEG");
|
||||
multimedia_extensions.insert("MPG");
|
||||
multimedia_extensions.insert("MPP");
|
||||
multimedia_extensions.insert("OGG");
|
||||
multimedia_extensions.insert("OGM");
|
||||
multimedia_extensions.insert("OGV");
|
||||
multimedia_extensions.insert("QT");
|
||||
multimedia_extensions.insert("RA");
|
||||
multimedia_extensions.insert("RAM");
|
||||
multimedia_extensions.insert("RM");
|
||||
multimedia_extensions.insert("RMV");
|
||||
multimedia_extensions.insert("RMVB");
|
||||
multimedia_extensions.insert("SWA");
|
||||
multimedia_extensions.insert("SWF");
|
||||
multimedia_extensions.insert("VOB");
|
||||
multimedia_extensions.insert("WAV");
|
||||
multimedia_extensions.insert("WMA");
|
||||
multimedia_extensions.insert("WMV");
|
||||
}
|
||||
|
||||
if (extension.isEmpty())
|
||||
return false;
|
||||
|
||||
return multimedia_extensions.contains(extension.toUpper());
|
||||
static const QSet<QString> multimediaExtensions = {
|
||||
"3GP",
|
||||
"AAC",
|
||||
"AC3",
|
||||
"AIF",
|
||||
"AIFC",
|
||||
"AIFF",
|
||||
"ASF",
|
||||
"AU",
|
||||
"AVI",
|
||||
"FLAC",
|
||||
"FLV",
|
||||
"M3U",
|
||||
"M4A",
|
||||
"M4P",
|
||||
"M4V",
|
||||
"MID",
|
||||
"MKV",
|
||||
"MOV",
|
||||
"MP2",
|
||||
"MP3",
|
||||
"MP4",
|
||||
"MPC",
|
||||
"MPE",
|
||||
"MPEG",
|
||||
"MPG",
|
||||
"MPP",
|
||||
"OGG",
|
||||
"OGM",
|
||||
"OGV",
|
||||
"QT",
|
||||
"RA",
|
||||
"RAM",
|
||||
"RM",
|
||||
"RMV",
|
||||
"RMVB",
|
||||
"SWA",
|
||||
"SWF",
|
||||
"VOB",
|
||||
"WAV",
|
||||
"WMA",
|
||||
"WMV"
|
||||
};
|
||||
return multimediaExtensions.contains(extension.toUpper());
|
||||
}
|
||||
|
||||
// Take a number of seconds and return an user-friendly
|
||||
|
||||
Reference in New Issue
Block a user