PageRenderTime 193ms CodeModel.GetById 100ms app.highlight 9ms RepoModel.GetById 82ms app.codeStats 0ms

/src/libtomahawk/playlist/artistview.h

http://github.com/tomahawk-player/tomahawk
C++ Header | 119 lines | 70 code | 30 blank | 19 comment | 0 complexity | 6f50c727f51a2d120fbf40b6fe27d0ff 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 ARTISTVIEW_H
 20#define ARTISTVIEW_H
 21
 22#include <QtGui/QSortFilterProxyModel>
 23#include <QtGui/QTreeView>
 24#include <QtCore/QTimer>
 25
 26#include "treeproxymodel.h"
 27#include "viewpage.h"
 28
 29#include "playlistinterface.h"
 30
 31#include "dllmacro.h"
 32
 33namespace Tomahawk
 34{
 35    class ContextMenu;
 36};
 37
 38class TreeHeader;
 39class LoadingSpinner;
 40class OverlayWidget;
 41class TreeModel;
 42
 43class DLLEXPORT ArtistView : public QTreeView, public Tomahawk::ViewPage
 44{
 45Q_OBJECT
 46
 47public:
 48    explicit ArtistView( QWidget* parent = 0 );
 49    ~ArtistView();
 50
 51    virtual QString guid() const;
 52    virtual void setGuid( const QString& guid ) { m_guid = guid; }
 53
 54    void setProxyModel( TreeProxyModel* model );
 55
 56    TreeModel* model() const { return m_model; }
 57    TreeProxyModel* proxyModel() const { return m_proxyModel; }
 58    OverlayWidget* overlay() const { return m_overlay; }
 59    //    PlaylistItemDelegate* delegate() { return m_delegate; }
 60
 61    void setModel( QAbstractItemModel* model );
 62    void setTreeModel( TreeModel* model );
 63
 64    virtual QWidget* widget() { return this; }
 65    virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return proxyModel()->playlistInterface(); }
 66
 67    virtual QString title() const { return m_model->title(); }
 68    virtual QString description() const { return m_model->description(); }
 69    virtual QPixmap pixmap() const { return m_model->icon(); }
 70
 71    virtual bool showStatsBar() const { return false; }
 72    virtual bool showFilter() const { return true; }
 73
 74    virtual void setShowModes( bool b ) { m_showModes = b; }
 75    virtual bool showModes() const { return m_showModes; }
 76
 77    virtual bool jumpToCurrentTrack();
 78
 79    bool updatesContextView() const { return m_updateContextView; }
 80    void setUpdatesContextView( bool b ) { m_updateContextView = b; }
 81
 82public slots:
 83    void onItemActivated( const QModelIndex& index );
 84
 85protected:
 86    virtual void startDrag( Qt::DropActions supportedActions );
 87    virtual void resizeEvent( QResizeEvent* event );
 88
 89    virtual void keyPressEvent( QKeyEvent* event );
 90
 91protected slots:
 92    virtual void currentChanged( const QModelIndex& current, const QModelIndex& previous );
 93
 94private slots:
 95    void onItemCountChanged( unsigned int items );
 96    void onFilterChanged( const QString& filter );
 97    void onFilteringStarted();
 98
 99    void onCustomContextMenu( const QPoint& pos );
100    void onMenuTriggered( int action );
101
102private:
103    TreeHeader* m_header;
104    OverlayWidget* m_overlay;
105    TreeModel* m_model;
106    TreeProxyModel* m_proxyModel;
107//    PlaylistItemDelegate* m_delegate;
108    LoadingSpinner* m_loadingSpinner;
109
110    bool m_updateContextView;
111
112    QModelIndex m_contextMenuIndex;
113    Tomahawk::ContextMenu* m_contextMenu;
114
115    bool m_showModes;
116    mutable QString m_guid;
117};
118
119#endif // ARTISTVIEW_H