1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-19 07:19:42 +01:00

* Support Footnotes in TreeViews.

This commit is contained in:
Christian Muehlhaeuser 2011-11-28 06:32:10 +01:00
parent 0a46febf36
commit 3ed443456a
12 changed files with 208 additions and 27 deletions

View File

@ -52,7 +52,9 @@ public:
virtual bool jumpToCurrentTrack() = 0;
public slots:
virtual void setQuery( const Tomahawk::query_ptr& query ) = 0;
virtual void setArtist( const Tomahawk::artist_ptr& artist ) { Q_UNUSED( artist ); }
virtual void setAlbum( const Tomahawk::album_ptr& album ) { Q_UNUSED( album ); }
virtual void setQuery( const Tomahawk::query_ptr& query ) { Q_UNUSED( query ); }
signals:
void nameChanged( const QString& );

View File

@ -94,6 +94,7 @@ ContextWidget::ContextWidget( QWidget* parent )
setAutoFillBackground( true );
setFixedHeight( m_minHeight );
ensurePolished();
QPalette pal = palette();
pal.setBrush( QPalette::Window, StyleHelper::headerLowerColor() );
setPalette( pal );
@ -229,6 +230,44 @@ ContextWidget::fadeOut( bool animate )
}
void
ContextWidget::setArtist( const Tomahawk::artist_ptr& artist )
{
if ( artist.isNull() )
return;
m_artist = artist;
if ( height() > m_minHeight )
{
foreach ( ContextProxyPage* proxy, m_pages )
{
proxy->page()->setArtist( artist );
}
layoutViews( true );
}
}
void
ContextWidget::setAlbum( const Tomahawk::album_ptr& album )
{
if ( album.isNull() )
return;
m_album = album;
if ( height() > m_minHeight )
{
foreach ( ContextProxyPage* proxy, m_pages )
{
proxy->page()->setAlbum( album );
}
layoutViews( true );
}
}
void
ContextWidget::setQuery( const Tomahawk::query_ptr& query, bool force )
{
@ -292,6 +331,8 @@ ContextWidget::onAnimationFinished()
fadeOut( false );
m_scene->setSceneRect( ui->contextView->viewport()->rect() );
layoutViews( false );
setArtist( m_artist );
setAlbum( m_album );
setQuery( m_query, true );
ui->toggleButton->setText( tr( "Hide Footnotes" ) );

View File

@ -50,6 +50,8 @@ public:
~ContextWidget();
public slots:
void setArtist( const Tomahawk::artist_ptr& artist );
void setAlbum( const Tomahawk::album_ptr& album );
void setQuery( const Tomahawk::query_ptr& query, bool force = false );
void toggleSize();
@ -82,6 +84,8 @@ private:
int m_currentView;
Tomahawk::artist_ptr m_artist;
Tomahawk::album_ptr m_album;
Tomahawk::query_ptr m_query;
bool m_visible;
};

View File

@ -32,6 +32,7 @@ RelatedArtistsContext::RelatedArtistsContext()
{
m_relatedView = new ArtistView();
m_relatedView->setGuid( "RelatedArtistsContext" );
m_relatedView->setUpdatesContextView( false );
m_relatedModel = new TreeModel( m_relatedView );
m_relatedModel->setColumnStyle( TreeModel::TrackOnly );
m_relatedView->setTreeModel( m_relatedModel );
@ -58,15 +59,17 @@ RelatedArtistsContext::~RelatedArtistsContext()
void
RelatedArtistsContext::setQuery( const Tomahawk::query_ptr& query )
RelatedArtistsContext::setArtist( const Tomahawk::artist_ptr& artist )
{
if ( !m_query.isNull() && query->artist() == m_query->artist() )
if ( artist.isNull() )
return;
if ( !m_artist.isNull() && m_artist->name() == artist->name() )
return;
m_query = query;
m_artist = artist;
Tomahawk::InfoSystem::InfoStringHash artistInfo;
artistInfo["artist"] = query->artist();
artistInfo["artist"] = artist->name();
Tomahawk::InfoSystem::InfoRequestData requestData;
requestData.caller = m_infoId;
@ -78,6 +81,26 @@ RelatedArtistsContext::setQuery( const Tomahawk::query_ptr& query )
}
void
RelatedArtistsContext::setQuery( const Tomahawk::query_ptr& query )
{
if ( query.isNull() )
return;
setArtist( Artist::get( query->artist(), false ) );
}
void
RelatedArtistsContext::setAlbum( const Tomahawk::album_ptr& album )
{
if ( album.isNull() )
return;
setArtist( album->artist() );
}
void
RelatedArtistsContext::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output )
{
@ -89,9 +112,9 @@ RelatedArtistsContext::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData req
if ( output.canConvert< QVariantMap >() )
{
if ( trackInfo["artist"] != m_query->artist() )
if ( trackInfo["artist"] != m_artist->name() )
{
qDebug() << "Returned info was for:" << trackInfo["artist"] << "- was looking for:" << m_query->artist();
qDebug() << "Returned info was for:" << trackInfo["artist"] << "- was looking for:" << m_artist->name();
return;
}
}

View File

@ -23,6 +23,8 @@
#include "dllmacro.h"
#include "artist.h"
#include "album.h"
#include "query.h"
#include "context/ContextPage.h"
#include "infosystem/infosystem.h"
@ -48,6 +50,8 @@ public:
virtual bool jumpToCurrentTrack() { return false; }
public slots:
virtual void setArtist( const Tomahawk::artist_ptr& artist );
virtual void setAlbum( const Tomahawk::album_ptr& album );
virtual void setQuery( const Tomahawk::query_ptr& query );
private slots:
@ -61,7 +65,7 @@ private:
QGraphicsProxyWidget* m_proxy;
QString m_infoId;
Tomahawk::query_ptr m_query;
Tomahawk::artist_ptr m_artist;
};
#endif // RELATEDARTISTSCONTEXT_H

View File

@ -58,15 +58,17 @@ TopTracksContext::~TopTracksContext()
void
TopTracksContext::setQuery( const Tomahawk::query_ptr& query )
TopTracksContext::setArtist( const Tomahawk::artist_ptr& artist )
{
if ( !m_query.isNull() && query->artist() == m_query->artist() )
if ( artist.isNull() )
return;
if ( !m_artist.isNull() && m_artist->name() == artist->name() )
return;
m_query = query;
m_artist = artist;
Tomahawk::InfoSystem::InfoStringHash artistInfo;
artistInfo["artist"] = query->artist();
artistInfo["artist"] = artist->name();
Tomahawk::InfoSystem::InfoRequestData requestData;
requestData.caller = m_infoId;
@ -78,6 +80,26 @@ TopTracksContext::setQuery( const Tomahawk::query_ptr& query )
}
void
TopTracksContext::setAlbum( const Tomahawk::album_ptr& album )
{
if ( album.isNull() )
return;
setArtist( album->artist() );
}
void
TopTracksContext::setQuery( const Tomahawk::query_ptr& query )
{
if ( query.isNull() )
return;
setArtist( Artist::get( query->artist(), false ) );
}
void
TopTracksContext::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output )
{
@ -89,9 +111,9 @@ TopTracksContext::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestD
if ( output.canConvert< QVariantMap >() )
{
if ( trackInfo["artist"] != m_query->artist() )
if ( trackInfo["artist"] != m_artist->name() )
{
qDebug() << "Returned info was for:" << trackInfo["artist"] << "- was looking for:" << m_query->artist();
qDebug() << "Returned info was for:" << trackInfo["artist"] << "- was looking for:" << m_artist->name();
return;
}
}
@ -107,7 +129,7 @@ TopTracksContext::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestD
int i = 0;
foreach ( const QString& track, tracks )
{
query_ptr query = Query::get( m_query->artist(), track, QString(), uuid() );
query_ptr query = Query::get( m_artist->name(), track, QString(), uuid() );
m_topHitsModel->append( query );
if ( ++i == 15 )

View File

@ -23,6 +23,8 @@
#include "dllmacro.h"
#include "artist.h"
#include "album.h"
#include "query.h"
#include "context/ContextPage.h"
#include "infosystem/infosystem.h"
@ -48,6 +50,8 @@ public:
virtual bool jumpToCurrentTrack() { return false; }
public slots:
virtual void setArtist( const Tomahawk::artist_ptr& artist );
virtual void setAlbum( const Tomahawk::album_ptr& album );
virtual void setQuery( const Tomahawk::query_ptr& query );
private slots:
@ -61,7 +65,7 @@ private:
QGraphicsProxyWidget* m_proxy;
QString m_infoId;
Tomahawk::query_ptr m_query;
Tomahawk::artist_ptr m_artist;
};
#endif // TOPTRACKSCONTEXT_H

View File

@ -22,22 +22,68 @@ using namespace Tomahawk;
void
WikipediaContext::setQuery( const Tomahawk::query_ptr& query )
WikipediaContext::setArtist( const Tomahawk::artist_ptr& artist )
{
if ( !m_query.isNull() && query->artist() == m_query->artist() )
if ( artist.isNull() )
return;
if ( !m_artist.isNull() && m_artist->name() == artist->name() )
return;
m_query = query;
webView()->load( QString( "http://en.wikipedia.org/w/index.php?useformat=mobile&title=%1" ).arg( query->artist() ) );
m_artist = artist;
webView()->load( QString( "http://en.wikipedia.org/w/index.php?useformat=mobile&title=%1" ).arg( m_artist->name() ) );
}
void
WikipediaContext::setAlbum( const Tomahawk::album_ptr& album )
{
if ( album.isNull() )
return;
setArtist( album->artist() );
}
void
WikipediaContext::setQuery( const Tomahawk::query_ptr& query )
{
if ( query.isNull() )
return;
setArtist( Artist::get( query->artist(), false ) );
}
void
LastfmContext::setArtist( const Tomahawk::artist_ptr& artist )
{
if ( artist.isNull() )
return;
if ( !m_artist.isNull() && m_artist->name() == artist->name() )
return;
m_artist = artist;
webView()->load( QString( "http://last.fm/music/%1" ).arg( m_artist->name() ) );
}
void
LastfmContext::setAlbum( const Tomahawk::album_ptr& album )
{
if ( album.isNull() )
return;
setArtist( album->artist() );
}
void
LastfmContext::setQuery( const Tomahawk::query_ptr& query )
{
if ( !m_query.isNull() && query->artist() == m_query->artist() )
if ( query.isNull() )
return;
m_query = query;
webView()->load( QString( "http://last.fm/music/%1" ).arg( query->artist() ) );
setArtist( Artist::get( query->artist(), false ) );
}

View File

@ -23,6 +23,8 @@
#include "dllmacro.h"
#include "artist.h"
#include "album.h"
#include "query.h"
#include "WebContext.h"
@ -42,10 +44,12 @@ public:
virtual bool jumpToCurrentTrack() { return false; }
public slots:
virtual void setArtist( const Tomahawk::artist_ptr& artist );
virtual void setAlbum( const Tomahawk::album_ptr& album );
virtual void setQuery( const Tomahawk::query_ptr& query );
private:
Tomahawk::query_ptr m_query;
Tomahawk::artist_ptr m_artist;
};
@ -65,10 +69,12 @@ public:
virtual bool jumpToCurrentTrack() { return false; }
public slots:
virtual void setArtist( const Tomahawk::artist_ptr& artist );
virtual void setAlbum( const Tomahawk::album_ptr& album );
virtual void setQuery( const Tomahawk::query_ptr& query );
private:
Tomahawk::query_ptr m_query;
Tomahawk::artist_ptr m_artist;
};
#endif // WIKIPEDIACONTEXT_H

View File

@ -24,6 +24,7 @@
#include <QScrollBar>
#include "audio/audioengine.h"
#include "context/ContextWidget.h"
#include "dynamic/widgets/LoadingSpinner.h"
#include "widgets/overlaywidget.h"
@ -47,6 +48,7 @@ ArtistView::ArtistView( QWidget* parent )
, m_proxyModel( 0 )
// , m_delegate( 0 )
, m_loadingSpinner( new LoadingSpinner( this ) )
, m_updateContextView( true )
, m_contextMenu( new ContextMenu( this ) )
, m_showModes( true )
{
@ -150,6 +152,27 @@ ArtistView::setTreeModel( TreeModel* model )
}
void
ArtistView::currentChanged( const QModelIndex& current, const QModelIndex& /* previous */ )
{
if ( !m_updateContextView )
return;
TreeModelItem* item = m_model->itemFromIndex( m_proxyModel->mapToSource( current ) );
if ( item )
{
if ( !item->result().isNull() )
ViewManager::instance()->context()->setQuery( item->result()->toQuery() );
else if ( !item->artist().isNull() )
ViewManager::instance()->context()->setArtist( item->artist() );
else if ( !item->album().isNull() )
ViewManager::instance()->context()->setAlbum( item->album() );
else if ( !item->query().isNull() )
ViewManager::instance()->context()->setQuery( item->query() );
}
}
void
ArtistView::onItemActivated( const QModelIndex& index )
{

View File

@ -70,6 +70,9 @@ public:
virtual bool jumpToCurrentTrack();
bool updatesContextView() const { return m_updateContextView; }
void setUpdatesContextView( bool b ) { m_updateContextView = b; }
public slots:
void onItemActivated( const QModelIndex& index );
@ -80,6 +83,9 @@ protected:
void paintEvent( QPaintEvent* event );
void keyPressEvent( QKeyEvent* event );
protected slots:
virtual void currentChanged( const QModelIndex& current, const QModelIndex& previous );
private slots:
void onItemCountChanged( unsigned int items );
void onFilterChanged( const QString& filter );
@ -98,6 +104,8 @@ private:
// PlaylistItemDelegate* m_delegate;
LoadingSpinner* m_loadingSpinner;
bool m_updateContextView;
QModelIndex m_contextMenuIndex;
Tomahawk::ContextMenu* m_contextMenu;

View File

@ -90,8 +90,6 @@ TrackView::TrackView( QWidget* parent )
TrackView::~TrackView()
{
tDebug() << Q_FUNC_INFO;
delete m_header;
}