1 /**************************************************************************************** 2 * Copyright (c) 2008 Peter ZHOU <peterzhoulei@gmail.com> * 3 * Copyright (c) 2008 Nikolaj Hald Nielsen <nhn@kde.org> * 4 * * 5 * This program is free software; you can redistribute it and/or modify it under * 6 * the terms of the GNU General Public License as published by the Free Software * 7 * Foundation; either version 2 of the License, or (at your option) any later * 8 * version. * 9 * * 10 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 11 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 12 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 13 * * 14 * You should have received a copy of the GNU General Public License along with * 15 * this program. If not, see <http://www.gnu.org/licenses/>. * 16 ****************************************************************************************/ 17 18 #ifndef AMAROK_SCRIPTABLE_SERVICE_SCRIPT_H 19 #define AMAROK_SCRIPTABLE_SERVICE_SCRIPT_H 20 21 #include <QMetaType> // for Q_DECLARE_METATYPE 22 #include <QObject> 23 #include <QJSValue> 24 25 class StreamItem; 26 class QPixmap; 27 class QJSEngine; 28 29 namespace AmarokScript 30 { 31 // SCRIPTDOX: ScriptableServiceScript 32 /** 33 * Usage: First create the scriptable service using a call to 34 * ScriptableServiceScript( string name, int levels, string shortDescription, string rootHtml, bool showSearchBar ) 35 */ 36 class ScriptableServiceScript : public QObject 37 { 38 Q_OBJECT 39 40 public: 41 explicit ScriptableServiceScript( QJSEngine* engine ); 42 43 void slotPopulate(const QString &name, int level, int parent_id, const QString &callbackData, const QString &filter ); 44 void slotRequestInfo(const QString &name, int level, const QString &callbackData ); 45 46 void slotCustomize( const QString &name ); 47 48 /** Script Invokable **/ 49 Q_INVOKABLE int insertItem( StreamItem* item ); 50 Q_INVOKABLE void setCurrentInfo( const QString &infoHtml ); 51 52 Q_INVOKABLE int donePopulating() const; 53 54 Q_INVOKABLE void setIcon( const QPixmap &icon ); 55 Q_INVOKABLE void setEmblem( const QPixmap &icon ); 56 Q_INVOKABLE void setScalableEmblem( const QString &emblemPath ); 57 58 Q_INVOKABLE QObject *ScriptableServiceScript_prototype_ctor( QString serviceName, int levels, QString shortDescription, QString rootHtml, bool showSearchBar ); 59 60 61 private: 62 QJSEngine* m_scriptEngine; 63 int m_currentId; 64 QString m_serviceName; 65 static QJSValue ScriptableServiceScript_prototype_populate( QJSEngine *engine ); 66 67 Q_SIGNALS: 68 void populate( int, const QString&, const QString& ); 69 void fetchInfo( int, const QString& ); 70 void customize(); 71 }; 72 } 73 74 Q_DECLARE_METATYPE( AmarokScript::ScriptableServiceScript* ) 75 76 #endif 77