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

« back to all changes in this revision

Viewing changes to src/libtomahawk/widgets/NewReleasesWidget.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 2012, Casey Link <unnamedrambler@gmail.com>
 
4
 *   Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
 
5
 *   Copyright 2011, Leo Franchi <lfranchi@kde.org>
 
6
 *   Copyright 2011, Jeff Mitchell <jeff@tomahawk-player.org>
 
7
 *
 
8
 *   Tomahawk is free software: you can redistribute it and/or modify
 
9
 *   it under the terms of the GNU General Public License as published by
 
10
 *   the Free Software Foundation, either version 3 of the License, or
 
11
 *   (at your option) any later version.
 
12
 *
 
13
 *   Tomahawk is distributed in the hope that it will be useful,
 
14
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
16
 *   GNU General Public License for more details.
 
17
 *
 
18
 *   You should have received a copy of the GNU General Public License
 
19
 *   along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
 
20
 */
 
21
 
 
22
#ifndef NEWRELEASESWIDGET_H
 
23
#define NEWRELEASESWIDGET_H
 
24
 
 
25
#include <QtGui/QWidget>
 
26
#include <QtGui/QListWidgetItem>
 
27
#include <QtGui/QStyledItemDelegate>
 
28
 
 
29
#include "PlaylistInterface.h"
 
30
#include "infosystem/InfoSystem.h"
 
31
#include "ViewPage.h"
 
32
 
 
33
#include "DllMacro.h"
 
34
 
 
35
class QSortFilterProxyModel;
 
36
class QStandardItemModel;
 
37
class QStandardItem;
 
38
class TreeModel;
 
39
class PlaylistModel;
 
40
class TreeProxyModel;
 
41
class AlbumModel;
 
42
class PlayableModel;
 
43
 
 
44
namespace Ui
 
45
{
 
46
    class NewReleasesWidget;
 
47
}
 
48
 
 
49
namespace Tomahawk
 
50
{
 
51
    class ChartDataLoader;
 
52
    class ChartsPlaylistInterface;
 
53
    class ChartDataLoader;
 
54
}
 
55
 
 
56
/**
 
57
 * \class
 
58
 * \brief The tomahawk page that shows music charts.
 
59
 */
 
60
class DLLEXPORT NewReleasesWidget : public QWidget, public Tomahawk::ViewPage
 
61
{
 
62
Q_OBJECT
 
63
 
 
64
public:
 
65
    NewReleasesWidget( QWidget* parent = 0 );
 
66
    ~NewReleasesWidget();
 
67
 
 
68
    virtual QWidget* widget() { return this; }
 
69
    virtual Tomahawk::playlistinterface_ptr playlistInterface() const;
 
70
 
 
71
    virtual QString title() const { return tr( "New Releases" ); }
 
72
    virtual QString description() const { return QString(); }
 
73
 
 
74
    virtual bool showInfoBar() const { return false; }
 
75
    virtual bool isBeingPlayed() const;
 
76
 
 
77
    virtual bool jumpToCurrentTrack();
 
78
 
 
79
protected:
 
80
    void changeEvent( QEvent* e );
 
81
 
 
82
signals:
 
83
    void destroyed( QWidget* widget );
 
84
 
 
85
public slots:
 
86
    void fetchData();
 
87
 
 
88
private slots:
 
89
    void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
 
90
    void infoSystemFinished( QString target );
 
91
    void leftCrumbIndexChanged( QModelIndex );
 
92
 
 
93
    void newReleasesLoaded( Tomahawk::ChartDataLoader*, const QList< Tomahawk::album_ptr >& );
 
94
 
 
95
private:
 
96
    void setLeftViewArtists( TreeModel* artistModel );
 
97
    void setLeftViewAlbums( PlayableModel* albumModel );
 
98
    void setLeftViewTracks( PlaylistModel* trackModel );
 
99
 
 
100
 
 
101
    QStandardItem* parseNode( QStandardItem* parentItem, const QString &label, const QVariant &data );
 
102
    Ui::NewReleasesWidget *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
    QString m_queueItemToShow;
 
117
    QSet< QString > m_queuedFetches;
 
118
    QTimer* m_timer;
 
119
 
 
120
    friend class Tomahawk::ChartsPlaylistInterface;
 
121
};
 
122
 
 
123
#endif // NEWRELEASESWIDGET_H