当前位置: 首页>>代码示例>>C++>>正文


C++ InfoStringHash类代码示例

本文整理汇总了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 );
    }
}
开发者ID:Renaceboy,项目名称:tomahawk,代码行数:29,代码来源:SpotifyInfoPlugin.cpp

示例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 );
    }
}
开发者ID:Renaceboy,项目名称:tomahawk,代码行数:33,代码来源:SpotifyInfoPlugin.cpp

示例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 );
}
开发者ID:chakra-project,项目名称:tomahawk,代码行数:27,代码来源:chartsplugin.cpp

示例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;
        }
    }
}
开发者ID:andrix,项目名称:tomahawk,代码行数:46,代码来源:musicbrainzPlugin.cpp

示例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 );
    }
}
开发者ID:chakra-project,项目名称:tomahawk,代码行数:46,代码来源:chartsplugin.cpp

示例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("&", "&amp;"); //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();
}
开发者ID:nowrep,项目名称:tomahawk,代码行数:46,代码来源:FdoNotifyPlugin.cpp

示例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 );
}
开发者ID:AshotN,项目名称:tomahawk,代码行数:44,代码来源:SnoreNotifyPlugin.cpp

示例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;
}
开发者ID:AltarBeastiful,项目名称:tomahawk,代码行数:19,代码来源:NewReleasesPlugin.cpp

示例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() ) );
}
开发者ID:Alex237,项目名称:tomahawk,代码行数:19,代码来源:EchonestPlugin.cpp

示例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 );
}
开发者ID:ChrisOHu,项目名称:tomahawk,代码行数:21,代码来源:RoviPlugin.cpp

示例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" );
}
开发者ID:seezer,项目名称:tomahawk,代码行数:23,代码来源:MprisPlugin.cpp

示例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 ) ) );
}
开发者ID:eowemanuel,项目名称:tomahawk,代码行数:71,代码来源:FdoNotifyPlugin.cpp

示例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* ) ) );
}
开发者ID:AidedPolecat6,项目名称:tomahawk,代码行数:76,代码来源:FdoNotifyPlugin.cpp


注:本文中的InfoStringHash类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。