mirror of https://github.com/KDE/kasts.git
Refactor conversion from enum to int and vice versa
This commit is contained in:
parent
9c6c77db7a
commit
c09925c59f
|
@ -120,34 +120,12 @@ void Enclosure::updateFromDb()
|
|||
|
||||
int Enclosure::statusToDb(Enclosure::Status status)
|
||||
{
|
||||
switch (status) {
|
||||
case Enclosure::Status::Downloadable:
|
||||
return 0;
|
||||
case Enclosure::Status::Downloading:
|
||||
return 1;
|
||||
case Enclosure::Status::PartiallyDownloaded:
|
||||
return 2;
|
||||
case Enclosure::Status::Downloaded:
|
||||
return 3;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
return static_cast<int>(status);
|
||||
}
|
||||
|
||||
Enclosure::Status Enclosure::dbToStatus(int value)
|
||||
{
|
||||
switch (value) {
|
||||
case 0:
|
||||
return Enclosure::Status::Downloadable;
|
||||
case 1:
|
||||
return Enclosure::Status::Downloading;
|
||||
case 2:
|
||||
return Enclosure::Status::PartiallyDownloaded;
|
||||
case 3:
|
||||
return Enclosure::Status::Downloaded;
|
||||
default:
|
||||
return Enclosure::Status::Error;
|
||||
}
|
||||
return Enclosure::Status(value);
|
||||
}
|
||||
|
||||
void Enclosure::download()
|
||||
|
|
|
@ -45,11 +45,11 @@ public:
|
|||
Enclosure(Entry *entry);
|
||||
|
||||
enum Status {
|
||||
Downloadable,
|
||||
Error = -1,
|
||||
Downloadable = 0,
|
||||
Downloading,
|
||||
PartiallyDownloaded,
|
||||
Downloaded,
|
||||
Error,
|
||||
};
|
||||
Q_ENUM(Status)
|
||||
|
||||
|
|
|
@ -69,52 +69,10 @@ QString Error::description() const
|
|||
|
||||
int Error::typeToDb(Error::Type type)
|
||||
{
|
||||
switch (type) {
|
||||
case Error::Type::FeedUpdate:
|
||||
return 0;
|
||||
case Error::Type::MediaDownload:
|
||||
return 1;
|
||||
case Error::Type::MeteredNotAllowed:
|
||||
return 2;
|
||||
case Error::Type::InvalidMedia:
|
||||
return 3;
|
||||
case Error::Type::DiscoverError:
|
||||
return 4;
|
||||
case Error::Type::StorageMoveError:
|
||||
return 5;
|
||||
case Error::Type::SyncError:
|
||||
return 6;
|
||||
case Error::Type::MeteredStreamingNotAllowed:
|
||||
return 7;
|
||||
case Error::Type::NoNetwork:
|
||||
return 8;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
return static_cast<int>(type);
|
||||
}
|
||||
|
||||
Error::Type Error::dbToType(int value)
|
||||
{
|
||||
switch (value) {
|
||||
case 0:
|
||||
return Error::Type::FeedUpdate;
|
||||
case 1:
|
||||
return Error::Type::MediaDownload;
|
||||
case 2:
|
||||
return Error::Type::MeteredNotAllowed;
|
||||
case 3:
|
||||
return Error::Type::InvalidMedia;
|
||||
case 4:
|
||||
return Error::Type::DiscoverError;
|
||||
case 5:
|
||||
return Error::Type::StorageMoveError;
|
||||
case 6:
|
||||
return Error::Type::SyncError;
|
||||
case 7:
|
||||
return Error::Type::MeteredStreamingNotAllowed;
|
||||
case 8:
|
||||
return Error::Type::NoNetwork;
|
||||
default:
|
||||
return Error::Type::Unknown;
|
||||
}
|
||||
return Error::Type(value);
|
||||
}
|
||||
|
|
|
@ -16,8 +16,8 @@ class Error : public QObject
|
|||
|
||||
public:
|
||||
enum Type {
|
||||
Unknown,
|
||||
FeedUpdate,
|
||||
Unknown = -1,
|
||||
FeedUpdate = 0,
|
||||
MediaDownload,
|
||||
MeteredNotAllowed,
|
||||
InvalidMedia,
|
||||
|
|
Loading…
Reference in New Issue