/src/libtomahawk/widgets/infowidgets/ArtistInfoWidget_p.h

http://github.com/tomahawk-player/tomahawk · C Header · 114 lines · 77 code · 17 blank · 20 comment · 3 complexity · b3eecf57c9021a522bacb3654b550176 MD5 · raw file

  1. /* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
  2. *
  3. * Copyright 2011, Leo Franchi <lfranchi@kde.org>
  4. * Copyright 2011-2012, Jeff Mitchell <jeff@tomahawk-player.org>
  5. *
  6. * Tomahawk is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Tomahawk is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef ARTISTINFOWIDGET_P_H
  20. #define ARTISTINFOWIDGET_P_H
  21. #include "ArtistInfoWidget.h"
  22. #include "ui_ArtistInfoWidget.h"
  23. #include "PlaylistInterface.h"
  24. #include "playlist/TreeProxyModel.h"
  25. #include "Result.h"
  26. #include "Typedefs.h"
  27. #include <QObject>
  28. class MetaArtistInfoInterface : public Tomahawk::PlaylistInterface
  29. {
  30. Q_OBJECT
  31. public:
  32. explicit MetaArtistInfoInterface( ArtistInfoWidget* w )
  33. : PlaylistInterface()
  34. , m_w( w )
  35. {
  36. connect( m_w->ui->albums->proxyModel()->playlistInterface().data(), SIGNAL( repeatModeChanged( Tomahawk::PlaylistModes::RepeatMode ) ),
  37. SLOT( anyRepeatModeChanged( Tomahawk::PlaylistModes::RepeatMode ) ) );
  38. connect( m_w->ui->relatedArtists->proxyModel()->playlistInterface().data(), SIGNAL( repeatModeChanged( Tomahawk::PlaylistModes::RepeatMode ) ),
  39. SLOT( anyRepeatModeChanged( Tomahawk::PlaylistModes::RepeatMode ) ) );
  40. connect( m_w->ui->topHits->proxyModel()->playlistInterface().data(), SIGNAL( repeatModeChanged( Tomahawk::PlaylistModes::RepeatMode ) ),
  41. SLOT( anyRepeatModeChanged( Tomahawk::PlaylistModes::RepeatMode ) ) );
  42. connect( m_w->ui->albums->proxyModel()->playlistInterface().data(), SIGNAL( shuffleModeChanged( bool ) ),
  43. SLOT( anyShuffleChanged( bool ) ) );
  44. connect( m_w->ui->relatedArtists->proxyModel()->playlistInterface().data(), SIGNAL( shuffleModeChanged( bool ) ),
  45. SLOT( anyShuffleChanged( bool ) ) );
  46. connect( m_w->ui->topHits->proxyModel()->playlistInterface().data(), SIGNAL( shuffleModeChanged( bool ) ),
  47. SLOT( anyShuffleChanged( bool ) ) );
  48. }
  49. virtual ~MetaArtistInfoInterface() {}
  50. // Any one is fine, we keep them all synched
  51. virtual Tomahawk::PlaylistModes::RepeatMode repeatMode() const { return m_w->ui->albums->proxyModel()->playlistInterface()->repeatMode(); }
  52. virtual bool shuffled() const { return m_w->ui->albums->proxyModel()->playlistInterface()->shuffled(); }
  53. // Do nothing
  54. virtual Tomahawk::query_ptr itemAt( unsigned int position ) const { Q_UNUSED( position ); Q_ASSERT( false ); return Tomahawk::query_ptr(); }
  55. virtual int indexOfResult( const Tomahawk::result_ptr& result ) const { Q_UNUSED( result ); Q_ASSERT( false ); return -1; }
  56. virtual int indexOfQuery( const Tomahawk::query_ptr& query ) const { Q_UNUSED( query ); Q_ASSERT( false ); return -1; }
  57. virtual Tomahawk::result_ptr currentItem() const { return Tomahawk::result_ptr(); }
  58. virtual Tomahawk::result_ptr siblingItem( int, bool ) { return Tomahawk::result_ptr(); }
  59. virtual int trackCount() const { return 0; }
  60. virtual QList< Tomahawk::query_ptr > tracks() { return QList< Tomahawk::query_ptr >(); }
  61. virtual int unfilteredTrackCount() const { return 0; }
  62. virtual bool hasChildInterface( Tomahawk::playlistinterface_ptr other )
  63. {
  64. return ( m_w->ui->albums->playlistInterface() == other ) ||
  65. ( m_w->ui->relatedArtists->playlistInterface() == other ) ||
  66. ( m_w->ui->topHits->playlistInterface() == other ) ||
  67. ( m_w->ui->albums->playlistInterface()->hasChildInterface( other ) ) ||
  68. ( m_w->ui->relatedArtists->playlistInterface()->hasChildInterface( other ) );
  69. }
  70. public slots:
  71. virtual void setRepeatMode( Tomahawk::PlaylistModes::RepeatMode mode )
  72. {
  73. m_w->ui->albums->proxyModel()->playlistInterface()->setRepeatMode( mode );
  74. m_w->ui->relatedArtists->proxyModel()->playlistInterface()->setRepeatMode( mode );
  75. m_w->ui->topHits->proxyModel()->playlistInterface()->setRepeatMode( mode );
  76. }
  77. virtual void setShuffled( bool enabled )
  78. {
  79. m_w->ui->albums->proxyModel()->playlistInterface()->setShuffled( enabled );
  80. m_w->ui->relatedArtists->proxyModel()->playlistInterface()->setShuffled( enabled );
  81. m_w->ui->topHits->proxyModel()->playlistInterface()->setShuffled( enabled );
  82. }
  83. signals:
  84. void nextTrackReady();
  85. private slots:
  86. void anyRepeatModeChanged( Tomahawk::PlaylistModes::RepeatMode mode )
  87. {
  88. emit repeatModeChanged( mode );
  89. }
  90. void anyShuffleChanged( bool enabled )
  91. {
  92. emit shuffleModeChanged( enabled );
  93. }
  94. private:
  95. ArtistInfoWidget* m_w;
  96. };
  97. #endif