Freeciv21
Develop your civilization from humble roots to a global empire
req_vec_fix.h
Go to the documentation of this file.
1 /**************************************************************************
2  Copyright (c) 1996-2020 Freeciv21 and Freeciv contributors. This file is
3  __ __ part of Freeciv21. Freeciv21 is free software: you can
4 / \\..// \ redistribute it and/or modify it under the terms of the GNU
5  ( oo ) General Public License as published by the Free Software
6  \__/ Foundation, either version 3 of the License, or (at your
7  option) any later version. You should have received
8  a copy of the GNU General Public License along with Freeciv21. If not,
9  see https://www.gnu.org/licenses/.
10 **************************************************************************/
11 
12 #ifndef FC__REQ_VEC_FIX_H
13 #define FC__REQ_VEC_FIX_H
14 
15 #include <fc_config.h>
16 
17 // Qt
18 #include <QWidget>
19 
20 // common
21 #include "requirements.h"
22 
23 class QButtonGroup;
24 class QListWidgetItem;
25 class QPushButton;
26 class QStackedLayout;
27 
28 class ruledit_gui;
29 
30 // How serious a req_vec_problem is considered
35 };
36 
37 void mark_item(QListWidgetItem *item,
38  enum req_vec_problem_seriousness problem_level);
39 
45 public:
46  /********************************************************************/
49  virtual void close() = 0;
50 
51  /********************************************************************/
55  virtual const void *item() = 0;
56 
57  /********************************************************************/
61  virtual void *item_working_copy() = 0;
62 
63  /********************************************************************/
69  virtual const char *name() = 0;
70 
71  /********************************************************************/
76  virtual struct req_vec_problem *find_next_problem() = 0;
77 
78  /********************************************************************/
84  virtual void apply_accepted_changes() = 0;
85 
86  /********************************************************************/
91  virtual void undo_accepted_changes() = 0;
92 
93  /********************************************************************/
97  virtual int num_vectors() = 0;
98 
99  /********************************************************************/
106 
107  /********************************************************************/
114 
115  /********************************************************************/
120  virtual bool vector_in_item(const struct requirement_vector *vec) = 0;
121 };
122 
126 class req_vec_fix_problem : public QWidget {
127  Q_OBJECT
128 
129 public:
130  explicit req_vec_fix_problem(const struct req_vec_problem *problem,
131  req_vec_fix_item *item_info);
132 
133 private:
134  QButtonGroup *solutions;
135 
136 signals:
137  void solution_accepted(int selected_solution);
138 
139 private slots:
140  void accept_solution();
141 };
142 
146 class req_vec_fix : public QWidget {
147  Q_OBJECT
148 
149 public:
151  ~req_vec_fix() override;
152 
153  const void *item();
154 
155  bool refresh();
156 
157 signals:
158  /********************************************************************/
162  void rec_vec_may_have_changed(const requirement_vector *vec);
163 
164 private:
168 
170 
172  QStackedLayout *current_problem_area;
173  QPushButton *apply_changes, *abort, *close;
174 
175 private slots:
176  void apply_solution(int selected_solution);
179 
180  void incoming_rec_vec_change(const requirement_vector *vec);
181 };
182 
183 #endif // FC__REQ_VEC_FIX_H
Ruleset entity specific methods for the ruleset item having its requirements fixed.
Definition: req_vec_fix.h:44
virtual requirement_vector_by_number vector_getter()=0
Returns a function pointer to a function that returns a writable pointer to the specified requirement...
virtual requirement_vector_namer vector_namer()=0
Returns a function pointer to a function that names this item kind's requirement vector number number...
virtual void close()=0
Tell the helper that it has outlived its usefulness.
virtual void * item_working_copy()=0
Returns a pointer to the working copy of the ruleset item.
virtual void undo_accepted_changes()=0
Undo all the changes the user has accepted to the ruleset item.
virtual const void * item()=0
Returns a pointer to the ruleset item.
virtual void apply_accepted_changes()=0
Do all the changes the user has accepted to the ruleset item.
virtual bool vector_in_item(const struct requirement_vector *vec)=0
Check if the specified vector belongs to this item.
virtual int num_vectors()=0
Returns the number of requirement vectors in this item.
virtual const char * name()=0
Returns a name to describe the item, hopefully good enough to distinguish it from other items.
virtual struct req_vec_problem * find_next_problem()=0
Returns the next detected requirement vector problem for the ruleset item or nullptr if no fix is fou...
Widget for choosing among the suggested solutions to a problem.
Definition: req_vec_fix.h:126
req_vec_fix_problem(const struct req_vec_problem *problem, req_vec_fix_item *item_info)
Set up the display and solution choice of the specified problem.
Definition: req_vec_fix.cpp:54
void solution_accepted(int selected_solution)
QButtonGroup * solutions
Definition: req_vec_fix.h:134
void accept_solution()
The user selected one of the suggested solutions to the requirement vector problem.
Widget for solving requirement vector problems for a ruleset item.
Definition: req_vec_fix.h:146
struct req_vec_problem * current_problem
Definition: req_vec_fix.h:165
QPushButton * close
Definition: req_vec_fix.h:173
void rec_vec_may_have_changed(const requirement_vector *vec)
A requirement vector may have been changed.
bool refresh()
Find the next requirement vector problem and its suggested solutions.
const void * item()
Returns the item this dialog is trying to fix.
void accept_applied_solutions()
Do all the accepted solutions for real.
req_vec_fix_problem * current_problem_viewer
Definition: req_vec_fix.h:171
void incoming_rec_vec_change(const requirement_vector *vec)
A requirement vector may have been changed.
QPushButton * abort
Definition: req_vec_fix.h:173
QStackedLayout * current_problem_area
Definition: req_vec_fix.h:172
void reject_applied_solutions()
Undo all accepted solutions.
ruledit_gui * ui
Definition: req_vec_fix.h:169
~req_vec_fix() override
Destructor for req_vec_fix.
void apply_solution(int selected_solution)
Apply the selected solution to the current requirement vector problem.
req_vec_fix(ruledit_gui *ui_in, req_vec_fix_item *item_info)
Set up a widget for displaying and fixing requirement vector problems for a specific ruleset entity i...
req_vec_fix_item * item_info
Definition: req_vec_fix.h:166
bool did_apply_a_solution
Definition: req_vec_fix.h:167
QPushButton * apply_changes
Definition: req_vec_fix.h:173
req_vec_problem_seriousness
Definition: req_vec_fix.h:31
@ RVPS_NO_PROBLEM
Definition: req_vec_fix.h:32
@ RVPS_REPAIR
Definition: req_vec_fix.h:34
@ RVPS_IMPROVE
Definition: req_vec_fix.h:33
void mark_item(QListWidgetItem *item, enum req_vec_problem_seriousness problem_level)
Mark a ruleset item in a list as having a problem.
Definition: req_vec_fix.cpp:32
struct requirement_vector *(* requirement_vector_by_number)(const void *parent_item, req_vec_num_in_item number)
Returns a writable pointer to the specified requirement vector in the specified parent item or nullpt...
Definition: requirements.h:164
const char *(* requirement_vector_namer)(req_vec_num_in_item number)
Returns the name of the specified requirement vector number in the parent item or nullptr if parent i...
Definition: requirements.h:174
Definition: climisc.h:66