1 #ifndef FILEZILLA_INTERFACE_LOCALLISTVIEW_HEADER
2 #define FILEZILLA_INTERFACE_LOCALLISTVIEW_HEADER
3 
4 #include "filelistctrl.h"
5 #include "state.h"
6 
7 class CInfoText;
8 class CQueueView;
9 class CLocalListViewDropTarget;
10 #ifdef __WXMSW__
11 class CVolumeDescriptionEnumeratorThread;
12 #endif
13 class CView;
14 class CWindowTinter;
15 
16 class CLocalFileData final : public CGenericFileData
17 {
18 public:
19 	std::wstring name;
20 #ifdef __WXMSW__
21 	fz::sparse_optional<std::wstring> label;
22 #endif
23 	fz::datetime time;
24 	int64_t size;
25 	int attributes;
26 	bool dir;
is_dir()27 	bool is_dir() const { return dir; }
28 };
29 
30 class CLocalListView final : public CFileListCtrl<CLocalFileData>, CStateEventHandler
31 {
32 	friend class CLocalListViewDropTarget;
33 	friend class CLocalListViewSortType;
34 
35 public:
36 	CLocalListView(CView* parent, CState& state, CQueueView *pQueue);
37 	virtual ~CLocalListView();
38 
39 protected:
40 	void OnStateChange(t_statechange_notifications notification, std::wstring const& data, const void*) override;
41 	bool DisplayDir(CLocalPath const& dirname);
42 	void ApplyCurrentFilter();
43 
44 	// Declared const due to design error in wxWidgets.
45 	// Won't be fixed since a fix would break backwards compatibility
46 	// Both functions use a const_cast<CLocalListView *>(this) and modify
47 	// the instance.
48 	virtual int OnGetItemImage(long item) const;
49 	virtual wxListItemAttr* OnGetItemAttr(long item) const;
50 
51 	// Clears all selections and returns the list of items that were selected
52 	std::vector<std::wstring> RememberSelectedItems(std::wstring & focused, int & focusedItem);
53 
54 	// Select a list of items based in their names.
55 	// Sort order may not change between call to RememberSelectedItems and
56 	// ReselectItems
57 	void ReselectItems(std::vector<std::wstring> const& selectedNames, std::wstring focused, int focusedItem, bool ensureVisible = false);
58 
59 #ifdef __WXMSW__
60 	void DisplayDrives();
61 	void DisplayShares(wxString computer);
62 #endif
63 
64 public:
65 	virtual bool CanStartComparison();
66 	virtual void StartComparison();
67 	virtual bool get_next_file(std::wstring_view & name, std::wstring & path, bool &dir, int64_t &size, fz::datetime& date) override;
68 	virtual void FinishComparison();
69 
70 	virtual bool ItemIsDir(int index) const;
71 	virtual int64_t ItemGetSize(int index) const;
72 
73 protected:
74 	virtual wxString GetItemText(int item, unsigned int column);
75 
76 	bool IsItemValid(unsigned int item) const;
77 	CLocalFileData *GetData(unsigned int item);
78 
79 	virtual std::unique_ptr<CFileListCtrlSortBase> GetSortComparisonObject() override;
80 
81 	void RefreshFile(std::wstring const& file);
82 
83 	virtual void OnNavigationEvent(bool forward);
84 
85 	virtual bool OnBeginRename(const wxListEvent& event);
86 	virtual bool OnAcceptRename(const wxListEvent& event);
87 
88 	CLocalPath m_dir;
89 
90 	int m_dropTarget{-1};
91 
92 	wxString MenuMkdir();
93 
94 	std::unique_ptr<CWindowTinter> m_windowTinter;
95 
96 	CView *m_parentView{};
97 
98 	CInfoText* m_pInfoText{};
99 	void SetInfoText(wxString const& text);
100 
101 	// Event handlers
102 	DECLARE_EVENT_TABLE()
103 	void OnItemActivated(wxListEvent& event);
104 	void OnContextMenu(wxContextMenuEvent& event);
105 	void OnMenuUpload(wxCommandEvent& event);
106 	void OnMenuMkdir(wxCommandEvent& event);
107 	void OnMenuMkdirChgDir(wxCommandEvent&);
108 	void OnMenuDelete(wxCommandEvent& event);
109 	void OnMenuRename(wxCommandEvent& event);
110 	void OnKeyDown(wxKeyEvent& event);
111 	void OnSize(wxSizeEvent& event);
112 	void OnBeginDrag(wxListEvent& event);
113 	void OnMenuOpen(wxCommandEvent& event);
114 	void OnMenuEdit(wxCommandEvent& event);
115 	void OnMenuEnter(wxCommandEvent& event);
116 	void OnMenuRefresh(wxCommandEvent& event);
117 
118 #ifdef __WXMSW__
119 	void OnVolumesEnumerated(wxCommandEvent& event);
120 	std::unique_ptr<CVolumeDescriptionEnumeratorThread> volumeEnumeratorThread_;
121 #endif
122 };
123 
124 #endif
125