playlist handling

This commit is contained in:
Carl Philipp Klemm 2026-03-04 22:16:20 +01:00
parent c4d2fa3ffa
commit 134e827053
5 changed files with 418 additions and 67 deletions

View file

@ -14,21 +14,24 @@ public:
: caption(caption), lyrics(lyrics) {}
};
class SongListModel : public QAbstractListModel
class SongListModel : public QAbstractTableModel
{
Q_OBJECT
public:
enum Roles {
CaptionRole = Qt::UserRole + 1,
LyricsRole = Qt::UserRole + 2
LyricsRole = Qt::UserRole + 2,
IsPlayingRole = Qt::UserRole + 3
};
explicit SongListModel(QObject *parent = nullptr);
// Basic functionality:
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
// Editable:
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
@ -40,8 +43,13 @@ public:
SongItem getSong(int index) const;
int findNextIndex(int currentIndex, bool shuffle = false) const;
// Playing indicator
void setPlayingIndex(int index);
int playingIndex() const { return m_playingIndex; }
private:
QList<SongItem> songList;
int m_playingIndex;
};
#endif // SONGLISTMODEL_H