Example #1
0
	void RadioManager::RemoveUrl (const QModelIndex& index)
	{
		WithSourceProv (index,
				[] (Media::IRadioStationProvider *prov, const QModelIndex& index)
				{
					const auto radio = prov->GetRadioStation (index, {});
					if (!radio)
					{
						qWarning () << Q_FUNC_INFO
								<< "got a null radio station from provider";
						return;
					}

					auto modifiable = qobject_cast<Media::IModifiableRadioStation*> (radio->GetQObject ());
					if (!modifiable)
					{
						qWarning () << Q_FUNC_INFO
								<< radio->GetRadioName ()
								<< "is not modifiable";
						return;
					}

					modifiable->RemoveItem (index);
				});
	}
Example #2
0
	void RadioManager::RemoveUrl (const QModelIndex& index)
	{
		const auto item = StationsModel_->itemFromIndex (index);
		const auto root = GetRootItem (item);
		if (!Root2Prov_.contains (root))
		{
			qWarning () << Q_FUNC_INFO
					<< "unknown provider for index"
					<< index;
			return;
		}

		const auto radio = Root2Prov_ [root]->GetRadioStation (item, {});
		if (!radio)
		{
			qWarning () << Q_FUNC_INFO
					<< "got a null radio station from provider";
			return;
		}

		auto modifiable = qobject_cast<Media::IModifiableRadioStation*> (radio->GetQObject ());
		if (!modifiable)
		{
			qWarning () << Q_FUNC_INFO
					<< radio->GetRadioName ()
					<< "is not modifiable";
			return;
		}

		modifiable->RemoveItem (index);
	}
Example #3
0
	void RadioManager::AddUrl (const QModelIndex& index, const QUrl& url, const QString& name)
	{
		WithSourceProv (index,
				[url, name] (Media::IRadioStationProvider *prov, const QModelIndex& srcIdx)
				{
					const auto radio = prov->GetRadioStation (srcIdx, {});
					if (!radio)
					{
						qWarning () << Q_FUNC_INFO
								<< "got a null radio station from provider";
						return;
					}

					auto modifiable = qobject_cast<Media::IModifiableRadioStation*> (radio->GetQObject ());
					if (!modifiable)
					{
						qWarning () << Q_FUNC_INFO
								<< radio->GetRadioName ()
								<< "is not modifiable";
						return;
					}

					modifiable->AddItem (url, name);
				});
	}