"Fossies" - the Fresh Open Source Software Archive

Member "amarok-2.9.0/src/scripting/scriptengine/AmarokPlaylistScript.h" (28 Feb 2018, 6155 Bytes) of package /linux/misc/amarok-2.9.0.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "AmarokPlaylistScript.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 2.8.90_vs_2.9.0.

    1 /****************************************************************************************
    2  * Copyright (c) 2008 Peter ZHOU <peterzhoulei@gmail.com>                               *
    3  *                                                                                      *
    4  * This program is free software; you can redistribute it and/or modify it under        *
    5  * the terms of the GNU General Public License as published by the Free Software        *
    6  * Foundation; either version 2 of the License, or (at your option) any later           *
    7  * version.                                                                             *
    8  *                                                                                      *
    9  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
   10  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
   11  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
   12  *                                                                                      *
   13  * You should have received a copy of the GNU General Public License along with         *
   14  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
   15  ****************************************************************************************/
   16 
   17 #ifndef AMAROK_PLAYLIST_SCRIPT_H
   18 #define AMAROK_PLAYLIST_SCRIPT_H
   19 
   20 #include "core/meta/forward_declarations.h"
   21 
   22 #include <QObject>
   23 #include <QMetaType>
   24 #include <QStringList>
   25 
   26 class QModelIndex;
   27 class QUrl;
   28 
   29 namespace AmarokScript
   30 {
   31     class AmarokScriptEngine;
   32 
   33     // SCRIPTDOX: Amarok.Playlist
   34     class AmarokPlaylistScript : public QObject
   35     {
   36         Q_OBJECT
   37 
   38         public:
   39             AmarokPlaylistScript( AmarokScriptEngine *engine );
   40 
   41             /**
   42              * Return the index of the currently playing track in the playlist.
   43              */
   44             Q_INVOKABLE int activeIndex();
   45 
   46             /**
   47              * Return the number of tracks in the playlist.
   48              */
   49             Q_INVOKABLE int totalTrackCount();
   50 
   51             /**
   52              * Save the current playlist in the default playlist path.
   53              */
   54             Q_INVOKABLE QString saveCurrentPlaylist();
   55 
   56             /**
   57              * Load the track represented by the url and append to playlist.
   58              */
   59             Q_INVOKABLE void addMedia( const QUrl &url );
   60 
   61             /**
   62              * Append @param track to playlist.
   63              */
   64             Q_INVOKABLE void addTrack( Meta::TrackPtr track );
   65 
   66             /**
   67              * Load the list of tracks represented by the urls and append to playlist.
   68              */
   69             Q_INVOKABLE void addMediaList( const QList<QUrl> &urls );
   70 
   71             /**
   72              * Append the list of tracks to playlist.
   73              */
   74             Q_INVOKABLE void addTrackList( const Meta::TrackList &tracks );
   75 
   76             /**
   77              * Clear the current playlist.
   78              */
   79             Q_INVOKABLE void clearPlaylist();
   80 
   81             /**
   82              * Play the track at the specified index in the playlist.
   83              */
   84             Q_INVOKABLE void playByIndex( int index );
   85 
   86             /**
   87              * Prepend the the track represented by the passed url and start playing it.
   88              */
   89             Q_INVOKABLE void playMedia( const QUrl &url );
   90 
   91             /**
   92              * Prepend @param track and start playing it.
   93              */
   94             Q_INVOKABLE void playTrack( Meta::TrackPtr track );
   95 
   96             /**
   97              * Prepend the tracks represented by the passed urls and start playing them.
   98              */
   99             Q_INVOKABLE void playMediaList( const QList<QUrl> &urls );
  100 
  101             /**
  102              * Prepend tracks in @param trackList and start playing them.
  103              */
  104             Q_INVOKABLE void playTrackList( const Meta::TrackList &trackList );
  105 
  106             /**
  107              * Remove the currently playing track from the playlist.
  108              */
  109             Q_INVOKABLE void removeCurrentTrack();
  110 
  111             /**
  112              * Remove the track at @param index from the playlist.
  113              */
  114             Q_INVOKABLE void removeByIndex( int index );
  115 
  116             /**
  117              * Save the current playlist at the absolute path @param path.
  118              */
  119             Q_INVOKABLE void savePlaylist( const QString& path );
  120 
  121             /**
  122              * Set whether to stop playing after the current track.
  123              */
  124             Q_INVOKABLE void setStopAfterCurrent( bool on );
  125 
  126             /*
  127              * Indicates whether will stop playing after the current track.
  128              */
  129             Q_INVOKABLE bool stopAfterCurrent();
  130 
  131             /**
  132              * Show/ Hide the playlist.
  133              */
  134             Q_INVOKABLE void togglePlaylist();
  135 
  136             /**
  137              * Return a list of urls representing all the tracks in the playlist.
  138              */
  139             Q_INVOKABLE QStringList filenames();
  140 
  141             /**
  142              * Return the track at the specified position in the playlist.
  143              */
  144             Q_INVOKABLE Meta::TrackPtr trackAt( int row );
  145 
  146             /**
  147              * Get an unsorted list of indices of the currently selected tracks in the playlist.
  148              */
  149             Q_INVOKABLE QList<int> selectedIndexes();
  150 
  151             /**
  152              * Get an unsorted list of urls of the currently selected tracks in the playlist.
  153              */
  154             Q_INVOKABLE QStringList selectedFilenames();
  155 
  156         signals:
  157             /**
  158              * Emitted when tracks are added to the playlist.
  159              */
  160             void trackInserted( int start, int end );
  161 
  162             /**
  163              * Emitted when tracks are removed from the playlist.
  164              */
  165             void trackRemoved( int start, int end );
  166 
  167         private slots:
  168             void slotTrackInserted( const QModelIndex&, int start, int end );
  169             void slotTrackRemoved( const QModelIndex&, int start, int end );
  170 
  171         private:
  172             AmarokScriptEngine* m_scriptEngine;
  173     };
  174 }
  175 
  176 Q_DECLARE_METATYPE( QList<QUrl> )
  177 
  178 #endif