Qmmp
|
#include <playlistmodel.h>
Public Types | |
enum | SortMode { TITLE = 0, ALBUM, DISCNUMBER, ARTIST, ALBUMARTIST, FILENAME, PATH_AND_FILENAME, DATE, TRACK, FILE_CREATION_DATE, FILE_MODIFICATION_DATE, GROUP } |
enum | UpdateFlags { STRUCTURE = 0x01, SELECTION = 0x02, QUEUE = 0x04, CURRENT = 0x08, STOP_AFTER = 0x10, METADATA = 0x20 } |
Public Slots | |
void | add (PlayListTrack *track) |
void | add (QList< PlayListTrack * > tracks) |
void | add (const QString &path) |
void | add (const QStringList &paths) |
void | insert (int index, PlayListTrack *track) |
void | insert (PlayListItem *before, PlayListTrack *track) |
void | insert (int index, QList< PlayListTrack * > tracks) |
void | insert (PlayListItem *before, QList< PlayListTrack * > tracks) |
void | insert (int index, const QString &path) |
void | insert (int index, const QStringList &paths) |
void | insert (int index, const QList< QUrl > &urls) |
void | clear () |
void | clearSelection () |
void | removeSelected () |
void | removeUnselected () |
void | removeTrack (int i) |
void | removeTrack (PlayListItem *track) |
void | invertSelection () |
void | selectAll () |
void | showDetails (QWidget *parent=0) |
void | showDetailsForCurrent (QWidget *parent=0) |
void | doCurrentVisibleRequest () |
void | randomizeList () |
void | reverseList () |
void | sortSelection (int mode) |
void | sort (int mode) |
void | sortByColumn (int column) |
void | addToQueue () |
void | setQueued (PlayListTrack *item) |
void | removeInvalidTracks () |
void | removeDuplicates () |
void | refresh () |
void | clearQueue () |
void | stopAfterSelected () |
void | rebuildGroups () |
void | updateMetaData () |
Signals | |
void | listChanged (int flags) |
void | trackAdded (PlayListTrack *track) |
void | nameChanged (const QString &name) |
void | loaderFinished () |
void | currentVisibleRequest () |
void | sortingByColumnFinished (int column, bool reverted) |
Public Member Functions | |
PlayListModel (const QString &name, QObject *parent=0) | |
~PlayListModel () | |
QString | name () const |
void | setName (const QString &name) |
int | count () const |
int | trackCount () const |
bool | isEmpty () const |
int | columnCount () const |
PlayListTrack * | currentTrack () const |
PlayListTrack * | nextTrack () const |
int | indexOf (PlayListItem *item) const |
PlayListItem * | item (int index) const |
PlayListTrack * | track (int index) const |
PlayListGroup * | group (int index) const |
int | currentIndex () const |
bool | setCurrent (int index) |
bool | setCurrent (PlayListTrack *item) |
bool | isTrack (int index) const |
bool | isGroup (int index) const |
bool | isSelected (int index) const |
void | setSelected (int index, bool selected=true) |
void | setSelected (QList< PlayListTrack * > tracks, bool selected=true) |
void | setSelected (QList< PlayListItem * > items, bool selected=true) |
void | setSelected (int first, int last, bool selected=true) |
void | setSelected (QList< int > indexes, bool selected=true) |
bool | next () |
bool | previous () |
QList< PlayListItem * > | mid (int pos, int count=-1) const |
void | moveItems (int from, int to) |
bool | isQueued (PlayListTrack *item) const |
bool | isEmptyQueue () const |
int | queuedIndex (PlayListTrack *track) const |
int | queueSize () const |
bool | isStopAfter (PlayListItem *item) const |
const SimpleSelection & | getSelection (int row) |
QList< int > | selectedIndexes () const |
QList< PlayListTrack * > | selectedTracks () const |
QList< PlayListItem * > | items () const |
int | firstSelectedUpper (int row) |
int | firstSelectedLower (int row) |
int | totalLength () const |
void | loadPlaylist (const QString &f_name) |
void | loadPlaylist (const QString &fmt, const QByteArray &data) |
void | savePlaylist (const QString &f_name) |
bool | isLoaderRunning () const |
bool | contains (const QString &url) |
int | indexOfTrack (int index) const |
PlayListTrack * | findTrack (int track_index) const |
The PlayListModel class provides a data model for the playlist.
Playlist Structure ----------------------- | item | track | item | | index | index | type | ----------------------- | 0 | | group | | 1 | 0 | track | | 2 | 1 | track | | 3 | 2 | track | | 4 | 3 | track | | 5 | | group | | 6 | 4 | track | | 7 | 5 | track | | 8 | 6 | track |
enum SortMode |
Enum of the available sort modes.
enum UpdateFlags |
PlayListModel | ( | const QString & | name, |
QObject * | parent = 0 |
||
) |
Constructs a playlist model.
name | Playlist name. |
parent | QObject parent |
~PlayListModel | ( | ) |
Object destructor.
void add | ( | PlayListTrack * | track | ) | [slot] |
Adds track to the playlist.
void add | ( | QList< PlayListTrack * > | tracks | ) | [slot] |
Adds a list of tracks to the playlist.
tracks | List of tracks. |
void add | ( | const QString & | path | ) | [slot] |
Adds a list of files and directories to the playlist
path | Full path of file or directory. |
void add | ( | const QStringList & | paths | ) | [slot] |
Adds a list of files and directories to the playlist
paths | Full paths of files and directories. |
void addToQueue | ( | ) | [slot] |
Adds/removes selected items to/from playback queue.
void clear | ( | ) | [slot] |
Removes all items.
void clearQueue | ( | ) | [slot] |
Removes all items from queue.
void clearSelection | ( | ) | [slot] |
Clears selection.
int columnCount | ( | ) | const |
Returns number of columns.
bool contains | ( | const QString & | url | ) |
Returns true if the playlist contains an item with URL url; otherwise returns false.
int count | ( | ) | const |
Returns number of items.
int currentIndex | ( | ) | const |
Returns index of the current item.
PlayListTrack* currentTrack | ( | ) | const |
Returns the current track.
void currentVisibleRequest | ( | ) | [signal] |
Emitted to ensure that the current track is visible.
void doCurrentVisibleRequest | ( | ) | [slot] |
Ensures that the current track is visible.
PlayListTrack* findTrack | ( | int | track_index | ) | const |
Finds track with index track_index. Return null pointer if playlist does not contain track with index track_index.
int firstSelectedLower | ( | int | row | ) |
Returns number of first item that selected lower the row item.
int firstSelectedUpper | ( | int | row | ) |
Returns number of first item that selected upper the row item.
const SimpleSelection& getSelection | ( | int | row | ) |
Returns current selection(playlist can contain a lot of selections, this method returns selection which row belongs to)
PlayListGroup* group | ( | int | index | ) | const |
Returns the group with the index index or 0 if group doesn't exist.
int indexOf | ( | PlayListItem * | item | ) | const |
Returns the row of the item
int indexOfTrack | ( | int | index | ) | const |
Converts item index index to track index Returns -1 if item with index index is not a track or does not exist.
void insert | ( | int | index, |
PlayListTrack * | track | ||
) | [slot] |
Inserts track at index position index in the playlist.
void insert | ( | PlayListItem * | before, |
PlayListTrack * | track | ||
) | [slot] |
Inserts track before playlist item before.
void insert | ( | int | index, |
QList< PlayListTrack * > | tracks | ||
) | [slot] |
Inserts tracks at index position index in the playlist.
void insert | ( | PlayListItem * | before, |
QList< PlayListTrack * > | tracks | ||
) | [slot] |
Inserts tracks after item before in the playlist.
void insert | ( | int | index, |
const QString & | path | ||
) | [slot] |
Inserts file or directory at index position index in the playlist.
path | Full path of file or directory. |
index | Position in the playlist. |
void insert | ( | int | index, |
const QStringList & | paths | ||
) | [slot] |
Adds a list of files and directories at index position index in the playlist.
paths | Full paths of files and directories. |
index | Position in the playlist. |
void insert | ( | int | index, |
const QList< QUrl > & | urls | ||
) | [slot] |
Adds a list of URLs at index position index in the playlist.
urls | A list of URLs. |
index | Position in the playlist. |
void invertSelection | ( | ) | [slot] |
Inverts selection (selects unselected items and unselects selected items)
bool isEmpty | ( | ) | const |
Returns true if the model contains no tracks; otherwise returns false.
bool isEmptyQueue | ( | ) | const |
Returns true if play queue is empty,otherwise returns - false.
bool isGroup | ( | int | index | ) | const |
Returns true if a playlist contains group separator with the index index. Otherwise returns false.
bool isLoaderRunning | ( | ) | const |
Returns true if the file loader thread is active; otherwise returns false.
bool isQueued | ( | PlayListTrack * | item | ) | const |
Returns true if f file is in play queue, otherwise returns false.
bool isSelected | ( | int | index | ) | const |
Returns true if item with index is selected, otherwise returns false
bool isStopAfter | ( | PlayListItem * | item | ) | const |
Returns true if playback stops after item, otherwise returns false.
bool isTrack | ( | int | index | ) | const |
Returns true if a playlist contains track with the index index. Otherwise returns false.
PlayListItem* item | ( | int | index | ) | const |
Returns the item with the index index or 0 if item doesn't exist.
QList<PlayListItem*> items | ( | ) | const |
Returns list of all PlayListItem pointers.
void listChanged | ( | int | flags | ) | [signal] |
Emitted when the state of PlayListModel has changed.
flags | Playlist updated flags. See UpdateFlags enum for details. |
void loaderFinished | ( | ) | [signal] |
Emitted when playlist loader thread has finished.
void loadPlaylist | ( | const QString & | f_name | ) |
Loads playlist with f_name name.
QList<PlayListItem *> mid | ( | int | pos, |
int | count = -1 |
||
) | const |
Returns a list of the items, starting at position pos
pos | First item position. |
count | A number of items. If count is -1 (the default), all items from pos are returned. |
void moveItems | ( | int | from, |
int | to | ||
) |
Moves the item at index position from to index position to.
QString name | ( | ) | const |
Returns playlist name.
void nameChanged | ( | const QString & | name | ) | [signal] |
Emitted when playlist name has chanded.
name | New playlist name. |
bool next | ( | ) |
Advances to the next item. Returns false if next iten doesn't exist, otherwise returns true
PlayListTrack* nextTrack | ( | ) | const |
Returns the next playing track or 0 if next track is unknown.
bool previous | ( | ) |
Goes back to the previous item. Returns false if previous iten doesn't exist, otherwise returns true
int queuedIndex | ( | PlayListTrack * | track | ) | const |
Returns index of f file in queue.e
int queueSize | ( | ) | const |
Returns the number of items in the queue
void randomizeList | ( | ) | [slot] |
Randomly changes items order.
void rebuildGroups | ( | ) | [slot] |
Rebuilds groups
void refresh | ( | ) | [slot] |
Removes invalid tracks and scans parent directories for the new files
void removeDuplicates | ( | ) | [slot] |
Removes duplicate tracks by URL.
void removeInvalidTracks | ( | ) | [slot] |
Removes invalid tracks from playlist
void removeSelected | ( | ) | [slot] |
Removes selected items.
void removeTrack | ( | int | i | ) | [slot] |
Removes items with i index.
void removeTrack | ( | PlayListItem * | track | ) | [slot] |
Removes item item from playlist
void removeUnselected | ( | ) | [slot] |
Removes unselected items.
void reverseList | ( | ) | [slot] |
Reverces items order.
void savePlaylist | ( | const QString & | f_name | ) |
Saves current songs to the playlist with f_name name.
void selectAll | ( | ) | [slot] |
Selects all items.
QList<int> selectedIndexes | ( | ) | const |
Returns list with selected items indexes.
QList<PlayListTrack *> selectedTracks | ( | ) | const |
Returns list of PlayListItem pointers that are selected.
bool setCurrent | ( | int | index | ) |
Sets current index. Returns false if item with this index doesn't exist, otherwise returns true
index | Number of item. |
bool setCurrent | ( | PlayListTrack * | item | ) |
Sets current item to item. Returns true if success, otherwise returns false
void setName | ( | const QString & | name | ) |
Sets the name of the playlist to name.
void setQueued | ( | PlayListTrack * | item | ) | [slot] |
Adds/removes item f to/from playback queue.
void setSelected | ( | int | index, |
bool | selected = true |
||
) |
Sets the selected state of the item to select
index | Number of item. |
selected | Selection state (true - select, false - unselect) |
void setSelected | ( | QList< PlayListTrack * > | tracks, |
bool | selected = true |
||
) |
Sets the selected state of the list of tracks to select
tracks | List of tracks. |
selected | Selection state (true - select, false - unselect) |
void setSelected | ( | QList< PlayListItem * > | items, |
bool | selected = true |
||
) |
Sets the selected state of the list of items to select
items | List of items. |
selected | Selection state (true - select, false - unselect) |
void setSelected | ( | int | first, |
int | last, | ||
bool | selected = true |
||
) |
Sets the selected state of the list of items range.
first | Firts item in the range. |
last | Last item in the range. |
selected | Selection state (true - select, false - unselect). |
void showDetails | ( | QWidget * | parent = 0 | ) | [slot] |
Shows details for the first selected item.
parent | parent Widget. |
void showDetailsForCurrent | ( | QWidget * | parent = 0 | ) | [slot] |
Shows the details for the current song (if any).
parent | parent widget. |
void sort | ( | int | mode | ) | [slot] |
Sorts items in mode sort mode.
void sortByColumn | ( | int | column | ) | [slot] |
Sorts tracks by the column with index column.
void sortingByColumnFinished | ( | int | column, |
bool | reverted | ||
) | [signal] |
Emitted when sorting by column is finished.
column | Column index. |
reverted | Sort direction. |
void sortSelection | ( | int | mode | ) | [slot] |
Sorts selected items in mode sort mode.
void stopAfterSelected | ( | ) | [slot] |
Toggles 'stop after selected' feature.
int totalLength | ( | ) | const |
Returns total lenght in seconds of all songs.
PlayListTrack* track | ( | int | index | ) | const |
Returns the track with the index index or 0 if track doesn't exist.
void trackAdded | ( | PlayListTrack * | track | ) | [signal] |
Emitted when new track has added.
track | Pointer of the new playlist track. |
int trackCount | ( | ) | const |
Returns number of tracks.
void updateMetaData | ( | ) | [slot] |
Requires to update metadata.