#include <qmmpui/playlistmodel.h>
|
| 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
} |
| |
|
| | PlayListModel (const QString &name, QObject *parent=nullptr) |
| |
| | ~PlayListModel () |
| |
| QString | name () const |
| |
| void | setName (const QString &name) |
| |
| int | groupCount () const |
| |
| int | trackCount () const |
| |
| bool | isEmpty () const |
| |
| int | columnCount () const |
| |
| PlayListTrack * | currentTrack () const |
| |
| PlayListTrack * | nextTrack () const |
| |
| int | indexOf (PlayListItem *item) const |
| |
| PlayListTrack * | track (int index) const |
| |
| PlayListGroup * | group (int index) const |
| |
| int | currentIndex () const |
| |
| bool | setCurrent (int index) |
| |
| bool | setCurrent (PlayListTrack *track) |
| |
| void | setSelected (PlayListItem *item, bool selected=true) |
| |
| void | setSelected (const QList< PlayListTrack * > &tracks, bool selected=true) |
| |
| void | setSelected (const QList< PlayListItem * > &items, bool selected=true) |
| |
| void | setSelectedLines (int firstLine, int lastLine, bool selected=true) |
| |
| bool | next () |
| |
| bool | previous () |
| |
| int | lineCount () const |
| |
| PlayListItem * | itemAtLine (int lineIndex) const |
| |
| PlayListTrack * | trackAtLine (int lineIndex) const |
| |
| QList< PlayListItem * > | itemsAtLines (int pos, int count=-1) const |
| |
| int | findLine (PlayListItem *item) const |
| |
| int | findLine (int trackIndex) const |
| |
| int | subIndexOfLine (int lineIndex) const |
| |
| int | trackIndexAtLine (int lineIndex) const |
| |
| bool | alternateColor (int lineIndex) const |
| |
| int | linesPerGroup () const |
| |
| void | moveTracks (int from, int to) |
| |
| const QList< PlayListTrack * > & | queuedTracks () const |
| |
| bool | isEmptyQueue () const |
| |
| int | queueSize () const |
| |
| bool | isStopAfter (const PlayListItem *track) const |
| |
| SimpleSelection | getSelection (int trackIndex) |
| |
| QList< int > | selectedLines () const |
| |
| void | setSelectedLine (int line, bool selected=true) |
| |
| QList< int > | selectedTrackIndexes () const |
| |
| QList< PlayListTrack * > | selectedTracks () const |
| |
| QList< PlayListTrack * > | tracks () const |
| |
| int | firstSelectedUpper (int trackIndex) |
| |
| int | firstSelectedLower (int trackIndex) |
| |
| qint64 | totalDuration () 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) |
| |
| PlayListTrack * | findTrack (int trackIndex) const |
| |
| QList< PlayListItem * > | findTracks (const QString &str) const |
| |
The PlayListModel class provides a data model for the playlist.
- Author
- Vladimir Kuznetsov vovan.nosp@m.ec@g.nosp@m.mail..nosp@m.com
-
Ilya Kotov forko.nosp@m.tov0.nosp@m.2@ya..nosp@m.ru
Playlist Structure
----------------------------------
| line | sub-line | item | item |
| index | index | index | type |
----------------------------------
| 0 | 0 | 0 | group |
| 1 | 1 | 0 | group |
| 2 | 2 | 0 | group |
----------------------------------
| 3 | 0 | 0 | track |
| 4 | 0 | 1 | track |
| 5 | 0 | 2 | track |
----------------------------------
| 6 | 0 | 1 | group |
| 7 | 1 | 1 | group |
| 8 | 2 | 1 | group |
----------------------------------
| 9 | 0 | 3 | track |
| 10 | 0 | 4 | track |
◆ SortMode
Enum of the available sort modes.
| Enumerator |
|---|
| TITLE | by title
|
| ALBUM | by album
|
| DISCNUMBER | by discnumber
|
| ARTIST | by artist
|
| ALBUMARTIST | by album artist
|
| FILENAME | by file name
|
| PATH_AND_FILENAME | by path and file name
|
| DATE | by date
|
| TRACK | by track
|
| FILE_CREATION_DATE | by file creation date
|
| FILE_MODIFICATION_DATE | by file modification date
|
| GROUP | by group name
|
◆ UpdateFlags
Enum of the playlist update flags.
| Enumerator |
|---|
| STRUCTURE | Structure of the playlist has been changed
|
| SELECTION | Current selection has been changed
|
| QUEUE | Track queue has been changed
|
| CURRENT | Current track has been changed
|
| STOP_AFTER | Stop track has been changed
|
| METADATA | Metadata has been changed
|
◆ PlayListModel()
| PlayListModel |
( |
const QString & | name, |
|
|
QObject * | parent = nullptr ) |
|
explicit |
Constructs a playlist model.
- Parameters
-
| name | Playlist name. |
| parent | QObject parent |
◆ ~PlayListModel()
◆ addPath
| void addPath |
( |
const QString & | path | ) |
|
|
slot |
Adds a list of files and directories to the playlist
- Parameters
-
| path | Full path of file or directory. |
◆ addPaths
| void addPaths |
( |
const QStringList & | paths | ) |
|
|
slot |
Adds a list of files and directories to the playlist
- Parameters
-
| paths | Full paths of files and directories. |
◆ addToQueue
Adds/removes selected items to/from playback queue.
◆ addTrack
Adds track to the playlist.
◆ addTracks
Adds a list of tracks to the playlist.
- Parameters
-
◆ alternateColor()
| bool alternateColor |
( |
int | lineIndex | ) |
const |
Return true if the line lineIndex should be painted using alternate color. Otherwise returns false.
◆ clear
◆ clearQueue
Removes all items from queue.
◆ clearSelection
◆ columnCount()
| int columnCount |
( |
| ) |
const |
Returns number of columns.
◆ contains()
| bool contains |
( |
const QString & | url | ) |
|
Returns true if the playlist contains an item with URL url; otherwise returns false.
◆ currentIndex()
| int currentIndex |
( |
| ) |
const |
Returns index of the current track or -1 if model is empty.
◆ currentTrack()
Returns the current track.
◆ currentTrackRemoved
| void currentTrackRemoved |
( |
| ) |
|
|
signal |
Emitted when the current track is removed.
◆ doCurrentVisibleRequest
| void doCurrentVisibleRequest |
( |
| ) |
|
|
slot |
Ensures that the current track is visible.
◆ findLine() [1/2]
| int findLine |
( |
int | trackIndex | ) |
const |
Finds line for track with index trackIndex. Returns -1 if the line for this track is not available.
◆ findLine() [2/2]
Finds line for item item. Returns -1 if line for this item is not available.
◆ findTrack()
Finds track with index trackIndex. Returns null pointer if playlist does not contain track with index track_index.
◆ findTracks()
| QList< PlayListItem * > findTracks |
( |
const QString & | str | ) |
const |
Finds tracks by string str. The search is case insensitive. Returns a list of PlayListItem pointers.
◆ firstSelectedLower()
| int firstSelectedLower |
( |
int | trackIndex | ) |
|
Returns number of first track that selected lower the trackIndex track.
◆ firstSelectedUpper()
| int firstSelectedUpper |
( |
int | trackIndex | ) |
|
Returns number of first track index that selected upper the trackIndex track.
◆ getSelection()
Returns current selection(playlist can contain a lot of selections, this method returns selection which trackIndex belongs to)
◆ group()
Returns the group with the index index or nullptr if group doesn't exist.
◆ groupCount()
Returns number of groups.
◆ indexOf()
Returns index of track or group.
- Parameters
-
| item | track or group pointer. |
◆ insertJson
| void insertJson |
( |
int | index, |
|
|
const QByteArray & | json ) |
|
slot |
Inserts serialized content json at index position index in the playlist. May be useful for fast drag-and-drop.
◆ insertPath
| void insertPath |
( |
int | index, |
|
|
const QString & | path ) |
|
slot |
Inserts file or directory at index position index in the playlist.
- Parameters
-
| path | Full path of file or directory. |
| index | Position in the playlist. |
◆ insertPaths
| void insertPaths |
( |
int | index, |
|
|
const QStringList & | paths ) |
|
slot |
Adds a list of files and directories at index position index in the playlist.
- Parameters
-
| paths | Full paths of files and directories. |
| index | Position in the playlist. |
◆ insertTrack
Inserts track at index position index in the playlist.
◆ insertTracks
| void insertTracks |
( |
int | index, |
|
|
const QList< PlayListTrack * > & | tracks ) |
|
slot |
Inserts tracks at index position index in the playlist.
◆ insertUrls
| void insertUrls |
( |
int | index, |
|
|
const QList< QUrl > & | urls ) |
|
slot |
Adds a list of URLs at index position index in the playlist.
- Parameters
-
| urls | A list of URLs. |
| index | Position in the playlist. |
◆ invertSelection
Inverts selection (selects unselected items and unselects selected items)
◆ isEmpty()
Returns true if the model contains no tracks; otherwise returns false.
◆ isEmptyQueue()
| bool isEmptyQueue |
( |
| ) |
const |
Returns true if play queue is empty, otherwise returns - false.
◆ isLoaderRunning()
| bool isLoaderRunning |
( |
| ) |
const |
Returns true if the file loader thread is active; otherwise returns false.
◆ isStopAfter()
Returns true if playback stops after track, otherwise returns false.
◆ itemAtLine()
Returns item at line lineIndex or nullptr if item at line lineIndex is not available.
◆ itemsAtLines()
| QList< PlayListItem * > itemsAtLines |
( |
int | pos, |
|
|
int | count = -1 ) const |
Returns a list of the items, starting at line pos
- Parameters
-
| pos | First item line. |
| count | A number of items. If count is -1 (the default), all items from pos are returned. |
◆ lineCount()
Returns total line count.
◆ linesPerGroup()
| int linesPerGroup |
( |
| ) |
const |
Returns the number of lines needed to draw the group.
◆ listChanged
| void listChanged |
( |
int | flags | ) |
|
|
signal |
Emitted when the state of PlayListModel has changed.
- Parameters
-
| flags | Playlist updated flags. See UpdateFlags enum for details. |
◆ loaderFinished
Emitted when playlist loader thread has finished.
◆ loadPlaylist() [1/2]
| void loadPlaylist |
( |
const QString & | f_name | ) |
|
Loads playlist with f_name name.
◆ loadPlaylist() [2/2]
| void loadPlaylist |
( |
const QString & | fmt, |
|
|
const QByteArray & | data ) |
Loads playlist from content.
- Parameters
-
| fmt | Playlist format (short name). |
| data | Content of the playlist file. |
◆ moveTracks()
| void moveTracks |
( |
int | from, |
|
|
int | to ) |
Moves the track at index position from to index position to.
◆ name()
◆ nameChanged
| void nameChanged |
( |
const QString & | name | ) |
|
|
signal |
Emitted when playlist name has chanded.
- Parameters
-
◆ next()
Advances to the next item. Returns false if next iten doesn't exist, otherwise returns true
◆ nextTrack()
Returns the next playing track or nullptr if next track is unknown.
◆ previous()
Goes back to the previous item. Returns false if previous iten doesn't exist, otherwise returns true
◆ queuedTracks()
Returns a list of queued tracks.
◆ queueSize()
Returns the number of tracks in the queue
◆ randomizeList
Randomly changes items order.
◆ rebuildGroups
◆ refresh
Removes invalid tracks and scans parent directories for the new files
◆ removeDuplicates
| void removeDuplicates |
( |
| ) |
|
|
slot |
Removes duplicate tracks by URL.
◆ removeInvalidTracks
| void removeInvalidTracks |
( |
| ) |
|
|
slot |
Removes invalid tracks from playlist
◆ removeSelected
◆ removeTrack [1/2]
| void removeTrack |
( |
int | i | ) |
|
|
slot |
Removes track with i index.
◆ removeTrack [2/2]
Removes track track from playlist.
◆ removeTracks [1/2]
Removes tracks items from playlist.
◆ removeTracks [2/2]
Removes tracks tracks from playlist.
◆ removeUnselected
| void removeUnselected |
( |
| ) |
|
|
slot |
Removes unselected items.
◆ reverseList
◆ savePlaylist()
| void savePlaylist |
( |
const QString & | f_name | ) |
|
Saves current songs to the playlist with f_name name.
◆ scrollTo
| void scrollTo |
( |
int | trackIndex | ) |
|
|
slot |
Ensures that the playlist track at trackIndex is visible.
◆ scrollToRequest
| void scrollToRequest |
( |
int | trackIndex | ) |
|
|
signal |
Tells playlist widget to show track at index trackIndex.
◆ selectAll
◆ selectedLines()
| QList< int > selectedLines |
( |
| ) |
const |
Returns a list of the selected lines.
◆ selectedTrackIndexes()
| QList< int > selectedTrackIndexes |
( |
| ) |
const |
Returns list with selected track indexes.
◆ selectedTracks()
◆ setCurrent() [1/2]
| bool setCurrent |
( |
int | index | ) |
|
Sets current track index. Returns false if the track with this index doesn't exist, otherwise returns true
- Parameters
-
| index | Number of the track. |
◆ setCurrent() [2/2]
Sets current track to track. Returns true if success, otherwise returns false
◆ setName()
| void setName |
( |
const QString & | name | ) |
|
Sets the name of the playlist to name.
◆ setQueued
Adds/removes track t to/from playback queue.
◆ setSelected() [1/3]
| void setSelected |
( |
const QList< PlayListItem * > & | items, |
|
|
bool | selected = true ) |
Sets the selected state of the list of items to select
- Parameters
-
| items | List of items. |
| selected | Selection state (true - select, false - unselect) |
◆ setSelected() [2/3]
| void setSelected |
( |
const QList< PlayListTrack * > & | tracks, |
|
|
bool | selected = true ) |
Sets the selected state of the list of tracks to select
- Parameters
-
| tracks | List of tracks. |
| selected | Selection state (true - select, false - unselect) |
◆ setSelected() [3/3]
| void setSelected |
( |
PlayListItem * | item, |
|
|
bool | selected = true ) |
Sets the selected state of the item to select
- Parameters
-
| item | Track or group pointer. |
| selected | Selection state (true - select, false - unselect) |
◆ setSelectedLine()
| void setSelectedLine |
( |
int | line, |
|
|
bool | selected = true ) |
Selects or unselects group or track at line line.
- Parameters
-
| line | Line number. |
| selected | Selection state. |
◆ setSelectedLines()
| void setSelectedLines |
( |
int | firstLine, |
|
|
int | lastLine, |
|
|
bool | selected = true ) |
Sets the selected state of the list of items range.
- Parameters
-
| firstLine | Firts line in the range. |
| lastLine | Last line in the range. |
| selected | Selection state (true - select, false - unselect). |
◆ showDetails
| void showDetails |
( |
QWidget * | parent = nullptr | ) |
|
|
slot |
Shows details for the first selected item.
- Parameters
-
◆ showDetailsForCurrent
| void showDetailsForCurrent |
( |
QWidget * | parent = nullptr | ) |
|
|
slot |
Shows the details for the current song (if any).
- Parameters
-
◆ sort
Sorts items in mode sort mode.
◆ sortByColumn
| void sortByColumn |
( |
int | column | ) |
|
|
slot |
Sorts tracks by the column with index column.
◆ sortingByColumnFinished
| void sortingByColumnFinished |
( |
int | column, |
|
|
bool | reverted ) |
|
signal |
Emitted when sorting by column is finished.
- Parameters
-
| column | Column index. |
| reverted | Sort direction. |
◆ sortSelection
Sorts selected items in mode sort mode.
◆ stopAfterSelected
| void stopAfterSelected |
( |
| ) |
|
|
slot |
Toggles 'stop after selected' feature.
◆ subIndexOfLine()
| int subIndexOfLine |
( |
int | lineIndex | ) |
const |
Return sub-index of the line lineIndex.
◆ totalDuration()
| qint64 totalDuration |
( |
| ) |
const |
Returns total duration in milliseconds of all songs.
◆ track()
Returns the track with the index index or nullptr if track doesn't exist.
◆ trackAtLine()
Returns track at line lineIndex or nullptr if track at line lineIndex is not available.
◆ trackCount()
Returns number of tracks.
◆ trackIndexAtLine()
| int trackIndexAtLine |
( |
int | lineIndex | ) |
const |
Return track index of the line lineIndex. Returns -1 if the line does not contain track.
◆ tracks()
◆ tracksAdded
Emitted when new tracks have added.
- Parameters
-
| tracks | A list of pointers of the new playlist tracks. |
◆ updateMetaData
Requires to update metadata.
The documentation for this class was generated from the following file: