PageRenderTime 249ms CodeModel.GetById 101ms app.highlight 76ms RepoModel.GetById 65ms app.codeStats 0ms

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