PageRenderTime 82ms CodeModel.GetById 40ms app.highlight 8ms RepoModel.GetById 33ms app.codeStats 0ms

/src/libtomahawk/playlist/dynamic/echonest/EchonestControl.h

http://github.com/tomahawk-player/tomahawk
C Header | 107 lines | 61 code | 26 blank | 20 comment | 0 complexity | b6f4fd3ca7585a377b30e02491d7f6ef 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 *
  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 ECHONEST_CONTROL_H
 20#define ECHONEST_CONTROL_H
 21
 22#include "playlist/dynamic/DynamicControl.h"
 23
 24#include <QTimer>
 25#include <QPointer>
 26
 27#include <echonest5/Playlist.h>
 28
 29namespace Tomahawk
 30{
 31
 32class EchonestControl : public DynamicControl
 33{
 34    Q_OBJECT
 35public:
 36    virtual QWidget* inputField();
 37    virtual QWidget* matchSelector();
 38
 39    /// Converts this to an echonest suitable parameter
 40    Echonest::DynamicPlaylist::PlaylistParamData toENParam() const;
 41
 42    virtual QString input() const;
 43    virtual QString match() const;
 44    virtual QString matchString() const;
 45    virtual QString summary() const;
 46
 47    virtual void setInput(const QString& input);
 48    virtual void setMatch(const QString& match);
 49
 50    /// DO NOT USE IF YOU ARE NOT A DBCMD
 51    EchonestControl( const QString& type, const QStringList& typeSelectors, QObject* parent = 0 );
 52
 53public slots:
 54    virtual void setSelectedType ( const QString& type );
 55
 56private slots:
 57    void updateData();
 58    void editingFinished();
 59    void editTimerFired();
 60
 61    void artistTextEdited( const QString& );
 62    void suggestFinished();
 63
 64    void checkForMoodsStylesOrGenresFetched();
 65private:
 66    void updateWidgets();
 67    void updateWidgetsFromData();
 68
 69    // utility
 70    void setupMinMaxWidgets( Echonest::DynamicPlaylist::PlaylistParam min, Echonest::DynamicPlaylist::PlaylistParam max, const QString& leftL, const QString& rightL, int maxRange );
 71    void updateFromComboAndSlider( bool smooth = false );
 72    void updateFromLabelAndCombo();
 73    bool insertMoodsStylesAndGenres();
 74
 75    void updateToComboAndSlider( bool smooth = false );
 76    void updateToLabelAndCombo();
 77
 78    void addArtistSuggestions( const QStringList& suggestions );
 79
 80    void calculateSummary();
 81
 82    Echonest::DynamicPlaylist::PlaylistParam m_currentType;
 83    int m_overrideType;
 84
 85    QPointer< QWidget > m_input;
 86    QPointer< QWidget > m_match;
 87    QString m_matchData;
 88    QString m_matchString;
 89    QString m_summary;
 90
 91    QTimer m_editingTimer;
 92    QTimer m_delayedEditTimer;
 93
 94    Echonest::DynamicPlaylist::PlaylistParamData m_data;
 95    QVariant m_cacheData;
 96    static bool s_fetchingMoodsStylesAndGenres;
 97    static int s_stylePollCount;
 98
 99    QSet< QNetworkReply* > m_suggestWorkers;
100    static QHash< QString, QStringList > s_suggestCache;
101
102    friend class EchonestGenerator;
103};
104
105};
106
107#endif