Freeciv-3.1: /fast/freeciv/nightly/S3_1/client/gui-qt/repodlgs.h Source File

Freeciv-3.1

Loading...
Searching...
No Matches
repodlgs.h
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#ifndef FC__REPODLGS_H
15#define FC__REPODLGS_H
16
17#ifdef HAVE_CONFIG_H
18#include <fc_config.h>
19#endif
20
21extern "C" {
22#include "repodlgs_g.h"
23}
24
25// Qt
26#include <QLabel>
27#include <QPushButton>
28#include <QWidget>
29
30// client
31#include "climisc.h"
32
33// gui-qt
34#include "fonts.h"
35#include "mapview.h"
36
37class progress_bar;
38class QComboBox;
39class QGridLayout;
40class QGroupBox;
41class QHBoxLayout;
42class QItemSelection;
43class QPushButton;
44class QScrollArea;
45class QTableWidget;
46class QTableWidgetItem;
47
48 class unittype_item: public QFrame {
49
50 Q_OBJECT
51
52 bool entered;
53 int unit_scroll;
54 QLabel label_pix;
55
56public:
57 unittype_item(QWidget *parent, unit_type *ut);
58 ~unittype_item();
59 void init_img();
60 QLabel food_upkeep;
61 QLabel gold_upkeep;
62 QLabel label_info_active;
63 QLabel label_info_inbuild;
64 QLabel label_info_unit;
65 QLabel shield_upkeep;
66 QPushButton upgrade_button;
67
68private:
69 unit_type *utype;
70
71private slots:
72 void upgrade_units();
73
74protected:
75#ifndef FC_QT5_MODE
76 void enterEvent(QEnterEvent *event);
77#else // FC_QT5_MODE
78 void enterEvent(QEvent *event);
79#endif // FC_QT5_MODE
80 void leaveEvent(QEvent *event);
81 void paintEvent(QPaintEvent *event);
82 void wheelEvent(QWheelEvent *event);
83};
84
85 class units_reports: public fcwidget {
86
87 Q_DISABLE_COPY(units_reports);
88 Q_OBJECT
89
90 close_widget *cw;
91 explicit units_reports();
92 QHBoxLayout *scroll_layout;
93 QScrollArea *scroll;
94 QWidget scroll_widget;
95 static units_reports *m_instance;
96
97public:
98 ~units_reports();
99 static units_reports *instance();
100 static void drop();
101 void clear_layout();
102 void init_layout();
103 void update_units(bool show = false);
104 void add_item(unittype_item *item);
105 virtual void update_menu();
106 QHBoxLayout *layout;
107 QList<unittype_item *> unittype_list;
108
109protected:
110 void paintEvent(QPaintEvent *event);
111};
112
113/****************************************************************************
114 Helper item for comboboxes, holding string of tech and its id
115****************************************************************************/
116 struct qlist_item {
117 QString tech_str;
118 Tech_type_id id;
119};
120
121/****************************************************************************
122 Helper item for research diagram, about drawn rectangles and what
123 tech/unit/improvement they point to.
124****************************************************************************/
125 class req_tooltip_help
126{
127public:
128 req_tooltip_help();
129 QRect rect;
130 Tech_type_id tech_id;
131 struct unit_type *tunit;
132 struct impr_type *timpr;
133 struct government *tgov;
134};
135/****************************************************************************
136 Custom widget representing research diagram in science_report
137****************************************************************************/
138 class research_diagram: public QWidget
139{
140 Q_OBJECT
141
142public:
143 research_diagram(QWidget *parent = 0);
144 ~research_diagram();
145 void update_reqtree();
146 void reset();
147 QSize size();
148private slots:
149 void show_tooltip();
150private:
151 void mousePressEvent(QMouseEvent *event);
152 void mouseMoveEvent(QMouseEvent *event);
153 void paintEvent(QPaintEvent *event);
154 void create_tooltip_help();
155 struct canvas *pcanvas;
156 struct reqtree *req;
157 bool timer_active;
158 int width;
159 int height;
160 QList<req_tooltip_help*> tt_help;
161 QPoint tooltip_pos;
162 QString tooltip_text;
163 QRect tooltip_rect;
164
165};
166
167/****************************************************************************
168 Widget embedded as tab on game view (F6 default)
169 Uses string "SCI" to mark it as opened
170 You can check it using if (gui()->is_repo_dlg_open("SCI"))
171****************************************************************************/
172class science_report: public QWidget
173{
174 Q_OBJECT
175
176 QComboBox *goal_combo;
177 QComboBox *researching_combo;
178 QGridLayout *sci_layout;
179 progress_bar *progress;
180 QLabel *info_label;
181 QLabel *progress_label;
182 QList<qlist_item> *curr_list;
183 QList<qlist_item> *goal_list;
184 research_diagram *res_diag;
185 QScrollArea *scroll;
186
187public:
188 science_report();
189 ~science_report();
190 void update_report();
191 void init();
192 void redraw();
193 void reset_tree();
194
195private:
196 void update_reqtree();
197 int index;
198
199private slots:
200 void current_tech_changed(int index);
201 void goal_tech_changed(int index);
202};
203
204
205/****************************************************************************
206 Tab widget to display economy report (F5)
207****************************************************************************/
208 class eco_report: public QWidget
209{
210 Q_OBJECT
211 QPushButton *disband_button;
212 QPushButton *sell_button;
213 QPushButton *sell_redun_button;
214 QTableWidget *eco_widget;
215 QLabel *eco_label;
216
217public:
218 eco_report();
219 ~eco_report();
220 void update_report();
221 void init();
222
223private:
224 int index;
225 int curr_row;
226 int max_row;
227 cid uid;
228 int counter;
229
230private slots:
231 void disband_units();
232 void sell_buildings();
233 void sell_redundant();
234 void selection_changed(const QItemSelection &sl,
235 const QItemSelection &ds);
236};
237
238/****************************************************************************
239 Tab widget to display economy report (F5)
240****************************************************************************/
241class endgame_report: public QWidget
242{
243 Q_OBJECT
244 QTableWidget *end_widget;
245
246public:
247 endgame_report(const struct packet_endgame_report *packet);
248 ~endgame_report();
249 void update_report(const struct packet_endgame_player *packet);
250 void init();
251
252private:
253 int index;
254 int players;
255
256};
257
258
259bool comp_less_than(const qlist_item &q1, const qlist_item &q2);
260void popdown_economy_report();
261void popdown_units_report();
262void popdown_science_report();
263void popdown_endgame_report();
264void popup_endgame_report();
265void toggle_units_report(bool);
266
267#endif /* FC__REPODLGS_H */
close_widget
Definition mapview.h:183
eco_report
Definition repodlgs.h:209
eco_report::eco_report
eco_report()
Definition repodlgs.cpp:1203
eco_report::sell_button
QPushButton * sell_button
Definition repodlgs.h:212
eco_report::selection_changed
void selection_changed(const QItemSelection &sl, const QItemSelection &ds)
Definition repodlgs.cpp:1393
eco_report::sell_redun_button
QPushButton * sell_redun_button
Definition repodlgs.h:213
eco_report::disband_button
QPushButton * disband_button
Definition repodlgs.h:211
eco_report::disband_units
void disband_units()
Definition repodlgs.cpp:1441
eco_report::eco_widget
QTableWidget * eco_widget
Definition repodlgs.h:214
eco_report::index
int index
Definition repodlgs.h:224
eco_report::max_row
int max_row
Definition repodlgs.h:226
eco_report::sell_buildings
void sell_buildings()
Definition repodlgs.cpp:1478
eco_report::init
void init()
Definition repodlgs.cpp:1262
eco_report::uid
cid uid
Definition repodlgs.h:227
eco_report::~eco_report
~eco_report()
Definition repodlgs.cpp:1254
eco_report::sell_redundant
void sell_redundant()
Definition repodlgs.cpp:1522
eco_report::curr_row
int curr_row
Definition repodlgs.h:225
eco_report::update_report
void update_report()
Definition repodlgs.cpp:1273
eco_report::eco_label
QLabel * eco_label
Definition repodlgs.h:215
eco_report::counter
int counter
Definition repodlgs.h:228
fcwidget
Definition mapview.h:172
progress_bar
Definition citydlg.h:111
req_tooltip_help
Definition repodlgs.h:126
req_tooltip_help::rect
QRect rect
Definition repodlgs.h:129
req_tooltip_help::tgov
struct government * tgov
Definition repodlgs.h:133
req_tooltip_help::tech_id
Tech_type_id tech_id
Definition repodlgs.h:130
req_tooltip_help::tunit
struct unit_type * tunit
Definition repodlgs.h:131
req_tooltip_help::timpr
struct impr_type * timpr
Definition repodlgs.h:132
req_tooltip_help::req_tooltip_help
req_tooltip_help()
Definition repodlgs.cpp:570
research_diagram
Definition repodlgs.h:139
research_diagram::show_tooltip
void show_tooltip()
Definition repodlgs.cpp:818
research_diagram::reset
void reset()
Definition repodlgs.cpp:693
research_diagram::pcanvas
struct canvas * pcanvas
Definition repodlgs.h:155
research_diagram::mousePressEvent
void mousePressEvent(QMouseEvent *event)
Definition repodlgs.cpp:713
research_diagram::size
QSize size()
Definition repodlgs.cpp:845
research_diagram::timer_active
bool timer_active
Definition repodlgs.h:157
research_diagram::~research_diagram
~research_diagram()
Definition repodlgs.cpp:559
research_diagram::create_tooltip_help
void create_tooltip_help()
Definition repodlgs.cpp:580
research_diagram::req
struct reqtree * req
Definition repodlgs.h:156
research_diagram::tooltip_text
QString tooltip_text
Definition repodlgs.h:162
research_diagram::tt_help
QList< req_tooltip_help * > tt_help
Definition repodlgs.h:160
research_diagram::tooltip_rect
QRect tooltip_rect
Definition repodlgs.h:163
research_diagram::height
int height
Definition repodlgs.h:159
research_diagram::mouseMoveEvent
void mouseMoveEvent(QMouseEvent *event)
Definition repodlgs.cpp:760
research_diagram::width
int width
Definition repodlgs.h:158
research_diagram::update_reqtree
void update_reqtree()
Definition repodlgs.cpp:682
research_diagram::paintEvent
void paintEvent(QPaintEvent *event)
Definition repodlgs.cpp:833
research_diagram::tooltip_pos
QPoint tooltip_pos
Definition repodlgs.h:161
units_reports
Definition repodlgs.h:85
units_reports::m_instance
static units_reports * m_instance
Definition repodlgs.h:95
units_reports::clear_layout
void clear_layout()
Definition repodlgs.cpp:514
units_reports::paintEvent
void paintEvent(QPaintEvent *event)
Definition repodlgs.cpp:409
units_reports::drop
static void drop()
Definition repodlgs.cpp:368
units_reports::units_reports
units_reports()
Definition repodlgs.cpp:326
units_reports::cw
close_widget * cw
Definition repodlgs.h:90
units_reports::add_item
void add_item(unittype_item *item)
Definition repodlgs.cpp:350
units_reports::instance
static units_reports * instance()
Definition repodlgs.cpp:358
units_reports::update_menu
virtual void update_menu()
Definition repodlgs.cpp:379
units_reports::Q_DISABLE_COPY
Q_DISABLE_COPY(units_reports)
units_reports::update_units
void update_units(bool show=false)
Definition repodlgs.cpp:417
units_reports::layout
QHBoxLayout * layout
Definition repodlgs.h:106
units_reports::unittype_list
QList< unittype_item * > unittype_list
Definition repodlgs.h:107
units_reports::scroll_layout
QHBoxLayout * scroll_layout
Definition repodlgs.h:92
units_reports::scroll_widget
QWidget scroll_widget
Definition repodlgs.h:94
units_reports::scroll
QScrollArea * scroll
Definition repodlgs.h:93
units_reports::init_layout
void init_layout()
Definition repodlgs.cpp:388
units_reports::~units_reports
~units_reports()
Definition repodlgs.cpp:340
unittype_item
Definition repodlgs.h:48
unittype_item::label_pix
QLabel label_pix
Definition repodlgs.h:54
unittype_item::unit_scroll
int unit_scroll
Definition repodlgs.h:53
unittype_item::label_info_active
QLabel label_info_active
Definition repodlgs.h:62
unittype_item::leaveEvent
void leaveEvent(QEvent *event)
Definition repodlgs.cpp:268
unittype_item::gold_upkeep
QLabel gold_upkeep
Definition repodlgs.h:61
unittype_item::label_info_inbuild
QLabel label_info_inbuild
Definition repodlgs.h:63
unittype_item::shield_upkeep
QLabel shield_upkeep
Definition repodlgs.h:65
unittype_item::~unittype_item
~unittype_item()
Definition repodlgs.cpp:182
unittype_item::init_img
void init_img()
Definition repodlgs.cpp:190
unittype_item::upgrade_units
void upgrade_units()
Definition repodlgs.cpp:201
unittype_item::enterEvent
void enterEvent(QEnterEvent *event)
Definition repodlgs.cpp:239
unittype_item::entered
bool entered
Definition repodlgs.h:52
unittype_item::food_upkeep
QLabel food_upkeep
Definition repodlgs.h:60
unittype_item::label_info_unit
QLabel label_info_unit
Definition repodlgs.h:64
unittype_item::utype
unit_type * utype
Definition repodlgs.h:69
unittype_item::upgrade_button
QPushButton upgrade_button
Definition repodlgs.h:66
unittype_item::paintEvent
void paintEvent(QPaintEvent *event)
Definition repodlgs.cpp:251
unittype_item::wheelEvent
void wheelEvent(QWheelEvent *event)
Definition repodlgs.cpp:277
climisc.h
cid
int cid
Definition climisc.h:31
event
enum event_type event
Definition events.c:81
Tech_type_id
int Tech_type_id
Definition fc_types.h:347
fonts.h
comp_less_than
bool comp_less_than(const qlist_item &q1, const qlist_item &q2)
Definition repodlgs.cpp:540
popdown_economy_report
void popdown_economy_report()
Definition repodlgs.cpp:1817
toggle_units_report
void toggle_units_report(bool)
Definition repodlgs.cpp:1861
popdown_science_report
void popdown_science_report()
Definition repodlgs.cpp:1835
popdown_endgame_report
void popdown_endgame_report()
Definition repodlgs.cpp:1755
popdown_units_report
void popdown_units_report()
Definition repodlgs.cpp:1853
popup_endgame_report
void popup_endgame_report()
Definition repodlgs.cpp:1768
mapview.h
slots
struct player_slot * slots
Definition player.c:50
repodlgs_g.h
canvas
Definition canvas.h:21
endgame_report
Definition repodlgs.c:1802
endgame_report::end_widget
QTableWidget * end_widget
Definition repodlgs.h:244
endgame_report::update_report
void update_report(const struct packet_endgame_player *packet)
Definition repodlgs.cpp:1613
endgame_report::players
int players
Definition repodlgs.h:254
endgame_report::~endgame_report
~endgame_report()
Definition repodlgs.cpp:1595
endgame_report::index
int index
Definition repodlgs.h:253
endgame_report::init
void init()
Definition repodlgs.cpp:1603
government
Definition government.h:52
impr_type
Definition improvement.h:68
item
Definition climisc.h:80
packet_endgame_player
Definition packets_gen.h:94
packet_endgame_report
Definition packets_gen.h:88
qlist_item
Definition repodlgs.h:116
qlist_item::id
Tech_type_id id
Definition repodlgs.h:118
qlist_item::tech_str
QString tech_str
Definition repodlgs.h:117
reqtree
Definition repodlgs.cpp:84
science_report
Definition repodlgs.c:69
science_report::sci_layout
QGridLayout * sci_layout
Definition repodlgs.h:178
science_report::progress_label
QLabel * progress_label
Definition repodlgs.h:181
science_report::~science_report
~science_report()
Definition repodlgs.cpp:910
science_report::index
int index
Definition repodlgs.h:197
science_report::init
void init()
Definition repodlgs.cpp:927
science_report::progress
progress_bar * progress
Definition repodlgs.h:179
science_report::science_report
science_report()
Definition repodlgs.cpp:857
science_report::scroll
QScrollArea * scroll
Definition repodlgs.h:185
science_report::goal_combo
QComboBox * goal_combo
Definition repodlgs.h:176
science_report::curr_list
QList< qlist_item > * curr_list
Definition repodlgs.h:182
science_report::info_label
QLabel * info_label
Definition repodlgs.h:180
science_report::res_diag
research_diagram * res_diag
Definition repodlgs.h:184
science_report::goal_list
QList< qlist_item > * goal_list
Definition repodlgs.h:183
science_report::update_report
void update_report()
Definition repodlgs.cpp:958
science_report::redraw
void redraw()
Definition repodlgs.cpp:938
science_report::update_reqtree
void update_reqtree()
Definition repodlgs.cpp:1112
science_report::reset_tree
void reset_tree()
Definition repodlgs.cpp:946
science_report::current_tech_changed
void current_tech_changed(int index)
Definition repodlgs.cpp:1120
science_report::goal_tech_changed
void goal_tech_changed(int index)
Definition repodlgs.cpp:1136
science_report::researching_combo
QComboBox * researching_combo
Definition repodlgs.h:177
unit_type
Definition unittype.h:481
show
#define show(id)
Definition widget.h:235