Make BitTorrent::TorrentState strongly-typed enum

This is needed to forward declare this type and pass it by value.

Conversion from/to QVariant are hanled via Q_DECLARE_METATYPE, while
TorrentState::toString() function was used in webui only and as such is
moved there.
This commit is contained in:
Eugene Shalygin
2017-02-18 01:38:40 +01:00
committed by sledgehammer999
parent a6c99844de
commit d3a0ac3b6e
6 changed files with 79 additions and 97 deletions

View File

@@ -120,48 +120,35 @@ namespace BitTorrent
quint32 numPeers = 0;
};
class TorrentState
enum class TorrentState
{
public:
enum
{
Unknown = -1,
Unknown = -1,
ForcedDownloading,
Downloading,
DownloadingMetadata,
Allocating,
StalledDownloading,
ForcedDownloading,
Downloading,
DownloadingMetadata,
Allocating,
StalledDownloading,
ForcedUploading,
Uploading,
StalledUploading,
QueuedDownloading,
QueuedUploading,
CheckingUploading,
CheckingDownloading,
ForcedUploading,
Uploading,
StalledUploading,
#if LIBTORRENT_VERSION_NUM < 10100
QueuedForChecking,
QueuedForChecking,
#endif
CheckingResumeData,
CheckingResumeData,
QueuedDownloading,
QueuedUploading,
PausedDownloading,
PausedUploading,
CheckingUploading,
CheckingDownloading,
MissingFiles,
Error
};
PausedDownloading,
PausedUploading,
TorrentState(int value);
operator int() const;
QString toString() const;
private:
int m_value;
MissingFiles,
Error
};
class TorrentHandle : public QObject
@@ -474,4 +461,6 @@ namespace BitTorrent
};
}
Q_DECLARE_METATYPE(BitTorrent::TorrentState)
#endif // BITTORRENT_TORRENTHANDLE_H