31 QFont font =
ui.eco_widget->horizontalHeader()->font();
32 font.setWeight(QFont::Bold);
33 ui.eco_widget->horizontalHeader()->setFont(font);
36 slist <<
_(
"Type") <<
Q_(
"?Building or Unit type:Name") <<
_(
"Redundant")
37 <<
_(
"Count") <<
_(
"Cost") <<
_(
"Total Upkeep")
38 <<
_(
"Redundant Cities");
40 ui.eco_widget->setColumnCount(slist.count());
41 ui.eco_widget->setHorizontalHeaderLabels(slist);
42 ui.eco_widget->setAlternatingRowColors(
true);
43 ui.bdisband->setText(
_(
"Disband"));
44 ui.bsell->setText(
_(
"Sell All"));
45 ui.bredun->setText(
_(
"Sell Redundant"));
47 connect(
ui.bdisband, &QAbstractButton::pressed,
this,
49 connect(
ui.bsell, &QAbstractButton::pressed,
this,
51 connect(
ui.bredun, &QAbstractButton::pressed,
this,
53 connect(
ui.eco_widget->selectionModel(),
54 &QItemSelectionModel::selectionChanged,
this,
56 setLayout(
ui.eco_layout);
78 int entries_used, building_total, unit_total, tax, i, j;
80 QTableWidgetItem *
item;
81 QFont f = QApplication::font();
83 int h = fm.height() + 24;
85 ui.eco_widget->setRowCount(0);
86 ui.eco_widget->clearContents();
89 for (i = 0; i < entries_used; i++) {
94 ui.eco_widget->insertRow(i);
95 for (j = 0; j < 7; j++) {
96 item =
new QTableWidgetItem;
101 QLabel *lbl =
new QLabel;
102 lbl->setPixmap(QPixmap(sprite));
103 lbl->setAlignment(Qt::AlignVCenter | Qt::AlignHCenter);
104 ui.eco_widget->setCellWidget(i, j, lbl);
105 item->setData(Qt::UserRole,
id);
108 item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
112 item->setTextAlignment(Qt::AlignVCenter | Qt::AlignHCenter);
116 item->setTextAlignment(Qt::AlignVCenter | Qt::AlignHCenter);
117 item->setData(Qt::DisplayRole, pentry->
count);
120 item->setTextAlignment(Qt::AlignVCenter | Qt::AlignHCenter);
121 item->setData(Qt::DisplayRole, pentry->
cost);
124 item->setTextAlignment(Qt::AlignVCenter | Qt::AlignHCenter);
128 item->setTextAlignment(Qt::AlignVCenter | Qt::AlignLeft);
131 ui.eco_widget->setItem(i, j,
item);
136 for (i = 0; i < entries_used; i++) {
142 for (j = 0; j < 7; j++) {
143 item =
new QTableWidgetItem;
149 QLabel *lbl =
new QLabel;
150 lbl->setPixmap(QPixmap(sprite));
151 lbl->setAlignment(Qt::AlignVCenter | Qt::AlignHCenter);
152 ui.eco_widget->setCellWidget(
max_row + i, j, lbl);
154 item->setData(Qt::UserRole,
id);
157 item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
161 item->setTextAlignment(Qt::AlignVCenter | Qt::AlignHCenter);
162 item->setData(Qt::DisplayRole, 0);
165 item->setTextAlignment(Qt::AlignVCenter | Qt::AlignHCenter);
166 item->setData(Qt::DisplayRole, pentry->
count);
169 item->setTextAlignment(Qt::AlignVCenter | Qt::AlignHCenter);
170 item->setData(Qt::DisplayRole, pentry->
cost);
173 item->setTextAlignment(Qt::AlignVCenter | Qt::AlignHCenter);
177 item->setTextAlignment(Qt::AlignVCenter | Qt::AlignLeft);
178 item->setText(
_(
"Not Applicable"));
184 buf = QString(
_(
"Income: %1 Total Costs: %2"))
185 .arg(QString::number(tax),
186 QString::number(building_total + unit_total));
187 ui.eco_label->setText(buf);
190 for (
int i = 0; i <
ui.eco_widget->columnCount() - 1; ++i) {
191 ui.eco_widget->resizeColumnToContents(i);
194 ui.eco_widget->resizeRowsToContents();
201 const QItemSelection &ds)
203 QTableWidgetItem *itm;
208 ui.bdisband->setEnabled(
false);
209 ui.bsell->setEnabled(
false);
210 ui.bredun->setEnabled(
false);
216 curr_row = sl.indexes().at(0).row();
219 qvar = itm->data(Qt::UserRole);
222 switch (selected.
kind) {
223 case VUT_IMPROVEMENT:
227 ui.bsell->setEnabled(
true);
230 i = itm->text().toInt();
232 ui.bredun->setEnabled(
true);
237 ui.bdisband->setEnabled(
true);
240 qCritical(
"Not supported type: %d.", selected.
kind);
257 buf = QString(
_(
"Do you really wish to disband every %1 (%2 total)?"))
262 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Yes);
263 ask->setDefaultButton(QMessageBox::Cancel);
264 ask->button(QMessageBox::Yes)->setText(
_(
"Yes Disband"));
265 ask->setAttribute(Qt::WA_DeleteOnClose);
266 connect(ask, &hud_message_box::accepted, [=]() {
275 result->setStandardButtons(QMessageBox::Ok);
276 result->setAttribute(Qt::WA_DeleteOnClose);
298 buf = QString(
_(
"Do you really wish to sell "
299 "every %1 (%2 total)?"))
304 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Yes);
305 ask->setDefaultButton(QMessageBox::Cancel);
306 ask->button(QMessageBox::Yes)->setText(
_(
"Yes Sell"));
307 ask->setAttribute(Qt::WA_DeleteOnClose);
308 connect(ask, &hud_message_box::accepted, [=]() {
321 result->setStandardButtons(QMessageBox::Ok);
322 result->setAttribute(Qt::WA_DeleteOnClose);
343 buf = QString::asprintf(
_(
"Do you really wish to sell "
344 "every redundant %s (%d total)?"),
348 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Yes);
349 ask->setDefaultButton(QMessageBox::Cancel);
350 ask->button(QMessageBox::Yes)->setText(
_(
"Yes Sell"));
351 ask->setAttribute(Qt::WA_DeleteOnClose);
352 connect(ask, &hud_message_box::accepted, [=]() {
365 result->setStandardButtons(QMessageBox::Ok);
366 result->setAttribute(Qt::WA_DeleteOnClose);
381 if (
queen()->isRepoDlgOpen(QStringLiteral(
"ECO"))) {
383 if (
queen()->game_tab_widget->currentIndex() == i) {
400 if (!
queen()->isRepoDlgOpen(QStringLiteral(
"ECO"))) {
408 if (w->isVisible()) {
427 if (
queen()->isRepoDlgOpen(QStringLiteral(
"ECO"))) {
432 eco_rep->deleteLater();
eco_report()
Constructor for economy report.
void selection_changed(const QItemSelection &sl, const QItemSelection &ds)
Action for selection changed in economy report.
void disband_units()
Disband pointed units (in economy report)
void sell_buildings()
Sell all pointed builings.
void init()
Initializes place in tab for economy report.
~eco_report()
Destructor for economy report.
void sell_redundant()
Sells redundant buildings.
void update_report()
Refresh all widgets for economy report.
void set_text_title(const QString &s1, const QString &s2)
Sets text and title and shows message box.
int gimmeIndexOf(const QString &str)
Returns index on game tab page of given report dialog.
int addGameTab(QWidget *widget)
Inserts tab widget to game view page.
void removeRepoDlg(const QString &str)
Removes report dialog string from the list marking it as closed.
void updateSidebarTooltips()
Updates top bar tooltips.
void gimmePlace(QWidget *widget, const QString &str)
Finds not used index on game_view_tab and returns it.
fc_game_tab_widget * game_tab_widget
cid cid_encode_building(const struct impr_type *pimprove)
Encode a CID for the target building.
struct universal cid_decode(cid id)
Decode the CID into a city_production structure.
cid cid_encode_unit(const struct unit_type *punittype)
Encode a CID for the target unit type.
class fc_client * king()
Return fc_client instance.
bool can_sell_building(const struct impr_type *pimprove)
Return TRUE iff the improvement can be sold.
struct impr_type * improvement_by_number(const Impr_type_id id)
Returns the improvement type for the given index/ID.
Impr_type_id improvement_number(const struct impr_type *pimprove)
Return the improvement index.
const char * improvement_name_translation(const struct impr_type *pimprove)
Return the (translated) name of the given improvement.
#define fc_assert(condition)
pageGame * queen()
Return game instandce.
void get_economy_report_units_data(struct unit_entry *entries, int *num_entries_used, int *total_cost)
Returns an array of units with gold_upkeep.
void get_economy_report_data(struct improvement_entry *entries, int *num_entries_used, int *total_cost, int *total_income)
Fills out the array of struct improvement_entry given by entries.
void sell_all_improvements(const struct impr_type *pimprove, bool redundant_only, char *message, size_t message_sz)
Sell all improvements of the given type in all cities.
void disband_all_units(const struct unit_type *punittype, bool in_cities_only, char *message, size_t message_sz)
Disband all supported units of the given type.
const QPixmap * get_unittype_sprite(const struct tileset *t, const struct unit_type *punittype, enum direction8 facing, const QColor &replace)
Return the sprite for the unit type (the base "unit" sprite).
const QPixmap * get_building_sprite(const struct tileset *t, const struct impr_type *pimprove)
Return the sprite for the building/improvement.
void top_bar_show_map()
Callback to show map.
const struct unit_type * utype
const struct impr_type * building
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_name_translation(const struct unit_type *punittype)
Return the (translated) name of the unit type.
Unit_type_id utype_number(const struct unit_type *punittype)
Return the unit type index.
void real_economy_report_dialog_update(void *unused)
Update the economy report.
void popdown_economy_report()
Closes economy report.
void economy_report_dialog_popup()
Display the economy report.