Esempio n. 1
0
SearchWidget::SearchWidget( const QString& search, QWidget* parent )
    : QWidget( parent )
    , ui( new Ui::SearchWidget )
    , m_search( search )
{
    ui->setupUi( this );

    ui->resultsView->setGuid( "searchwidget" );
    m_resultsModel = new PlaylistModel( ui->resultsView );
    ui->resultsView->setPlaylistModel( m_resultsModel );
    ui->resultsView->overlay()->setEnabled( false );
    ui->resultsView->sortByColumn( PlaylistModel::Score, Qt::DescendingOrder );

    m_albumsModel = new AlbumModel( ui->albumView );
    ui->albumView->setAlbumModel( m_albumsModel );

    m_artistsModel = new AlbumModel( ui->artistView );
    ui->artistView->setAlbumModel( m_artistsModel );

    ui->artistView->setAutoFitItems( false );
    ui->albumView->setAutoFitItems( false );
    ui->artistView->setSpacing( 8 );
    ui->albumView->setSpacing( 8 );

    ui->artistView->proxyModel()->sort( -1 );
    ui->albumView->proxyModel()->sort( -1 );

    TomahawkUtils::unmarginLayout( ui->verticalLayout );

    ui->artistView->setContentsMargins( 0, 0, 0, 0 );
    ui->artistView->setFrameShape( QFrame::NoFrame );
    ui->artistView->setAttribute( Qt::WA_MacShowFocusRect, 0 );

    ui->albumView->setContentsMargins( 0, 0, 0, 0 );
    ui->albumView->setFrameShape( QFrame::NoFrame );
    ui->albumView->setAttribute( Qt::WA_MacShowFocusRect, 0 );

    ui->resultsView->setContentsMargins( 0, 0, 0, 0 );
    ui->resultsView->setFrameShape( QFrame::NoFrame );
    ui->resultsView->setAttribute( Qt::WA_MacShowFocusRect, 0 );

    ui->resultsView->loadingSpinner()->fadeIn();
    m_queries << Tomahawk::Query::get( search, uuid() );

    ui->splitter_2->setStretchFactor( 0, 0 );
    ui->splitter_2->setStretchFactor( 1, 1 );

    foreach ( const Tomahawk::query_ptr& query, m_queries )
    {
        connect( query.data(), SIGNAL( artistsAdded( QList<Tomahawk::artist_ptr> ) ), SLOT( onArtistsFound( QList<Tomahawk::artist_ptr> ) ) );
        connect( query.data(), SIGNAL( albumsAdded( QList<Tomahawk::album_ptr> ) ), SLOT( onAlbumsFound( QList<Tomahawk::album_ptr> ) ) );
        connect( query.data(), SIGNAL( resultsAdded( QList<Tomahawk::result_ptr> ) ), SLOT( onResultsFound( QList<Tomahawk::result_ptr> ) ) );
        connect( query.data(), SIGNAL( resolvingFinished( bool ) ), SLOT( onQueryFinished() ) );
    }
Esempio n. 2
0
SearchWidget::SearchWidget( const QString& search, QWidget* parent )
    : QWidget( parent )
    , ui( new Ui::SearchWidget )
    , m_search( search )
{
    ui->setupUi( this );

    ui->resultsView->setGuid( "searchwidget" );
    m_resultsModel = new PlaylistModel( ui->resultsView );
    ui->resultsView->setPlaylistModel( m_resultsModel );
    ui->resultsView->sortByColumn( PlaylistModel::Score, Qt::DescendingOrder );

    m_albumsModel = new PlayableModel( ui->albumView );
    ui->albumView->setPlayableModel( m_albumsModel );

    m_artistsModel = new PlayableModel( ui->artistView );
    ui->artistView->setPlayableModel( m_artistsModel );

    ui->artistView->proxyModel()->sort( -1 );
    ui->albumView->proxyModel()->sort( -1 );
    ui->artistView->proxyModel()->setHideDupeItems( true );
    ui->albumView->proxyModel()->setHideDupeItems( true );

    TomahawkUtils::unmarginLayout( ui->verticalLayout );

    m_artistsModel->startLoading();
    m_albumsModel->startLoading();
    m_resultsModel->startLoading();
    m_queries << Tomahawk::Query::get( search, uuid() );

    ui->splitter_2->setStretchFactor( 0, 0 );
    ui->splitter_2->setStretchFactor( 1, 1 );

    foreach ( const Tomahawk::query_ptr& query, m_queries )
    {
        connect( query.data(), SIGNAL( artistsAdded( QList<Tomahawk::artist_ptr> ) ), SLOT( onArtistsFound( QList<Tomahawk::artist_ptr> ) ) );
        connect( query.data(), SIGNAL( albumsAdded( QList<Tomahawk::album_ptr> ) ), SLOT( onAlbumsFound( QList<Tomahawk::album_ptr> ) ) );
        connect( query.data(), SIGNAL( resultsAdded( QList<Tomahawk::result_ptr> ) ), SLOT( onResultsFound( QList<Tomahawk::result_ptr> ) ) );
        connect( query.data(), SIGNAL( resolvingFinished( bool ) ), SLOT( onQueryFinished() ) );
    }