13 #include <QButtonGroup>
14 #include <QHBoxLayout>
16 #include <QListWidgetItem>
17 #include <QMessageBox>
18 #include <QPushButton>
19 #include <QRadioButton>
20 #include <QStackedLayout>
35 QWidget *in =
item->listWidget();
36 switch (problem_level) {
38 item->setIcon(QIcon());
41 item->setIcon(in->style()->standardIcon(QStyle::SP_MessageBoxWarning));
44 item->setIcon(in->style()->standardIcon(QStyle::SP_MessageBoxCritical));
56 : QWidget(), solutions(nullptr)
62 QVBoxLayout *layout_main =
new QVBoxLayout();
67 description =
new QLabel();
68 layout_main->addWidget(description);
70 if (problem ==
nullptr) {
75 description->setText(
R__(
"No problem found"));
76 this->setLayout(layout_main);
88 R__(
"Don't know how to fix %s: %s"), item_info->
name(),
91 description->setText(buf);
92 this->setLayout(layout_main);
109 solution->setChecked(i == 0);
111 layout_main->addWidget(solution);
115 accept =
new QPushButton(
R__(
"Accept selected solution"));
116 connect(accept, &QAbstractButton::pressed,
this,
118 layout_main->addWidget(accept);
120 this->setLayout(layout_main);
142 QVBoxLayout *layout_main =
new QVBoxLayout();
143 QHBoxLayout *layout_buttons =
new QHBoxLayout();
154 this->setWindowTitle(
R__(
"Requirement problem"));
155 this->setAttribute(Qt::WA_DeleteOnClose);
164 abort =
new QPushButton(
R__(
"Undo all"));
167 abort->setToolTip(
R__(
"Undo all accepted solutions since you started or"
168 " since last time you ordered all accepted changes"
170 connect(
abort, &QAbstractButton::pressed,
this,
172 layout_buttons->addWidget(
abort);
180 " to the ruleset item. You can then fix the"
181 " current issue by hand and come back here"
182 " to find the next issue."));
187 close =
new QPushButton(
R__(
"Close"));
188 connect(
close, &QAbstractButton::pressed,
this, &QWidget::close);
189 layout_buttons->addWidget(
close);
191 layout_main->addLayout(layout_buttons);
193 this->setLayout(layout_main);
270 QMessageBox *box =
new QMessageBox();
272 box->setWindowTitle(
R__(
"Unable to apply solution"));
276 QString(
R__(
"Failed to apply solution %1 for %2 to %3."))
280 box->setStandardButtons(QMessageBox::Ok);
Ruleset entity specific methods for the ruleset item having its requirements fixed.
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.
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.
void solution_accepted(int selected_solution)
void accept_solution()
The user selected one of the suggested solutions to the requirement vector problem.
struct req_vec_problem * current_problem
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
void incoming_rec_vec_change(const requirement_vector *vec)
A requirement vector may have been changed.
QStackedLayout * current_problem_area
void reject_applied_solutions()
Undo all accepted solutions.
~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
bool did_apply_a_solution
QPushButton * apply_changes
void rec_vec_may_have_changed(const requirement_vector *vec)
A requirement vector may have been changed.
void unregister_req_vec_fix(req_vec_fix *fixer)
Unregister closed req_vec_fix dialog.
#define fc_assert_ret(condition)
void mark_item(QListWidgetItem *item, enum req_vec_problem_seriousness problem_level)
Mark a ruleset item in a list as having a problem.
req_vec_problem_seriousness
bool req_vec_change_apply(const struct req_vec_change *modification, requirement_vector_by_number getter, const void *parent_item)
Returns TRUE iff the specified requirement vector modification was successfully applied to the specif...
void req_vec_problem_free(struct req_vec_problem *issue)
De-allocates resources associated with the given requirement vector problem.
const char * req_vec_change_translation(const struct req_vec_change *change, const requirement_vector_namer namer)
Returns the specified requirement vector change as a translated string ready for use in the user inte...
int num_suggested_solutions
char description_translated[500]
struct req_vec_change * suggested_solutions
int fc_snprintf(char *str, size_t n, const char *format,...)
See also fc_utf8_snprintf_trunc(), fc_utf8_snprintf_rep().