Freeciv-3.3: /fast/freeciv/nightly/main/client/gui-qt/repodlgs.h Source File

Freeciv-3.3

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