Debian Codegraph @

plugins/dm.gui/XDataSelector.h

raw
1 #pragma once
2
3 #include "XDataLoader.h"
4 #include "wxutil/Icon.h"
5 #include "wxutil/dialog/DialogBase.h"
6 #include "wxutil/dataview/VFSTreePopulator.h"
7 #include "wxutil/dataview/TreeView.h"
8
9 namespace ui
10 {
11
12 class ReadableEditorDialog;
13
14 ///////////////////////////// XDataSelector:
15 // Runs a dialog for choosing XData definitions, which updates the guiView of the calling
16 // ReadableEditorDialog for previewing.
17 class XDataSelector :
18 public wxutil::DialogBase,
19 public wxutil::VFSTreePopulator::Visitor
20 {
21 private:
22 // Treestore enum
23 struct XdataTreeModelColumns :
24 public wxutil::TreeModel::ColumnRecord
25 {
26 XdataTreeModelColumns() :
27 name(add(wxutil::TreeModel::Column::IconText)),
28 fullName(add(wxutil::TreeModel::Column::String)),
29 isFolder(add(wxutil::TreeModel::Column::Boolean))
30 {}
31
32 wxutil::TreeModel::Column name;
33 wxutil::TreeModel::Column fullName;
34 wxutil::TreeModel::Column isFolder;
35 };
36
37 // The tree
38 XdataTreeModelColumns _columns;
39 wxutil::TreeModel::Ptr _store;
40 wxutil::TreeView* _view;
41
42 // A Map of XData files. Basically just the keyvalues are needed.
43 XData::StringVectorMap _files;
44
45 // The name of the chosen definition
46 std::string _selection;
47
48 // Pointer to the ReadableEditorDialog for updating the guiView.
49 ReadableEditorDialog* _editorDialog;
50
51 wxutil::Icon _xdataIcon;
52 wxutil::Icon _folderIcon;
53
54 public:
55 // Runs the dialog and returns the name of the chosen definition.
56 static std::string run(const XData::StringVectorMap& files, ReadableEditorDialog* editorDialog);
57
58 void visit(wxutil::TreeModel& store, wxutil::TreeModel::Row& row,
59 const std::string& path, bool isExplicit);
60
61 private:
62 // private contructor called by the run method.
63 XDataSelector(const XData::StringVectorMap& files, ReadableEditorDialog* editorDialog);
64
65 void fillTree();
66
67 void onSelectionChanged(wxDataViewEvent& ev); // view is manually bound
68 };
69
70 } //namespace ui