Exemple #1
0
void
XClient::propDictToQHash (const std::string &key,
						  const Xmms::Dict::Variant &value,
						  const std::string &source,
#ifdef SOURCEPREF_HACK
                          const QList<QRegExp> &prio_list,
                          QHash<QString, int> &curr_prio,
#endif
						  QHash<QString, QVariant> &hash)
{
#ifdef SOURCEPREF_HACK
	// braces because of tmp_prio definition
	{
		int tmp_prio = getPriority (QString::fromStdString (source), prio_list);
		QString tmp_key = QString::fromStdString (key);
		// Don't add a new value if the priority of it isn't better than the
		// priority already present in hash. If there is no "*" source
		// preference, this also get's rid of values we don't want at all
		if (tmp_prio >= curr_prio.value (tmp_key, prio_list.size ()))
			return;

		// Set the priority of the current source-key combination for the key, so
		// that we do not overwrite our value with a worse source for this key.
		// (higher priority values are worse)
		curr_prio[tmp_key] = tmp_prio;
	}
#endif
	if (value.type () == typeid (int32_t)) {
		hash.insert (QString::fromLatin1 (key.c_str ()),
		             QVariant (boost::get< int32_t > (value)));
	} else if (value.type () == typeid (uint32_t)) {
		hash.insert (QString::fromLatin1 (key.c_str ()),
		             QVariant (boost::get< int32_t > (value)));
	} else {
		QString val;
		if (key == "url") {
			QString tmp = QString::fromUtf8 (boost::get< std::string >(value).c_str ());
#if 0
			val = decodeXmmsUrl (tmp);
#else
			tmp = decodeXmmsUrl (tmp);
			val = tmp.mid (tmp.lastIndexOf ("/") + 1);
			if (val.isEmpty ()) {
				val = tmp;
			}
#endif
		} else {
			val = QString::fromUtf8 (boost::get< std::string > (value).c_str ());
		}

		hash.insert (stdToQ (key), QVariant (val));
	}
}
Exemple #2
0
void
XClient::dictToQHash (const std::string &key,
					  const Xmms::Dict::Variant &value,
					  QHash<QString, QVariant> &hash)
{
	if (value.type () == typeid (int32_t)) {
		hash.insert (QString::fromLatin1 (key.c_str ()),
		             QVariant (boost::get< int32_t > (value)));
	} else if (value.type () == typeid (uint32_t)) {
		hash.insert (QString::fromLatin1 (key.c_str ()),
		             QVariant (boost::get< int32_t > (value)));
	} else {
		QString val;
		val = QString::fromUtf8 (boost::get< std::string > (value).c_str ());
        hash.insert (stdToQ (key), QVariant (val));
	}
}
Exemple #3
0
void PlayAudio::propDictToQHash(const std::string&         key,
                                const Xmms::Dict::Variant& value,
                                const std::string&         source,
                                MusicInfo&                 hash) 
{
	Q_UNUSED( source );

	if(value.type () == typeid (int32_t))
	{
		hash.insert (QString::fromLatin1 (key.c_str ()),
					 QVariant (boost::get< int32_t > (value)));
	}
	else
	{
		if(value.type () == typeid (uint32_t))
		{
			hash.insert (QString::fromLatin1 (key.c_str ()),
						 QVariant (boost::get< uint32_t > (value)));
		}
		else
		{
			QString val;
			if(key == "url")
			{
				/* This really is wrong ...*/
				char *tmpUrl = const_cast<char *>(xmmsc_result_decode_url (NULL, boost::get< std::string >(value).c_str ()));
				val = QString::fromUtf8 (tmpUrl);
				if(val.isEmpty ())
				{
					val = QString::fromUtf8 (tmpUrl);
				}
				free (tmpUrl);
			}
			else
			{
				val = QString::fromUtf8 (boost::get< std::string > (value).c_str ());
			}
			hash.insert (QString::fromUtf8 (key.c_str ()), QVariant (val));
		}
	}
}