1
0
Fork 0
mirror of https://github.com/HenkKalkwater/harbour-sailfin.git synced 2025-09-04 01:42:44 +00:00

Implement playlist model and UI

This commit is contained in:
Chris Josten 2021-08-21 22:01:13 +02:00
parent e04ec364c1
commit f09593c245
13 changed files with 309 additions and 36 deletions

View file

@ -52,6 +52,11 @@ public:
/// Returns the current item in the queue
QSharedPointer<Item> currentItem();
QSharedPointer<Item> nextItem();
/**
* @return the current index of the playing item if it is in the list. If playing from the queue,
* returns -1.
*/
int currentItemIndexInList() const;
/**
* @brief Determine the previous item to be played.
@ -63,13 +68,26 @@ public:
*/
void next();
// int queueSize() { return m_queue.size(); };
int queueSize() { return m_queue.size(); };
int listSize() const { return m_list.size(); };
int totalSize() const { return m_queue.size() + m_list.size(); }
QSharedPointer<const Item> listAt(int index) const;
/**
* @brief Removes all the items from the playlist
* @brief Returns the item at the given index of the currently selected playlist, excluding the queue.
* @param index
* @return The given item.
*/
QSharedPointer<const Item> listAt(int index) const;
/**
* @brief Returns the item at the given index of the currently queue, excluding the playlist.
* @param index
* @return The given item.
*/
QSharedPointer<const Item> queueAt(int index) const;
/**
* @brief Removes all the items from the playlist, but not from the queue.
*/
void clearList();
@ -83,11 +101,26 @@ public:
* @param index The index to start from.
*/
void play(int index = 0);
/**
* @brief playingFromQueue
* @return True if the currently played item comes from the queue.
*/
bool playingFromQueue() const;
signals:
void beforeListCleared();
void listCleared();
void itemsAddedToQueue(int index, int count);
void itemsAddedToList(int index, int count);
void beforeItemsAddedToQueue(int index, int count);
void beforeItemsAddedToList(int index, int count);
void itemsAddedToQueue();
void itemsAddedToList();
void beforeItemsRemovedFromQueue(int index, int count);
void beforeItemsRemovedFromList(int index, int count);
void itemsRemovedFromQueue();
void itemsRemovedFromList();
void listReshuffled();
void currentItemChanged();
private:
void reshuffle();

View file

@ -103,6 +103,7 @@ public:
virtual int currentItem() const override;
virtual int nextItem() const override;
virtual int itemAt(int index) const override;
virtual void previous() override;
virtual void next() override;
@ -122,6 +123,7 @@ public:
ListShuffleBase(const Playlist *parent);
virtual int currentItem() const override;
virtual int nextItem() const override;
virtual int itemAt(int index) const override;
protected:
QVector<int> m_map;
};