PageRenderTime 245ms CodeModel.GetById 60ms app.highlight 133ms RepoModel.GetById 39ms app.codeStats 0ms

/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
 20#ifndef ARTISTINFOWIDGET_P_H
 21#define ARTISTINFOWIDGET_P_H
 22
 23#include "ArtistInfoWidget.h"
 24#include "ui_ArtistInfoWidget.h"
 25#include "PlaylistInterface.h"
 26#include "playlist/TreeProxyModel.h"
 27#include "Result.h"
 28#include "Typedefs.h"
 29
 30#include <QObject>
 31
 32class MetaArtistInfoInterface : public Tomahawk::PlaylistInterface
 33{
 34    Q_OBJECT
 35public:
 36    explicit MetaArtistInfoInterface( ArtistInfoWidget* w )
 37        : PlaylistInterface()
 38        , m_w( w )
 39    {
 40        connect( m_w->ui->albums->proxyModel()->playlistInterface().data(), SIGNAL( repeatModeChanged( Tomahawk::PlaylistModes::RepeatMode ) ),
 41                 SLOT( anyRepeatModeChanged( Tomahawk::PlaylistModes::RepeatMode ) ) );
 42        connect( m_w->ui->relatedArtists->proxyModel()->playlistInterface().data(), SIGNAL( repeatModeChanged( Tomahawk::PlaylistModes::RepeatMode ) ),
 43                 SLOT( anyRepeatModeChanged( Tomahawk::PlaylistModes::RepeatMode ) ) );
 44        connect( m_w->ui->topHits->proxyModel()->playlistInterface().data(), SIGNAL( repeatModeChanged( Tomahawk::PlaylistModes::RepeatMode ) ),
 45                 SLOT( anyRepeatModeChanged( Tomahawk::PlaylistModes::RepeatMode ) ) );
 46
 47        connect( m_w->ui->albums->proxyModel()->playlistInterface().data(), SIGNAL( shuffleModeChanged( bool ) ),
 48                 SLOT( anyShuffleChanged( bool ) ) );
 49        connect( m_w->ui->relatedArtists->proxyModel()->playlistInterface().data(), SIGNAL( shuffleModeChanged( bool ) ),
 50                 SLOT( anyShuffleChanged( bool ) ) );
 51        connect( m_w->ui->topHits->proxyModel()->playlistInterface().data(), SIGNAL( shuffleModeChanged( bool ) ),
 52                 SLOT( anyShuffleChanged( bool ) ) );
 53    }
 54    virtual ~MetaArtistInfoInterface() {}
 55
 56    // Any one is fine, we keep them all synched
 57    virtual Tomahawk::PlaylistModes::RepeatMode repeatMode() const { return m_w->ui->albums->proxyModel()->playlistInterface()->repeatMode(); }
 58
 59    virtual bool shuffled() const { return m_w->ui->albums->proxyModel()->playlistInterface()->shuffled(); }
 60
 61    // Do nothing
 62    virtual Tomahawk::query_ptr itemAt( unsigned int position ) const { Q_UNUSED( position ); Q_ASSERT( false ); return Tomahawk::query_ptr(); }
 63    virtual int indexOfResult( const Tomahawk::result_ptr& result ) const { Q_UNUSED( result ); Q_ASSERT( false ); return -1; }
 64    virtual int indexOfQuery( const Tomahawk::query_ptr& query ) const { Q_UNUSED( query ); Q_ASSERT( false ); return -1; }
 65    virtual Tomahawk::result_ptr currentItem() const { return Tomahawk::result_ptr(); }
 66    virtual Tomahawk::result_ptr siblingItem( int, bool ) { return Tomahawk::result_ptr(); }
 67    virtual int trackCount() const { return 0; }
 68    virtual QList< Tomahawk::query_ptr > tracks() { return QList< Tomahawk::query_ptr >(); }
 69    virtual int unfilteredTrackCount() const { return 0; }
 70
 71    virtual bool hasChildInterface( Tomahawk::playlistinterface_ptr other )
 72    {
 73        return ( m_w->ui->albums->playlistInterface() == other ) ||
 74               ( m_w->ui->relatedArtists->playlistInterface() == other ) ||
 75               ( m_w->ui->topHits->playlistInterface() == other ) ||
 76               ( m_w->ui->albums->playlistInterface()->hasChildInterface( other ) ) ||
 77               ( m_w->ui->relatedArtists->playlistInterface()->hasChildInterface( other ) );
 78    }
 79
 80public slots:
 81    virtual void setRepeatMode( Tomahawk::PlaylistModes::RepeatMode mode )
 82    {
 83        m_w->ui->albums->proxyModel()->playlistInterface()->setRepeatMode( mode );
 84        m_w->ui->relatedArtists->proxyModel()->playlistInterface()->setRepeatMode( mode );
 85        m_w->ui->topHits->proxyModel()->playlistInterface()->setRepeatMode( mode );
 86    }
 87
 88    virtual void setShuffled( bool enabled )
 89    {
 90        m_w->ui->albums->proxyModel()->playlistInterface()->setShuffled( enabled );
 91        m_w->ui->relatedArtists->proxyModel()->playlistInterface()->setShuffled( enabled );
 92        m_w->ui->topHits->proxyModel()->playlistInterface()->setShuffled( enabled );
 93    }
 94
 95signals:
 96    void nextTrackReady();
 97
 98private slots:
 99    void anyRepeatModeChanged( Tomahawk::PlaylistModes::RepeatMode mode )
100    {
101        emit repeatModeChanged( mode );
102    }
103
104    void anyShuffleChanged( bool enabled )
105    {
106        emit shuffleModeChanged( enabled );
107    }
108
109private:
110    ArtistInfoWidget* m_w;
111
112};
113
114#endif