2011-09-24 23:49:04 +02:00
|
|
|
/* This file is part of Clementine.
|
|
|
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
|
|
|
|
|
|
|
Clementine is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Clementine is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "digitallyimportedsearchprovider.h"
|
|
|
|
#include "core/logging.h"
|
|
|
|
#include "internet/digitallyimportedservicebase.h"
|
|
|
|
|
|
|
|
DigitallyImportedSearchProvider::DigitallyImportedSearchProvider(
|
2012-02-13 21:44:04 +01:00
|
|
|
DigitallyImportedServiceBase* service, Application* app, QObject* parent)
|
|
|
|
: SimpleSearchProvider(app, parent),
|
2011-09-24 23:49:04 +02:00
|
|
|
service_(service)
|
|
|
|
{
|
2011-11-04 23:54:27 +01:00
|
|
|
Init(service_->name(), service->api_service_name(), service_->icon(),
|
2011-11-06 17:41:00 +01:00
|
|
|
ArtIsInSongMetadata | CanGiveSuggestions | CanShowConfig);
|
2011-09-24 23:49:04 +02:00
|
|
|
|
|
|
|
set_safe_words(QStringList() << "sky.fm" << "skyfm" << "di.fm" << "difm"
|
|
|
|
<< "digitallyimported");
|
2012-06-11 00:05:30 +02:00
|
|
|
set_max_suggestion_count(5);
|
2011-09-24 23:49:04 +02:00
|
|
|
|
2011-10-01 18:41:28 +02:00
|
|
|
connect(service_, SIGNAL(StreamsChanged()), SLOT(MaybeRecreateItems()));
|
2011-11-08 19:35:33 +01:00
|
|
|
|
|
|
|
// Load the channel list on startup only if it doesn't involve going to update
|
|
|
|
// info from the server.
|
|
|
|
if (!service_->IsChannelListStale())
|
|
|
|
RecreateItems();
|
2011-09-24 23:49:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void DigitallyImportedSearchProvider::RecreateItems() {
|
|
|
|
QList<Item> items;
|
|
|
|
|
2011-11-04 23:31:19 +01:00
|
|
|
DigitallyImportedClient::ChannelList channels = service_->Channels();
|
2011-09-24 23:49:04 +02:00
|
|
|
|
2011-11-04 23:31:19 +01:00
|
|
|
foreach (const DigitallyImportedClient::Channel& channel, channels) {
|
2011-09-24 23:49:04 +02:00
|
|
|
Song song;
|
2011-11-04 23:31:19 +01:00
|
|
|
service_->SongFromChannel(channel, &song);
|
2011-09-24 23:49:04 +02:00
|
|
|
items << Item(song);
|
|
|
|
}
|
|
|
|
|
|
|
|
SetItems(items);
|
|
|
|
}
|
2011-11-06 17:41:00 +01:00
|
|
|
|
|
|
|
void DigitallyImportedSearchProvider::ShowConfig() {
|
|
|
|
service_->ShowSettingsDialog();
|
|
|
|
}
|