/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. #ifndef ALBUMVIEW_H
  19. #define ALBUMVIEW_H
  20. #include <QListView>
  21. #include <QSortFilterProxyModel>
  22. #include <QTimer>
  23. #include "viewpage.h"
  24. #include "albumproxymodel.h"
  25. #include "widgets/overlaywidget.h"
  26. #include "dllmacro.h"
  27. class AlbumModel;
  28. class LoadingSpinner;
  29. class AlbumItemDelegate;
  30. class DLLEXPORT AlbumView : public QListView, public Tomahawk::ViewPage
  31. {
  32. Q_OBJECT
  33. public:
  34. explicit AlbumView( QWidget* parent = 0 );
  35. ~AlbumView();
  36. void setProxyModel( AlbumProxyModel* model );
  37. AlbumModel* model() const { return m_model; }
  38. AlbumProxyModel* proxyModel() const { return m_proxyModel; }
  39. // PlaylistItemDelegate* delegate() { return m_delegate; }
  40. bool autoFitItems() const { return m_autoFitItems; }
  41. void setAutoFitItems( bool b ) { m_autoFitItems = b; }
  42. void setAlbumModel( AlbumModel* model );
  43. void setModel( QAbstractItemModel* model );
  44. virtual QWidget* widget() { return this; }
  45. virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return proxyModel()->playlistInterface(); }
  46. virtual QString title() const { return m_model->title(); }
  47. virtual QString description() const { return m_model->description(); }
  48. virtual bool showModes() const { return true; }
  49. virtual bool jumpToCurrentTrack() { return false; }
  50. public slots:
  51. void onItemActivated( const QModelIndex& index );
  52. protected:
  53. virtual void startDrag( Qt::DropActions supportedActions );
  54. void paintEvent( QPaintEvent* event );
  55. void resizeEvent( QResizeEvent* event );
  56. private slots:
  57. void onItemCountChanged( unsigned int items );
  58. void onFilterChanged( const QString& filter );
  59. private:
  60. AlbumModel* m_model;
  61. AlbumProxyModel* m_proxyModel;
  62. AlbumItemDelegate* m_delegate;
  63. LoadingSpinner* m_loadingSpinner;
  64. OverlayWidget* m_overlay;
  65. bool m_inited;
  66. bool m_autoFitItems;
  67. };
  68. #endif // ALBUMVIEW_H