xbmc
GUIWindowFileManager.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 "filesystem/DirectoryHistory.h"
12 #include "filesystem/VirtualDirectory.h"
13 #include "guilib/GUIWindow.h"
14 #include "utils/JobManager.h"
15 
16 #include <atomic>
17 #include <string>
18 #include <vector>
19 
20 class CFileItem;
21 class CFileItemList;
22 class CGUIDialogProgress;
23 
25  public CGUIWindow,
26  public CJobQueue
27 {
28 public:
29 
31  ~CGUIWindowFileManager(void) override;
32  bool OnMessage(CGUIMessage& message) override;
33  bool OnAction(const CAction &action) override;
34  bool OnBack(int actionID) override;
35  const CFileItem &CurrentDirectory(int indx) const;
36 
37  static int64_t CalculateFolderSize(const std::string &strDirectory, CGUIDialogProgress *pProgress = NULL);
38 
39  void OnJobComplete(unsigned int jobID, bool success, CJob *job) override;
40 protected:
41  void OnInitWindow() override;
42  void SetInitialPath(const std::string &path);
43  void GoParentFolder(int iList);
44  void UpdateControl(int iList, int item);
45  bool Update(int iList, const std::string &strDirectory); //???
46  void OnStart(CFileItem *pItem, const std::string &player);
47  bool SelectItem(int iList, int &item);
48  void ClearFileItems(int iList);
49  void OnClick(int iList, int iItem);
50  void OnMark(int iList, int iItem);
51  void OnSort(int iList);
52  void UpdateButtons();
53  void OnCopy(int iList);
54  void OnMove(int iList);
55  void OnDelete(int iList);
56  void OnRename(int iList);
57  void OnSelectAll(int iList);
58  void OnNewFolder(int iList);
59  void Refresh();
60  void Refresh(int iList);
61  int GetSelectedItem(int iList);
62  bool HaveDiscOrConnection( std::string& strPath, int iDriveType );
63  void GetDirectoryHistoryString(const CFileItem* pItem, std::string& strHistoryString);
64  bool GetDirectory(int iList, const std::string &strDirectory, CFileItemList &items);
65  int NumSelected(int iList);
66  int GetFocusedList() const;
67  // functions to check for actions that we can perform
68  bool CanRename(int iList);
69  bool CanCopy(int iList);
70  bool CanMove(int iList);
71  bool CanDelete(int iList);
72  bool CanNewFolder(int iList);
73  void OnPopupMenu(int iList, int iItem, bool bContextDriven = true);
74  void ShowShareErrorMessage(CFileItem* pItem);
75  void UpdateItemCounts();
76 
77  //
78  bool bCheckShareConnectivity;
79  std::string strCheckSharePath;
80 
81  XFILE::CVirtualDirectory m_rootDir;
82  CFileItemList* m_vecItems[2];
83  typedef std::vector <CFileItem*> ::iterator ivecItems;
84  CFileItem* m_Directory[2];
85  std::string m_strParentPath[2];
86  CDirectoryHistory m_history[2];
87 
88  int m_errorHeading, m_errorLine;
89 private:
90  std::atomic_bool m_updating = {false};
91  class CUpdateGuard
92  {
93  public:
94  CUpdateGuard(std::atomic_bool &update) : m_update(update)
95  {
96  m_update = true;
97  }
98  ~CUpdateGuard()
99  {
100  m_update = false;
101  }
102  private:
103  std::atomic_bool &m_update;
104  };
105 };
Base class for jobs that are executed asynchronously.
Definition: Job.h:109
void GetDirectoryHistoryString(const CFileItem *pItem, std::string &strHistoryString)
Build a directory history string.
Definition: GUIWindowFileManager.cpp:890
Represents a list of files.
Definition: FileItem.h:721
void OnInitWindow() override
Called on window open.
Definition: GUIWindowFileManager.cpp:1244
bool HaveDiscOrConnection(std::string &strPath, int iDriveType)
Definition: GUIWindowFileManager.cpp:695
void OnJobComplete(unsigned int jobID, bool success, CJob *job) override
The callback used when a job completes.
Definition: GUIWindowFileManager.cpp:1211
bool CanRename(int iList)
Definition: GUIWindowFileManager.cpp:943
void OnStart(CFileItem *pItem, const std::string &player)
Definition: GUIWindowFileManager.cpp:638
class encapsulating information regarding a particular user action to be sent to windows and controls...
Definition: Action.h:22
Get access to shares and it&#39;s directories.
Definition: VirtualDirectory.h:24
Definition: GUIMessage.h:365
void OnPopupMenu(int iList, int iItem, bool bContextDriven=true)
Definition: GUIWindowFileManager.cpp:1003
Definition: GUIWindow.h:58
Definition: GUIWindowFileManager.h:24
Definition: GUIDialogProgress.h:16
Definition: DirectoryHistory.h:15
bool CanCopy(int iList)
Definition: GUIWindowFileManager.cpp:953
Represents a file on a share.
Definition: FileItem.h:102
Job Queue class to handle a queue of unique jobs to be processed sequentially.
Definition: JobManager.h:63