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