Feature #1043 ยป 0055-Ruledit-Add-enabler-comment-editing.patch
tools/ruledit/tab_enablers.cpp | ||
---|---|---|
QGridLayout *enabler_layout = new QGridLayout();
|
||
QLabel *label;
|
||
QPushButton *add_button;
|
||
QLabel *lbl;
|
||
int row = 0;
|
||
ui = ui_in;
|
||
connect(ui, SIGNAL(req_vec_may_have_changed(const requirement_vector *)),
|
||
... | ... | |
type_button->setText(R__("None"));
|
||
type_button->setEnabled(false);
|
||
enabler_layout->addWidget(type_button, 0, 2);
|
||
enabler_layout->addWidget(type_button, row++, 2);
|
||
act_reqs_button
|
||
= new QPushButton(QString::fromUtf8(R__("Actor Requirements")), this);
|
||
connect(act_reqs_button, SIGNAL(pressed()),
|
||
this, SLOT(edit_actor_reqs()));
|
||
act_reqs_button->setEnabled(false);
|
||
enabler_layout->addWidget(act_reqs_button, 1, 2);
|
||
enabler_layout->addWidget(act_reqs_button, row++, 2);
|
||
tgt_reqs_button
|
||
= new QPushButton(QString::fromUtf8(R__("Target Requirements")),
|
||
... | ... | |
connect(tgt_reqs_button, SIGNAL(pressed()),
|
||
this, SLOT(edit_target_reqs()));
|
||
tgt_reqs_button->setEnabled(false);
|
||
enabler_layout->addWidget(tgt_reqs_button, 2, 2);
|
||
enabler_layout->addWidget(tgt_reqs_button, row++, 2);
|
||
lbl = new QLabel(QString::fromUtf8(R__("Comment")));
|
||
enabler_layout->addWidget(lbl, row, 0);
|
||
comment = new QLineEdit(this);
|
||
connect(comment, SIGNAL(returnPressed()), this, SLOT(comment_given()));
|
||
enabler_layout->addWidget(comment, row++, 1);
|
||
add_button = new QPushButton(QString::fromUtf8(R__("Add Enabler")), this);
|
||
connect(add_button, SIGNAL(pressed()), this, SLOT(add_now()));
|
||
enabler_layout->addWidget(add_button, 3, 0);
|
||
enabler_layout->addWidget(add_button, row, 0);
|
||
show_experimental(add_button);
|
||
delete_button = new QPushButton(QString::fromUtf8(R__("Remove this Enabler")), this);
|
||
connect(delete_button, SIGNAL(pressed()), this, SLOT(delete_now()));
|
||
delete_button->setEnabled(false);
|
||
enabler_layout->addWidget(delete_button, 3, 2);
|
||
enabler_layout->addWidget(delete_button, row, 2);
|
||
show_experimental(delete_button);
|
||
repair_button = new QPushButton(this);
|
||
connect(repair_button, SIGNAL(pressed()), this, SLOT(repair_now()));
|
||
repair_button->setEnabled(false);
|
||
repair_button->setText(QString::fromUtf8(R__("Enabler Issues")));
|
||
enabler_layout->addWidget(repair_button, 3, 1);
|
||
enabler_layout->addWidget(repair_button, row++, 1);
|
||
refresh();
|
||
... | ... | |
act_reqs_button->setEnabled(true);
|
||
tgt_reqs_button->setEnabled(true);
|
||
if (selected->rulesave.comment != nullptr) {
|
||
comment->setText(selected->rulesave.comment);
|
||
} else {
|
||
comment->setText("");
|
||
}
|
||
delete_button->setEnabled(true);
|
||
switch (enabler_problem_level(selected)) {
|
||
... | ... | |
repair_button->setEnabled(false);
|
||
repair_button->setText(QString::fromUtf8(R__("Enabler Issues")));
|
||
comment->setText("");
|
||
delete_button->setEnabled(false);
|
||
}
|
||
... | ... | |
{
|
||
int i = 0;
|
||
// Save previously selected one's comment.
|
||
comment_given();
|
||
action_enablers_iterate(enabler) {
|
||
QListWidgetItem *item = enabler_list->item(i++);
|
||
... | ... | |
**************************************************************************/
|
||
bool tab_enabler::initialize_new_enabler(struct action_enabler *enabler)
|
||
{
|
||
if (enabler->rulesave.comment != nullptr) {
|
||
free(enabler->rulesave.comment);
|
||
enabler->rulesave.comment = nullptr;
|
||
}
|
||
return true;
|
||
}
|
||
... | ... | |
}
|
||
}
|
||
/**********************************************************************//**
|
||
User entered comment for the enabler
|
||
**************************************************************************/
|
||
void tab_enabler::comment_given()
|
||
{
|
||
if (selected != nullptr) {
|
||
if (selected->rulesave.comment != nullptr) {
|
||
free(selected->rulesave.comment);
|
||
}
|
||
if (!comment->text().isEmpty()) {
|
||
selected->rulesave.comment = fc_strdup(comment->text().toUtf8());
|
||
} else {
|
||
selected->rulesave.comment = nullptr;
|
||
}
|
||
}
|
||
}
|
||
/**********************************************************************//**
|
||
Construct fix_enabler_item to help req_vec_fix with the action enabler
|
||
unique stuff.
|
tools/ruledit/tab_enablers.h | ||
---|---|---|
QPushButton *delete_button;
|
||
QPushButton *repair_button;
|
||
QListWidget *enabler_list;
|
||
QLineEdit *comment;
|
||
struct action_enabler *selected;
|
||
... | ... | |
void edit_type(QAction *action);
|
||
void edit_target_reqs();
|
||
void edit_actor_reqs();
|
||
void comment_given();
|
||
};
|
||
#endif // FC__TAB_ENABLERS_H
|