本文整理汇总了C++中InfoStringHash类的典型用法代码示例。如果您正苦于以下问题:C++ InfoStringHash类的具体用法?C++ InfoStringHash怎么用?C++ InfoStringHash使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了InfoStringHash类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tLog
void
SpotifyInfoPlugin::sendLoveSong( const InfoType type, QVariant input )
{
if ( m_account.isNull() || !m_account.data()->loggedIn() )
return;
if( !m_account.data()->loveSync() )
return;
if ( !input.toMap().contains( "trackinfo" ) || !input.toMap()[ "trackinfo" ].canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
{
tLog( LOGVERBOSE ) << "SpotifyInfoPlugin::sendLoveSong cannot convert input!";
return;
}
InfoStringHash hash = input.toMap()[ "trackinfo" ].value< Tomahawk::InfoSystem::InfoStringHash >();
if ( !hash.contains( "title" ) || !hash.contains( "artist" ) || !hash.contains( "album" ) )
return;
if ( type == Tomahawk::InfoSystem::InfoLove )
{
m_account.data()->starTrack( hash["artist"], hash["title"], true );
}
else if ( type == Tomahawk::InfoSystem::InfoUnLove )
{
m_account.data()->starTrack( hash["artist"], hash["title"], false );
}
}
示例2: switch
void
SpotifyInfoPlugin::getInfo( InfoRequestData requestData )
{
switch ( requestData.type )
{
case InfoAlbumSongs:
{
if ( !requestData.input.canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
{
dataError( requestData );
return;
}
InfoStringHash hash = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash >();
if ( !hash.contains( "album" ) )
{
dataError( requestData );
return;
}
Tomahawk::InfoSystem::InfoStringHash criteria;
criteria[ "album" ] = hash[ "album" ];
if ( hash.contains( "artist" ) )
criteria["artist"] = hash["artist"];
emit getCachedInfo( criteria, Q_INT64_C(2419200000), requestData );
return;
}
default:
dataError( requestData );
}
}
示例3: dataError
void
ChartsPlugin::fetchChart( Tomahawk::InfoSystem::InfoRequestData requestData )
{
if ( !requestData.input.canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
{
dataError( requestData );
return;
}
InfoStringHash hash = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash >();
Tomahawk::InfoSystem::InfoStringHash criteria;
/// Each request needs to contain both a id and source
if ( !hash.contains( "chart_id" ) && !hash.contains( "chart_source" ) )
{
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Hash did not contain required params!";
dataError( requestData );
return;
}
/// Set the criterias for current chart
criteria["chart_id"] = hash["chart_id"];
criteria["chart_source"] = hash["chart_source"];
emit getCachedInfo( criteria, 86400000, requestData );
}
示例4: info
void
MusicBrainzPlugin::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData )
{
if ( !requestData.input.canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
{
emit info( requestData, QVariant() );
return;
}
InfoStringHash hash = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash >();
if ( !hash.contains( "artist" ) )
{
emit info( requestData, QVariant() );
return;
}
switch ( requestData.type )
{
case InfoArtistReleases:
{
Tomahawk::InfoSystem::InfoStringHash criteria;
criteria["artist"] = hash["artist"];
emit getCachedInfo( criteria, 2419200000, requestData );
break;
}
case InfoAlbumSongs:
{
Tomahawk::InfoSystem::InfoStringHash criteria;
criteria["artist"] = hash["artist"];
criteria["album"] = hash["album"];
emit getCachedInfo( criteria, 2419200000, requestData );
break;
}
default:
{
Q_ASSERT( false );
break;
}
}
}
示例5: switch
void
ChartsPlugin::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData )
{
//qDebug() << Q_FUNC_INFO << requestData.caller;
//qDebug() << Q_FUNC_INFO << requestData.customData;
InfoStringHash hash = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash >();
bool foundSource = false;
switch ( requestData.type )
{
case InfoChart:
/// We need something to check if the request is actually ment to go to this plugin
if ( !hash.contains( "chart_source" ) )
{
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Hash did not contain required param!";
dataError( requestData );
break;
}
else
{
foreach( QString resource, m_chartResources )
{
if( resource == hash["chart_source"] )
{
foundSource = true;
}
}
if( !foundSource )
{
dataError( requestData );
break;
}
}
fetchChart( requestData );
break;
case InfoChartCapabilities:
fetchChartCapabilities( requestData );
break;
default:
dataError( requestData );
}
}
示例6: tDebug
void
FdoNotifyPlugin::nowPlaying( const QVariant &input )
{
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
if ( !input.canConvert< QVariantMap >() )
return;
QVariantMap map = input.toMap();
if ( !map.contains( "trackinfo" ) || !map[ "trackinfo" ].canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
return;
InfoStringHash hash = map[ "trackinfo" ].value< Tomahawk::InfoSystem::InfoStringHash >();
if ( !hash.contains( "title" ) || !hash.contains( "artist" ) || !hash.contains( "album" ) )
return;
QString messageText = tr( "Tomahawk is playing \"%1\" by %2%3." )
.arg( hash[ "title" ] )
.arg( hash[ "artist" ] )
.arg( hash[ "album" ].isEmpty() ? QString() : QString( " %1" ).arg( tr( "on \"%1\"" ).arg( hash[ "album" ] ) ) );
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "sending message" << messageText;
QDBusMessage message = QDBusMessage::createMethodCall( "org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications", "Notify" );
QList<QVariant> arguments;
arguments << QString( "Tomahawk" ); //app_name
arguments << m_nowPlayingId; //notification_id
arguments << QString(); //app_icon
arguments << QString( "Tomahawk" ); //summary
arguments << messageText.replace("&", "&"); //body
arguments << QStringList(); //actions
QVariantMap dict;
dict["desktop-entry"] = QString( "tomahawk" );
if ( map.contains( "coveruri" ) && map[ "coveruri" ].canConvert< QString >() )
dict[ "image_data" ] = ImageConverter::variantForImage( QImage( map[ "coveruri" ].toString(), "PNG" ) );
else
dict[ "image_data" ] = ImageConverter::variantForImage( QImage( RESPATH "icons/tomahawk-icon-128x128.png" ) );
arguments << dict; //hints
arguments << qint32( -1 ); //expire_timeout
message.setArguments( arguments );
const QDBusMessage &reply = QDBusConnection::sessionBus().call( message );
const QVariantList &list = reply.arguments();
if ( list.count() > 0 )
m_nowPlayingId = list.at( 0 ).toInt();
}
示例7: tDebug
void
SnoreNotifyPlugin::nowPlaying( const QVariant& input )
{
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
if ( !input.canConvert< QVariantMap >() )
return;
QVariantMap map = input.toMap();
if ( !map.contains( "trackinfo" ) || !map[ "trackinfo" ].canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
return;
InfoStringHash hash = map[ "trackinfo" ].value< Tomahawk::InfoSystem::InfoStringHash >();
if ( !hash.contains( "title" ) || !hash.contains( "artist" ) || !hash.contains( "album" ) )
return;
QString messageText;
// If the window manager supports notification styling then use it.
// Remark: If using xml-based markup in notifications, the supplied strings need to be escaped.
QString album;
if ( !hash[ "album" ].isEmpty() )
album = QString( "<br><i>%1</i> %2" ).arg( tr( "on", "'on' is followed by an album name" ) ).arg( hash[ "album" ].toHtmlEscaped() );
messageText = tr( "%1%4 %2%3.", "%1 is a title, %2 is an artist and %3 is replaced by either the previous message or nothing, %4 is the preposition used to link track and artist ('by' in english)" )
.arg( hash[ "title" ].toHtmlEscaped() )
.arg( hash[ "artist" ].toHtmlEscaped() )
.arg( album )
.arg( QString( "<br><i>%1</i>" ).arg( tr( "by", "preposition to link track and artist" ) ) );
// Dirty hack(TM) so that KNotify/QLabel recognizes the message as Rich Text
messageText = QString( "<i></i>%1" ).arg( messageText );
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "sending message" << messageText;
// If there is a cover availble use it, else use Tomahawk logo as default.
Snore::Icon image = m_defaultIcon;
if ( map.contains( "cover" ) && map[ "cover" ].canConvert< QImage >() )
{
image = Snore::Icon( QPixmap::fromImage( map[ "cover" ].value< QImage >() ) );
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << image;
}
notifyUser( InfoNowPlaying, messageText, image );
}
示例8: newReleaseSort
bool
newReleaseSort( const InfoStringHash& left, const InfoStringHash& right )
{
if ( left.contains( "rank" ) && right.contains( "rank" ) )
{
const int lRank = left[ "rank" ].toInt();
const int rRank = right[ "rank" ].toInt();
return lRank < rRank;
}
if ( left.contains( "date" ) && right.contains( "date" ) )
{
const QDate lDate = QDate::fromString( left[ "date" ], "yyyy-MM-dd" );
const QDate rDate = QDate::fromString( right[ "date" ], "yyyy-MM-dd" );
return lDate > rDate;
}
return true;
}
示例9: artist
void
EchonestPlugin::getArtistBiography( const Tomahawk::InfoSystem::InfoRequestData &requestData )
{
if ( !requestData.input.canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
{
return;
}
InfoStringHash hash = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash >();
if ( !hash.contains( "artist" ) )
{
return;
}
Echonest::Artist artist( hash["artist"] );
QNetworkReply *reply = artist.fetchBiographies();
reply->setProperty( "artist", QVariant::fromValue< Echonest::Artist >( artist ) );
reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) );
connect( reply, SIGNAL( finished() ), SLOT( getArtistBiographySlot() ) );
}
示例10: info
void
RoviPlugin::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData )
{
if ( !requestData.input.canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
{
emit info( requestData, QVariant() );
return;
}
InfoStringHash hash = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash >();
if ( !hash.contains( "artist" ) || !hash.contains( "album" ) )
{
emit info( requestData, QVariant() );
return;
}
Tomahawk::InfoSystem::InfoStringHash criteria;
criteria["artist"] = hash["artist"];
criteria["album"] = hash["album"];
emit getCachedInfo( criteria, 0, requestData );
}
示例11: notifyPropertyChanged
/** Audio state slots */
void
MprisPlugin::audioStarted( const QVariant& input )
{
if ( !input.canConvert< QVariantMap >() )
return;
QVariantMap map = input.toMap();
if ( !map.contains( "trackinfo" ) || !map[ "trackinfo" ].canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
return;
InfoStringHash hash = map[ "trackinfo" ].value< Tomahawk::InfoSystem::InfoStringHash >();
if ( !hash.contains( "title" ) || !hash.contains( "artist" ) || !hash.contains( "album" ) )
return;
m_playbackStatus = "Playing";
if ( map.contains( "coveruri" ) )
m_coverTempFile = map[ "coveruri" ].toString();
notifyPropertyChanged( "org.mpris.MediaPlayer2.Player", "Metadata" );
}
示例12: tDebug
void
FdoNotifyPlugin::nowPlaying( const QVariant& input )
{
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
if ( !input.canConvert< QVariantMap >() )
return;
QVariantMap map = input.toMap();
if ( !map.contains( "trackinfo" ) || !map[ "trackinfo" ].canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
return;
InfoStringHash hash = map[ "trackinfo" ].value< Tomahawk::InfoSystem::InfoStringHash >();
if ( !hash.contains( "title" ) || !hash.contains( "artist" ) || !hash.contains( "album" ) )
return;
QString messageText;
// If the window manager supports notification styling then use it.
if ( m_wmSupportsBodyMarkup )
{
// Remark: If using xml-based markup in notifications, the supplied strings need to be escaped.
QString album;
if ( !hash[ "album" ].isEmpty() )
album = tr( "<br /><i>on</i> %1", "%1 is an album name" ).arg( Qt::escape( hash[ "album" ] ) );
messageText = tr( "%1<br /><i>by</i> %2%3.", "%1 is a title, %2 is an artist and %3 is replaced by either the previous message or nothing" )
.arg( Qt::escape( hash[ "title" ] ) )
.arg( Qt::escape( hash[ "artist" ] ) )
.arg( album );
}
else
{
QString album;
if ( !hash[ "album" ].isEmpty() )
album = QString( " %1" ).arg( tr( "on \"%1\"", "%1 is an album name" ).arg( hash[ "album" ] ) );
messageText = tr( "\"%1\" by %2%3.", "%1 is a title, %2 is an artist and %3 is replaced by either the previous message or nothing" )
.arg( hash[ "title" ] )
.arg( hash[ "artist" ] )
.arg( album );
}
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "sending message" << messageText;
QDBusMessage message = QDBusMessage::createMethodCall( "org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications", "Notify" );
QList<QVariant> arguments;
arguments << QString( "Tomahawk" ); //app_name
arguments << m_nowPlayingId; //notification_id
arguments << QString(); //app_icon
arguments << QString( "Tomahawk - Now Playing" ); //summary
arguments << messageText; //body
arguments << QStringList(); //actions
QVariantMap dict;
dict["desktop-entry"] = QString( "tomahawk" );
// If there is a cover availble use it, else use Tomahawk logo as default.
QImage image;
if ( map.contains( "coveruri" ) && map[ "coveruri" ].canConvert< QString >() )
image = QImage( map[ "coveruri" ].toString(), "PNG" );
else
image = QImage( RESPATH "icons/tomahawk-icon-512x512.png" );
// Convert image to QVariant and scale to a consistent size.
dict[ "image_data" ] = ImageConverter::variantForImage( image.scaledToHeight( getNotificationIconHeight() ) );
arguments << dict; //hints
arguments << qint32( -1 ); //expire_timeout
message.setArguments( arguments );
// Handle reply in a callback, so that this a non-blocking call
QDBusConnection::sessionBus().callWithCallback( message, this, SLOT( dbusPlayingReplyReceived( QDBusMessage ) ) );
}
示例13: tDebug
void
FdoNotifyPlugin::nowPlaying( const QVariant& input )
{
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
if ( !input.canConvert< QVariantMap >() )
return;
QVariantMap map = input.toMap();
if ( !map.contains( "trackinfo" ) || !map[ "trackinfo" ].canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
return;
InfoStringHash hash = map[ "trackinfo" ].value< Tomahawk::InfoSystem::InfoStringHash >();
if ( !hash.contains( "title" ) || !hash.contains( "artist" ) || !hash.contains( "album" ) )
return;
QString messageText;
// If the window manager supports notification styling then use it.
if ( m_wmSupportsBodyMarkup )
{
// Remark: If using xml-based markup in notifications, the supplied strings need to be escaped.
QString album;
if ( !hash[ "album" ].isEmpty() )
album = QString( "\n<i>%1</i> %2" )
.arg( tr( "on", "'on' is followed by an album name" ) )
.arg( escapeHtml( hash[ "album" ] ) );
messageText = tr( "%1%4 %2%3.", "%1 is a title, %2 is an artist and %3 is replaced by either the previous message or nothing, %4 is the preposition used to link track and artist ('by' in english)" )
.arg( escapeHtml( hash[ "title" ] ) )
.arg( escapeHtml( hash[ "artist" ] ) )
.arg( album )
.arg( QString( "\n<i>%1</i>" ).arg( tr( "by", "preposition to link track and artist" ) ) );
// Dirty hack(TM) so that KNotify/QLabel recognizes the message as Rich Text
messageText = QString( "<i></i>%1" ).arg( messageText );
}
else
{
QString album;
if ( !hash[ "album" ].isEmpty() )
album = QString( " %1" ).arg( tr( "on \"%1\"", "%1 is an album name" ).arg( hash[ "album" ] ) );
messageText = tr( "\"%1\" by %2%3.", "%1 is a title, %2 is an artist and %3 is replaced by either the previous message or nothing" )
.arg( hash[ "title" ] )
.arg( hash[ "artist" ] )
.arg( album );
}
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "sending message" << messageText;
QVariantMap hints;
hints["desktop-entry"] = QString( "tomahawk" );
// If there is a cover availble use it, else use Tomahawk logo as default.
QImage image;
if ( map.contains( "coveruri" ) && map[ "coveruri" ].canConvert< QString >() )
image = QImage( map[ "coveruri" ].toString(), "PNG" );
else
image = QImage( RESPATH "icons/tomahawk-icon-512x512.png" );
// Convert image to QVariant and scale to a consistent size.
hints[ "image_data" ] = ImageConverter::variantForImage( image.scaledToHeight( getNotificationIconHeight() ) );
QDBusPendingReply<> reply = notifications_interface->Notify(
TOMAHAWK_APPLICATION_NAME, // app_name
m_nowPlayingId, // notification_id
"", // app_icon
tr( "Tomahawk - Now Playing" ), // summary
messageText, // body
QStringList(), // actions
hints, // hints
-1 // expire_timeout
);
QDBusPendingCallWatcher* watcher = new QDBusPendingCallWatcher( reply, this );
connect( watcher, SIGNAL( finished( QDBusPendingCallWatcher* ) ), SLOT( dbusPlayingReplyReceived( QDBusPendingCallWatcher* ) ) );
}