15 #include <QGridLayout>
17 #include <QListWidget>
19 #include <QMessageBox>
20 #include <QPushButton>
21 #include <QToolButton>
40 void close()
override;
42 const void *
item()
override;
44 const char *
name()
override;
51 bool vector_in_item(
const struct requirement_vector *vec)
override;
69 if (problem !=
nullptr) {
75 if (problem !=
nullptr) {
88 QVBoxLayout *main_layout =
new QVBoxLayout(
this);
89 QGridLayout *enabler_layout =
new QGridLayout();
91 QPushButton *add_button;
101 connect(
enabler_list, &QListWidget::itemSelectionChanged,
this,
105 enabler_layout->setSizeConstraint(QLayout::SetMaximumSize);
107 label =
new QLabel(QString::fromUtf8(
R__(
"Type")));
108 label->setParent(
this);
109 enabler_layout->addWidget(label, 0, 0);
119 type_button->setToolButtonStyle(Qt::ToolButtonTextOnly);
120 type_button->setPopupMode(QToolButton::MenuButtonPopup);
128 new QPushButton(QString::fromUtf8(
R__(
"Actor Requirements")),
this);
135 new QPushButton(QString::fromUtf8(
R__(
"Target Requirements")),
this);
141 add_button =
new QPushButton(QString::fromUtf8(
R__(
"Add Enabler")),
this);
142 connect(add_button, &QAbstractButton::pressed,
this,
144 enabler_layout->addWidget(add_button, 3, 0);
148 new QPushButton(QString::fromUtf8(
R__(
"Remove this Enabler")),
this);
163 main_layout->addLayout(enabler_layout);
165 setLayout(main_layout);
181 QListWidgetItem *
item;
186 item =
new QListWidgetItem(QString::fromUtf8(buffer));
254 if (
item ==
nullptr) {
274 if (
item !=
nullptr &&
item->isSelected()) {
375 an_bytes =
action->text().toUtf8();
378 if (
selected !=
nullptr && paction !=
nullptr) {
417 : current_enabler(nullptr), local_copy(nullptr)
475 if (out !=
nullptr) {
const char * action_rule_name(const struct action *action)
Get the rule name of the action.
struct action_enabler * action_enabler_copy(const struct action_enabler *original)
Create a new copy of an existing action enabler.
struct req_vec_problem * action_enabler_suggest_repair(const struct action_enabler *enabler)
Returns a suggestion to fix the specified action enabler or nullptr if no fix is found to be needed.
void action_enabler_free(struct action_enabler *enabler)
Free resources allocated for the action enabler.
struct action * action_by_rule_name(const char *name)
Return the action with the given name.
struct requirement_vector * action_enabler_vector_by_number(const void *enabler, req_vec_num_in_item number)
Returns a writable pointer to the specified requirement vector in the action enabler or nullptr if th...
struct action_enabler * action_enabler_new()
Create a new action enabler.
void action_enabler_add(struct action_enabler *enabler)
Add an action enabler to the current ruleset.
struct action * action_by_number(action_id act_id)
Return the action with the given id.
struct req_vec_problem * action_enabler_suggest_improvement(const struct action_enabler *enabler)
Returns a suggestion to improve the specified action enabler or nullptr if nothing to improve is foun...
bool action_id_exists(const action_id act_id)
Returns TRUE iff the specified action ID refers to a valid action.
bool action_enabler_remove(struct action_enabler *enabler)
Remove an action enabler from the current ruleset.
const char * action_enabler_vector_by_number_name(req_vec_num_in_item vec)
Returns the name of the given requirement vector number n in an action enabler or nullptr if enablers...
const char * action_id_rule_name(action_id act_id)
Get the rule name of the action.
#define action_enablers_iterate_end
#define enabler_get_action(_enabler_)
#define action_iterate_end
#define action_enablers_iterate(_enabler_)
#define action_iterate(_act_)
requirement_vector_namer vector_namer() override
Returns a function pointer to a function that names this item kind's requirement vector number number...
fix_enabler_item(struct action_enabler *enabler)
Construct fix_enabler_item to help req_vec_fix with the action enabler unique stuff.
void close() override
Tell the helper that it has outlived its usefulnes.
const void * item() override
Returns a pointer to the ruleset item.
int num_vectors() override
Returns the number of requirement vectors in this item.
virtual ~fix_enabler_item()
Destructor for fix_enabler_item.
struct action_enabler * local_copy
bool vector_in_item(const struct requirement_vector *vec) override
Check if the specified vector belongs to this item.
void undo_accepted_changes() override
Undo all the changes the user has accepted to the ruleset item.
requirement_vector_by_number vector_getter() override
Returns a function pointer to a function that returns a writable pointer to the specified requirement...
void * item_working_copy() override
Returns a pointer to the working copy of the ruleset item.
void apply_accepted_changes() override
Do all the changes the user has accepted to the ruleset item.
struct action_enabler * current_enabler
struct req_vec_problem * find_next_problem() override
Returns the next detected requirement vector problem for the ruleset item or nullptr if no fix is fou...
const char * name() override
Returns a name to describe the item, hopefully good enough to distinguish it from other items.
Ruleset entity specific methods for the ruleset item having its requirements fixed.
void open_req_vec_fix(req_vec_fix_item *item_info)
Open req_vec_fix dialog.
void rec_vec_may_have_changed(const requirement_vector *vec)
A requirement vector may have been changed.
void open_req_edit(const QString &target, struct requirement_vector *preqs)
Open req_edit dialog.
void delete_now()
User requested enabler deletion.
void refresh()
Refresh the information.
void edit_type(QAction *action)
User selected action to enable.
struct action_enabler * selected
QPushButton * act_reqs_button
QToolButton * type_button
void edit_actor_reqs()
User wants to edit actor reqs.
tab_enabler(ruledit_gui *ui_in)
Setup tab_enabler object.
QPushButton * tgt_reqs_button
void repair_now()
User requested enabler repair.
void edit_target_reqs()
User wants to edit target reqs.
void select_enabler()
User selected enabler from the list.
QListWidget * enabler_list
QPushButton * delete_button
bool initialize_new_enabler(struct action_enabler *enabler)
Initialize new enabler for use.
QPushButton * repair_button
void update_enabler_info(struct action_enabler *enabler)
Update info of the enabler.
void add_now()
User requested new enabler.
void incoming_rec_vec_change(const requirement_vector *vec)
A requirement vector may have been changed.
#define fc_assert_ret(condition)
#define fc_assert_action(condition, action)
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
void req_vec_problem_free(struct req_vec_problem *issue)
De-allocates resources associated with the given requirement vector problem.
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...
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...
void show_experimental(QWidget *wdg)
Show widget if experimental features enabled, hide otherwise.
struct requirement_vector actor_reqs
struct requirement_vector target_reqs
int fc_snprintf(char *str, size_t n, const char *format,...)
See also fc_utf8_snprintf_trunc(), fc_utf8_snprintf_rep().
static enum req_vec_problem_seriousness enabler_problem_level(struct action_enabler *enabler)
Returns how big a problem an action enabler has.