PageRenderTime 102ms CodeModel.GetById 61ms app.highlight 5ms RepoModel.GetById 35ms app.codeStats 0ms

/src/libtomahawk/infosystem/infoplugins/generic/chartsplugin.h

http://github.com/tomahawk-player/tomahawk
C++ Header | 92 lines | 53 code | 22 blank | 17 comment | 0 complexity | 11d4a1adae81cce1700411f055a33a80 MD5 | raw file
 1/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
 2 *
 3 *   Copyright 2010-2011, Hugo Lindstr??m <hugolm84@gmail.com>
 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
19#ifndef ChartsPlugin_H
20#define ChartsPlugin_H
21
22#include "infosystem/infosystem.h"
23#include "infosystem/infosystemworker.h"
24#include <QtNetwork/QNetworkReply>
25#include <QtCore/QObject>
26
27class QNetworkReply;
28
29namespace Tomahawk
30{
31
32namespace InfoSystem
33{
34
35class ChartsPlugin : public InfoPlugin
36{
37    Q_OBJECT
38
39public:
40    ChartsPlugin();
41    virtual ~ChartsPlugin();
42
43    enum ChartType {
44        None =      0x00,
45        Track =     0x01,
46        Album =     0x02,
47        Artist =    0x04
48
49    };
50
51    void setChartType( ChartType type ) { m_chartType = type; }
52    ChartType chartType() const { return m_chartType; }
53
54public slots:
55    void chartReturned();
56    void chartTypes();
57
58protected slots:
59    virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData );
60    virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData );
61
62    virtual void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant data )
63    {
64        Q_UNUSED( caller )
65        Q_UNUSED( type )
66        Q_UNUSED( data )
67    }
68
69private:
70    void fetchChart( Tomahawk::InfoSystem::InfoRequestData requestData );
71    void fetchChartCapabilities( Tomahawk::InfoSystem::InfoRequestData requestData );
72    void dataError( Tomahawk::InfoSystem::InfoRequestData requestData );
73
74    QStringList m_chartResources;
75    QList< InfoStringHash > m_charts;
76    ChartType m_chartType;
77
78    QVariantMap m_allChartsMap;
79
80    uint m_chartsFetchJobs;
81    QList< InfoRequestData > m_cachedRequests;
82
83    QHash< QString, QString > m_cachedCountries;
84
85    QWeakPointer< QNetworkAccessManager > m_nam;
86};
87
88}
89
90}
91
92#endif // ChartsPlugin_H