コード例 #1
0
ファイル: MainWindow.cpp プロジェクト: Visse/QTYoutubeViewer
void MainWindow::ChannelSearchParsed( ChannelFeedPtr Search ) {
    QListWidgetItem *Item = new QListWidgetItem( ui->ItemView );

    Item->setSizeHint( QSize(300,64) );

    ListElement *Widget = new ListElement;

    Widget->setInfo( Search->cast_BaseInfo() );
    Widget->setSelected(false);

    ui->ItemView->setItemWidget( Item, Widget );
}
コード例 #2
0
ファイル: MainWindow.cpp プロジェクト: Visse/QTYoutubeViewer
void MainWindow::UserParsed( UserPtr User )
{
    QListWidgetItem *Item = new QListWidgetItem( ui->ItemView );

    Item->setSizeHint( QSize(300,64) );

    ListElement *Widget = new ListElement;

    Widget->setInfo( User->cast_BaseInfo() );
    Widget->setSelected(false);

    ui->ItemView->setItemWidget( Item, Widget );
}
コード例 #3
0
ファイル: MainWindow.cpp プロジェクト: Visse/QTYoutubeViewer
void MainWindow::PlaylistParsed( VideoFeedPtr Playlist )
{
    QListWidgetItem *Item = new QListWidgetItem( ui->ItemView );

    Item->setSizeHint( QSize(300,64) );

    ListElement *Widget = new ListElement;

    Widget->setInfo( Playlist->cast_BaseInfo() );
    Widget->setSelected(false);

    ui->ItemView->setItemWidget( Item, Widget );
}
コード例 #4
0
ファイル: MainWindow.cpp プロジェクト: Visse/QTYoutubeViewer
void MainWindow::VideosAddded( VideoFeedPtr Video )
{
    if( Video == mCurContent ) {
        for( int i=ui->ItemContent->count(); i < Video->Content.size(); i++ )
        {
            QListWidgetItem *Item = new QListWidgetItem( ui->ItemContent );
            Item->setSizeHint( QSize(300,64) );
            ListElement *Widget = new ListElement;
            Widget->setInfo( Video->Content.at(i)->cast_BaseInfo() );
            Widget->setSelected(false);
            ui->ItemContent->setItemWidget( Item, Widget );
        }
        if( !Video->HasFullFeed ) {
            /// this can seem like a memory leek but it is not, then ItemContent is cleared this element is also deleted :)
            mMoreItems = new QListWidgetItem( "Double click for more!", ui->ItemContent );
        }
    }
}
コード例 #5
0
ファイル: MainWindow.cpp プロジェクト: Visse/QTYoutubeViewer
void MainWindow::ItemDoubleClicked( QListWidgetItem *Item )
{
    if( Item == mMoreItems )
    {
        if( !mCurContent.isNull() && mCurContent->getType() == IT_VideoFeed )
            mParser->ParseNextPage(  mCurContent->cast_VideoFeed() );
        delete mMoreItems; mMoreItems = 0;
        return;
    }
    QWidget *Widget = Item->listWidget()->itemWidget(Item);
    if( Widget && typeid(*Widget) == typeid(ListElement) )
    {
        BasePtr Info = static_cast<ListElement*>(Widget)->getInfo();

        ui->ItemContent->clear();
        switch( Info->getType() ) {
        case( IT_VideoInfo ):
            {
                QListWidgetItem *Item = new QListWidgetItem( ui->ItemContent );
                Item->setSizeHint( QSize(300,64) );
                ListElement *Widget = new ListElement;
                Widget->setInfo( Info->cast_VideoInfo()->Releated->cast_BaseInfo() );
                Widget->setSelected(false);
                ui->ItemContent->setItemWidget( Item, Widget );

                Item = new QListWidgetItem( ui->ItemContent );
                Item->setSizeHint( QSize(300,64) );
                Widget = new ListElement;
                Widget->setInfo( Info->cast_VideoInfo()->Responces->cast_BaseInfo() );
                Widget->setSelected(false);
                ui->ItemContent->setItemWidget( Item, Widget );
                break;
            }
        case( IT_VideoFeed ): {
            if( Info->cast_VideoFeed()->ParsedPages == 0 ) {
                mParser->ParseNextPage(Info->cast_VideoFeed() );
                mCurContent = Info;
                return;
            }
                VideoFeedPtr fInfo = Info->cast_VideoFeed();
                for( int i=0; i < fInfo->Content.size(); i++ ) {
                    QListWidgetItem *Item = new QListWidgetItem( ui->ItemContent );
                    Item->setSizeHint( QSize(300,64) );
                    ListElement *Widget = new ListElement;
                    Widget->setInfo( fInfo->Content.at(i)->cast_BaseInfo() );
                    Widget->setSelected(false);
                    ui->ItemContent->setItemWidget( Item, Widget );
                }
                if( !fInfo->HasFullFeed ) {
                    /// this can seem like a memory leek but it is not, then ItemContent is cleared this element is also deleted :)
                    mMoreItems = new QListWidgetItem( "Double click for more!", ui->ItemContent );
                }
            break;
        } case( IT_UserInfo ): {
                // Fix this
                UserPtr User = Info->cast_UserInfo();

                QListWidgetItem *Item = 0;
                ListElement *Widget = 0;

                Item = new QListWidgetItem( ui->ItemContent );
                Item->setSizeHint( QSize(300,64) );
                Widget = new ListElement;
                Widget->setInfo( User->Favorites->cast_BaseInfo() );
                Widget->setSelected(false);
                ui->ItemContent->setItemWidget( Item, Widget );

                Item = new QListWidgetItem( ui->ItemContent );
                Item->setSizeHint( QSize(300,64) );
                Widget = new ListElement;
                Widget->setInfo( User->Uploads->cast_BaseInfo() );
                Widget->setSelected(false);
                ui->ItemContent->setItemWidget( Item, Widget );

                /* This does not work... I think its something with my parser....
                   have to look it up, maybe something with that it never parsed the playlists...
                   Solved it, I think forgot to create a playlist feed :P */
                Item = new QListWidgetItem( ui->ItemContent );
                Item->setSizeHint( QSize(300,64) );
                Widget = new ListElement;
                Widget->setInfo( User->Playlists->cast_BaseInfo() );
                Widget->setSelected(false);
                ui->ItemContent->setItemWidget( Item, Widget );

                break;
            break;
        } case( IT_PlaylistFeed ):
            /// @todo
            break;
        case( IT_ChannelFeed ):
            /// @todo
            break;
        default:
            break;
        }
        mCurContent = Info;
    }
}