kodi
DirectoryHistory.h
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 <map>
12 #include <string>
13 #include <vector>
14 
16 {
17 public:
19  {
20  public:
21  CHistoryItem() = default;
22  virtual ~CHistoryItem() = default;
23  std::string m_strItem;
24  int m_indexItem{-1};
25  };
26 
28  {
29  public:
30  CPathHistoryItem() = default;
31  virtual ~CPathHistoryItem() = default;
32 
33  const std::string& GetPath(bool filter = false) const;
34 
35  std::string m_strPath;
36  std::string m_strFilterPath;
37  };
38 
39  CDirectoryHistory() = default;
40  virtual ~CDirectoryHistory();
41 
49  void SetSelectedItem(const std::string& strSelectedItem,
50  const std::string& strDirectory,
51  const int indexItem = -1);
52  const std::string& GetSelectedItem(const std::string& strDirectory) const;
53  int GetSelectedItemIndex(const std::string& strDirectory) const;
54  void RemoveSelectedItem(const std::string& strDirectory);
55 
56  void AddPath(const std::string& strPath, const std::string &m_strFilterPath = "");
57  void AddPathFront(const std::string& strPath, const std::string &m_strFilterPath = "");
58  std::string GetParentPath(bool filter = false);
59  std::string RemoveParentPath(bool filter = false);
60  void ClearPathHistory();
61  void ClearSearchHistory();
62  void DumpPathHistory();
63 
68  bool IsInHistory(const std::string &path) const;
69 
70 private:
71  static std::string preparePath(const std::string &strDirectory, bool tolower = true);
72 
73  typedef std::map<std::string, CHistoryItem> HistoryMap;
74  HistoryMap m_vecHistory;
75  std::vector<CPathHistoryItem> m_vecPathHistory;
76  static bool IsMusicSearchUrl(CPathHistoryItem &i);
77 };
Definition: DirectoryHistory.h:27
void SetSelectedItem(const std::string &strSelectedItem, const std::string &strDirectory, const int indexItem=-1)
Store the currently selected item for the navigation path.
Definition: DirectoryHistory.cpp:38
bool IsInHistory(const std::string &path) const
Returns whether a path is in the history.
Definition: DirectoryHistory.cpp:111
Definition: DirectoryHistory.h:15
Definition: DirectoryHistory.h:18