Freeciv-3.2
Loading...
Searching...
No Matches
tools
ruledit
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
/**********************************************************************/
40
tab_nation::tab_nation
(
ruledit_gui
*
ui_in
) : QWidget()
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
/**********************************************************************/
68
void
tab_nation::refresh
()
69
{
70
if
(
ui
->
data
.
nationlist
==
NULL
) {
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
/**********************************************************************/
83
void
tab_nation::flush_widgets
()
84
{
85
FC_FREE
(
ui
->
data
.
nationlist
);
86
87
if
(
via_include
->isChecked()) {
88
QByteArray
nln_bytes
;
89
90
nln_bytes
=
nationlist
->text().toUtf8();
91
ui
->
data
.
nationlist
=
fc_strdup
(
nln_bytes
.data());
92
}
else
{
93
ui
->
data
.
nationlist
=
NULL
;
94
}
95
}
96
97
/**********************************************************************/
100
void
tab_nation::nationlist_toggle
(
bool
checked
)
101
{
102
if
(
checked
) {
103
if
(
ui
->
data
.
nationlist_saved
!=
NULL
) {
104
ui
->
data
.
nationlist
=
ui
->
data
.
nationlist_saved
;
105
}
else
{
106
ui
->
data
.
nationlist
=
fc_strdup
(
"default/nationlist.ruleset"
);
107
}
108
}
else
{
109
QByteArray
nln_bytes
;
110
111
FC_FREE
(
ui
->
data
.
nationlist_saved
);
112
nln_bytes
=
nationlist
->text().toUtf8();
113
ui
->
data
.
nationlist_saved
=
fc_strdup
(
nln_bytes
.data());
114
ui
->
data
.
nationlist
=
NULL
;
115
}
116
117
refresh
();
118
}
ruledit_gui
Definition
ruledit_qt.h:97
ruledit_gui::data
struct rule_data data
Definition
ruledit_qt.h:118
tab_nation::nationlist_toggle
void nationlist_toggle(bool checked)
Definition
tab_nation.cpp:100
tab_nation::via_include
QCheckBox * via_include
Definition
tab_nation.h:40
tab_nation::flush_widgets
void flush_widgets()
Definition
tab_nation.cpp:83
tab_nation::ui
ruledit_gui * ui
Definition
tab_nation.h:38
tab_nation::refresh
void refresh()
Definition
tab_nation.cpp:68
tab_nation::nationlist
QLineEdit * nationlist
Definition
tab_nation.h:41
tab_nation::tab_nation
tab_nation(ruledit_gui *ui_in)
Definition
tab_nation.cpp:40
incite_cost
char * incite_cost
Definition
comments.c:75
fcintl.h
R__
#define R__(String)
Definition
fcintl.h:75
game.h
log.h
FC_FREE
#define FC_FREE(ptr)
Definition
mem.h:41
fc_strdup
#define fc_strdup(str)
Definition
mem.h:43
registry.h
ruledit_qt.h
rule_data::nationlist
char * nationlist
Definition
rulesave.h:22
rule_data::nationlist_saved
char * nationlist_saved
Definition
rulesave.h:23
tab_nation.h
Generated on Sun Dec 22 2024 23:00:34 for Freeciv-3.2 by
1.9.8