15 #include <QGridLayout>
17 #include <QListWidget>
19 #include <QPushButton>
20 #include <QRadioButton>
42 QVBoxLayout *main_layout =
new QVBoxLayout(
this);
43 QGridLayout *unit_layout =
new QGridLayout();
45 QPushButton *effects_button;
46 QPushButton *add_button;
47 QPushButton *delete_button;
48 QPushButton *edit_button;
55 connect(
unit_list, &QListWidget::itemSelectionChanged,
this,
59 unit_layout->setSizeConstraint(QLayout::SetMaximumSize);
61 label =
new QLabel(QString::fromUtf8(
R__(
"Rule Name")));
62 label->setParent(
this);
63 rname =
new QLineEdit(
this);
64 rname->setText(QStringLiteral(
"None"));
66 unit_layout->addWidget(label, 0, 0);
67 unit_layout->addWidget(
rname, 0, 2);
69 label =
new QLabel(QString::fromUtf8(
R__(
"Name")));
70 label->setParent(
this);
72 connect(
same_name, &QAbstractButton::toggled,
this,
74 name =
new QLineEdit(
this);
75 name->setText(QStringLiteral(
"None"));
77 unit_layout->addWidget(label, 1, 0);
79 unit_layout->addWidget(
name, 1, 2);
81 edit_button =
new QPushButton(QString::fromUtf8(
R__(
"Edit Unit")),
this);
83 unit_layout->addWidget(edit_button, 2, 2);
85 effects_button =
new QPushButton(QString::fromUtf8(
R__(
"Effects")),
this);
86 connect(effects_button, &QAbstractButton::pressed,
this,
88 unit_layout->addWidget(effects_button, 3, 2);
90 add_button =
new QPushButton(QString::fromUtf8(
R__(
"Add Unit")),
this);
92 unit_layout->addWidget(add_button, 4, 0);
96 new QPushButton(QString::fromUtf8(
R__(
"Remove this Unit")),
this);
97 connect(delete_button, &QAbstractButton::pressed,
this,
99 unit_layout->addWidget(delete_button, 4, 2);
104 main_layout->addLayout(unit_layout);
106 setLayout(main_layout);
118 if (!ptype->ruledit_disabled) {
138 name->setText(dispn);
139 rname->setText(rulen);
140 if (dispn == rulen) {
141 name->setEnabled(
false);
145 name->setEnabled(
true);
148 name->setText(QStringLiteral(
"None"));
149 rname->setText(QStringLiteral(
"None"));
151 name->setEnabled(
false);
160 QList<QListWidgetItem *> select_list =
unit_list->selectedItems();
162 if (!select_list.isEmpty()) {
165 un_bytes = select_list.at(0)->text().toUtf8();
176 QByteArray name_bytes;
177 QByteArray rname_bytes;
182 rname_bytes =
rname->text().toUtf8();
196 name_bytes =
name->text().toUtf8();
197 rname_bytes =
rname->text().toUtf8();
259 if (ptype->ruledit_disabled) {
261 ptype->ruledit_disabled =
false;
293 name->setEnabled(!checked);
308 uni.
kind = VUT_UTYPE;
void display_msg(const char *msg)
Display status message.
requirers_dlg * create_requirers(const char *title)
Create requirers dlg.
void open_effect_edit(const QString &target, struct universal *uni, enum effect_filter_main_class efmc)
Open effect_edit dialog.
void refresh()
Refresh the information.
struct unit_type * selected
void add_now()
User requested new unit.
void edit_effects()
User wants to edit effects.
bool initialize_new_utype(struct unit_type *ptype)
Initialize new tech for use.
void edit_now()
User requested unit edit dialog.
void select_unit()
User selected unit from the list.
void same_name_toggle(bool checked)
Toggled whether rule_name and name should be kept identical.
tab_unit(ruledit_gui *ui_in)
Setup tab_unit object.
void name_given()
User entered name for the unit.
void update_utype_info(struct unit_type *ptype)
Update info of the unit.
void delete_now()
User requested unit deletion.
static void name_set(struct name_translation *ptrans, const char *domain, const char *vernacular_name)
static const char * untranslated_name(const struct name_translation *ptrans)
static void names_set(struct name_translation *ptrans, const char *domain, const char *vernacular_name, const char *rule_name)
void show_experimental(QWidget *wdg)
Show widget if experimental features enabled, hide otherwise.
void ruledit_qt_display_requirers(const char *msg, void *data)
Display requirer list.
struct packet_ruleset_control control
struct name_translation name
const struct unit_type * utype
struct unit_type * utype_by_number(const Unit_type_id id)
Return a pointer for the unit type struct for the given unit type id.
const char * utype_rule_name(const struct unit_type *punittype)
Return the (untranslated) rule name of the unit type.
struct unit_type * unit_type_by_rule_name(const char *name)
Returns the unit type that has the given (untranslated) rule name.
Unit_type_id utype_index(const struct unit_type *punittype)
Return the unit type index.
#define unit_type_iterate(_p)
#define unit_type_iterate_end
bool is_utype_needed(struct unit_type *ptype, requirers_cb cb, void *data)
Check if anything in ruleset needs unit type.