~ubuntu-branches/ubuntu/trusty/tomahawk/trusty-proposed

« back to all changes in this revision

Viewing changes to src/libtomahawk/widgets/WhatsHotWidget.h

  • Committer: Package Import Robot
  • Author(s): Harald Sitter
  • Date: 2013-03-07 21:50:13 UTC
  • Revision ID: package-import@ubuntu.com-20130307215013-6gdjkdds7i9uenvs
Tags: upstream-0.6.0+dfsg
ImportĀ upstreamĀ versionĀ 0.6.0+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
 
2
 *
 
3
 *   Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
 
4
 *   Copyright 2011, Leo Franchi <lfranchi@kde.org>
 
5
 *   Copyright 2011, Jeff Mitchell <jeff@tomahawk-player.org>
 
6
 *
 
7
 *   Tomahawk is free software: you can redistribute it and/or modify
 
8
 *   it under the terms of the GNU General Public License as published by
 
9
 *   the Free Software Foundation, either version 3 of the License, or
 
10
 *   (at your option) any later version.
 
11
 *
 
12
 *   Tomahawk is distributed in the hope that it will be useful,
 
13
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
15
 *   GNU General Public License for more details.
 
16
 *
 
17
 *   You should have received a copy of the GNU General Public License
 
18
 *   along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
 
19
 */
 
20
 
 
21
#ifndef WHATSHOTWIDGET_H
 
22
#define WHATSHOTWIDGET_H
 
23
 
 
24
#include <QtGui/QWidget>
 
25
#include <QtGui/QListWidgetItem>
 
26
#include <QtGui/QStyledItemDelegate>
 
27
 
 
28
#include "PlaylistInterface.h"
 
29
#include "infosystem/InfoSystem.h"
 
30
#include "ViewPage.h"
 
31
 
 
32
#include "DllMacro.h"
 
33
 
 
34
class QSortFilterProxyModel;
 
35
class QStandardItemModel;
 
36
class QStandardItem;
 
37
class TreeModel;
 
38
class PlaylistModel;
 
39
class TreeProxyModel;
 
40
class PlayableModel;
 
41
class AnimatedSpinner;
 
42
namespace Ui
 
43
{
 
44
    class WhatsHotWidget;
 
45
}
 
46
 
 
47
namespace Tomahawk
 
48
{
 
49
    class ChartDataLoader;
 
50
    class ChartsPlaylistInterface;
 
51
    class ChartDataLoader;
 
52
}
 
53
 
 
54
/**
 
55
 * \class
 
56
 * \brief The tomahawk page that shows music charts.
 
57
 */
 
58
class DLLEXPORT WhatsHotWidget : public QWidget, public Tomahawk::ViewPage
 
59
{
 
60
Q_OBJECT
 
61
 
 
62
public:
 
63
    WhatsHotWidget( QWidget* parent = 0 );
 
64
    ~WhatsHotWidget();
 
65
 
 
66
    virtual QWidget* widget() { return this; }
 
67
    virtual Tomahawk::playlistinterface_ptr playlistInterface() const;
 
68
 
 
69
    virtual QString title() const { return tr( "Charts" ); }
 
70
    virtual QString description() const { return QString(); }
 
71
 
 
72
    virtual bool showInfoBar() const { return false; }
 
73
    virtual bool isBeingPlayed() const;
 
74
 
 
75
    virtual bool jumpToCurrentTrack();
 
76
 
 
77
protected:
 
78
    void changeEvent( QEvent* e );
 
79
 
 
80
signals:
 
81
    void destroyed( QWidget* widget );
 
82
 
 
83
public slots:
 
84
    void fetchData();
 
85
 
 
86
private slots:
 
87
    void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
 
88
    void infoSystemFinished( QString target );
 
89
    void leftCrumbIndexChanged( QModelIndex );
 
90
 
 
91
    void chartArtistsLoaded( Tomahawk::ChartDataLoader*, const QList< Tomahawk::artist_ptr >& );
 
92
    void chartAlbumsLoaded( Tomahawk::ChartDataLoader*, const QList< Tomahawk::album_ptr >& );
 
93
    void chartTracksLoaded( Tomahawk::ChartDataLoader*, const QList< Tomahawk::query_ptr >& );
 
94
 
 
95
private:
 
96
    void setLeftViewArtists( TreeModel* artistModel );
 
97
    void setLeftViewAlbums( PlayableModel* albumModel );
 
98
    void setLeftViewTracks( PlaylistModel* trackModel );
 
99
 
 
100
    QStandardItem* parseNode( QStandardItem* parentItem, const QString &label, const QVariant &data );
 
101
 
 
102
    Ui::WhatsHotWidget *ui;
 
103
    Tomahawk::playlistinterface_ptr m_playlistInterface;
 
104
 
 
105
    QStandardItemModel* m_crumbModelLeft;
 
106
    QSortFilterProxyModel* m_sortedProxy;
 
107
 
 
108
    // Load artist, album, and track objects in a thread
 
109
    // {Artist,Album,Track}::get() calls are all synchronous db calls
 
110
    // and we don't want to lock up out UI in case the db is busy (e.g. on startup)
 
111
    QThread* m_workerThread;
 
112
    QSet< Tomahawk::ChartDataLoader* > m_workers;
 
113
 
 
114
    // Cache our model data
 
115
    QHash< QString, PlayableModel* > m_albumModels;
 
116
    QHash< QString, TreeModel* > m_artistModels;
 
117
    QHash< QString, PlaylistModel* > m_trackModels;
 
118
    QString m_queueItemToShow;
 
119
    QSet< QString > m_queuedFetches;
 
120
    QTimer* m_timer;
 
121
    QMap<QString, QVariant> m_currentVIds;
 
122
    AnimatedSpinner* m_loadingSpinner;
 
123
    friend class Tomahawk::ChartsPlaylistInterface;
 
124
};
 
125
 
 
126
#endif // WHATSHOTWIDGET_H