/src/libtomahawk/playlist/dynamic/widgets/DynamicWidget.h

http://github.com/tomahawk-player/tomahawk · C Header · 134 lines · 79 code · 31 blank · 24 comment · 0 complexity · 82f3fd1f22b0ea58505b6a7879478181 MD5 · raw file

  1. /* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
  2. *
  3. * Copyright 2010-2011, Leo Franchi <lfranchi@kde.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. #ifndef DYNAMIC_WIDGET_H
  20. #define DYNAMIC_WIDGET_H
  21. #include <QWidget>
  22. #include "Typedefs.h"
  23. #include "ViewPage.h"
  24. #include "playlist/dynamic/DynamicPlaylistRevision.h"
  25. class AnimatedSpinner;
  26. class BasicHeader;
  27. class QShowEvent;
  28. class QHideEvent;
  29. class QVBoxLayout;
  30. class QLabel;
  31. namespace Tomahawk
  32. {
  33. class DynamicModel;
  34. class DynamicControl;
  35. class DynamicSetupWidget;
  36. class DynamicView;
  37. class CollapsibleControls;
  38. /**
  39. * This class contains the dynamic playlist config and the playlist view itself
  40. */
  41. class DynamicWidget : public QWidget, public Tomahawk::ViewPage
  42. {
  43. Q_OBJECT
  44. public:
  45. explicit DynamicWidget( const dynplaylist_ptr& playlist, QWidget* parent = 0);
  46. virtual ~DynamicWidget();
  47. void loadDynamicPlaylist( const dynplaylist_ptr& playlist );
  48. dynplaylist_ptr playlist();
  49. virtual Tomahawk::playlistinterface_ptr playlistInterface() const;
  50. virtual QSize sizeHint() const;
  51. virtual void resizeEvent( QResizeEvent* );
  52. virtual void showEvent( QShowEvent* );
  53. static void paintRoundedFilledRect( QPainter& p, QPalette& pal, QRect& r, qreal opacity = .95 );
  54. virtual QWidget* widget() { return this; }
  55. virtual QString title() const;
  56. virtual QString description() const;
  57. virtual QPixmap pixmap() const;
  58. virtual bool jumpToCurrentTrack();
  59. public slots:
  60. void onRevisionLoaded( const Tomahawk::DynamicPlaylistRevision& rev );
  61. void playlistTypeChanged( QString );
  62. void startStation();
  63. void stopStation( bool stopPlaying = true );
  64. void trackStarted();
  65. void stationFailed( const QString& );
  66. void playlistChanged( Tomahawk::playlistinterface_ptr );
  67. void tracksAdded();
  68. signals:
  69. void nameChanged( const QString& name );
  70. void descriptionChanged( const QString& caption );
  71. void destroyed( QWidget* widget );
  72. private slots:
  73. void generate( int = -1 );
  74. void tracksGenerated( const QList< Tomahawk::query_ptr>& queries );
  75. void generatorError( const QString& title, const QString& content );
  76. void controlsChanged( bool added );
  77. void controlChanged( const Tomahawk::dyncontrol_ptr& control );
  78. void steeringChanged();
  79. void showPreview();
  80. void layoutFloatingWidgets();
  81. void onDeleted();
  82. void onChanged();
  83. private:
  84. dynplaylist_ptr m_playlist;
  85. QVBoxLayout* m_layout;
  86. bool m_resolveOnNextLoad;
  87. int m_seqRevLaunched; // if we shoot off multiple createRevision calls, we don'y want to set one of the middle ones
  88. bool m_activePlaylist;
  89. // loading animation
  90. AnimatedSpinner* m_loading;
  91. // setup controls
  92. DynamicSetupWidget* m_setup;
  93. // used in OnDemand mode
  94. bool m_runningOnDemand;
  95. bool m_controlsChanged;
  96. QWidget* m_steering;
  97. BasicHeader* m_header;
  98. CollapsibleControls* m_controls;
  99. DynamicView* m_view;
  100. DynamicModel* m_model;
  101. };
  102. };
  103. #endif