PageRenderTime 123ms CodeModel.GetById 70ms app.highlight 6ms RepoModel.GetById 44ms app.codeStats 0ms

/src/libtomahawk/ViewPage.h

http://github.com/tomahawk-player/tomahawk
C Header | 119 lines | 50 code | 27 blank | 42 comment | 0 complexity | ecee160df8f61f86388e22226b3d4bfb MD5 | raw file
  1/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
  2 *
  3 *   Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
  4 *   Copyright 2010-2011, 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 VIEWPAGE_H
 21#define VIEWPAGE_H
 22
 23#include "Typedefs.h"
 24#include "PlaylistInterface.h"
 25#include "Artist.h"
 26#include "Album.h"
 27#include "Source.h"
 28#include "utils/TomahawkUtils.h"
 29#include "playlist/PlaylistUpdaterInterface.h"
 30
 31#include <QtGui/QPixmap>
 32
 33namespace Tomahawk
 34{
 35
 36
 37class DLLEXPORT ViewPage
 38{
 39public:
 40    enum DescriptionType {
 41        TextType = 0,
 42        ArtistType = 1,
 43        AlbumType = 2
 44    };
 45
 46    ViewPage() {}
 47    virtual ~ViewPage();
 48
 49    virtual QWidget* widget() = 0;
 50    virtual Tomahawk::playlistinterface_ptr playlistInterface() const = 0;
 51
 52    virtual QString title() const = 0;
 53
 54    virtual DescriptionType descriptionType() { return TextType; }
 55    virtual QString description() const = 0;
 56    virtual Tomahawk::artist_ptr descriptionArtist() const { return Tomahawk::artist_ptr(); }
 57    virtual Tomahawk::album_ptr descriptionAlbum() const { return Tomahawk::album_ptr(); }
 58
 59    virtual QString longDescription() const { return QString(); }
 60    virtual QPixmap pixmap() const { return QPixmap( RESPATH "icons/tomahawk-icon-128x128.png" ); }
 61
 62    virtual bool queueVisible() const { return true; }
 63
 64    virtual QString filter() const { return m_filter; }
 65    virtual bool setFilter( const QString& filter );
 66
 67    virtual bool willAcceptDrag( const QMimeData* data ) const;
 68    virtual bool dropMimeData( const QMimeData*, Qt::DropAction );
 69
 70    virtual bool jumpToCurrentTrack() = 0;
 71
 72    virtual bool isTemporaryPage() const { return false; }
 73
 74    /**
 75     * Should we add a row in the SourceTreeView for this page.
 76     */
 77    virtual bool addPageItem() const;
 78
 79    virtual bool isRemovable() const { return false; }
 80
 81    /**
 82     * This page is actually a constant page that will be shown on every
 83     * restart of Tomahawk until the user selects it to be removed.
 84     *
 85     * The main distinction between this and isTemporaryPage() is that the
 86     * page will not be listed in the search history.
 87     */
 88    virtual bool isDeletable() const { return false; }
 89
 90    /**
 91     * The ViewPage item in the SourcesModel was deleted.
 92     */
 93    virtual void onItemDeleted();
 94
 95    virtual bool isBeingPlayed() const { return false; }
 96
 97    virtual QList<PlaylistUpdaterInterface*> updaters() const { return QList<PlaylistUpdaterInterface*>(); }
 98
 99    /** subclasses implementing ViewPage can emit the following signals:
100     * nameChanged( const QString& )
101     * descriptionChanged( const QString& )
102     * descriptionChanged( const Tomahawk::artist_ptr& artist )
103     * descriptionChanged( const Tomahawk::album_ptr& album )
104     * longDescriptionChanged( const QString& )
105     * pixmapChanged( const QPixmap& )
106     * destroyed( QWidget* widget );
107     *
108     * See DynamicWidget for an example
109     */
110
111private:
112    QString m_filter;
113};
114
115} // ns
116
117Q_DECLARE_METATYPE( Tomahawk::ViewPage* )
118
119#endif //VIEWPAGE_H