Debian Codegraph @

radiant/ui/filters/editor/FilterDialog.h

raw
1 #pragma once
2
3 #include "icommandsystem.h"
4 #include "wxutil/dialog/DialogBase.h"
5 #include <map>
6 #include "Filter.h"
7 #include "wxutil/dataview/TreeView.h"
8 #include "wxutil/XmlResourceBasedWidget.h"
9
10 class wxButton;
11
12 namespace ui
13 {
14
15 class FilterDialog :
16 public wxutil::DialogBase,
17 private wxutil::XmlResourceBasedWidget
18 {
19 private:
20 // Treemodel definition
21 struct TreeColumns :
22 public wxutil::TreeModel::ColumnRecord
23 {
24 TreeColumns() :
25 name(add(wxutil::TreeModel::Column::String)),
26 state(add(wxutil::TreeModel::Column::String)),
27 readonly(add(wxutil::TreeModel::Column::Boolean))
28 {}
29
30 wxutil::TreeModel::Column name;
31 wxutil::TreeModel::Column state;
32 wxutil::TreeModel::Column readonly;
33 };
34
35 TreeColumns _columns;
36
37 wxutil::TreeModel::Ptr _filterStore;
38
39 // The treeview listing all the filters
40 wxutil::TreeView* _filterView;
41
42 // Holds the name of the currently selected filter (or "" if none selected)
43 std::string _selectedFilter;
44
45 typedef std::map<int, wxButton*> ButtonMap;
46 ButtonMap _buttons;
47
48 // The current working set, indexed by name
49 typedef std::map<std::string, FilterPtr> FilterMap;
50 FilterMap _filters;
51
52 // The deleted filters, the actual deletion happens in the save() method
53 FilterMap _deletedFilters;
54
55 // Private constructor
56 FilterDialog();
57
58 public:
59 /**
60 * greebo: Shows the dialog (command target)
61 */
62 static void ShowDialog(const cmd::ArgumentList& args);
63
64 private:
65 // Saves filter settings and exits
66 void save();
67
68 // Reload filter settings and fill widges
69 void update();
70
71 // Loads the filters from the filtersystem (happens at dialog construction)
72 void loadFilters();
73
74 // This is called to create the widgets
75 void populateWindow();
76 void createFiltersPanel();
77
78 // Update buttons
79 void updateWidgetSensitivity();
80
81 // callbacks
82 void onSave(wxCommandEvent& ev);
83 void onCancel(wxCommandEvent& ev);
84
85 void onAddFilter(wxCommandEvent& ev);
86 void onEditFilter(wxCommandEvent& ev);
87 void onViewFilter(wxCommandEvent& ev);
88 void onDeleteFilter(wxCommandEvent& ev);
89 void onCopyFilter(wxCommandEvent& ev);
90
91 void showEditDialogForNewFilter(const FilterPtr& filter);
92
93 void onFilterSelectionChanged(wxDataViewEvent& ev);
94 };
95
96 } // namespace ui