PageRenderTime 102ms CodeModel.GetById 40ms app.highlight 6ms RepoModel.GetById 54ms app.codeStats 0ms

/src/libtomahawk/playlist/albumview.h

http://github.com/tomahawk-player/tomahawk
C++ Header | 90 lines | 50 code | 22 blank | 18 comment | 0 complexity | b91418bff78af7e36e6755196f53f2f5 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 *
 5 *   Tomahawk is free software: you can redistribute it and/or modify
 6 *   it under the terms of the GNU General Public License as published by
 7 *   the Free Software Foundation, either version 3 of the License, or
 8 *   (at your option) any later version.
 9 *
10 *   Tomahawk is distributed in the hope that it will be useful,
11 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 *   GNU General Public License for more details.
14 *
15 *   You should have received a copy of the GNU General Public License
16 *   along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef ALBUMVIEW_H
20#define ALBUMVIEW_H
21
22#include <QListView>
23#include <QSortFilterProxyModel>
24#include <QTimer>
25
26#include "viewpage.h"
27#include "albumproxymodel.h"
28#include "widgets/overlaywidget.h"
29#include "dllmacro.h"
30
31class AlbumModel;
32class LoadingSpinner;
33class AlbumItemDelegate;
34
35class DLLEXPORT AlbumView : public QListView, public Tomahawk::ViewPage
36{
37Q_OBJECT
38
39public:
40    explicit AlbumView( QWidget* parent = 0 );
41    ~AlbumView();
42
43    void setProxyModel( AlbumProxyModel* model );
44
45    AlbumModel* model() const { return m_model; }
46    AlbumProxyModel* proxyModel() const { return m_proxyModel; }
47//    PlaylistItemDelegate* delegate() { return m_delegate; }
48
49    bool autoFitItems() const { return m_autoFitItems; }
50    void setAutoFitItems( bool b ) { m_autoFitItems = b; }
51
52    void setAlbumModel( AlbumModel* model );
53    void setModel( QAbstractItemModel* model );
54
55    virtual QWidget* widget() { return this; }
56    virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return proxyModel()->playlistInterface(); }
57
58    virtual QString title() const { return m_model->title(); }
59    virtual QString description() const { return m_model->description(); }
60
61    virtual bool showModes() const { return true; }
62
63    virtual bool jumpToCurrentTrack() { return false; }
64
65public slots:
66    void onItemActivated( const QModelIndex& index );
67
68protected:
69    virtual void startDrag( Qt::DropActions supportedActions );
70
71    void paintEvent( QPaintEvent* event );
72    void resizeEvent( QResizeEvent* event );
73
74private slots:
75    void onItemCountChanged( unsigned int items );
76
77    void onFilterChanged( const QString& filter );
78
79private:
80    AlbumModel* m_model;
81    AlbumProxyModel* m_proxyModel;
82    AlbumItemDelegate* m_delegate;
83    LoadingSpinner* m_loadingSpinner;
84    OverlayWidget* m_overlay;
85
86    bool m_inited;
87    bool m_autoFitItems;
88};
89
90#endif // ALBUMVIEW_H