From bfff7b2878bc202989af367f59bd82df1c49043c Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Sat, 23 Aug 2014 12:16:39 +0200 Subject: [PATCH] * Remove now unused context-widget sources. --- src/libtomahawk/context/ContextPage.cpp | 111 ------ src/libtomahawk/context/ContextPage.h | 94 ----- src/libtomahawk/context/ContextWidget.cpp | 370 ------------------ src/libtomahawk/context/ContextWidget.h | 93 ----- src/libtomahawk/context/ContextWidget.ui | 76 ---- .../context/pages/RelatedArtistsContext.cpp | 107 ----- .../context/pages/RelatedArtistsContext.h | 69 ---- .../context/pages/TopTracksContext.cpp | 106 ----- .../context/pages/TopTracksContext.h | 69 ---- src/libtomahawk/context/pages/WebContext.cpp | 38 -- src/libtomahawk/context/pages/WebContext.h | 45 --- .../context/pages/WikipediaContext.cpp | 98 ----- .../context/pages/WikipediaContext.h | 81 ---- 13 files changed, 1357 deletions(-) delete mode 100644 src/libtomahawk/context/ContextPage.cpp delete mode 100644 src/libtomahawk/context/ContextPage.h delete mode 100644 src/libtomahawk/context/ContextWidget.cpp delete mode 100644 src/libtomahawk/context/ContextWidget.h delete mode 100644 src/libtomahawk/context/ContextWidget.ui delete mode 100644 src/libtomahawk/context/pages/RelatedArtistsContext.cpp delete mode 100644 src/libtomahawk/context/pages/RelatedArtistsContext.h delete mode 100644 src/libtomahawk/context/pages/TopTracksContext.cpp delete mode 100644 src/libtomahawk/context/pages/TopTracksContext.h delete mode 100644 src/libtomahawk/context/pages/WebContext.cpp delete mode 100644 src/libtomahawk/context/pages/WebContext.h delete mode 100644 src/libtomahawk/context/pages/WikipediaContext.cpp delete mode 100644 src/libtomahawk/context/pages/WikipediaContext.h diff --git a/src/libtomahawk/context/ContextPage.cpp b/src/libtomahawk/context/ContextPage.cpp deleted file mode 100644 index 45106f5dc..000000000 --- a/src/libtomahawk/context/ContextPage.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* === This file is part of Tomahawk Player - === - * - * Copyright 2010-2011, Christian Muehlhaeuser - * - * Tomahawk is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Tomahawk is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Tomahawk. If not, see . - */ - -#include "ContextPage.h" - -#include - -#include "PlaylistInterface.h" -#include "utils/TomahawkStyle.h" -#include "utils/TomahawkUtilsGui.h" - -// Forward Declarations breaking QSharedPointer -#if QT_VERSION < QT_VERSION_CHECK( 5, 0, 0 ) - #include "collection/Collection.h" - #include "Source.h" -#endif - - -using namespace Tomahawk; - - -void -ContextProxyPage::paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget ) -{ - painter->save(); - - painter->setRenderHint( QPainter::Antialiasing, true ); - painter->setPen( TomahawkStyle::HEADER_HIGHLIGHT ); - painter->setBrush( TomahawkStyle::HEADER_HIGHLIGHT ); - painter->drawRoundedRect( option->rect, 4.0, 4.0 ); - - QFont f( font() ); - f.setBold( true ); - f.setPointSize( TomahawkUtils::defaultFontSize() - 1 ); - painter->setFont( f ); - painter->setPen( Qt::white ); - - QFontMetrics fm( f ); - QRect r( 1, 1, option->rect.width(), fm.height() * 1.1 ); - QTextOption to( Qt::AlignCenter ); - painter->drawText( r, m_page->title(), to ); - - painter->restore(); - - QGraphicsWidget::paint( painter, option, widget ); -} - - -void -ContextProxyPage::setPage( Tomahawk::ContextPage* page ) -{ - m_page = page; - -#ifdef Q_WS_X11 //FIXME: why do we need this? maybe it's only oxygen style misbehaving? - QGraphicsWebView* testWebView = qobject_cast( page->widget() ); - if ( testWebView ) - { - setContentsMargins( 4, 4, 4, 4 ); - } -#endif - - QFont f( font() ); - f.setBold( true ); - f.setPointSize( TomahawkUtils::defaultFontSize() - 1 ); - QFontMetrics fm( f ); - QGraphicsLinearLayout* layout = new QGraphicsLinearLayout(); - layout->setContentsMargins( 4, fm.height() * 1.1, 4, 4 ); - layout->addItem( page->widget() ); - setLayout( layout ); - - page->widget()->installEventFilter( this ); -} - - -bool -ContextProxyPage::eventFilter( QObject* watched, QEvent* event ) -{ - if ( event->type() == QEvent::GrabMouse ) - { - emit focused(); - } - - return QGraphicsWidget::eventFilter( watched, event ); -} - - -bool -ContextProxyPage::sceneEvent( QEvent* event ) -{ - if ( event->type() == QEvent::GrabMouse ) - { - emit focused(); - } - - return QGraphicsWidget::sceneEvent( event ); -} diff --git a/src/libtomahawk/context/ContextPage.h b/src/libtomahawk/context/ContextPage.h deleted file mode 100644 index 2af3fb8b0..000000000 --- a/src/libtomahawk/context/ContextPage.h +++ /dev/null @@ -1,94 +0,0 @@ -/* === This file is part of Tomahawk Player - === - * - * Copyright 2010-2011, Christian Muehlhaeuser - * Copyright 2010-2011, Jeff Mitchell - * - * Tomahawk is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Tomahawk is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Tomahawk. If not, see . - */ - -#ifndef CONTEXTPAGE_H -#define CONTEXTPAGE_H - -#include -#include -#include - -#include "Typedefs.h" -#include "utils/TomahawkUtils.h" - -#include "DllMacro.h" -#include - -class PlaylistInterface; - -namespace Tomahawk -{ - -class DLLEXPORT ContextPage : public QObject -{ - Q_OBJECT - -public: - ContextPage() {} - virtual ~ContextPage() {} - - virtual QGraphicsWidget* widget() = 0; - virtual Tomahawk::playlistinterface_ptr playlistInterface() const = 0; - - virtual QString title() const = 0; - virtual QString description() const = 0; - virtual QPixmap pixmap() const { return QPixmap( RESPATH "icons/tomahawk-icon-128x128.png" ); } - - virtual bool jumpToCurrentTrack() = 0; - -public slots: - 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& ); - void descriptionChanged( const QString& ); - void pixmapChanged( const QPixmap& ); - void destroyed( QWidget* widget ); -}; - - -class DLLEXPORT ContextProxyPage : public QGraphicsWidget -{ - Q_OBJECT - -public: - ContextProxyPage() : QGraphicsWidget() - {} - - Tomahawk::ContextPage* page() const { return m_page; } - void setPage( Tomahawk::ContextPage* page ); - - virtual bool eventFilter( QObject* watched, QEvent* event ); - -signals: - void focused(); - -protected: - virtual void paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget ); - virtual bool sceneEvent( QEvent* event ); - -private: - Tomahawk::ContextPage* m_page; -}; - -}; // ns - -#endif //CONTEXTPAGE_H diff --git a/src/libtomahawk/context/ContextWidget.cpp b/src/libtomahawk/context/ContextWidget.cpp deleted file mode 100644 index f96185a13..000000000 --- a/src/libtomahawk/context/ContextWidget.cpp +++ /dev/null @@ -1,370 +0,0 @@ -/* === This file is part of Tomahawk Player - === - * - * Copyright 2010-2011, Christian Muehlhaeuser - * - * Tomahawk is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Tomahawk is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Tomahawk. If not, see . - */ - -#include "ContextWidget.h" -#include "ui_ContextWidget.h" - -#include -#include -#include -#include - -#include "context/ContextPage.h" -#include "context/pages/RelatedArtistsContext.h" -#include "context/pages/TopTracksContext.h" -#include "context/pages/WikipediaContext.h" -#include "utils/TomahawkStyle.h" -#include "utils/TomahawkUtilsGui.h" - -// Forward Declarations breaking QSharedPointer -#if QT_VERSION < QT_VERSION_CHECK( 5, 0, 0 ) - #include "PlaylistInterface.h" -#endif - - -#include "Source.h" -#include "Track.h" - - -#define ANIMATION_TIME 450 -#define SLIDE_TIME 350 - -using namespace Tomahawk; - - -ContextWidget::ContextWidget( QWidget* parent ) - : QWidget( parent ) - , ui( new Ui::ContextWidget ) - , m_currentView( 0 ) - , m_visible( false ) -{ - ui->setupUi( this ); - TomahawkUtils::unmarginLayout( layout() ); - setContentsMargins( 0, 0, 0, 0 ); - - m_scene = new QGraphicsScene( this ); - - TopTracksContext* ttc = new TopTracksContext(); - RelatedArtistsContext* rac = new RelatedArtistsContext(); - WebContext* wiki = new WikipediaContext(); - /*WebContext* lastfm = new LastfmContext();*/ - - m_views << ttc; - m_views << rac; - m_views << wiki; -/* m_views << lastfm;*/ - - foreach ( ContextPage* view, m_views ) - { - ContextProxyPage* page = new ContextProxyPage(); - page->setPage( view ); - m_scene->addItem( page ); - - connect( page, SIGNAL( focused() ), SLOT( onPageFocused() ) ); - m_pages << page; - } - - ui->contextView->setScene( m_scene ); - ui->contextView->setFrameShape( QFrame::NoFrame ); - ui->contextView->setStyleSheet( "QGraphicsView { background: transparent; }" ); - ui->contextView->setAttribute( Qt::WA_MacShowFocusRect, 0 ); - ui->contextView->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); - - ui->contextView->hide(); - - QPalette whitePal = ui->toggleButton->palette(); - whitePal.setColor( QPalette::Foreground, Qt::white ); - ui->toggleButton->setPalette( whitePal ); - ui->toggleButton->setCursor( Qt::PointingHandCursor ); - - m_minHeight = TomahawkUtils::defaultFontHeight() * 1.4; - ui->toggleButton->setMinimumHeight( m_minHeight ); - - setAutoFillBackground( true ); - setFixedHeight( m_minHeight ); - - ensurePolished(); - QPalette pal = palette(); - pal.setBrush( QPalette::Window, TomahawkStyle::FOOTNOTES_BACKGROUND ); - setPalette( pal ); - - connect( ui->toggleButton, SIGNAL( clicked() ), SLOT( toggleSize() ) ); - - m_timeLine = new QTimeLine( ANIMATION_TIME, this ); - m_timeLine->setUpdateInterval( 20 ); - m_timeLine->setEasingCurve( QEasingCurve::OutCubic ); - - connect( m_timeLine, SIGNAL( frameChanged( int ) ), SLOT( onAnimationStep( int ) ) ); - connect( m_timeLine, SIGNAL( finished() ), SLOT( onAnimationFinished() ) ); -} - - -ContextWidget::~ContextWidget() -{ -} - - -void -ContextWidget::changeEvent( QEvent* e ) -{ - QWidget::changeEvent( e ); - switch ( e->type() ) - { - case QEvent::LanguageChange: - ui->retranslateUi( this ); - break; - - default: - break; - } -} - - -void -ContextWidget::layoutViews( bool animate ) -{ - int smallViewWidth = 120; - float smallViewOpacity = 0.6; - - int margin = 6; - int maxVisible = 2; - int itemSize = ( m_scene->sceneRect().width() - smallViewWidth * 2 ) / maxVisible; - int firstPos = margin; - float opacity; - - if ( m_currentView > 0 ) - firstPos = smallViewWidth; - - if ( m_currentView + maxVisible >= m_pages.count() ) - { - int delta = m_pages.count() - m_currentView; - firstPos = m_scene->sceneRect().width() - ( delta * itemSize ) + 1; - } - - for ( int i = 0; i < m_pages.count(); i++ ) - { - QGraphicsWidget* view = m_pages.at( i ); - - int x = firstPos - ( ( m_currentView - i ) * itemSize ); - - if ( ( x < smallViewWidth && x < firstPos ) || i > m_currentView + maxVisible - 1 ) - { - opacity = smallViewOpacity; - } - else - { - opacity = 1.0; - } - - { - QPropertyAnimation* animation = new QPropertyAnimation( view, "opacity" ); - animation->setDuration( SLIDE_TIME ); - animation->setEndValue( opacity ); - animation->start(); - } - - QRect rect( x, margin, itemSize - margin * 2, m_scene->sceneRect().height() - margin * 2 ); - if ( animate ) - { - { - QPropertyAnimation* animation = new QPropertyAnimation( view, "geometry" ); - animation->setDuration( SLIDE_TIME ); - animation->setEndValue( rect ); - animation->start(); - } - } - else - { - view->setGeometry( rect ); - } - } -} - - -void -ContextWidget::onPageFocused() -{ - ContextProxyPage* widget = qobject_cast< ContextProxyPage* >( sender() ); - - int i = 0; - foreach ( ContextProxyPage* view, m_pages ) - { - if ( view == widget ) - { - m_currentView = i; - layoutViews( true ); - return; - } - - i++; - } -} - - -void -ContextWidget::fadeOut( bool animate ) -{ - foreach ( QGraphicsWidget* view, m_pages ) - { - if ( animate ) - { - QPropertyAnimation* animation = new QPropertyAnimation( view, "opacity" ); - animation->setDuration( SLIDE_TIME ); - animation->setEndValue( 0.0 ); - animation->start(); - } - else - view->setOpacity( 0.0 ); - } -} - - -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 ) -{ - if ( query.isNull() ) - return; - if ( !force && !m_query.isNull() && query->track()->artist() == m_query->track()->artist() ) - return; - - m_query = query; - if ( height() > m_minHeight ) - { - foreach ( ContextProxyPage* proxy, m_pages ) - { - proxy->page()->setQuery( query ); - } - - layoutViews( true ); - } -} - - -void -ContextWidget::toggleSize() -{ - m_maxHeight = TomahawkUtils::tomahawkWindow()->height() * 0.3; - - if ( height() == m_minHeight ) - { - m_timeLine->setFrameRange( height(), m_maxHeight ); - m_timeLine->setDirection( QTimeLine::Forward ); - m_timeLine->start(); - } - else - { - m_visible = false; - ui->contextView->hide(); - - m_timeLine->setFrameRange( m_minHeight, height() ); - m_timeLine->setDirection( QTimeLine::Backward ); - m_timeLine->start(); - } -} - - -void -ContextWidget::onAnimationStep( int frame ) -{ - setFixedHeight( frame ); -} - - -void -ContextWidget::onAnimationFinished() -{ - if ( m_timeLine->direction() == QTimeLine::Forward ) - { - setFixedHeight( m_maxHeight ); - m_visible = true; - ui->contextView->show(); - - 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" ) ); - } - else - { - setFixedHeight( m_minHeight ); - - ui->toggleButton->setText( tr( "Show Footnotes" ) ); - } -} - - -void -ContextWidget::paintEvent( QPaintEvent* e ) -{ - QWidget::paintEvent( e ); -} - - -void -ContextWidget::resizeEvent( QResizeEvent* e ) -{ - QWidget::resizeEvent( e ); - - if ( m_visible ) - { - m_scene->setSceneRect( ui->contextView->viewport()->rect() ); - layoutViews( false ); - } -} diff --git a/src/libtomahawk/context/ContextWidget.h b/src/libtomahawk/context/ContextWidget.h deleted file mode 100644 index 617bba5ec..000000000 --- a/src/libtomahawk/context/ContextWidget.h +++ /dev/null @@ -1,93 +0,0 @@ -/* === This file is part of Tomahawk Player - === - * - * Copyright 2010-2011, Christian Muehlhaeuser - * - * Tomahawk is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Tomahawk is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Tomahawk. If not, see . - */ - -#ifndef CONTEXTWIDGET_H -#define CONTEXTWIDGET_H - -#include - -#include "DllMacro.h" - -#include "Query.h" - -class QGraphicsScene; -class QGraphicsWebView; -class QGraphicsWidget; -class QTimeLine; - -namespace Tomahawk -{ - class ContextPage; - class ContextProxyPage; -} - -namespace Ui -{ - class ContextWidget; -} - -class DLLEXPORT ContextWidget : public QWidget -{ -Q_OBJECT - -public: - ContextWidget( QWidget* parent = 0 ); - ~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(); - -private slots: - void onPageFocused(); - - void onAnimationStep( int frame ); - void onAnimationFinished(); - -protected: - void paintEvent( QPaintEvent* e ); - void resizeEvent( QResizeEvent* e ); - void changeEvent( QEvent* e ); - -private: - void fadeOut( bool animate ); - - void layoutViews( bool animate = true ); - - Ui::ContextWidget* ui; - - int m_minHeight; - int m_maxHeight; - QTimeLine* m_timeLine; - - QGraphicsScene* m_scene; - QList m_views; - QList m_pages; - - int m_currentView; - - Tomahawk::artist_ptr m_artist; - Tomahawk::album_ptr m_album; - Tomahawk::query_ptr m_query; - bool m_visible; -}; - -#endif // CONTEXTWIDGET_H diff --git a/src/libtomahawk/context/ContextWidget.ui b/src/libtomahawk/context/ContextWidget.ui deleted file mode 100644 index f47b6a15f..000000000 --- a/src/libtomahawk/context/ContextWidget.ui +++ /dev/null @@ -1,76 +0,0 @@ - - - ContextWidget - - - - 0 - 0 - 774 - 173 - - - - - 0 - 0 - - - - - 0 - 72 - - - - InfoBar - - - - - - - 0 - 0 - - - - Show Footnotes - - - Qt::AlignCenter - - - - - - - - - Qt::Vertical - - - - 1 - 16 - - - - - - - - - - - - - - HeaderLabel - QLabel -
widgets/HeaderLabel.h
-
-
- - -
diff --git a/src/libtomahawk/context/pages/RelatedArtistsContext.cpp b/src/libtomahawk/context/pages/RelatedArtistsContext.cpp deleted file mode 100644 index 40cc0ea0d..000000000 --- a/src/libtomahawk/context/pages/RelatedArtistsContext.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* === This file is part of Tomahawk Player - === - * - * Copyright 2010-2011, Christian Muehlhaeuser - * Copyright 2010-2011, Jeff Mitchell - * - * Tomahawk is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Tomahawk is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Tomahawk. If not, see . - */ - -#include "RelatedArtistsContext.h" - -#include - -#include "playlist/TreeView.h" -#include "playlist/TreeModel.h" -#include "Source.h" - -using namespace Tomahawk; - - -RelatedArtistsContext::RelatedArtistsContext() - : ContextPage() -{ - m_relatedView = new TreeView(); - m_relatedView->setGuid( "RelatedArtistsContext" ); - m_relatedView->setUpdatesContextView( false ); - m_relatedModel = new TreeModel( m_relatedView ); - m_relatedView->proxyModel()->setStyle( PlayableProxyModel::Large ); - m_relatedView->setTreeModel( m_relatedModel ); - m_relatedView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); - m_relatedView->setSortingEnabled( false ); - m_relatedView->proxyModel()->sort( -1 ); - - QPalette pal = m_relatedView->palette(); - pal.setColor( QPalette::Window, QColor( 0, 0, 0, 0 ) ); - m_relatedView->setPalette( pal ); - - m_proxy = new QGraphicsProxyWidget(); - m_proxy->setWidget( m_relatedView ); -} - - -RelatedArtistsContext::~RelatedArtistsContext() -{ -} - - -void -RelatedArtistsContext::setArtist( const Tomahawk::artist_ptr& artist ) -{ - if ( artist.isNull() ) - return; - if ( !m_artist.isNull() && m_artist->name() == artist->name() ) - return; - - if ( !m_artist.isNull() ) - { - disconnect( m_artist.data(), SIGNAL( similarArtistsLoaded() ), this, SLOT( onSimilarArtistsLoaded() ) ); - } - - m_artist = artist; - - connect( m_artist.data(), SIGNAL( similarArtistsLoaded() ), SLOT( onSimilarArtistsLoaded() ) ); - - m_relatedModel->clear(); - onSimilarArtistsLoaded(); -} - - -void -RelatedArtistsContext::setQuery( const Tomahawk::query_ptr& query ) -{ - if ( query.isNull() ) - return; - - setArtist( query->track()->artistPtr() ); -} - - -void -RelatedArtistsContext::setAlbum( const Tomahawk::album_ptr& album ) -{ - if ( album.isNull() ) - return; - - setArtist( album->artist() ); -} - - -void -RelatedArtistsContext::onSimilarArtistsLoaded() -{ - foreach ( const artist_ptr& artist, m_artist->similarArtists() ) - { - m_relatedModel->addArtists( artist ); - } -} diff --git a/src/libtomahawk/context/pages/RelatedArtistsContext.h b/src/libtomahawk/context/pages/RelatedArtistsContext.h deleted file mode 100644 index 3e45cebce..000000000 --- a/src/libtomahawk/context/pages/RelatedArtistsContext.h +++ /dev/null @@ -1,69 +0,0 @@ -/* === This file is part of Tomahawk Player - === - * - * Copyright 2010-2011, Christian Muehlhaeuser - * Copyright 2010-2011, Jeff Mitchell - * - * Tomahawk is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Tomahawk is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Tomahawk. If not, see . - */ - -#ifndef RELATEDARTISTSCONTEXT_H -#define RELATEDARTISTSCONTEXT_H - -#include - -#include "DllMacro.h" - -#include "Artist.h" -#include "Album.h" -#include "Query.h" -#include "context/ContextPage.h" - -class TreeModel; -class TreeView; - -class DLLEXPORT RelatedArtistsContext : public Tomahawk::ContextPage -{ -Q_OBJECT - -public: - RelatedArtistsContext(); - ~RelatedArtistsContext(); - - virtual QGraphicsWidget* widget() { return m_proxy; } - - virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return Tomahawk::playlistinterface_ptr(); } - - virtual QString title() const { return tr( "Related Artists" ); } - virtual QString description() const { return QString(); } - - 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: - void onSimilarArtistsLoaded(); - -private: - TreeView* m_relatedView; - TreeModel* m_relatedModel; - - QGraphicsProxyWidget* m_proxy; - - Tomahawk::artist_ptr m_artist; -}; - -#endif // RELATEDARTISTSCONTEXT_H diff --git a/src/libtomahawk/context/pages/TopTracksContext.cpp b/src/libtomahawk/context/pages/TopTracksContext.cpp deleted file mode 100644 index b27b7cce1..000000000 --- a/src/libtomahawk/context/pages/TopTracksContext.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/* === This file is part of Tomahawk Player - === - * - * Copyright 2010-2011, Christian Muehlhaeuser - * Copyright 2010-2011, Jeff Mitchell - * - * Tomahawk is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Tomahawk is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Tomahawk. If not, see . - */ - -#include "TopTracksContext.h" - -#include "playlist/PlaylistModel.h" -#include "playlist/PlaylistView.h" -#include "Source.h" - -using namespace Tomahawk; - - -TopTracksContext::TopTracksContext() - : ContextPage() -{ - m_topHitsView = new PlaylistView(); - m_topHitsView->setGuid( "TopTracksContext" ); - m_topHitsView->setUpdatesContextView( false ); - m_topHitsModel = new PlaylistModel( m_topHitsView ); - m_topHitsView->proxyModel()->setStyle( PlayableProxyModel::Short ); - m_topHitsView->setPlaylistModel( m_topHitsModel ); - m_topHitsView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); - - QPalette pal = m_topHitsView->palette(); - pal.setColor( QPalette::Window, QColor( 0, 0, 0, 0 ) ); - m_topHitsView->setPalette( pal ); - - m_proxy = new QGraphicsProxyWidget(); - m_proxy->setWidget( m_topHitsView ); -} - - -TopTracksContext::~TopTracksContext() -{ -} - - -void -TopTracksContext::setArtist( const Tomahawk::artist_ptr& artist ) -{ - if ( artist.isNull() ) - return; - if ( !m_artist.isNull() && m_artist->name() == artist->name() ) - return; - - if ( !m_artist.isNull() ) - { - disconnect( m_artist.data(), SIGNAL( tracksAdded( QList, Tomahawk::ModelMode, Tomahawk::collection_ptr ) ), - this, SLOT( onTracksFound( QList, Tomahawk::ModelMode ) ) ); - } - - m_artist = artist; - - connect( m_artist.data(), SIGNAL( tracksAdded( QList, Tomahawk::ModelMode, Tomahawk::collection_ptr ) ), - SLOT( onTracksFound( QList, Tomahawk::ModelMode ) ) ); - - m_topHitsModel->clear(); - onTracksFound( m_artist->tracks(), Mixed ); -} - - -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( query->track()->artistPtr() ); -} - - -void -TopTracksContext::onTracksFound( const QList& queries, ModelMode mode ) -{ - Q_UNUSED( mode ); - - m_topHitsModel->appendQueries( queries ); -} - - diff --git a/src/libtomahawk/context/pages/TopTracksContext.h b/src/libtomahawk/context/pages/TopTracksContext.h deleted file mode 100644 index bc8219b62..000000000 --- a/src/libtomahawk/context/pages/TopTracksContext.h +++ /dev/null @@ -1,69 +0,0 @@ -/* === This file is part of Tomahawk Player - === - * - * Copyright 2010-2011, Christian Muehlhaeuser - * Copyright 2010-2011, Jeff Mitchell - * - * Tomahawk is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Tomahawk is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Tomahawk. If not, see . - */ - -#ifndef TOPTRACKSCONTEXT_H -#define TOPTRACKSCONTEXT_H - -#include - -#include "DllMacro.h" - -#include "Artist.h" -#include "Album.h" -#include "Query.h" -#include "context/ContextPage.h" - -class PlaylistModel; -class PlaylistView; - -class DLLEXPORT TopTracksContext : public Tomahawk::ContextPage -{ -Q_OBJECT - -public: - TopTracksContext(); - ~TopTracksContext(); - - virtual QGraphicsWidget* widget() { return m_proxy; } - - virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return Tomahawk::playlistinterface_ptr(); } - - virtual QString title() const { return tr( "Top Hits" ); } - virtual QString description() const { return QString(); } - - 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: - void onTracksFound( const QList& queries, Tomahawk::ModelMode mode ); - -private: - PlaylistView* m_topHitsView; - PlaylistModel* m_topHitsModel; - - QGraphicsProxyWidget* m_proxy; - - Tomahawk::artist_ptr m_artist; -}; - -#endif // TOPTRACKSCONTEXT_H diff --git a/src/libtomahawk/context/pages/WebContext.cpp b/src/libtomahawk/context/pages/WebContext.cpp deleted file mode 100644 index e9a93a22d..000000000 --- a/src/libtomahawk/context/pages/WebContext.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* === This file is part of Tomahawk Player - === - * - * Copyright 2010-2011, Christian Muehlhaeuser - * - * Tomahawk is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Tomahawk is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Tomahawk. If not, see . - */ - -#include "WebContext.h" -#include "Source.h" - -using namespace Tomahawk; - - -WebContext::WebContext() - : ContextPage() -{ - m_webView = new QGraphicsWebView(); - - QPalette pal = m_webView->palette(); - pal.setColor( QPalette::Window, QColor( 0, 0, 0, 0 ) ); - m_webView->setPalette( pal ); -} - - -WebContext::~WebContext() -{ -} diff --git a/src/libtomahawk/context/pages/WebContext.h b/src/libtomahawk/context/pages/WebContext.h deleted file mode 100644 index d041180e3..000000000 --- a/src/libtomahawk/context/pages/WebContext.h +++ /dev/null @@ -1,45 +0,0 @@ -/* === This file is part of Tomahawk Player - === - * - * Copyright 2010-2011, Christian Muehlhaeuser - * - * Tomahawk is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Tomahawk is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Tomahawk. If not, see . - */ - -#ifndef WEBCONTEXT_H -#define WEBCONTEXT_H - -#include - -#include "DllMacro.h" - -#include "Query.h" -#include "context/ContextPage.h" - -class DLLEXPORT WebContext : public Tomahawk::ContextPage -{ -Q_OBJECT - -public: - WebContext(); - ~WebContext(); - - QGraphicsWebView* webView() const { return m_webView; } - virtual QGraphicsWidget* widget() { return m_webView; } - -private: - QGraphicsWebView* m_webView; - Tomahawk::query_ptr m_query; -}; - -#endif // WEBCONTEXT_H diff --git a/src/libtomahawk/context/pages/WikipediaContext.cpp b/src/libtomahawk/context/pages/WikipediaContext.cpp deleted file mode 100644 index e59ee927c..000000000 --- a/src/libtomahawk/context/pages/WikipediaContext.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* === This file is part of Tomahawk Player - === - * - * Copyright 2010-2011, Christian Muehlhaeuser - * - * Tomahawk is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Tomahawk is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Tomahawk. If not, see . - */ - -#include "WikipediaContext.h" -#include "Source.h" -#include "Track.h" - -// Forward Declarations breaking QSharedPointer -#if QT_VERSION < QT_VERSION_CHECK( 5, 0, 0 ) - #include "PlaylistInterface.h" -#endif - - -using namespace Tomahawk; - - -void -WikipediaContext::setArtist( const Tomahawk::artist_ptr& artist ) -{ - if ( artist.isNull() ) - return; - if ( !m_artist.isNull() && m_artist->name() == artist->name() ) - return; - - m_artist = artist; - - QString lang = QLocale::system().name().split("_").first(); - webView()->load( QString( "http://%1.wikipedia.org/w/index.php?useformat=mobile&title=%2" ).arg( lang ).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( query->track()->artistPtr() ); -} - - -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 ( query.isNull() ) - return; - - setArtist( query->track()->artistPtr() ); -} diff --git a/src/libtomahawk/context/pages/WikipediaContext.h b/src/libtomahawk/context/pages/WikipediaContext.h deleted file mode 100644 index 22ff451aa..000000000 --- a/src/libtomahawk/context/pages/WikipediaContext.h +++ /dev/null @@ -1,81 +0,0 @@ -/* === This file is part of Tomahawk Player - === - * - * Copyright 2010-2011, Christian Muehlhaeuser - * Copyright 2010-2011, Jeff Mitchell - * - * Tomahawk is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Tomahawk is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Tomahawk. If not, see . - */ - -#ifndef WIKIPEDIACONTEXT_H -#define WIKIPEDIACONTEXT_H - -#include - -#include "DllMacro.h" - -#include "Artist.h" -#include "Album.h" -#include "Query.h" -#include "WebContext.h" - -class DLLEXPORT WikipediaContext : public WebContext -{ -Q_OBJECT - -public: - WikipediaContext() : WebContext() {} - ~WikipediaContext() {} - - virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return Tomahawk::playlistinterface_ptr(); } - - virtual QString title() const { return tr( "Wikipedia" ); } - virtual QString description() const { return QString(); } - - 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::artist_ptr m_artist; -}; - - -class DLLEXPORT LastfmContext : public WebContext -{ -Q_OBJECT - -public: - LastfmContext() : WebContext() {} - ~LastfmContext() {} - - virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return Tomahawk::playlistinterface_ptr(); } - - virtual QString title() const { return tr( "Last.fm" ); } - virtual QString description() const { return QString(); } - - 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::artist_ptr m_artist; -}; - -#endif // WIKIPEDIACONTEXT_H