Debian Codegraph @

xbmc/playlists/PlayList.h

raw
1 /*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9 #pragma once
10
11 #include "PlayListTypes.h"
12
13 #include <memory>
14 #include <string>
15 #include <vector>
16
17 class CFileItem;
18 class CFileItemList;
19
20 namespace PLAYLIST
21 {
22
23 class CPlayList
24 {
25 public:
26 explicit CPlayList(PLAYLIST::Id id = PLAYLIST::TYPE_NONE);
27 virtual ~CPlayList(void) = default;
28 virtual bool Load(const std::string& strFileName);
29 virtual bool LoadData(std::istream &stream);
30 virtual bool LoadData(const std::string& strData);
31 virtual void Save(const std::string& strFileName) const {};
32
33 void Add(const CPlayList& playlist);
34 void Add(const std::shared_ptr<CFileItem>& pItem);
35 void Add(const CFileItemList& items);
36
37 // for Party Mode
38 void Insert(const CPlayList& playlist, int iPosition = -1);
39 void Insert(const CFileItemList& items, int iPosition = -1);
40 void Insert(const std::shared_ptr<CFileItem>& item, int iPosition = -1);
41
42 int FindOrder(int iOrder) const;
43 const std::string& GetName() const;
44 void Remove(const std::string& strFileName);
45 void Remove(int position);
46 bool Swap(int position1, int position2);
47 bool Expand(int position); // expands any playlist at position into this playlist
48 void Clear();
49 int size() const;
50 int RemoveDVDItems();
51
52 const std::shared_ptr<CFileItem> operator[](int iItem) const;
53 std::shared_ptr<CFileItem> operator[](int iItem);
54
55 void Shuffle(int iPosition = 0);
56 void UnShuffle();
57 bool IsShuffled() const { return m_bShuffled; }
58
59 void SetPlayed(bool bPlayed) { m_bWasPlayed = true; }
60 bool WasPlayed() const { return m_bWasPlayed; }
61
62 void SetUnPlayable(int iItem);
63 int GetPlayable() const { return m_iPlayableItems; }
64
65 void UpdateItem(const CFileItem *item);
66
67 const std::string& ResolveURL(const std::shared_ptr<CFileItem>& item) const;
68
69 protected:
70 PLAYLIST::Id m_id;
71 std::string m_strPlayListName;
72 std::string m_strBasePath;
73 int m_iPlayableItems;
74 bool m_bShuffled;
75 bool m_bWasPlayed;
76
77 // CFileItemList m_vecItems;
78 std::vector<std::shared_ptr<CFileItem>> m_vecItems;
79 typedef std::vector<std::shared_ptr<CFileItem>>::iterator ivecItems;
80
81 private:
82 void Add(const std::shared_ptr<CFileItem>& item, int iPosition, int iOrderOffset);
83 void DecrementOrder(int iOrder);
84 void IncrementOrder(int iPosition, int iOrder);
85
86 void AnnounceRemove(int pos);
87 void AnnounceClear();
88 void AnnounceAdd(const std::shared_ptr<CFileItem>& item, int pos);
89 };
90
91 typedef std::shared_ptr<CPlayList> CPlayListPtr;
92 }