24 if(m_enable && items.count() != m_data.count())
28 std::shuffle(m_data.begin(), m_data.end(), std::default_random_engine(std::random_device()()));
34 m_index = m_data.indexOf(item);
46 if(++m_index >= m_data.count())
55 m_index = m_data.count() - 1;
62 return m_data[m_index];
76 m_shuffle.setEnabled(shuffle);
86 m_playbackMode =
mode;
87 Q_EMIT playbackModeChanged(m_playbackMode);
130 static void updatePlayItems(
const TTK::IndexPropertyList &rows, MusicPlayItemList &items)
136 if(item.m_playlistRow != row.m_first)
141 item.m_playlistRow = row.m_second;
160 return m_mediaList.indexOf({playlistRow, content}, from);
172 for(
const QString &path :
qAsConst(items))
185 for(
const QString &path :
qAsConst(items))
219 const int index =
find(playlistRow, content);
234 #define GENERATE_RANDOM_INDEX(index) \
235 m_currentIndex = m_shuffle.isEnabled() ? find(m_shuffle.setCurrentIndex(index)) : TTK::random(m_mediaList.count());
306 #undef GENERATE_RANDOM_INDEX
312 if(m_currentIndex < 0 || m_currentIndex >=
m_mediaList.count())
323 const int playIndex =
find({playlistRow, path});
void appendQueue(int playlistRow, const QString &content)
The class of the music play item.
const MusicPlayItemList & queueList() const noexcept
MusicPlaylist(QObject *parent=nullptr)
void setShuffleMode(bool shuffle) noexcept
bool isEnabled() const noexcept
MusicPlayItem currentItem() const noexcept
bool isEmpty() const noexcept
TTK::PlayMode playbackMode() const noexcept
TTK_MODULE_EXPORT void initRandom()
#define GENERATE_RANDOM_INDEX(index)
MusicPlayItemList m_queueList
int find(const MusicPlayItem &item) const
The class of the index property.
void add(int playlistRow, const QString &content)
static constexpr int PLAY_PREVIOUS_LEVEL
void removeQueue() noexcept
The namespace of the application object.
void currentIndexChanged(int index)
MusicPlayItemList m_mediaList
static constexpr int PLAY_NEXT_LEVEL
void setPlaybackMode(TTK::PlayMode mode) noexcept
void setCurrentIndex(int index)
int count() const noexcept
class MusicPlaylist::Shuffle m_shuffle
TTK::PlayMode m_playbackMode
static void updatePlayItems(const TTK::IndexPropertyList &rows, MusicPlayItemList &items)
int currentIndex() const noexcept
void append(int playlistRow, const QString &content)
void setCurrentIndex(const MusicPlayItem &item) noexcept
const MusicPlayItemList & mediaList() const noexcept
void initialize(const MusicPlayItemList &items) noexcept
void update(const TTK::IndexPropertyList &rows)
void setEnabled(bool enable) noexcept