Qmmp
Loading...
Searching...
No Matches
groupedcontainer_p.h
1#ifndef GROUPEDCONTAINER_H
2#define GROUPEDCONTAINER_H
3
4#include <QList>
5#include "playlistgroup.h"
6#include "playlistcontainer_p.h"
7#include "playlisttrack.h"
8
9class GroupedContainer : public PlayListContainer
10{
11public:
12 GroupedContainer();
13
14 void addTrack(PlayListTrack *track) override;
15 void addTracks(const QList<PlayListTrack *> &tracks) override;
16 int insertTrack(int index, PlayListTrack *track) override;
17 void replaceTracks(const QList<PlayListTrack *> &tracks) override;
18 QList<PlayListGroup *> groups() const override;
19 QList<PlayListTrack *> tracks() const override;
20 int groupCount() const override;
21 int trackCount() const override;
22 QList<PlayListTrack *> mid(int pos, int count) const override;
23 bool isEmpty() const override;
24 void clearSelection() override;
25 int indexOf(PlayListItem *item) const override;
26 PlayListTrack *track(int index) const override;
27 PlayListGroup *group(int index) const override;
28 bool contains(PlayListTrack *track) const override;
29 void removeTrack(PlayListTrack *track) override;
30 void removeTracks(QList<PlayListTrack *> tracks) override;
31 bool move(const QList<int> &indexes, int from, int to) override;
32 QList<PlayListTrack *> takeAllTracks() override;
33 void clear() override;
34 void reverseList() override;
35 void randomizeList() override;
36
37 //playlist view api
38 int lineCount() const override;
39 PlayListItem *itemAtLine(int lineIndex) const override;
40 QList<PlayListItem *> itemsAtLines(int pos, int length = -1) const override;
41 int subIndexOfLine(int lineIndex) const override;
42 int trackIndexAtLine(int lineIndex) const override;
43 bool alternateColor(int lineIndex) const override;
44
45private:
46 void updateCache() const;
47
48 struct PlayListLine
49 {
50 bool isGroup = false;
51 int index = -1;
52 int subindex = -1;
53 bool alternateColor = false;
54 };
55
56 QList<PlayListTrack *> m_tracks;
57 QList<PlayListGroup *> m_groups;
58 mutable QList<PlayListLine> m_lines;
59 mutable bool m_update = true;
60};
61
62#endif // GROUPEDCONTAINER_H