Qmmp
Loading...
Searching...
No Matches
groupedcontainer_p.h
1/***************************************************************************
2 * Copyright (C) 2013-2025 by Ilya Kotov *
3 * forkotov02@ya.ru *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
20
21#ifndef GROUPEDCONTAINER_H
22#define GROUPEDCONTAINER_H
23
24#include <QList>
25#include "playlistgroup.h"
26#include "playlistcontainer_p.h"
27#include "playlisttrack.h"
28
29class GroupedContainer : public PlayListContainer
30{
31public:
32 GroupedContainer();
33
34 void addTrack(PlayListTrack *track) override;
35 void addTracks(const QList<PlayListTrack *> &tracks) override;
36 int insertTrack(int index, PlayListTrack *track) override;
37 void replaceTracks(const QList<PlayListTrack *> &tracks) override;
38 QList<PlayListGroup *> groups() const override;
39 QList<PlayListTrack *> tracks() const override;
40 int groupCount() const override;
41 int trackCount() const override;
42 QList<PlayListTrack *> mid(int pos, int count) const override;
43 bool isEmpty() const override;
44 void clearSelection() override;
45 int indexOf(PlayListItem *item) const override;
46 PlayListTrack *track(int index) const override;
47 PlayListGroup *group(int index) const override;
48 bool contains(PlayListTrack *track) const override;
49 void removeTrack(PlayListTrack *track) override;
50 void removeTracks(QList<PlayListTrack *> tracks) override;
51 bool move(const QList<int> &indexes, int from, int to) override;
52 QList<PlayListTrack *> takeAllTracks() override;
53 void clear() override;
54 void reverseList() override;
55 void randomizeList() override;
56
57 //playlist view api
58 int lineCount() const override;
59 PlayListItem *itemAtLine(int lineIndex) const override;
60 QList<PlayListItem *> itemsAtLines(int pos, int length = -1) const override;
61 int subIndexOfLine(int lineIndex) const override;
62 int trackIndexAtLine(int lineIndex) const override;
63 bool alternateColor(int lineIndex) const override;
64
65private:
66 void updateCache() const;
67
68 struct PlayListLine
69 {
70 bool isGroup = false;
71 int index = -1;
72 int subindex = -1;
73 bool alternateColor = false;
74 };
75
76 QList<PlayListTrack *> m_tracks;
77 QList<PlayListGroup *> m_groups;
78 mutable QList<PlayListLine> m_lines;
79 mutable bool m_update = true;
80};
81
82#endif // GROUPEDCONTAINER_H