Ejemplo n.º 1
0
	void BioViewManager::handleBioReady ()
	{
		auto pending = qobject_cast<Media::IPendingArtistBio*> (sender ());
		const auto& bio = pending->GetArtistBio ();
		BioPropProxy_->SetBio (bio);

		emit gotArtistImage (bio.BasicInfo_.Name_, bio.BasicInfo_.LargeImage_);
	}
Ejemplo n.º 2
0
	void HypedArtistsFetcher::pendingBioReady ()
	{
		auto pendingBio = qobject_cast<PendingArtistBio*> (sender ());
		pendingBio->deleteLater ();

		const auto& info = pendingBio->GetArtistBio ();
		const auto pos = std::find_if (Infos_.begin (), Infos_.end (),
				[&info] (decltype (Infos_.at (0)) thatInfo) { return thatInfo.Info_.Name_ == info.BasicInfo_.Name_; });
		if (pos != Infos_.end ())
			pos->Info_ = info.BasicInfo_;

		DecrementWaiting ();
	}
Ejemplo n.º 3
0
	CheckModel::CheckModel (const Collection::Artists_t& artists,
			const ICoreProxy_ptr& proxy, const ILMPProxy_ptr& lmpProxy, QObject *parent)
	: RoleNamesMixin<QStandardItemModel> { parent }
	, AllArtists_ { artists }
	, Proxy_ { lmpProxy }
	, DefaultAlbumIcon_ { GetIcon (proxy, "media-optical", AASize * 2) }
	, DefaultArtistIcon_ { GetIcon (proxy, "view-media-artist", ArtistSize * 2) }
	, AAProv_ { proxy->GetPluginsManager ()->
				GetAllCastableTo<Media::IAlbumArtProvider*> ().value (0) }
	, BioProv_ { proxy->GetPluginsManager ()->
				GetAllCastableTo<Media::IArtistBioFetcher*> ().value (0) }
	{
		QHash<int, QByteArray> roleNames;
		roleNames [Role::ArtistId] = "artistId";
		roleNames [Role::ArtistName] = "artistName";
		roleNames [Role::ScheduledToCheck] = "scheduled";
		roleNames [Role::IsChecked] = "isChecked";
		roleNames [Role::ArtistImage] = "artistImageUrl";
		roleNames [Role::Releases] = "releases";
		roleNames [Role::MissingCount] = "missingCount";
		roleNames [Role::PresentCount] = "presentCount";
		setRoleNames (roleNames);

		for (const auto& artist : artists)
		{
			if (artist.Name_.contains (" vs. ") ||
					artist.Name_.contains (" with ") ||
					artist.Albums_.isEmpty ())
				continue;

			auto item = new QStandardItem { artist.Name_ };
			item->setData (artist.ID_, Role::ArtistId);
			item->setData (artist.Name_, Role::ArtistName);
			item->setData (true, Role::ScheduledToCheck);
			item->setData (false, Role::IsChecked);
			item->setData (DefaultArtistIcon_, Role::ArtistImage);
			item->setData (0, Role::MissingCount);
			item->setData (artist.Albums_.size (), Role::PresentCount);

			const auto submodel = new ReleasesSubmodel { this };
			item->setData (QVariant::fromValue<QObject*> (submodel), Role::Releases);

			appendRow (item);

			Artist2Submodel_ [artist.ID_] = submodel;
			Artist2Item_ [artist.ID_] = item;

			Scheduled_ << artist.ID_;

			const auto proxy = BioProv_->RequestArtistBio (artist.Name_, false);
			new Util::OneTimeRunner
			{
				[this, artist, item, proxy] () -> void
				{
					if (!Artist2Item_.contains (artist.ID_))
						return;

					const auto& url = proxy->GetArtistBio ().BasicInfo_.LargeImage_;
					item->setData (url, Role::ArtistImage);
				},
				proxy->GetQObject (),
				{
					SIGNAL (ready ()),
					SIGNAL (error ())
				},
				this
			};
		}
	}