Freeciv-3.3
Loading...
Searching...
No Matches
tab_nation.cpp
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18// Qt
19#include <QCheckBox>
20#include <QGridLayout>
21#include <QLineEdit>
22#include <QPushButton>
23
24// utility
25#include "fcintl.h"
26#include "log.h"
27#include "registry.h"
28
29// common
30#include "game.h"
31
32// ruledit
33#include "ruledit_qt.h"
34
35#include "tab_nation.h"
36
37/**********************************************************************/
41{
42 QGridLayout *main_layout = new QGridLayout(this);
43 QLabel *nationlist_label;
44 int row = 0;
45
46 ui = ui_in;
47
48 main_layout->setSizeConstraint(QLayout::SetMaximumSize);
49
50 via_include = new QCheckBox(QString::fromUtf8(R__("Use nationlist")));
51 main_layout->addWidget(via_include, row++, 0);
52 connect(via_include, SIGNAL(toggled(bool)), this, SLOT(nationlist_toggle(bool)));
53
54 nationlist_label = new QLabel(QString::fromUtf8(R__("Nationlist")));
55 nationlist_label->setParent(this);
56 main_layout->addWidget(nationlist_label, row, 0);
57 nationlist = new QLineEdit(this);
58 main_layout->addWidget(nationlist, row++, 1);
59
60 refresh();
61
62 setLayout(main_layout);
63}
64
65/**********************************************************************/
69{
70 if (ui->data.nationlist == nullptr) {
71 via_include->setChecked(false);
72 nationlist->setEnabled(false);
73 } else {
74 via_include->setChecked(true);
75 nationlist->setText(ui->data.nationlist);
76 nationlist->setEnabled(true);
77 }
78}
79
80/**********************************************************************/
84{
86
87 if (via_include->isChecked()) {
89
90 nln_bytes = nationlist->text().toUtf8();
92 } else {
93 ui->data.nationlist = nullptr;
94 }
95}
96
97/**********************************************************************/
101{
102 if (checked) {
103 if (ui->data.nationlist_saved != nullptr) {
105 } else {
106 ui->data.nationlist = fc_strdup("default/nationlist.ruleset");
107 }
108 } else {
110
112 nln_bytes = nationlist->text().toUtf8();
114 ui->data.nationlist = nullptr;
115 }
116
117 refresh();
118}
struct rule_data data
Definition ruledit_qt.h:118
void nationlist_toggle(bool checked)
QCheckBox * via_include
Definition tab_nation.h:40
void flush_widgets()
ruledit_gui * ui
Definition tab_nation.h:38
void refresh()
QLineEdit * nationlist
Definition tab_nation.h:41
tab_nation(ruledit_gui *ui_in)
char * incite_cost
Definition comments.c:76
#define R__(String)
Definition fcintl.h:75
#define FC_FREE(ptr)
Definition mem.h:41
#define fc_strdup(str)
Definition mem.h:43
char * nationlist
Definition rulesave.h:22
char * nationlist_saved
Definition rulesave.h:23