コード例 #1
0
void PLSelector::createItems()
{
    PLSelItem *pl = putPLData( addItem( PL_ITEM_TYPE, "Playlist", true ),
                               THEPL->p_playing );
    pl->treeItem()->setData( 0, SPECIAL_ROLE, QVariant( IS_PL ) );

    PLSelItem *ml = putPLData( addItem( PL_ITEM_TYPE, "Media Library", true ),
                               THEPL->p_media_library );
    ml->treeItem()->setData( 0, SPECIAL_ROLE, QVariant( IS_ML ) );

    QTreeWidgetItem *mycomp = addItem( CATEGORY_TYPE, "My Computer",
                                       false )->treeItem();
    QTreeWidgetItem *devices = addItem( CATEGORY_TYPE, "Devices",
                                        false )->treeItem();
    QTreeWidgetItem *lan = addItem( CATEGORY_TYPE, "Local Network",
                                    false )->treeItem();
    QTreeWidgetItem *internet = addItem( CATEGORY_TYPE, "Internet",
                                         false )->treeItem();;

    char **ppsz_longnames;
    int *p_categories;
    char **ppsz_names = vlc_sd_GetNames( THEPL, &ppsz_longnames, &p_categories );
    if( !ppsz_names )
        return;

    char **ppsz_name = ppsz_names, **ppsz_longname = ppsz_longnames;
    int *p_category = p_categories;
    for( ; *ppsz_name; ppsz_name++, ppsz_longname++, p_category++ )
    {
        //msg_Dbg( p_intf, "Adding a SD item: %s", *ppsz_longname );

        if( *p_category == SD_CAT_INTERNET )
        {
            PLSelItem *selItem = addItem( SD_TYPE, *ppsz_longname, false, internet );
            putSDData( selItem, *ppsz_name, *ppsz_longname );
            if( !strncmp( *ppsz_name, "podcast", 7 ) )
            {
                selItem->treeItem()->setData( 0, SPECIAL_ROLE, QVariant( IS_PODCAST ) );
                selItem->addAction( ADD_ACTION, qtr( "Subscribe to a podcast" ) );
                CONNECT( selItem, action( PLSelItem* ), this, podcastAdd( PLSelItem* ) );
                podcastsParent = selItem->treeItem();
            }
        }
コード例 #2
0
void PLSelector::createItems()
{
    /* PL */
    playlistItem = putPLData( addItem( PL_ITEM_TYPE, N_("Playlist"), true ),
                              THEPL->p_playing );
    playlistItem->treeItem()->setData( 0, SPECIAL_ROLE, QVariant( IS_PL ) );
    playlistItem->treeItem()->setData( 0, Qt::DecorationRole, QIcon( ":/sidebar/playlist" ) );
    setCurrentItem( playlistItem->treeItem() );

    /* ML */
    PLSelItem *ml = putPLData( addItem( PL_ITEM_TYPE, N_("Media Library"), true ),
                              THEPL->p_media_library );
    ml->treeItem()->setData( 0, SPECIAL_ROLE, QVariant( IS_ML ) );
    ml->treeItem()->setData( 0, Qt::DecorationRole, QIcon( ":/sidebar/library" ) );

#ifdef MEDIA_LIBRARY
    /* SQL ML */
    ml = addItem( SQL_ML_TYPE, "SQL Media Library" )->treeItem();
    ml->treeItem()->setData( 0, Qt::DecorationRole, QIcon( ":/sidebar/library" ) );
#endif

    /* SD nodes */
    QTreeWidgetItem *mycomp = addItem( CATEGORY_TYPE, N_("My Computer"), false, true )->treeItem();
    QTreeWidgetItem *devices = addItem( CATEGORY_TYPE, N_("Devices"), false, true )->treeItem();
    QTreeWidgetItem *lan = addItem( CATEGORY_TYPE, N_("Local Network"), false, true )->treeItem();
    QTreeWidgetItem *internet = addItem( CATEGORY_TYPE, N_("Internet"), false, true )->treeItem();

#define NOT_SELECTABLE(w) w->setFlags( w->flags() ^ Qt::ItemIsSelectable );
    NOT_SELECTABLE( mycomp );
    NOT_SELECTABLE( devices );
    NOT_SELECTABLE( lan );
    NOT_SELECTABLE( internet );
#undef NOT_SELECTABLE

    /* SD subnodes */
    char **ppsz_longnames;
    int *p_categories;
    char **ppsz_names = vlc_sd_GetNames( THEPL, &ppsz_longnames, &p_categories );
    if( !ppsz_names )
        return;

    char **ppsz_name = ppsz_names, **ppsz_longname = ppsz_longnames;
    int *p_category = p_categories;
    for( ; *ppsz_name; ppsz_name++, ppsz_longname++, p_category++ )
    {
        //msg_Dbg( p_intf, "Adding a SD item: %s", *ppsz_longname );

        PLSelItem *selItem;
        QIcon icon;
        QString name( *ppsz_name );
        switch( *p_category )
        {
        case SD_CAT_INTERNET:
            {
            selItem = addItem( SD_TYPE, *ppsz_longname, false, false, internet );
            if( name.startsWith( "podcast" ) )
            {
                selItem->treeItem()->setData( 0, SPECIAL_ROLE, QVariant( IS_PODCAST ) );
                selItem->addAction( ADD_ACTION, qtr( "Subscribe to a podcast" ) );
                CONNECT( selItem, action( PLSelItem* ), this, podcastAdd( PLSelItem* ) );
                podcastsParent = selItem->treeItem();
                icon = QIcon( ":/sidebar/podcast" );
            }
            else if ( name.startsWith( "lua{" ) )
            {
                int i_head = name.indexOf( "sd='" ) + 4;
                int i_tail = name.indexOf( '\'', i_head );
                QString iconname = QString( ":/sidebar/sd/%1" ).arg( name.mid( i_head, i_tail - i_head ) );
                QResource resource( iconname );
                if ( !resource.isValid() )
                    icon = QIcon( ":/sidebar/network" );
                else
                    icon = QIcon( iconname );
            }
            }
            break;
        case SD_CAT_DEVICES:
            name = name.mid( 0, name.indexOf( '{' ) );
            selItem = addItem( SD_TYPE, *ppsz_longname, false, false, devices );
            if ( name == "xcb_apps" )
                icon = QIcon( ":/sidebar/screen" );
            else if ( name == "mtp" )
                icon = QIcon( ":/sidebar/mtp" );
            else if ( name == "disc" )
                icon = QIcon( ":/sidebar/disc" );
            else
                icon = QIcon( ":/sidebar/capture" );
            break;
        case SD_CAT_LAN:
            selItem = addItem( SD_TYPE, *ppsz_longname, false, false, lan );
            icon = QIcon( ":/sidebar/lan" );
            break;
        case SD_CAT_MYCOMPUTER:
            name = name.mid( 0, name.indexOf( '{' ) );
            selItem = addItem( SD_TYPE, *ppsz_longname, false, false, mycomp );
            if ( name == "video_dir" )
                icon = QIcon( ":/sidebar/movie" );
            else if ( name == "audio_dir" )
                icon = QIcon( ":/sidebar/music" );
            else if ( name == "picture_dir" )
                icon = QIcon( ":/sidebar/pictures" );
            else
                icon = QIcon( ":/sidebar/movie" );
            break;
        default:
            selItem = addItem( SD_TYPE, *ppsz_longname );
        }
コード例 #3
0
ファイル: selector.cpp プロジェクト: cmassiot/vlc-broadcast
void PLSelector::createItems()
{
    /* PL */
    PLSelItem *pl = putPLData( addItem( PL_ITEM_TYPE, N_("Playlist"), true ),
                              THEPL->p_playing );
    pl->treeItem()->setData( 0, SPECIAL_ROLE, QVariant( IS_PL ) );

    /* ML */
    PLSelItem *ml = putPLData( addItem( PL_ITEM_TYPE, N_("Media Library"), true ),
                              THEPL->p_media_library );
    ml->treeItem()->setData( 0, SPECIAL_ROLE, QVariant( IS_ML ) );

    /* SD nodes */
    QTreeWidgetItem *mycomp = addItem( CATEGORY_TYPE, N_("My Computer") )->treeItem();
    QTreeWidgetItem *devices = addItem( CATEGORY_TYPE, N_("Devices") )->treeItem();
    QTreeWidgetItem *lan = addItem( CATEGORY_TYPE, N_("Local Network") )->treeItem();
    QTreeWidgetItem *internet = addItem( CATEGORY_TYPE, N_("Internet") )->treeItem();

    /* SD subnodes */
    char **ppsz_longnames;
    int *p_categories;
    char **ppsz_names = vlc_sd_GetNames( THEPL, &ppsz_longnames, &p_categories );
    if( !ppsz_names )
        return;

    char **ppsz_name = ppsz_names, **ppsz_longname = ppsz_longnames;
    int *p_category = p_categories;
    for( ; *ppsz_name; ppsz_name++, ppsz_longname++, p_category++ )
    {
        //msg_Dbg( p_intf, "Adding a SD item: %s", *ppsz_longname );

        PLSelItem *selItem;
        switch( *p_category )
        {
        case SD_CAT_INTERNET:
            {
            selItem = addItem( SD_TYPE, *ppsz_longname, false, internet );
            if( !strncmp( *ppsz_name, "podcast", 7 ) )
            {
                selItem->treeItem()->setData( 0, SPECIAL_ROLE, QVariant( IS_PODCAST ) );
                selItem->addAction( ADD_ACTION, qtr( "Subscribe to a podcast" ) );
                CONNECT( selItem, action( PLSelItem* ), this, podcastAdd( PLSelItem* ) );
                podcastsParent = selItem->treeItem();
            }
            }
            break;
        case SD_CAT_DEVICES:
            selItem = addItem( SD_TYPE, *ppsz_longname, false, devices );
            break;
        case SD_CAT_LAN:
            selItem = addItem( SD_TYPE, *ppsz_longname, false, lan );
            break;
        case SD_CAT_MYCOMPUTER:
            selItem = addItem( SD_TYPE, *ppsz_longname, false, mycomp );
            break;
        default:
            selItem = addItem( SD_TYPE, *ppsz_longname );
        }

        putSDData( selItem, *ppsz_name, *ppsz_longname );
        free( *ppsz_name );
        free( *ppsz_longname );
    }