Use C++11 enum class

This commit is contained in:
Jonas Kvinge
2023-02-18 14:09:27 +01:00
parent e6c5f76872
commit dd72fb4ca5
237 changed files with 2915 additions and 2840 deletions

View File

@@ -69,7 +69,7 @@ void RadioBackend::AddChannels(const RadioChannelList &channels) {
q.prepare(QString("INSERT INTO radio_channels (source, name, url, thumbnail_url) VALUES (:source, :name, :url, :thumbnail_url)"));
for (const RadioChannel &channel : channels) {
q.BindValue(":source", channel.source);
q.BindValue(":source", static_cast<int>(channel.source));
q.BindValue(":name", channel.name);
q.BindValue(":url", channel.url);
q.BindValue(":thumbnail_url", channel.thumbnail_url);

View File

@@ -27,7 +27,7 @@ Song RadioChannel::ToSong() const {
Song song(source);
song.set_valid(true);
song.set_filetype(Song::FileType_Stream);
song.set_filetype(Song::FileType::Stream);
song.set_title(Song::DescriptionForSource(source) + " " + name);
song.set_url(url);

View File

@@ -27,7 +27,7 @@
#include "core/song.h"
struct RadioChannel {
explicit RadioChannel(const Song::Source _source = Song::Source_Unknown, const QString &_name = QString(), const QUrl &_url = QUrl(), const QUrl &_thumbnail_url = QUrl()) : source(_source), name(_name), url(_url), thumbnail_url(_thumbnail_url) {}
explicit RadioChannel(const Song::Source _source = Song::Source::Unknown, const QString &_name = QString(), const QUrl &_url = QUrl(), const QUrl &_thumbnail_url = QUrl()) : source(_source), name(_name), url(_url), thumbnail_url(_thumbnail_url) {}
Song::Source source;
QString name;
@@ -39,5 +39,6 @@ struct RadioChannel {
using RadioChannelList = QList<RadioChannel>;
Q_DECLARE_METATYPE(RadioChannel)
Q_DECLARE_METATYPE(RadioChannelList)
#endif // RADIOCHANNEL_H

View File

@@ -33,7 +33,7 @@ class RadioItem : public SimpleTreeItem<RadioItem> {
Type_LoadingIndicator,
Type_Root,
Type_Service,
Type_Channel,
Type_Channel
};
explicit RadioItem(SimpleTreeModel<RadioItem> *_model) : SimpleTreeItem<RadioItem>(Type_Root, _model) {}

View File

@@ -110,7 +110,7 @@ QVariant RadioModel::data(const RadioItem *item, int role) const {
return item->SortText();
break;
case Role_Source:
return item->source;
return QVariant::fromValue(item->source);
break;
case Role_Homepage:{
RadioService *service = app_->radio_services()->ServiceBySource(item->source);

View File

@@ -57,7 +57,7 @@ class RadioModel : public SimpleTreeModel<RadioItem> {
Role_Url,
Role_Homepage,
Role_Donate,
RoleCount,
RoleCount
};
// QAbstractItemModel

View File

@@ -25,7 +25,7 @@
#include "radiochannel.h"
RadioParadiseService::RadioParadiseService(Application *app, NetworkAccessManager *network, QObject *parent)
: RadioService(Song::Source_RadioParadise, "Radio Paradise", IconLoader::Load("radioparadise"), app, network, parent) {}
: RadioService(Song::Source::RadioParadise, "Radio Paradise", IconLoader::Load("radioparadise"), app, network, parent) {}
QUrl RadioParadiseService::Homepage() { return QUrl("https://radioparadise.com/"); }
QUrl RadioParadiseService::Donate() { return QUrl("https://payments.radioparadise.com/rp2s-content.php?name=Support&file=support"); }

View File

@@ -51,8 +51,8 @@ QVariant RadioPlaylistItem::DatabaseValue(DatabaseColumn column) const {
void RadioPlaylistItem::InitMetadata() {
if (metadata_.title().isEmpty()) metadata_.set_title(metadata_.url().toString());
if (metadata_.source() == Song::Source_Unknown) metadata_.set_source(Song::Source_Stream);
if (metadata_.filetype() == Song::FileType_Unknown) metadata_.set_filetype(Song::FileType_Stream);
if (metadata_.source() == Song::Source::Unknown) metadata_.set_source(Song::Source::Stream);
if (metadata_.filetype() == Song::FileType::Unknown) metadata_.set_filetype(Song::FileType::Stream);
metadata_.set_valid(true);
}

View File

@@ -37,7 +37,7 @@
const char *SomaFMService::kApiChannelsUrl = "https://somafm.com/channels.json";
SomaFMService::SomaFMService(Application *app, NetworkAccessManager *network, QObject *parent)
: RadioService(Song::Source_SomaFM, "SomaFM", IconLoader::Load("somafm"), app, network, parent) {}
: RadioService(Song::Source::SomaFM, "SomaFM", IconLoader::Load("somafm"), app, network, parent) {}
SomaFMService::~SomaFMService() {
Abort();