qBittorrent
anonymous_namespace{rss_autodownloadrule.cpp} Namespace Reference

Functions

std::optional< bool > toOptionalBool (const QJsonValue &jsonVal)
 
QJsonValue toJsonValue (const std::optional< bool > boolValue)
 
std::optional< bool > addPausedLegacyToOptionalBool (const int val)
 
int toAddPausedLegacy (const std::optional< bool > boolValue)
 
std::optional< BitTorrent::TorrentContentLayoutjsonValueToContentLayout (const QJsonValue &jsonVal)
 
QJsonValue contentLayoutToJsonValue (const std::optional< BitTorrent::TorrentContentLayout > contentLayout)
 

Function Documentation

◆ addPausedLegacyToOptionalBool()

std::optional<bool> anonymous_namespace{rss_autodownloadrule.cpp}::addPausedLegacyToOptionalBool ( const int  val)

Definition at line 66 of file rss_autodownloadrule.cpp.

67  {
68  switch (val)
69  {
70  case 1:
71  return true; // always
72  case 2:
73  return false; // never
74  default:
75  return std::nullopt; // default
76  }
77  }

Referenced by RSS::AutoDownloadRule::fromLegacyDict().

Here is the caller graph for this function:

◆ contentLayoutToJsonValue()

QJsonValue anonymous_namespace{rss_autodownloadrule.cpp}::contentLayoutToJsonValue ( const std::optional< BitTorrent::TorrentContentLayout contentLayout)

Definition at line 95 of file rss_autodownloadrule.cpp.

96  {
97  if (!contentLayout)
98  return {};
99  return Utils::String::fromEnum(*contentLayout);
100  }
QString fromEnum(const T &value)
Definition: string.h:67

References Utils::String::fromEnum().

Referenced by RSS::AutoDownloadRule::toJsonObject().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ jsonValueToContentLayout()

std::optional<BitTorrent::TorrentContentLayout> anonymous_namespace{rss_autodownloadrule.cpp}::jsonValueToContentLayout ( const QJsonValue &  jsonVal)

Definition at line 87 of file rss_autodownloadrule.cpp.

88  {
89  const QString str = jsonVal.toString();
90  if (str.isEmpty())
91  return std::nullopt;
92  return Utils::String::toEnum(str, BitTorrent::TorrentContentLayout::Original);
93  }
T toEnum(const QString &serializedValue, const T &defaultValue)
Definition: string.h:77

References Utils::String::toEnum().

Referenced by RSS::AutoDownloadRule::fromJsonObject().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toAddPausedLegacy()

int anonymous_namespace{rss_autodownloadrule.cpp}::toAddPausedLegacy ( const std::optional< bool >  boolValue)

Definition at line 79 of file rss_autodownloadrule.cpp.

80  {
81  if (!boolValue.has_value())
82  return 0; // default
83 
84  return (*boolValue ? 1 /* always */ : 2 /* never */);
85  }

Referenced by RSS::AutoDownloadRule::toLegacyDict().

Here is the caller graph for this function:

◆ toJsonValue()

QJsonValue anonymous_namespace{rss_autodownloadrule.cpp}::toJsonValue ( const std::optional< bool >  boolValue)

Definition at line 61 of file rss_autodownloadrule.cpp.

62  {
63  return boolValue.has_value() ? *boolValue : QJsonValue {};
64  }

Referenced by RSS::Session::store(), and RSS::AutoDownloadRule::toJsonObject().

Here is the caller graph for this function:

◆ toOptionalBool()

std::optional<bool> anonymous_namespace{rss_autodownloadrule.cpp}::toOptionalBool ( const QJsonValue &  jsonVal)

Definition at line 53 of file rss_autodownloadrule.cpp.

54  {
55  if (jsonVal.isBool())
56  return jsonVal.toBool();
57 
58  return std::nullopt;
59  }

Referenced by RSS::AutoDownloadRule::fromJsonObject().

Here is the caller graph for this function: