mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-01 13:18:06 -06:00
Use c++11 enum classes instead of macros.
This commit is contained in:
@@ -63,7 +63,7 @@ namespace
|
||||
const quint32 __ENDIAN_TEST__ = 0x00000001;
|
||||
const bool __IS_LITTLE_ENDIAN__ = (reinterpret_cast<const uchar *>(&__ENDIAN_TEST__)[0] == 0x01);
|
||||
|
||||
BEGIN_SCOPED_ENUM(DataType)
|
||||
enum class DataType
|
||||
{
|
||||
Unknown = 0,
|
||||
Pointer = 1,
|
||||
@@ -81,8 +81,7 @@ namespace
|
||||
EndMarker = 13,
|
||||
Boolean = 14,
|
||||
Float = 15
|
||||
}
|
||||
END_SCOPED_ENUM
|
||||
};
|
||||
|
||||
struct DataFieldDescriptor
|
||||
{
|
||||
|
||||
@@ -974,12 +974,12 @@ void Preferences::setGlobalMaxRatio(qreal ratio)
|
||||
|
||||
MaxRatioAction Preferences::getMaxRatioAction() const
|
||||
{
|
||||
return value("Preferences/Bittorrent/MaxRatioAction", MaxRatioAction::Pause).toInt();
|
||||
return value("Preferences/Bittorrent/MaxRatioAction", QVariant::fromValue(MaxRatioAction::Pause)).value<MaxRatioAction>();
|
||||
}
|
||||
|
||||
void Preferences::setMaxRatioAction(MaxRatioAction act)
|
||||
{
|
||||
setValue("Preferences/Bittorrent/MaxRatioAction", act);
|
||||
setValue("Preferences/Bittorrent/MaxRatioAction", QVariant::fromValue(act));
|
||||
}
|
||||
|
||||
// IP Filter
|
||||
|
||||
@@ -31,43 +31,28 @@
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
#define BEGIN_SCOPED_ENUM(name) class name\
|
||||
{\
|
||||
int m_val;\
|
||||
\
|
||||
public:\
|
||||
name() {}\
|
||||
name(int val) : m_val(val) {}\
|
||||
operator int() const { return m_val; }\
|
||||
operator QVariant() const { return m_val; }\
|
||||
\
|
||||
enum
|
||||
|
||||
#define END_SCOPED_ENUM ; };
|
||||
|
||||
const qlonglong MAX_ETA = 8640000;
|
||||
|
||||
BEGIN_SCOPED_ENUM(MaxRatioAction)
|
||||
enum class MaxRatioAction
|
||||
{
|
||||
Pause,
|
||||
Remove
|
||||
}
|
||||
END_SCOPED_ENUM
|
||||
};
|
||||
|
||||
BEGIN_SCOPED_ENUM(TorrentExportFolder)
|
||||
Q_DECLARE_METATYPE(MaxRatioAction)
|
||||
|
||||
enum class TorrentExportFolder
|
||||
{
|
||||
Regular,
|
||||
Finished
|
||||
}
|
||||
END_SCOPED_ENUM
|
||||
};
|
||||
|
||||
BEGIN_SCOPED_ENUM(ShutdownAction)
|
||||
enum class ShutdownAction
|
||||
{
|
||||
None,
|
||||
Shutdown,
|
||||
Suspend,
|
||||
Hibernate
|
||||
}
|
||||
END_SCOPED_ENUM
|
||||
};
|
||||
|
||||
#endif // TYPES_H
|
||||
|
||||
Reference in New Issue
Block a user