1 #pragma once 2 3 #include "IView.h" 4 5 #include <string> 6 #include <vector> 7 #include <deque> 8 #include <set> 9 10 #include <scx/Signal.h> 11 12 class ExplorerView: public IView 13 { 14 public: 15 ExplorerView(); 16 ~ExplorerView(); 17 18 void Refresh(); 19 void MoveTo(int x, int y); 20 void Resize(int w, int h); 21 22 bool InjectKey(int key); 23 24 void Show(bool show); 25 bool IsShown() const; 26 27 void SetFocus(bool focus); 28 bool HasFocus() const; 29 30 public: 31 scx::Signal<void (const std::string&)> SigTmpOpen; 32 scx::Signal<void (const std::string&)> SigUserOpen; 33 34 void AddSuffixes(const std::vector<std::string>&); 35 36 private: 37 void BuildFileItems(); 38 void CdUp(); 39 void CdIn(); 40 void ScrollUp(); 41 void ScrollDown(); 42 43 private: 44 struct FileItem 45 { 46 std::string name; 47 bool isDir; 48 off_t size; 49 mutable bool cacheOk; 50 mutable std::string nameCache; 51 mutable std::string sizeCache; 52 }; 53 54 private: 55 Window d; 56 bool m_Focused = false; 57 std::string m_Path; 58 std::string m_PathCache; 59 bool m_HideDot = true; 60 bool m_HideUnknown = false; 61 std::deque<int> m_BeginStack; 62 std::deque<int> m_SelectionStack; 63 std::vector<FileItem> m_FileItems; 64 std::set<std::string> m_Suffixes; 65 }; 66 67