1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-16 02:54:33 +02:00

* Applied new design to search page.

This commit is contained in:
Christian Muehlhaeuser
2014-08-19 13:46:31 +02:00
parent 03d774b9e7
commit 14f2549951
3 changed files with 474 additions and 316 deletions

View File

@@ -1,6 +1,6 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> === /* === 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 2012 Leo Franchi <lfranchi@kde.org>
* *
* Tomahawk is free software: you can redistribute it and/or modify * Tomahawk is free software: you can redistribute it and/or modify
@@ -19,10 +19,13 @@
#include "SearchWidget.h" #include "SearchWidget.h"
#include "ui_SearchWidget.h" #include "ui_SearchWidget.h"
#include "ui_HeaderWidget.h"
#include "SourceList.h" #include "SourceList.h"
#include "MetaPlaylistInterface.h"
#include "ViewManager.h" #include "ViewManager.h"
#include "audio/AudioEngine.h" #include "audio/AudioEngine.h"
#include "playlist/ContextView.h"
#include "playlist/PlayableModel.h" #include "playlist/PlayableModel.h"
#include "playlist/PlaylistModel.h" #include "playlist/PlaylistModel.h"
#include "utils/AnimatedSpinner.h" #include "utils/AnimatedSpinner.h"
@@ -33,91 +36,107 @@
#include <QPushButton> #include <QPushButton>
#include <QScrollArea> #include <QScrollArea>
using namespace Tomahawk;
SearchWidget::SearchWidget( const QString& search, QWidget* parent ) SearchWidget::SearchWidget( const QString& search, QWidget* parent )
: QWidget( parent ) : QWidget( parent )
, ui( new Ui::SearchWidget ) , ui( new Ui::SearchWidget )
, uiHeader( new Ui::HeaderWidget )
, m_search( search ) , m_search( search )
{ {
QWidget* widget = new QWidget; QWidget* widget = new QWidget;
QWidget* headerWidget = new QWidget;
ui->setupUi( widget ); ui->setupUi( widget );
uiHeader->setupUi( headerWidget );
ui->lineAbove->setStyleSheet( QString( "QFrame { border: 1px solid black; }" ) ); headerWidget->setFixedHeight( 160 );
ui->lineBelow->setStyleSheet( QString( "QFrame { border: 1px solid %1; }" ).arg( TomahawkStyle::HEADER_BACKGROUND.name() ) );
{ {
ui->resultsView->setGuid( "searchwidget" ); ui->artists->setAutoResize( true );
m_resultsModel = new PlaylistModel( ui->resultsView ); 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(); m_artistsModel = new PlayableModel( ui->artists );
p.setColor( QPalette::Text, TomahawkStyle::PAGE_TRACKLIST_TRACK_SOLVED ); ui->artists->setPlayableModel( m_artistsModel );
p.setColor( QPalette::BrightText, TomahawkStyle::PAGE_TRACKLIST_TRACK_UNRESOLVED ); ui->artists->proxyModel()->sort( -1 );
p.setColor( QPalette::Foreground, TomahawkStyle::PAGE_TRACKLIST_NUMBER ); ui->artists->setEmptyTip( tr( "Sorry, we could not find any artists!" ) );
p.setColor( QPalette::Highlight, TomahawkStyle::PAGE_TRACKLIST_HIGHLIGHT );
p.setColor( QPalette::HighlightedText, TomahawkStyle::PAGE_TRACKLIST_HIGHLIGHT_TEXT );
ui->resultsView->setPalette( p ); TomahawkStyle::stylePageFrame( ui->artists );
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->artistFrame ); TomahawkStyle::stylePageFrame( ui->artistFrame );
TomahawkStyle::styleScrollBar( ui->artists->verticalScrollBar() );
} }
{ {
QFont f = ui->label->font(); ui->albums->setAutoResize( true );
f.setFamily( "Pathway Gothic One" ); 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(); m_albumsModel = new PlayableModel( ui->albums );
p.setColor( QPalette::Foreground, TomahawkStyle::PAGE_CAPTION ); 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->albums->setStyleSheet( QString( "QListView { background-color: white; }" ) );
ui->label->setPalette( p ); TomahawkStyle::stylePageFrame( ui->albumFrame );
TomahawkStyle::styleScrollBar( ui->albums->verticalScrollBar() );
TomahawkStyle::styleScrollBar( ui->albums->horizontalScrollBar() );
} }
{ {
QFont f = ui->label_2->font(); ui->tracks->setAutoResize( true );
f.setFamily( "Pathway Gothic One" ); 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(); m_resultsModel = new PlayableModel( ui->tracks );
p.setColor( QPalette::Foreground, TomahawkStyle::HEADER_TEXT ); 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->tracks->setStyleSheet( QString( "QListView { background-color: white; }" ) );
ui->label_3->setFont( f ); TomahawkStyle::stylePageFrame( ui->trackFrame );
ui->label_2->setPalette( p );
ui->label_3->setPalette( p );
} }
{
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(); QScrollArea* area = new QScrollArea();
area->setWidgetResizable( true ); area->setWidgetResizable( true );
@@ -125,29 +144,112 @@ SearchWidget::SearchWidget( const QString& search, QWidget* parent )
area->setWidget( widget ); area->setWidget( widget );
QPalette pal = palette(); QPalette pal = palette();
pal.setBrush( backgroundRole(), TomahawkStyle::HEADER_BACKGROUND ); pal.setBrush( backgroundRole(), Qt::white );
area->setPalette( pal ); area->setPalette( pal );
area->setAutoFillBackground( true ); area->setAutoFillBackground( true );
area->setFrameShape( QFrame::NoFrame ); area->setFrameShape( QFrame::NoFrame );
area->setAttribute( Qt::WA_MacShowFocusRect, 0 ); 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(); QVBoxLayout* layout = new QVBoxLayout();
layout->addWidget( area ); layout->addWidget( headerWidget );
layout->addWidget( m_stackedWidget );
setLayout( layout ); setLayout( layout );
TomahawkUtils::unmarginLayout( layout ); TomahawkUtils::unmarginLayout( layout );
} }
{ MetaPlaylistInterface* mpl = new MetaPlaylistInterface();
QPalette pal = palette(); mpl->addChildInterface( ui->artists->playlistInterface() );
pal.setBrush( backgroundRole(), TomahawkStyle::PAGE_BACKGROUND ); mpl->addChildInterface( ui->tracks->playlistInterface() );
ui->resultsContainer->setPalette( pal ); mpl->addChildInterface( ui->albums->playlistInterface() );
ui->resultsContainer->setAutoFillBackground( true ); 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_artistsModel->startLoading();
m_albumsModel->startLoading(); m_albumsModel->startLoading();
m_resultsModel->startLoading(); m_resultsModel->startLoading();
m_queries << Tomahawk::Query::get( search, uuid() ); m_queries << Tomahawk::Query::get( search, uuid() );
uiHeader->artistLabel->setText( title().toUpper() );
foreach ( const Tomahawk::query_ptr& query, m_queries ) foreach ( const Tomahawk::query_ptr& query, m_queries )
{ {
@@ -186,14 +288,23 @@ SearchWidget::changeEvent( QEvent* e )
Tomahawk::playlistinterface_ptr Tomahawk::playlistinterface_ptr
SearchWidget::playlistInterface() const SearchWidget::playlistInterface() const
{ {
return ui->resultsView->playlistInterface(); return m_plInterface;
} }
bool bool
SearchWidget::jumpToCurrentTrack() 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; QList< Tomahawk::result_ptr > rl;
rl << result; rl << result;
Tomahawk::query_ptr q = result->toQuery(); Tomahawk::query_ptr query = result->toQuery();
q->addResults( rl ); 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(); artists << result->track()->artistPtr();
albums << result->track()->albumPtr(); 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 ); onArtistsFound( artists );
onAlbumsFound( albums ); onAlbumsFound( albums );
} }
@@ -235,6 +386,9 @@ SearchWidget::onAlbumsFound( const QList<Tomahawk::album_ptr>& albums )
foreach ( const Tomahawk::album_ptr& album, albums ) foreach ( const Tomahawk::album_ptr& album, albums )
{ {
if ( m_albums.contains( album ) )
continue;
int distance = TomahawkUtils::levenshtein( m_search, album->name() ); int distance = TomahawkUtils::levenshtein( m_search, album->name() );
int maxlen = qMax( m_search.length(), album->name().length() ); int maxlen = qMax( m_search.length(), album->name().length() );
float score = (float)( maxlen - distance ) / maxlen; float score = (float)( maxlen - distance ) / maxlen;
@@ -242,11 +396,11 @@ SearchWidget::onAlbumsFound( const QList<Tomahawk::album_ptr>& albums )
if ( score <= 0.1 ) if ( score <= 0.1 )
continue; continue;
m_albums.insert( score, album ); m_albums.insert( album, score );
// tDebug() << Q_FUNC_INFO << "found album:" << album->name() << "score:" << 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 ) foreach ( const Tomahawk::artist_ptr& artist, artists )
{ {
if ( m_artists.contains( artist ) )
continue;
int distance = TomahawkUtils::levenshtein( m_search, artist->name() ); int distance = TomahawkUtils::levenshtein( m_search, artist->name() );
int maxlen = qMax( m_search.length(), artist->name().length() ); int maxlen = qMax( m_search.length(), artist->name().length() );
float score = (float)( maxlen - distance ) / maxlen; float score = (float)( maxlen - distance ) / maxlen;
@@ -264,11 +421,11 @@ SearchWidget::onArtistsFound( const QList<Tomahawk::artist_ptr>& artists )
if ( score <= 0.1 ) if ( score <= 0.1 )
continue; continue;
m_artists.insert( score, artist ); m_artists.insert( artist, score );
// tDebug() << Q_FUNC_INFO << "found artist:" << artist->name() << "score:" << score; // tDebug() << Q_FUNC_INFO << "found artist:" << artist->name() << "score:" << score;
} }
updateArtists(); // updateArtists();
} }
@@ -280,6 +437,9 @@ SearchWidget::onQueryFinished()
m_artistsModel->finishLoading(); m_artistsModel->finishLoading();
m_albumsModel->finishLoading(); m_albumsModel->finishLoading();
m_resultsModel->finishLoading(); m_resultsModel->finishLoading();
updateArtists();
updateAlbums();
} }
@@ -289,12 +449,23 @@ SearchWidget::updateArtists()
tDebug() << Q_FUNC_INFO; tDebug() << Q_FUNC_INFO;
QList< Tomahawk::artist_ptr > sortedArtists; 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() ); 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(); m_artistsModel->clear();
@@ -308,12 +479,23 @@ SearchWidget::updateAlbums()
tDebug() << Q_FUNC_INFO; tDebug() << Q_FUNC_INFO;
QList< Tomahawk::album_ptr > sortedAlbums; 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() ); 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(); m_albumsModel->clear();
@@ -331,20 +513,48 @@ SearchWidget::pixmap() const
bool bool
SearchWidget::isBeingPlayed() const SearchWidget::isBeingPlayed() const
{ {
if ( ui->resultsView->playlistInterface() == AudioEngine::instance()->currentTrackPlaylist() ) if ( ui->albums && ui->albums->isBeingPlayed() )
return true;
if ( ui->resultsView->playlistInterface()->hasChildInterface( AudioEngine::instance()->currentTrackPlaylist() ) )
return true; return true;
if ( ui->albumView->playlistInterface() == AudioEngine::instance()->currentTrackPlaylist() ) if ( ui->artists && ui->artists->isBeingPlayed() )
return true;
if ( ui->albumView->playlistInterface()->hasChildInterface( AudioEngine::instance()->currentTrackPlaylist() ) )
return true; return true;
if ( ui->artistView->playlistInterface() == AudioEngine::instance()->currentTrackPlaylist() ) if ( ui->albums && ui->albums->playlistInterface() == AudioEngine::instance()->currentTrackPlaylist() )
return true; 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 true;
return false; 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 );
}

View File

@@ -1,6 +1,6 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> === /* === 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 2012 Leo Franchi <lfranchi@kde.org>
* Copyright 2010-2011, Jeff Mitchell <jeff@tomahawk-player.org> * Copyright 2010-2011, Jeff Mitchell <jeff@tomahawk-player.org>
* *
@@ -31,12 +31,14 @@
#include "DllMacro.h" #include "DllMacro.h"
class QPushButton; class QPushButton;
class QStackedWidget;
class PlayableModel; class PlayableModel;
class PlaylistModel; class PlaylistModel;
namespace Ui namespace Ui
{ {
class SearchWidget; class SearchWidget;
class HeaderWidget;
} }
class DLLEXPORT SearchWidget : public QWidget, public Tomahawk::ViewPage 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 QString description() const { return tr( "Results for '%1'" ).arg( m_search ); }
virtual QPixmap pixmap() const; virtual QPixmap pixmap() const;
virtual bool showInfoBar() const { return true; } virtual bool showInfoBar() const { return false; }
virtual bool isBeingPlayed() const; virtual bool isBeingPlayed() const;
virtual bool isTemporaryPage() const { return true; } virtual bool isTemporaryPage() const { return true; }
virtual bool jumpToCurrentTrack(); virtual bool jumpToCurrentTrack();
@@ -72,21 +74,30 @@ private slots:
void onQueryFinished(); void onQueryFinished();
void onArtistsMoreClicked();
void onAlbumsMoreClicked();
void onTopHitsMoreClicked();
void onTopHitsMoreClosed();
private: private:
void updateArtists(); void updateArtists();
void updateAlbums(); void updateAlbums();
Ui::SearchWidget *ui; Ui::SearchWidget *ui;
Ui::HeaderWidget* uiHeader;
QStackedWidget* m_stackedWidget;
QString m_search; QString m_search;
PlayableModel* m_artistsModel; PlayableModel* m_artistsModel;
PlayableModel* m_albumsModel; PlayableModel* m_albumsModel;
PlaylistModel* m_resultsModel; PlayableModel* m_resultsModel;
Tomahawk::playlistinterface_ptr m_plInterface;
QList< Tomahawk::query_ptr > m_queries; QList< Tomahawk::query_ptr > m_queries;
QMap< float, Tomahawk::artist_ptr > m_artists; QMap< Tomahawk::artist_ptr, float > m_artists;
QMap< float, Tomahawk::album_ptr > m_albums; QMap< Tomahawk::album_ptr, float > m_albums;
QMap< Tomahawk::query_ptr, float > m_results;
}; };
#endif // NEWPLAYLISTWIDGET_H #endif // NEWPLAYLISTWIDGET_H

View File

@@ -6,14 +6,14 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>939</width> <width>796</width>
<height>647</height> <height>1132</height>
</rect> </rect>
</property> </property>
<property name="focusPolicy"> <property name="windowTitle">
<enum>Qt::TabFocus</enum> <string>Form</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_7" stretch="0,0,1,0,0"> <layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
@@ -21,121 +21,56 @@
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QWidget" name="resultsContainer" native="true"> <widget class="QFrame" name="trackFrame">
<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"> <property name="frameShape">
<enum>QFrame::StyledPanel</enum> <enum>QFrame::StyledPanel</enum>
</property> </property>
<property name="frameShadow"> <property name="frameShadow">
<enum>QFrame::Raised</enum> <enum>QFrame::Raised</enum>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_6">
<property name="spacing"> <property name="spacing">
<number>4</number> <number>4</number>
</property> </property>
<property name="leftMargin"> <property name="margin">
<number>8</number> <number>32</number>
</property>
<property name="topMargin">
<number>4</number>
</property>
<property name="rightMargin">
<number>8</number>
</property>
<property name="bottomMargin">
<number>4</number>
</property> </property>
<item> <item>
<widget class="QLabel" name="label"> <widget class="CaptionLabel" name="label_2">
<property name="font">
<font>
<pointsize>20</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text"> <property name="text">
<string>Tracks</string> <string>Songs</string>
</property>
<property name="margin">
<number>0</number>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="PlaylistView" name="resultsView"/> <widget class="GridView" name="tracks">
</item> <property name="sizePolicy">
<item> <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<spacer name="verticalSpacer"> <horstretch>0</horstretch>
<property name="orientation"> <verstretch>0</verstretch>
<enum>Qt::Vertical</enum> </sizepolicy>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="minimumSize">
<size> <size>
<width>20</width> <width>0</width>
<height>0</height> <height>190</height>
</size> </size>
</property> </property>
</spacer> </widget>
</item> </item>
</layout> <item>
<widget class="ClickableLabel" name="topHitsMoreLabel">
<property name="text">
<string>Show More</string>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="Line" name="lineAbove">
<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="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>
<property name="topMargin">
<number>16</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>16</number>
</property>
<item> <item>
<widget class="QFrame" name="artistFrame"> <widget class="QFrame" name="artistFrame">
<property name="frameShape"> <property name="frameShape">
@@ -144,38 +79,40 @@
<property name="frameShadow"> <property name="frameShadow">
<enum>QFrame::Raised</enum> <enum>QFrame::Raised</enum>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_5">
<property name="spacing"> <property name="spacing">
<number>4</number> <number>4</number>
</property> </property>
<property name="leftMargin"> <property name="leftMargin">
<number>28</number> <number>32</number>
</property> </property>
<property name="topMargin"> <property name="topMargin">
<number>4</number> <number>4</number>
</property> </property>
<property name="rightMargin"> <property name="rightMargin">
<number>8</number> <number>32</number>
</property> </property>
<property name="bottomMargin"> <property name="bottomMargin">
<number>4</number> <number>32</number>
</property> </property>
<item> <item>
<widget class="QLabel" name="label_2"> <widget class="CaptionLabel" name="label_3">
<property name="font">
<font>
<pointsize>20</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text"> <property name="text">
<string>Artists</string> <string>Artists</string>
</property> </property>
<property name="margin">
<number>0</number>
</property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="GridView" name="artistView"> <widget class="GridView" name="artists">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
@@ -184,27 +121,16 @@
</property> </property>
</widget> </widget>
</item> </item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item> <item>
<widget class="QWidget" name="widget_3" native="true"> <widget class="ClickableLabel" name="artistsMoreLabel">
<layout class="QVBoxLayout" name="verticalLayout_5"> <property name="text">
<property name="leftMargin"> <string>Show More</string>
<number>0</number>
</property>
<property name="topMargin">
<number>16</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>16</number>
</property> </property>
</widget>
</item>
</layout>
</widget>
</item>
<item> <item>
<widget class="QFrame" name="albumFrame"> <widget class="QFrame" name="albumFrame">
<property name="frameShape"> <property name="frameShape">
@@ -213,38 +139,40 @@
<property name="frameShadow"> <property name="frameShadow">
<enum>QFrame::Raised</enum> <enum>QFrame::Raised</enum>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout_4">
<property name="spacing"> <property name="spacing">
<number>4</number> <number>4</number>
</property> </property>
<property name="leftMargin"> <property name="leftMargin">
<number>28</number> <number>32</number>
</property> </property>
<property name="topMargin"> <property name="topMargin">
<number>4</number> <number>4</number>
</property> </property>
<property name="rightMargin"> <property name="rightMargin">
<number>8</number> <number>32</number>
</property> </property>
<property name="bottomMargin"> <property name="bottomMargin">
<number>4</number> <number>32</number>
</property> </property>
<item> <item>
<widget class="QLabel" name="label_3"> <widget class="CaptionLabel" name="albumLabel">
<property name="font">
<font>
<pointsize>20</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text"> <property name="text">
<string>Albums</string> <string>Albums</string>
</property> </property>
<property name="margin">
<number>0</number>
</property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="GridView" name="albumView"> <widget class="GridView" name="albums">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
@@ -253,7 +181,11 @@
</property> </property>
</widget> </widget>
</item> </item>
</layout> <item>
<widget class="ClickableLabel" name="albumsMoreLabel">
<property name="text">
<string>Show More</string>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>
@@ -262,15 +194,20 @@
</layout> </layout>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget>
<class>PlaylistView</class>
<extends>QTreeView</extends>
<header location="global">playlist/PlaylistView.h</header>
</customwidget>
<customwidget> <customwidget>
<class>GridView</class> <class>GridView</class>
<extends>QListView</extends> <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> </customwidget>
</customwidgets> </customwidgets>
<resources/> <resources/>