mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-13 17:43:59 +02:00
* Applied new design to search page.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
* Copyright 2010-2014, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
* Copyright 2012 Leo Franchi <lfranchi@kde.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
@@ -19,10 +19,13 @@
|
||||
|
||||
#include "SearchWidget.h"
|
||||
#include "ui_SearchWidget.h"
|
||||
#include "ui_HeaderWidget.h"
|
||||
|
||||
#include "SourceList.h"
|
||||
#include "MetaPlaylistInterface.h"
|
||||
#include "ViewManager.h"
|
||||
#include "audio/AudioEngine.h"
|
||||
#include "playlist/ContextView.h"
|
||||
#include "playlist/PlayableModel.h"
|
||||
#include "playlist/PlaylistModel.h"
|
||||
#include "utils/AnimatedSpinner.h"
|
||||
@@ -33,91 +36,107 @@
|
||||
#include <QPushButton>
|
||||
#include <QScrollArea>
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
|
||||
SearchWidget::SearchWidget( const QString& search, QWidget* parent )
|
||||
: QWidget( parent )
|
||||
, ui( new Ui::SearchWidget )
|
||||
, uiHeader( new Ui::HeaderWidget )
|
||||
, m_search( search )
|
||||
{
|
||||
QWidget* widget = new QWidget;
|
||||
QWidget* headerWidget = new QWidget;
|
||||
ui->setupUi( widget );
|
||||
|
||||
ui->lineAbove->setStyleSheet( QString( "QFrame { border: 1px solid black; }" ) );
|
||||
ui->lineBelow->setStyleSheet( QString( "QFrame { border: 1px solid %1; }" ).arg( TomahawkStyle::HEADER_BACKGROUND.name() ) );
|
||||
uiHeader->setupUi( headerWidget );
|
||||
headerWidget->setFixedHeight( 160 );
|
||||
|
||||
{
|
||||
ui->resultsView->setGuid( "searchwidget" );
|
||||
m_resultsModel = new PlaylistModel( ui->resultsView );
|
||||
ui->artists->setAutoResize( true );
|
||||
ui->artists->setAutoFitItems( false );
|
||||
ui->artists->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
|
||||
ui->artists->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
|
||||
ui->artists->setWrapping( false );
|
||||
ui->artists->setItemSize( QSize( 140, 140 + 32 ) );
|
||||
ui->artists->setFixedHeight( 140 + 32 + 32 );
|
||||
|
||||
QPalette p = ui->resultsView->palette();
|
||||
p.setColor( QPalette::Text, TomahawkStyle::PAGE_TRACKLIST_TRACK_SOLVED );
|
||||
p.setColor( QPalette::BrightText, TomahawkStyle::PAGE_TRACKLIST_TRACK_UNRESOLVED );
|
||||
p.setColor( QPalette::Foreground, TomahawkStyle::PAGE_TRACKLIST_NUMBER );
|
||||
p.setColor( QPalette::Highlight, TomahawkStyle::PAGE_TRACKLIST_HIGHLIGHT );
|
||||
p.setColor( QPalette::HighlightedText, TomahawkStyle::PAGE_TRACKLIST_HIGHLIGHT_TEXT );
|
||||
m_artistsModel = new PlayableModel( ui->artists );
|
||||
ui->artists->setPlayableModel( m_artistsModel );
|
||||
ui->artists->proxyModel()->sort( -1 );
|
||||
ui->artists->setEmptyTip( tr( "Sorry, we could not find any artists!" ) );
|
||||
|
||||
ui->resultsView->setPalette( p );
|
||||
TomahawkStyle::stylePageFrame( ui->resultsView );
|
||||
ui->resultsView->setFrameShape( QFrame::Panel );
|
||||
TomahawkStyle::stylePageFrame( ui->resultsFrame );
|
||||
|
||||
ui->resultsView->setAlternatingRowColors( false );
|
||||
ui->resultsView->setAutoResize( true );
|
||||
ui->resultsView->setPlaylistModel( m_resultsModel );
|
||||
ui->resultsView->sortByColumn( PlaylistModel::Score, Qt::DescendingOrder );
|
||||
ui->resultsView->setEmptyTip( tr( "Sorry, we could not find any tracks!" ) );
|
||||
}
|
||||
|
||||
{
|
||||
m_albumsModel = new PlayableModel( ui->albumView );
|
||||
ui->albumView->setPlayableModel( m_albumsModel );
|
||||
|
||||
ui->albumView->proxyModel()->sort( -1 );
|
||||
ui->albumView->proxyModel()->setHideDupeItems( true );
|
||||
|
||||
ui->albumView->setAutoResize( true );
|
||||
ui->albumView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
|
||||
TomahawkStyle::stylePageFrame( ui->albumView );
|
||||
TomahawkStyle::stylePageFrame( ui->albumFrame );
|
||||
}
|
||||
|
||||
{
|
||||
m_artistsModel = new PlayableModel( ui->artistView );
|
||||
ui->artistView->setPlayableModel( m_artistsModel );
|
||||
|
||||
ui->artistView->proxyModel()->sort( -1 );
|
||||
ui->artistView->proxyModel()->setHideDupeItems( true );
|
||||
|
||||
ui->artistView->setAutoResize( true );
|
||||
ui->artistView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
|
||||
TomahawkStyle::stylePageFrame( ui->artistView );
|
||||
TomahawkStyle::stylePageFrame( ui->artists );
|
||||
TomahawkStyle::stylePageFrame( ui->artistFrame );
|
||||
TomahawkStyle::styleScrollBar( ui->artists->verticalScrollBar() );
|
||||
}
|
||||
|
||||
{
|
||||
QFont f = ui->label->font();
|
||||
f.setFamily( "Pathway Gothic One" );
|
||||
ui->albums->setAutoResize( true );
|
||||
ui->albums->setAutoFitItems( false );
|
||||
ui->albums->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
|
||||
ui->albums->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
|
||||
ui->albums->setWrapping( false );
|
||||
ui->albums->setItemSize( QSize( 140, 140 + 56 ) );
|
||||
// ui->albums->proxyModel()->setHideDupeItems( true );
|
||||
ui->albums->setFixedHeight( 140 + 56 + 32 );
|
||||
|
||||
QPalette p = ui->label->palette();
|
||||
p.setColor( QPalette::Foreground, TomahawkStyle::PAGE_CAPTION );
|
||||
m_albumsModel = new PlayableModel( ui->albums );
|
||||
ui->albums->setPlayableModel( m_albumsModel );
|
||||
ui->albums->proxyModel()->sort( -1 );
|
||||
ui->albums->setEmptyTip( tr( "Sorry, we could not find any albums!" ) );
|
||||
|
||||
ui->label->setFont( f );
|
||||
ui->label->setPalette( p );
|
||||
ui->albums->setStyleSheet( QString( "QListView { background-color: white; }" ) );
|
||||
TomahawkStyle::stylePageFrame( ui->albumFrame );
|
||||
TomahawkStyle::styleScrollBar( ui->albums->verticalScrollBar() );
|
||||
TomahawkStyle::styleScrollBar( ui->albums->horizontalScrollBar() );
|
||||
}
|
||||
|
||||
{
|
||||
QFont f = ui->label_2->font();
|
||||
f.setFamily( "Pathway Gothic One" );
|
||||
ui->tracks->setAutoResize( true );
|
||||
ui->tracks->setAutoFitItems( false );
|
||||
ui->tracks->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
|
||||
ui->tracks->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
|
||||
ui->tracks->setWrapping( false );
|
||||
ui->tracks->setItemSize( QSize( 140, 140 + 56 ) );
|
||||
// ui->tracks->proxyModel()->setHideDupeItems( true );
|
||||
ui->tracks->setFixedHeight( 140 + 56 + 32 );
|
||||
|
||||
QPalette p = ui->label_2->palette();
|
||||
p.setColor( QPalette::Foreground, TomahawkStyle::HEADER_TEXT );
|
||||
m_resultsModel = new PlayableModel( ui->tracks );
|
||||
ui->tracks->setPlayableModel( m_resultsModel );
|
||||
ui->tracks->proxyModel()->sort( -1 );
|
||||
ui->tracks->setEmptyTip( tr( "Sorry, we could not find any songs!" ) );
|
||||
|
||||
ui->label_2->setFont( f );
|
||||
ui->label_3->setFont( f );
|
||||
ui->label_2->setPalette( p );
|
||||
ui->label_3->setPalette( p );
|
||||
ui->tracks->setStyleSheet( QString( "QListView { background-color: white; }" ) );
|
||||
TomahawkStyle::stylePageFrame( ui->trackFrame );
|
||||
}
|
||||
|
||||
{
|
||||
QFont f = ui->topHitsMoreLabel->font();
|
||||
f.setWeight( QFont::Light );
|
||||
f.setPointSize( 11 );
|
||||
ui->topHitsMoreLabel->setFont( f );
|
||||
ui->artistsMoreLabel->setFont( f );
|
||||
ui->albumsMoreLabel->setFont( f );
|
||||
|
||||
connect( ui->artistsMoreLabel, SIGNAL( clicked() ), SLOT( onArtistsMoreClicked() ) );
|
||||
connect( ui->albumsMoreLabel, SIGNAL( clicked() ), SLOT( onAlbumsMoreClicked() ) );
|
||||
connect( ui->topHitsMoreLabel, SIGNAL( clicked() ), SLOT( onTopHitsMoreClicked() ) );
|
||||
}
|
||||
|
||||
{
|
||||
QFont f = uiHeader->artistLabel->font();
|
||||
f.setBold( true );
|
||||
f.setPointSize( 16 );
|
||||
|
||||
QPalette p = uiHeader->artistLabel->palette();
|
||||
p.setColor( QPalette::Foreground, Qt::white );
|
||||
|
||||
uiHeader->artistLabel->setFont( f );
|
||||
uiHeader->artistLabel->setPalette( p );
|
||||
}
|
||||
|
||||
m_stackedWidget = new QStackedWidget();
|
||||
|
||||
{
|
||||
QScrollArea* area = new QScrollArea();
|
||||
area->setWidgetResizable( true );
|
||||
@@ -125,29 +144,112 @@ SearchWidget::SearchWidget( const QString& search, QWidget* parent )
|
||||
area->setWidget( widget );
|
||||
|
||||
QPalette pal = palette();
|
||||
pal.setBrush( backgroundRole(), TomahawkStyle::HEADER_BACKGROUND );
|
||||
pal.setBrush( backgroundRole(), Qt::white );
|
||||
area->setPalette( pal );
|
||||
area->setAutoFillBackground( true );
|
||||
area->setFrameShape( QFrame::NoFrame );
|
||||
area->setAttribute( Qt::WA_MacShowFocusRect, 0 );
|
||||
|
||||
m_stackedWidget->addWidget( area );
|
||||
}
|
||||
{
|
||||
ContextView* topHitsFullView = new ContextView( m_stackedWidget );
|
||||
topHitsFullView->setCaption( tr( "Songs" ) );
|
||||
topHitsFullView->setShowCloseButton( true );
|
||||
topHitsFullView->setPlayableModel( m_resultsModel );
|
||||
m_stackedWidget->addWidget( topHitsFullView );
|
||||
|
||||
connect( topHitsFullView, SIGNAL( closeClicked() ), SLOT( onTopHitsMoreClosed() ) );
|
||||
}
|
||||
{
|
||||
GridView* artistsFullView = new GridView();
|
||||
// artistsFullView->setCaption( tr( "Artists" ) );
|
||||
// artistsFullView->setShowCloseButton( true );
|
||||
artistsFullView->setPlayableModel( m_artistsModel );
|
||||
|
||||
CaptionLabel* captionLabel = new CaptionLabel( this );
|
||||
captionLabel->setText( tr( "Artists" ) );
|
||||
captionLabel->setShowCloseButton( true );
|
||||
|
||||
QWidget* vbox = new QWidget;
|
||||
QPalette pal = vbox->palette();
|
||||
pal.setBrush( vbox->backgroundRole(), Qt::white );
|
||||
vbox->setPalette( pal );
|
||||
vbox->setAutoFillBackground( true );
|
||||
|
||||
QVBoxLayout* vboxl = new QVBoxLayout;
|
||||
TomahawkUtils::unmarginLayout( vboxl );
|
||||
vboxl->setContentsMargins( 32, 32, 32, 32 );
|
||||
vboxl->setSpacing( 8 );
|
||||
vbox->setLayout( vboxl );
|
||||
|
||||
vboxl->addWidget( captionLabel );
|
||||
vboxl->addWidget( artistsFullView );
|
||||
vboxl->addStretch();
|
||||
vboxl->setStretchFactor( artistsFullView, 1 );
|
||||
|
||||
m_stackedWidget->addWidget( vbox );
|
||||
|
||||
connect( captionLabel, SIGNAL( clicked() ), SLOT( onTopHitsMoreClosed() ) );
|
||||
}
|
||||
{
|
||||
GridView* albumsFullView = new GridView( m_stackedWidget );
|
||||
// albumsFullView->setCaption( tr( "Albums" ) );
|
||||
// albumsFullView->setShowCloseButton( true );
|
||||
albumsFullView->setPlayableModel( m_albumsModel );
|
||||
|
||||
CaptionLabel* captionLabel = new CaptionLabel( this );
|
||||
captionLabel->setText( tr( "Albums" ) );
|
||||
captionLabel->setShowCloseButton( true );
|
||||
|
||||
QWidget* vbox = new QWidget;
|
||||
QPalette pal = vbox->palette();
|
||||
pal.setBrush( vbox->backgroundRole(), Qt::white );
|
||||
vbox->setPalette( pal );
|
||||
vbox->setAutoFillBackground( true );
|
||||
|
||||
QVBoxLayout* vboxl = new QVBoxLayout;
|
||||
TomahawkUtils::unmarginLayout( vboxl );
|
||||
vboxl->setContentsMargins( 32, 32, 32, 32 );
|
||||
vboxl->setSpacing( 8 );
|
||||
vbox->setLayout( vboxl );
|
||||
|
||||
vboxl->addWidget( captionLabel );
|
||||
vboxl->addWidget( albumsFullView );
|
||||
vboxl->addStretch();
|
||||
vboxl->setStretchFactor( albumsFullView, 1 );
|
||||
|
||||
m_stackedWidget->addWidget( vbox );
|
||||
|
||||
connect( captionLabel, SIGNAL( clicked() ), SLOT( onTopHitsMoreClosed() ) );
|
||||
}
|
||||
|
||||
{
|
||||
QVBoxLayout* layout = new QVBoxLayout();
|
||||
layout->addWidget( area );
|
||||
layout->addWidget( headerWidget );
|
||||
layout->addWidget( m_stackedWidget );
|
||||
setLayout( layout );
|
||||
TomahawkUtils::unmarginLayout( layout );
|
||||
}
|
||||
|
||||
{
|
||||
QPalette pal = palette();
|
||||
pal.setBrush( backgroundRole(), TomahawkStyle::PAGE_BACKGROUND );
|
||||
ui->resultsContainer->setPalette( pal );
|
||||
ui->resultsContainer->setAutoFillBackground( true );
|
||||
}
|
||||
MetaPlaylistInterface* mpl = new MetaPlaylistInterface();
|
||||
mpl->addChildInterface( ui->artists->playlistInterface() );
|
||||
mpl->addChildInterface( ui->tracks->playlistInterface() );
|
||||
mpl->addChildInterface( ui->albums->playlistInterface() );
|
||||
m_plInterface = playlistinterface_ptr( mpl );
|
||||
|
||||
// ui->albumView->proxyModel()->sort( -1 );
|
||||
// ui->albumView->proxyModel()->setHideDupeItems( true );
|
||||
|
||||
// ui->artistView->proxyModel()->sort( -1 );
|
||||
// ui->artistView->proxyModel()->setHideDupeItems( true );
|
||||
|
||||
m_artistsModel->startLoading();
|
||||
m_albumsModel->startLoading();
|
||||
m_resultsModel->startLoading();
|
||||
|
||||
m_queries << Tomahawk::Query::get( search, uuid() );
|
||||
uiHeader->artistLabel->setText( title().toUpper() );
|
||||
|
||||
foreach ( const Tomahawk::query_ptr& query, m_queries )
|
||||
{
|
||||
@@ -186,14 +288,23 @@ SearchWidget::changeEvent( QEvent* e )
|
||||
Tomahawk::playlistinterface_ptr
|
||||
SearchWidget::playlistInterface() const
|
||||
{
|
||||
return ui->resultsView->playlistInterface();
|
||||
return m_plInterface;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
SearchWidget::jumpToCurrentTrack()
|
||||
{
|
||||
return ui->resultsView->jumpToCurrentTrack();
|
||||
if ( ui->albums && ui->albums->jumpToCurrentTrack() )
|
||||
return true;
|
||||
|
||||
if ( ui->artists && ui->artists->jumpToCurrentTrack() )
|
||||
return true;
|
||||
|
||||
if ( ui->tracks && ui->tracks->jumpToCurrentTrack() )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -214,15 +325,55 @@ SearchWidget::onResultsFound( const QList<Tomahawk::result_ptr>& results )
|
||||
QList< Tomahawk::result_ptr > rl;
|
||||
rl << result;
|
||||
|
||||
Tomahawk::query_ptr q = result->toQuery();
|
||||
q->addResults( rl );
|
||||
Tomahawk::query_ptr query = result->toQuery();
|
||||
query->disallowReresolve();
|
||||
|
||||
bool found = false;
|
||||
foreach ( const Tomahawk::query_ptr& q, m_results.keys() )
|
||||
{
|
||||
if ( q->equals( query, true, true ) )
|
||||
{
|
||||
found = true;
|
||||
q->addResults( rl );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !found )
|
||||
{
|
||||
m_results.insert( query, result->score() );
|
||||
queries << query;
|
||||
}
|
||||
|
||||
queries << q;
|
||||
artists << result->track()->artistPtr();
|
||||
albums << result->track()->albumPtr();
|
||||
}
|
||||
|
||||
m_resultsModel->appendQueries( queries );
|
||||
while ( queries.count() )
|
||||
{
|
||||
query_ptr q = queries.takeFirst();
|
||||
|
||||
bool done = false;
|
||||
for ( int i = 0; i < m_resultsModel->rowCount( QModelIndex() ); i++ )
|
||||
{
|
||||
PlayableItem* item = m_resultsModel->itemFromIndex( m_resultsModel->index( i, 0, QModelIndex() ) );
|
||||
if ( item && item->query() )
|
||||
{
|
||||
if ( item->query()->results().first()->score() < q->results().first()->score() )
|
||||
{
|
||||
m_resultsModel->insertQuery( q, i );
|
||||
done = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( !done )
|
||||
{
|
||||
m_resultsModel->appendQuery( q );
|
||||
}
|
||||
}
|
||||
|
||||
onArtistsFound( artists );
|
||||
onAlbumsFound( albums );
|
||||
}
|
||||
@@ -235,6 +386,9 @@ SearchWidget::onAlbumsFound( const QList<Tomahawk::album_ptr>& albums )
|
||||
|
||||
foreach ( const Tomahawk::album_ptr& album, albums )
|
||||
{
|
||||
if ( m_albums.contains( album ) )
|
||||
continue;
|
||||
|
||||
int distance = TomahawkUtils::levenshtein( m_search, album->name() );
|
||||
int maxlen = qMax( m_search.length(), album->name().length() );
|
||||
float score = (float)( maxlen - distance ) / maxlen;
|
||||
@@ -242,11 +396,11 @@ SearchWidget::onAlbumsFound( const QList<Tomahawk::album_ptr>& albums )
|
||||
if ( score <= 0.1 )
|
||||
continue;
|
||||
|
||||
m_albums.insert( score, album );
|
||||
m_albums.insert( album, score );
|
||||
// tDebug() << Q_FUNC_INFO << "found album:" << album->name() << "score:" << score;
|
||||
}
|
||||
|
||||
updateAlbums();
|
||||
// updateAlbums();
|
||||
}
|
||||
|
||||
|
||||
@@ -257,6 +411,9 @@ SearchWidget::onArtistsFound( const QList<Tomahawk::artist_ptr>& artists )
|
||||
|
||||
foreach ( const Tomahawk::artist_ptr& artist, artists )
|
||||
{
|
||||
if ( m_artists.contains( artist ) )
|
||||
continue;
|
||||
|
||||
int distance = TomahawkUtils::levenshtein( m_search, artist->name() );
|
||||
int maxlen = qMax( m_search.length(), artist->name().length() );
|
||||
float score = (float)( maxlen - distance ) / maxlen;
|
||||
@@ -264,11 +421,11 @@ SearchWidget::onArtistsFound( const QList<Tomahawk::artist_ptr>& artists )
|
||||
if ( score <= 0.1 )
|
||||
continue;
|
||||
|
||||
m_artists.insert( score, artist );
|
||||
m_artists.insert( artist, score );
|
||||
// tDebug() << Q_FUNC_INFO << "found artist:" << artist->name() << "score:" << score;
|
||||
}
|
||||
|
||||
updateArtists();
|
||||
// updateArtists();
|
||||
}
|
||||
|
||||
|
||||
@@ -280,6 +437,9 @@ SearchWidget::onQueryFinished()
|
||||
m_artistsModel->finishLoading();
|
||||
m_albumsModel->finishLoading();
|
||||
m_resultsModel->finishLoading();
|
||||
|
||||
updateArtists();
|
||||
updateAlbums();
|
||||
}
|
||||
|
||||
|
||||
@@ -289,12 +449,23 @@ SearchWidget::updateArtists()
|
||||
tDebug() << Q_FUNC_INFO;
|
||||
|
||||
QList< Tomahawk::artist_ptr > sortedArtists;
|
||||
QList< float > floats = m_artists.keys();
|
||||
QList< artist_ptr > artists = m_artists.keys();
|
||||
QList< float > floats = m_artists.values();
|
||||
|
||||
qSort( floats.begin(), floats.end() );
|
||||
|
||||
for ( int i = floats.count() - 1; i >= 0; i-- )
|
||||
while ( floats.count() > 0 )
|
||||
{
|
||||
sortedArtists << m_artists.value( floats.at( i ) );
|
||||
float f = floats.takeLast();
|
||||
foreach ( const artist_ptr& a, artists )
|
||||
{
|
||||
if ( m_artists.value( a ) == f )
|
||||
{
|
||||
artists.removeAll( a );
|
||||
sortedArtists << a;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_artistsModel->clear();
|
||||
@@ -308,12 +479,23 @@ SearchWidget::updateAlbums()
|
||||
tDebug() << Q_FUNC_INFO;
|
||||
|
||||
QList< Tomahawk::album_ptr > sortedAlbums;
|
||||
QList< float > floats = m_albums.keys();
|
||||
QList< album_ptr > albums = m_albums.keys();
|
||||
QList< float > floats = m_albums.values();
|
||||
|
||||
qSort( floats.begin(), floats.end() );
|
||||
|
||||
for ( int i = floats.count() - 1; i >= 0; i-- )
|
||||
while ( floats.count() > 0 )
|
||||
{
|
||||
sortedAlbums << m_albums.value( floats.at( i ) );
|
||||
float f = floats.takeLast();
|
||||
foreach ( const album_ptr& a, albums )
|
||||
{
|
||||
if ( m_albums.value( a ) == f )
|
||||
{
|
||||
albums.removeAll( a );
|
||||
sortedAlbums << a;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_albumsModel->clear();
|
||||
@@ -331,20 +513,48 @@ SearchWidget::pixmap() const
|
||||
bool
|
||||
SearchWidget::isBeingPlayed() const
|
||||
{
|
||||
if ( ui->resultsView->playlistInterface() == AudioEngine::instance()->currentTrackPlaylist() )
|
||||
return true;
|
||||
if ( ui->resultsView->playlistInterface()->hasChildInterface( AudioEngine::instance()->currentTrackPlaylist() ) )
|
||||
if ( ui->albums && ui->albums->isBeingPlayed() )
|
||||
return true;
|
||||
|
||||
if ( ui->albumView->playlistInterface() == AudioEngine::instance()->currentTrackPlaylist() )
|
||||
return true;
|
||||
if ( ui->albumView->playlistInterface()->hasChildInterface( AudioEngine::instance()->currentTrackPlaylist() ) )
|
||||
if ( ui->artists && ui->artists->isBeingPlayed() )
|
||||
return true;
|
||||
|
||||
if ( ui->artistView->playlistInterface() == AudioEngine::instance()->currentTrackPlaylist() )
|
||||
if ( ui->albums && ui->albums->playlistInterface() == AudioEngine::instance()->currentTrackPlaylist() )
|
||||
return true;
|
||||
if ( ui->artistView->playlistInterface()->hasChildInterface( AudioEngine::instance()->currentTrackPlaylist() ) )
|
||||
|
||||
if ( ui->artists && ui->artists->playlistInterface() == AudioEngine::instance()->currentTrackPlaylist() )
|
||||
return true;
|
||||
|
||||
if ( ui->tracks && ui->tracks->playlistInterface() == AudioEngine::instance()->currentTrackPlaylist() )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SearchWidget::onTopHitsMoreClicked()
|
||||
{
|
||||
m_stackedWidget->setCurrentIndex( 1 );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SearchWidget::onArtistsMoreClicked()
|
||||
{
|
||||
m_stackedWidget->setCurrentIndex( 2 );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SearchWidget::onAlbumsMoreClicked()
|
||||
{
|
||||
m_stackedWidget->setCurrentIndex( 3 );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SearchWidget::onTopHitsMoreClosed()
|
||||
{
|
||||
m_stackedWidget->setCurrentIndex( 0 );
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
* Copyright 2010-2014, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
* Copyright 2012 Leo Franchi <lfranchi@kde.org>
|
||||
* Copyright 2010-2011, Jeff Mitchell <jeff@tomahawk-player.org>
|
||||
*
|
||||
@@ -31,12 +31,14 @@
|
||||
#include "DllMacro.h"
|
||||
|
||||
class QPushButton;
|
||||
class QStackedWidget;
|
||||
class PlayableModel;
|
||||
class PlaylistModel;
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class SearchWidget;
|
||||
class HeaderWidget;
|
||||
}
|
||||
|
||||
class DLLEXPORT SearchWidget : public QWidget, public Tomahawk::ViewPage
|
||||
@@ -54,7 +56,7 @@ public:
|
||||
virtual QString description() const { return tr( "Results for '%1'" ).arg( m_search ); }
|
||||
virtual QPixmap pixmap() const;
|
||||
|
||||
virtual bool showInfoBar() const { return true; }
|
||||
virtual bool showInfoBar() const { return false; }
|
||||
virtual bool isBeingPlayed() const;
|
||||
virtual bool isTemporaryPage() const { return true; }
|
||||
virtual bool jumpToCurrentTrack();
|
||||
@@ -72,21 +74,30 @@ private slots:
|
||||
|
||||
void onQueryFinished();
|
||||
|
||||
void onArtistsMoreClicked();
|
||||
void onAlbumsMoreClicked();
|
||||
void onTopHitsMoreClicked();
|
||||
void onTopHitsMoreClosed();
|
||||
|
||||
private:
|
||||
void updateArtists();
|
||||
void updateAlbums();
|
||||
|
||||
Ui::SearchWidget *ui;
|
||||
Ui::HeaderWidget* uiHeader;
|
||||
|
||||
QStackedWidget* m_stackedWidget;
|
||||
QString m_search;
|
||||
|
||||
PlayableModel* m_artistsModel;
|
||||
PlayableModel* m_albumsModel;
|
||||
PlaylistModel* m_resultsModel;
|
||||
PlayableModel* m_resultsModel;
|
||||
Tomahawk::playlistinterface_ptr m_plInterface;
|
||||
|
||||
QList< Tomahawk::query_ptr > m_queries;
|
||||
QMap< float, Tomahawk::artist_ptr > m_artists;
|
||||
QMap< float, Tomahawk::album_ptr > m_albums;
|
||||
QMap< Tomahawk::artist_ptr, float > m_artists;
|
||||
QMap< Tomahawk::album_ptr, float > m_albums;
|
||||
QMap< Tomahawk::query_ptr, float > m_results;
|
||||
};
|
||||
|
||||
#endif // NEWPLAYLISTWIDGET_H
|
||||
|
@@ -6,14 +6,14 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>939</width>
|
||||
<height>647</height>
|
||||
<width>796</width>
|
||||
<height>1132</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::TabFocus</enum>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_7" stretch="0,0,1,0,0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
@@ -21,239 +21,171 @@
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QWidget" name="resultsContainer" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<property name="leftMargin">
|
||||
<number>12</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>16</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>12</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>16</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QFrame" name="resultsFrame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<property name="spacing">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>20</pointsize>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Tracks</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="PlaylistView" name="resultsView"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="lineAbove">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>1</height>
|
||||
</size>
|
||||
<widget class="QFrame" name="trackFrame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="lineBelow">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>1</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
<property name="spacing">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>16</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>16</number>
|
||||
<property name="margin">
|
||||
<number>32</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QFrame" name="artistFrame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
<widget class="CaptionLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Songs</string>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="GridView" name="tracks">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>190</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="ClickableLabel" name="topHitsMoreLabel">
|
||||
<property name="text">
|
||||
<string>Show More</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="spacing">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>28</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>20</pointsize>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Artists</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="GridView" name="artistView">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>190</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_3" native="true">
|
||||
<widget class="QFrame" name="artistFrame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<property name="spacing">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
<number>32</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>16</number>
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
<number>32</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>16</number>
|
||||
<number>32</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QFrame" name="albumFrame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
<widget class="CaptionLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Artists</string>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="GridView" name="artists">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>190</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="ClickableLabel" name="artistsMoreLabel">
|
||||
<property name="text">
|
||||
<string>Show More</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="albumFrame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<property name="spacing">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>32</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>32</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>32</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="CaptionLabel" name="albumLabel">
|
||||
<property name="text">
|
||||
<string>Albums</string>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="GridView" name="albums">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>190</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="ClickableLabel" name="albumsMoreLabel">
|
||||
<property name="text">
|
||||
<string>Show More</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>28</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>20</pointsize>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Albums</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="GridView" name="albumView">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>190</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@@ -262,15 +194,20 @@
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>PlaylistView</class>
|
||||
<extends>QTreeView</extends>
|
||||
<header location="global">playlist/PlaylistView.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>GridView</class>
|
||||
<extends>QListView</extends>
|
||||
<header location="global">playlist/GridView.h</header>
|
||||
<header>playlist/GridView.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>CaptionLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>widgets/CaptionLabel.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>ClickableLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>widgets/ClickableLabel.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
|
Reference in New Issue
Block a user