1 #pragma once 2 3 #include <QtCore/QObject> 4 5 #include <mission/EditorViewport.h> 6 7 #include "AbstractDialogModel.h" 8 9 namespace fso { 10 namespace fred { 11 namespace dialogs { 12 13 class SelectionDialogModel : public AbstractDialogModel { 14 Q_OBJECT 15 public: 16 struct ListEntry { 17 SCP_string name; 18 int id = -1; 19 bool selected = false; 20 }; 21 22 private: 23 void initializeData(); 24 25 void updateObjectList(); 26 27 void updateWingListSelection(); 28 29 void updateShipListSelection(); 30 31 void updateStatus(bool first_time); 32 33 SCP_vector<ListEntry> _obj_list; 34 35 SCP_vector<ListEntry> _wing_list; 36 37 SCP_vector<ListEntry> _waypoint_list; 38 39 bool _filter_ships = true; 40 bool _filter_starts = true; 41 bool _filter_waypoints = true; 42 std::array<bool, MAX_IFFS> _filter_iff; 43 44 public: 45 bool apply() override; 46 void reject() override; 47 48 signals: 49 void selectionUpdated(); 50 51 public: 52 SelectionDialogModel(QObject* parent, EditorViewport* viewport); 53 54 void clearSelection(); 55 56 void selectAll(); 57 58 void invertSelection(); 59 60 const SCP_vector<ListEntry>& getObjectList() const; 61 62 const SCP_vector<ListEntry>& getWingList() const; 63 64 const SCP_vector<ListEntry>& getWaypointList() const; 65 66 bool isFilterShips() const; 67 void setFilterShips(bool filter_ships); 68 69 bool isFilterStarts() const; 70 void setFilterStarts(bool filter_starts); 71 72 bool isFilterWaypoints() const; 73 void setFilterWaypoints(bool filter_waypoints); 74 75 bool isFilterIFFTeam(int team) const; 76 void setFilterIFFTeam(int team, bool filter); 77 78 /** 79 * @brief Updates the selection status of the objects in the list 80 * 81 * The list must be the same as returned by getObjectList with only the selection status changed. 82 * 83 * @param newSelection The new selection list 84 */ 85 void updateObjectSelection(const SCP_vector<ListEntry>& newSelection); 86 87 void selectWing(int wing_id); 88 89 void selectWaypointPath(int wp_id); 90 }; 91 92 } 93 } 94 } 95 96 97