#include <playlistmodel.h>
Inherits QObject.
|
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 | 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 (const QList< PlayListTrack * > &tracks, bool selected=true) |
|
void | setSelected (const QList< PlayListItem * > &items, bool selected=true) |
|
void | setSelected (int first, int last, bool selected=true) |
|
void | setSelected (const 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) |
|
const QList< PlayListTrack * > & | queuedTracks () const |
|
bool | isEmptyQueue () const |
|
int | queueSize () const |
|
bool | isStopAfter (const 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) |
|
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) |
|
int | indexOfTrack (int index) const |
|
PlayListTrack * | findTrack (int track_index) 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
-----------------------
| 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 |
◆ 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()
◆ add [1/4]
Adds a list of tracks to the playlist.
- Parameters
-
◆ add [2/4]
void add |
( |
const QString & |
path | ) |
|
|
slot |
Adds a list of files and directories to the playlist
- Parameters
-
path | Full path of file or directory. |
◆ add [3/4]
void add |
( |
const QStringList & |
paths | ) |
|
|
slot |
Adds a list of files and directories to the playlist
- Parameters
-
paths | Full paths of files and directories. |
◆ add [4/4]
Adds track to the playlist.
◆ addToQueue
Adds/removes selected items to/from playback queue.
◆ 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.
◆ count()
◆ currentIndex()
int currentIndex |
( |
| ) |
const |
Returns index of the current item.
◆ currentTrack()
Returns the current track.
◆ doCurrentVisibleRequest
void doCurrentVisibleRequest |
( |
| ) |
|
|
slot |
Ensures that the current track is visible.
◆ findTrack()
Finds track with index track_index. 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 |
row | ) |
|
Returns number of first item that selected lower the row item.
◆ firstSelectedUpper()
int firstSelectedUpper |
( |
int |
row | ) |
|
Returns number of first item that selected upper the row item.
◆ getSelection()
Returns current selection(playlist can contain a lot of selections, this method returns selection which row belongs to)
◆ group()
Returns the group with the index index or 0 if group doesn't exist.
◆ indexOf()
Returns the row of the item
◆ indexOfTrack()
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.
◆ insert [1/8]
void insert |
( |
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.
◆ insert [2/8]
void insert |
( |
int |
index, |
|
|
const QList< PlayListTrack * > & |
tracks |
|
) |
| |
|
slot |
Inserts tracks at index position index in the playlist.
◆ insert [3/8]
void insert |
( |
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. |
◆ insert [4/8]
void insert |
( |
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. |
◆ insert [5/8]
void insert |
( |
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. |
◆ insert [6/8]
Inserts track at index position index in the playlist.
◆ insert [7/8]
Inserts tracks after item before in the playlist.
◆ insert [8/8]
Inserts track before playlist item before.
◆ 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.
◆ isGroup()
bool isGroup |
( |
int |
index | ) |
const |
Returns true if a playlist contains group separator with the index index. Otherwise returns false.
◆ isLoaderRunning()
bool isLoaderRunning |
( |
| ) |
const |
Returns true if the file loader thread is active; otherwise returns false.
◆ isSelected()
bool isSelected |
( |
int |
index | ) |
const |
Returns true if item with index is selected, otherwise returns false
◆ isStopAfter()
Returns true if playback stops after item, otherwise returns false.
◆ isTrack()
bool isTrack |
( |
int |
index | ) |
const |
Returns true if a playlist contains track with the index index. Otherwise returns false.
◆ item()
Returns the item with the index index or 0 if item doesn't exist.
◆ items()
◆ 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. |
◆ mid()
Returns a list of the items, starting at position pos
- Parameters
-
pos | First item position. |
count | A number of items. If count is -1 (the default), all items from pos are returned. |
◆ moveItems()
void moveItems |
( |
int |
from, |
|
|
int |
to |
|
) |
| |
Moves the item 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 0 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 items 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 |
index | ) |
|
|
slot |
Ensures that the playlist item at index is visible.
◆ scrollToRequest
void scrollToRequest |
( |
int |
index | ) |
|
|
signal |
Tells playlist widget to show item at index index.
◆ selectAll
◆ selectedIndexes()
QList<int> selectedIndexes |
( |
| ) |
const |
Returns list with selected items indexes.
◆ selectedTracks()
◆ setCurrent() [1/2]
bool setCurrent |
( |
int |
index | ) |
|
Sets current index. Returns false if item with this index doesn't exist, otherwise returns true
- Parameters
-
◆ setCurrent() [2/2]
Sets current item to item. 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/5]
void setSelected |
( |
const QList< int > & |
indexes, |
|
|
bool |
selected = true |
|
) |
| |
Sets the selected state of the items with indexes to select
- Parameters
-
indexes | List of item indexes. |
selected | Selection state (true - select, false - unselect) |
◆ setSelected() [2/5]
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() [3/5]
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() [4/5]
void setSelected |
( |
int |
first, |
|
|
int |
last, |
|
|
bool |
selected = true |
|
) |
| |
Sets the selected state of the list of items range.
- Parameters
-
first | Firts item in the range. |
last | Last item in the range. |
selected | Selection state (true - select, false - unselect). |
◆ setSelected() [5/5]
void setSelected |
( |
int |
index, |
|
|
bool |
selected = true |
|
) |
| |
Sets the selected state of the item to select
- Parameters
-
index | Number of item. |
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.
◆ totalDuration()
qint64 totalDuration |
( |
| ) |
const |
Returns total duration in milliseconds of all songs.
◆ track()
Returns the track with the index index or 0 if track doesn't exist.
◆ trackAdded
Emitted when new track has added.
- Parameters
-
track | Pointer of the new playlist track. |
◆ trackCount()
Returns number of tracks.
◆ updateMetaData
Requires to update metadata.
The documentation for this class was generated from the following file: