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