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 15 class CDirectoryHistory 16 { 17 public: 18 class CHistoryItem 19 { 20 public: 21 CHistoryItem() = default; 22 virtual ~CHistoryItem() = default; 23 std::string m_strItem; 24 std::string m_strDirectory; 25 }; 26 27 class CPathHistoryItem 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 42 void SetSelectedItem(const std::string& strSelectedItem, const std::string& strDirectory); 43 const std::string& GetSelectedItem(const std::string& strDirectory) const; 44 void RemoveSelectedItem(const std::string& strDirectory); 45 46 void AddPath(const std::string& strPath, const std::string &m_strFilterPath = ""); 47 void AddPathFront(const std::string& strPath, const std::string &m_strFilterPath = ""); 48 std::string GetParentPath(bool filter = false); 49 std::string RemoveParentPath(bool filter = false); 50 void ClearPathHistory(); 51 void ClearSearchHistory(); 52 void DumpPathHistory(); 53 54 /*! \brief Returns whether a path is in the history. 55 \param path to test 56 \return true if the path is in the history, false otherwise. 57 */ 58 bool IsInHistory(const std::string &path) const; 59 60 private: 61 static std::string preparePath(const std::string &strDirectory, bool tolower = true); 62 63 typedef std::map<std::string, CHistoryItem> HistoryMap; 64 HistoryMap m_vecHistory; 65 std::vector<CPathHistoryItem> m_vecPathHistory; ///< History of traversed directories 66 static bool IsMusicSearchUrl(CPathHistoryItem &i); 67 }; 68