mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-31 04:38:04 -06:00
Move parsing of TriStateBool to a static class function
This commit is contained in:
@@ -28,6 +28,17 @@
|
||||
|
||||
#include "tristatebool.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
const TriStateBool TriStateBool::Undefined(-1);
|
||||
const TriStateBool TriStateBool::False(0);
|
||||
const TriStateBool TriStateBool::True(1);
|
||||
|
||||
TriStateBool TriStateBool::fromString(const QString &string)
|
||||
{
|
||||
if (string.compare("true", Qt::CaseInsensitive) == 0)
|
||||
return True;
|
||||
if (string.compare("false", Qt::CaseInsensitive) == 0)
|
||||
return False;
|
||||
return Undefined;
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
class QString;
|
||||
|
||||
class TriStateBool
|
||||
{
|
||||
public:
|
||||
@@ -54,6 +56,8 @@ public:
|
||||
return (left.m_value == right.m_value);
|
||||
}
|
||||
|
||||
static TriStateBool fromString(const QString &string);
|
||||
|
||||
private:
|
||||
explicit constexpr TriStateBool(const int value)
|
||||
: m_value((value < 0) ? -1 : ((value > 0) ? 1 : 0))
|
||||
|
||||
@@ -42,8 +42,6 @@
|
||||
#include <QThreadStorage>
|
||||
#endif
|
||||
|
||||
#include "base/tristatebool.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
class NaturalCompare
|
||||
@@ -199,15 +197,6 @@ bool Utils::String::parseBool(const QString &string, const bool defaultValue)
|
||||
return (string.compare("true", Qt::CaseInsensitive) == 0) ? true : false;
|
||||
}
|
||||
|
||||
TriStateBool Utils::String::parseTriStateBool(const QString &string)
|
||||
{
|
||||
if (string.compare("true", Qt::CaseInsensitive) == 0)
|
||||
return TriStateBool::True;
|
||||
if (string.compare("false", Qt::CaseInsensitive) == 0)
|
||||
return TriStateBool::False;
|
||||
return TriStateBool::Undefined;
|
||||
}
|
||||
|
||||
QString Utils::String::join(const QVector<QStringRef> &strings, const QString &separator)
|
||||
{
|
||||
if (strings.empty())
|
||||
|
||||
@@ -37,8 +37,6 @@
|
||||
|
||||
class QStringRef;
|
||||
|
||||
class TriStateBool;
|
||||
|
||||
namespace Utils
|
||||
{
|
||||
namespace String
|
||||
@@ -69,7 +67,6 @@ namespace Utils
|
||||
}
|
||||
|
||||
bool parseBool(const QString &string, bool defaultValue);
|
||||
TriStateBool parseTriStateBool(const QString &string);
|
||||
|
||||
QString join(const QVector<QStringRef> &strings, const QString &separator);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user