SearchWidget::SearchWidget( const QString& search, QWidget* parent ) : QWidget( parent ) , ui( new Ui::SearchWidget ) , m_search( search ) { ui->setupUi( this ); m_resultsModel = new PlaylistModel( ui->resultsView ); ui->resultsView->setPlaylistModel( m_resultsModel ); ui->resultsView->overlay()->setEnabled( false ); ui->resultsView->sortByColumn( PlaylistModel::Score, Qt::DescendingOrder ); TomahawkUtils::unmarginLayout( ui->verticalLayout ); 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() ); foreach ( const Tomahawk::query_ptr& query, m_queries ) { connect( query.data(), SIGNAL( resultsAdded( QList<Tomahawk::result_ptr> ) ), SLOT( onResultsFound( QList<Tomahawk::result_ptr> ) ) ); connect( query.data(), SIGNAL( resolvingFinished( bool ) ), SLOT( onQueryFinished() ) ); }
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() ) ); }