mirror of
https://github.com/clementine-player/Clementine
synced 2024-12-16 19:31:02 +01:00
Remove the individual global search provider boolean flags and replace them with with a Q_FLAGS enum. Also add a flag for "probably has remote album art"
This commit is contained in:
parent
452fccc2f5
commit
348faef9e1
@ -24,7 +24,7 @@ DigitallyImportedSearchProvider::DigitallyImportedSearchProvider(
|
||||
: SimpleSearchProvider(parent),
|
||||
service_(service)
|
||||
{
|
||||
Init(service_->name(), service->url_scheme(), service_->icon(), false, false);
|
||||
Init(service_->name(), service->url_scheme(), service_->icon());
|
||||
icon_ = ScaleAndPad(QImage(service_->icon_path()));
|
||||
|
||||
set_safe_words(QStringList() << "sky.fm" << "skyfm" << "di.fm" << "difm"
|
||||
|
@ -31,7 +31,9 @@ GroovesharkSearchProvider::GroovesharkSearchProvider(QObject* parent)
|
||||
void GroovesharkSearchProvider::Init(GroovesharkService* service) {
|
||||
service_ = service;
|
||||
SearchProvider::Init("Grooveshark", "grooveshark",
|
||||
QIcon(":providers/grooveshark.png"), true, false);
|
||||
QIcon(":providers/grooveshark.png"),
|
||||
WantsDelayedQueries | ArtIsProbablyRemote);
|
||||
|
||||
connect(service_, SIGNAL(SimpleSearchResults(int, SongList)),
|
||||
SLOT(SearchDone(int, SongList)));
|
||||
connect(service_, SIGNAL(AlbumSearchResult(int, SongList)),
|
||||
|
@ -23,7 +23,7 @@
|
||||
LastFMSearchProvider::LastFMSearchProvider(LastFMService* service, QObject* parent)
|
||||
: SimpleSearchProvider(parent),
|
||||
service_(service) {
|
||||
Init("Last.fm", "lastfm", QIcon(":last.fm/as.png"), false, false);
|
||||
Init("Last.fm", "lastfm", QIcon(":last.fm/as.png"));
|
||||
icon_ = ScaleAndPad(QImage(":last.fm/as.png"));
|
||||
|
||||
set_safe_words(QStringList() << "lastfm" << "last.fm");
|
||||
|
@ -33,7 +33,7 @@ LibrarySearchProvider::LibrarySearchProvider(LibraryBackendInterface* backend,
|
||||
backend_(backend),
|
||||
cover_loader_(new BackgroundThreadImplementation<AlbumCoverLoader, AlbumCoverLoader>(this))
|
||||
{
|
||||
Init(name, id, icon, false, true);
|
||||
Init(name, id, icon, WantsSerialisedArtQueries);
|
||||
|
||||
cover_loader_->Start(true);
|
||||
cover_loader_->Worker()->SetDesiredHeight(kArtHeight);
|
||||
|
@ -25,17 +25,17 @@ const int SearchProvider::kArtHeight = 32;
|
||||
|
||||
|
||||
SearchProvider::SearchProvider(QObject* parent)
|
||||
: QObject(parent)
|
||||
: QObject(parent),
|
||||
hints_(0)
|
||||
{
|
||||
}
|
||||
|
||||
void SearchProvider::Init(const QString& name, const QString& id, const QIcon& icon,
|
||||
bool delay_searches, bool serialised_art) {
|
||||
void SearchProvider::Init(const QString& name, const QString& id,
|
||||
const QIcon& icon, Hints hints) {
|
||||
name_ = name;
|
||||
id_ = id;
|
||||
icon_ = icon;
|
||||
delay_searches_ = delay_searches;
|
||||
serialised_art_ = serialised_art;
|
||||
hints_ = hints;
|
||||
}
|
||||
|
||||
QStringList SearchProvider::TokenizeQuery(const QString& query) {
|
||||
|
@ -76,11 +76,34 @@ public:
|
||||
};
|
||||
typedef QList<Result> ResultList;
|
||||
|
||||
enum Hint {
|
||||
NoHints = 0x00,
|
||||
|
||||
// Indicates that queries to this provider mean making requests to a third
|
||||
// party. To be polite, queries should be buffered by a few milliseconds
|
||||
// instead of executing them each time the user types a character.
|
||||
WantsDelayedQueries = 0x01,
|
||||
|
||||
// Indicates that this provider wants to be given art queries one after the
|
||||
// other (serially), instead of all at once (in parallel).
|
||||
WantsSerialisedArtQueries = 0x02,
|
||||
|
||||
// Indicates that album cover art is probably going to be loaded remotely.
|
||||
// If a third-party application is making art requests over dbus and has
|
||||
// to get all the art it can before showing results to the user, it might
|
||||
// not load art from this provider.
|
||||
ArtIsProbablyRemote = 0x04
|
||||
};
|
||||
Q_DECLARE_FLAGS(Hints, Hint)
|
||||
|
||||
const QString& name() const { return name_; }
|
||||
const QString& id() const { return id_; }
|
||||
const QIcon& icon() const { return icon_; }
|
||||
const bool wants_delayed_queries() const { return delay_searches_; }
|
||||
const bool wants_serialised_art() const { return serialised_art_; }
|
||||
|
||||
Hints hints() const { return hints_; }
|
||||
bool wants_delayed_queries() const { return hints() & WantsDelayedQueries; }
|
||||
bool wants_serialised_art() const { return hints() & WantsSerialisedArtQueries; }
|
||||
bool art_is_probably_remote() const { return hints() & ArtIsProbablyRemote; }
|
||||
|
||||
// Starts a search. Must emit ResultsAvailable zero or more times and then
|
||||
// SearchFinished exactly once, using this ID.
|
||||
@ -116,18 +139,18 @@ protected:
|
||||
|
||||
// Subclasses must call this from their constructors.
|
||||
void Init(const QString& name, const QString& id, const QIcon& icon,
|
||||
bool delay_searches, bool serialised_art);
|
||||
Hints hints = NoHints);
|
||||
|
||||
private:
|
||||
QString name_;
|
||||
QString id_;
|
||||
QIcon icon_;
|
||||
bool delay_searches_;
|
||||
bool serialised_art_;
|
||||
Hints hints_;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(SearchProvider::Result)
|
||||
Q_DECLARE_METATYPE(SearchProvider::ResultList)
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(SearchProvider::Hints)
|
||||
|
||||
|
||||
class BlockingSearchProvider : public SearchProvider {
|
||||
|
@ -28,7 +28,8 @@ SpotifySearchProvider::SpotifySearchProvider(QObject* parent)
|
||||
server_(NULL),
|
||||
service_(NULL)
|
||||
{
|
||||
Init("Spotify", "spotify", QIcon(":icons/svg/spotify.svg"), true, true);
|
||||
Init("Spotify", "spotify", QIcon(":icons/svg/spotify.svg"),
|
||||
WantsDelayedQueries | WantsSerialisedArtQueries | ArtIsProbablyRemote);
|
||||
}
|
||||
|
||||
SpotifyServer* SpotifySearchProvider::server() {
|
||||
|
Loading…
Reference in New Issue
Block a user