source: filezilla/trunk/fuentes/src/interface/filter.h @ 130

Last change on this file since 130 was 130, checked in by jrpelegrina, 3 years ago

First release to xenial

File size: 3.3 KB
Line 
1#ifndef __FILTER_H__
2#define __FILTER_H__
3
4#include "dialogex.h"
5#include <wx/regex.h>
6
7#include <memory>
8
9enum t_filterType
10{
11        filter_name = 0x01,
12        filter_size = 0x02,
13        filter_attributes = 0x04,
14        filter_permissions = 0x08,
15        filter_path = 0x10,
16        filter_date = 0x20,
17        filter_time = 0x40,
18#ifdef __WXMSW__
19        filter_meta = filter_attributes,
20        filter_foreign = filter_permissions,
21#else
22        filter_meta = filter_permissions,
23        filter_foreign = filter_attributes
24#endif
25};
26
27class CFilterCondition
28{
29public:
30        CFilterCondition();
31
32        enum t_filterType type;
33        int condition;
34
35        wxString strValue; // All other types
36        int64_t value; // If type is size
37        CDateTime date; // If type is date
38        bool matchCase;
39        std::shared_ptr<wxRegEx> pRegEx;
40};
41
42class CFilter
43{
44public:
45        enum t_matchType
46        {
47                all,
48                any,
49                none
50        };
51
52        CFilter();
53
54        wxString name;
55
56        bool filterFiles;
57        bool filterDirs;
58        enum t_matchType matchType;
59        bool matchCase;
60
61        std::vector<CFilterCondition> filters;
62
63        bool HasConditionOfType(enum t_filterType type) const;
64        bool IsLocalFilter() const;
65};
66
67class CFilterSet
68{
69public:
70        wxString name;
71        std::vector<bool> local;
72        std::vector<bool> remote;
73};
74
75namespace pugi { class xml_node; }
76class CFilterManager
77{
78public:
79        CFilterManager();
80        virtual ~CFilterManager() {}
81
82        // Note: Under non-windows, attributes are permissions
83        bool FilenameFiltered(const wxString& name, const wxString& path, bool dir, int64_t size, bool local, int attributes, CDateTime const& date) const;
84        bool FilenameFiltered(std::vector<CFilter> const& filters, const wxString& name, const wxString& path, bool dir, int64_t size, bool local, int attributes, CDateTime const& date) const;
85        static bool FilenameFilteredByFilter(const CFilter& filter, const wxString& name, const wxString& path, bool dir, int64_t size, int attributes, CDateTime const& date);
86        static bool HasActiveFilters(bool ignore_disabled = false);
87
88        bool HasSameLocalAndRemoteFilters() const;
89
90        static void ToggleFilters();
91
92        std::vector<CFilter> GetActiveFilters(bool local);
93
94        static bool CompileRegexes(CFilter& filter);
95
96        static bool LoadFilter(pugi::xml_node& element, CFilter& filter);
97
98protected:
99        static bool CompileRegexes();
100
101        static void LoadFilters();
102        static bool m_loaded;
103
104        static std::vector<CFilter> m_globalFilters;
105
106        static std::vector<CFilterSet> m_globalFilterSets;
107        static unsigned int m_globalCurrentFilterSet;
108
109        static bool m_filters_disabled;
110};
111
112class CMainFrame;
113class CFilterDialog : public wxDialogEx, public CFilterManager
114{
115public:
116        CFilterDialog();
117        virtual ~CFilterDialog() {}
118
119        bool Create(CMainFrame* parent);
120
121        static void SaveFilter(pugi::xml_node& element, const CFilter& filter);
122
123protected:
124
125        void SaveFilters();
126
127        void DisplayFilters();
128
129        void SetCtrlState();
130
131        DECLARE_EVENT_TABLE()
132        void OnOkOrApply(wxCommandEvent& event);
133        void OnCancel(wxCommandEvent& event);
134        void OnEdit(wxCommandEvent& event);
135        void OnFilterSelect(wxCommandEvent& event);
136        void OnMouseEvent(wxMouseEvent& event);
137        void OnKeyEvent(wxKeyEvent& event);
138        void OnSaveAs(wxCommandEvent& event);
139        void OnRename(wxCommandEvent& event);
140        void OnDeleteSet(wxCommandEvent& event);
141        void OnSetSelect(wxCommandEvent& event);
142
143        void OnChangeAll(wxCommandEvent& event);
144
145        bool m_shiftClick;
146
147        CMainFrame* m_pMainFrame;
148
149        std::vector<CFilter> m_filters;
150        std::vector<CFilterSet> m_filterSets;
151        unsigned int m_currentFilterSet;
152};
153
154#endif //__FILTER_H__
Note: See TracBrowser for help on using the repository browser.