19#include <QApplication>
27#include <QRadioButton>
36#include <QWidgetAction>
75extern QString
split_text(QString text,
bool cut);
121 if (VUT_UTYPE == target->
kind) {
123 direction8_invalid());
127 if (
pix !=
nullptr) {
136 cropped_img =
img.copy(crop);
137 tpix = QPixmap::fromImage(cropped_img);
138 pix =
new QPixmap(tpix.width(), tpix.height());
139 pix->fill(Qt::transparent);
140 pixmap_copy(
pix, &tpix, 0 , 0, 0, 0, tpix.width(), tpix.height());
155 if (
pix !=
nullptr) {
164 pix->fill(Qt::transparent);
177 if ((value() != minimum() && value() < maximum())
178 || (0 == minimum() && 0 == maximum())) {
190 QLinearGradient g, gx;
196 int pixel_size =
sfont->pixelSize();
199 if (
pix !=
nullptr) {
203 if (pixel_size > 0) {
204 f_pixel_size = pixel_size;
206 QFontMetrics fm(*
sfont);
208 f_pixel_size = fm.height();
219 p.drawLine(rx.topLeft(), rx.topRight());
220 p.drawLine(rx.bottomLeft(), rx.bottomRight());
228 r = QRect(0, 0, pbw * value() / max, pbh);
230 gx = QLinearGradient(0 , 0, 0, pbh);
231 c = QColor(palette().
color(QPalette::Highlight));
233 gx.setColorAt(0.5, QColor(40, 40, 40));
235 p.fillRect(r, QBrush(gx));
238 g = QLinearGradient(0 , 0, pbw, pbh);
243 p.fillRect(r, QBrush(g));
245 p.setClipping(
false);
246 r2 = QRect(pbw * value() / max, 0, pbw, pbh);
247 c = palette().color(QPalette::Window);
251 if (
pix !=
nullptr) {
252 p.setCompositionMode(QPainter::CompositionMode_SourceOver);
253 p.drawPixmap(2 , 2, pix_width
254 *
static_cast<float>(
pix->width()) /
pix->height(),
255 pix_width, *
pix, 0, 0,
pix->width(),
pix->height());
259 c = palette().color(QPalette::Text);
261 sfont->setCapitalization(QFont::AllUppercase);
262 sfont->setBold(
true);
264 if (text().contains(
'\n')) {
267 QFont tmp_font = *
sfont;
269 i = text().indexOf(
'\n');
271 s2 = text().right(text().length() - i);
273 if (2 * f_pixel_size >= 3 * pbh / 2) {
274 tmp_font.setPixelSize(pbh / 3);
279 j = pbh - 2 * f_pixel_size;
280 p.setCompositionMode(QPainter::CompositionMode_ColorDodge);
281 QFontMetrics fm(tmp_font);
283 if (fm.horizontalAdvance(s1) > rx.width()) {
284 s1 = fm.elidedText(s1, Qt::ElideRight, rx.width());
287 i = rx.width() - fm.horizontalAdvance(s1) + pix_width;
289 p.drawText(i / 2, j / 3 + f_pixel_size, s1);
291 if (fm.horizontalAdvance(s2) > rx.width()) {
292 s2 = fm.elidedText(s2, Qt::ElideRight, rx.width());
295 i = rx.width() - fm.horizontalAdvance(s2) + pix_width;
298 p.drawText(i / 2, pbh - j / 3, s2);
306 j = pbh - f_pixel_size;
307 p.setCompositionMode(QPainter::CompositionMode_ColorDodge);
308 QFontMetrics fm(*
sfont);
310 if (fm.horizontalAdvance(s) > rx.width()) {
311 s = fm.elidedText(s, Qt::ElideRight, rx.width());
314 i = rx.width() - fm.horizontalAdvance(s) + pix_width;
316 p.drawText(i / 2, j / 2 + f_pixel_size, s);
329 int chunk_width = 16;
333 for (offset = 0; offset < (
size * 2); offset += (chunk_width * 2)) {
336 a.setPoints(4, r.x(), r.y() + offset,
337 r.x() + r.width(), (r.y() + offset) -
size,
339 (r.y() + offset + chunk_width) -
size,
340 r.x(), r.y() + offset + chunk_width);
351 QPen pen(QColor(0, 0, 0));
356 p.setRenderHint(QPainter::Antialiasing);
358 p.drawLine(0, 0, pix->width(), pix->height());
359 p.drawLine(pix->width(), 0, 0, pix->height());
367 struct city *pcity): QLabel(parent)
431 impr_pixmap->map_pixmap.fill(QColor(palette().
color(QPalette::Highlight)));
436 impr_pixmap->map_pixmap.fill(QColor(palette().
color(QPalette::Highlight)));
474 layout =
new QHBoxLayout(
this);
483 QSizePolicy size_fixed_policy(QSizePolicy::Fixed,
484 QSizePolicy::MinimumExpanding,
485 QSizePolicy::Slider);
487 setSizePolicy(size_fixed_policy);
515 setUpdatesEnabled(
false);
516 setMouseTracking(
false);
518 for (j = 0; j < i; j++) {
528 setMouseTracking(
true);
529 setUpdatesEnabled(
true);
539 p = parentWidget()->parentWidget()->pos();
542 QWheelEvent new_event(QPoint(5, 5), p + QPoint(5,5),
event->pixelDelta(),
548 QWheelEvent new_event(QPoint(5, 5), p + QPoint(5,5),
event->pixelDelta(),
550 event->angleDelta().y(),
551 Qt::Horizontal,
event->buttons(),
554 QApplication::sendEvent(parentWidget(), &new_event);
567 setUpdatesEnabled(
false);
570 for (j = 0; j < i; j++) {
573 layout->addWidget(ui, 0, Qt::AlignVCenter);
580 parentWidget()->parentWidget()->setFixedHeight(0);
584 setUpdatesEnabled(
true);
596 p = parentWidget()->parentWidget()->pos();
599 QWheelEvent new_event(QPoint(5, 5), p + QPoint(5,5),
event->pixelDelta(),
605 QWheelEvent new_event(QPoint(5, 5), p + QPoint(5,5),
event->pixelDelta(),
607 event->angleDelta().y(),
608 Qt::Horizontal,
event->buttons(),
611 QApplication::sendEvent(parentWidget()->parentWidget(),
624 if (
event->button() == Qt::LeftButton) {
640 PL_(
"Sell %s for %d gold?",
641 "Sell %s for %d gold?", price),
645 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
646 ask->setAttribute(Qt::WA_DeleteOnClose);
647 connect(ask, &hud_message_box::accepted, [=]() {
650 if (pcity ==
nullptr) {
663 bool supp,
int hppy_cost) : QLabel()
670 struct canvas *unit_pixmap;
696 unit_pixmap->
map_pixmap.fill(Qt::transparent);
706 unit_pixmap->
map_pixmap.fill(Qt::transparent);
711 cropped_img =
img.copy(crop);
714 * isosize, Qt::SmoothTransformation);
717 Qt::SmoothTransformation);
720 if (tmp !=
nullptr) {
725 setFixedWidth(
unit_img.width() + 4);
735 setPixmap(QPixmap::fromImage(
unit_img));
761 menu =
new QMenu(
gui()->central_wdg);
778 menu->addAction(
load);
797 menu->popup(
event->globalPos());
805 struct unit_list *qunits;
811 qunits = unit_list_new();
812 unit_list_append(qunits,
qunit);
813 activate =
new QAction(
_(
"Activate unit"),
this);
820 sentry =
new QAction(
_(
"Sentry unit"),
this);
827 fortify =
new QAction(
_(
"Fortify unit"),
this);
848 load =
new QAction(
_(
"Load"),
this);
855 unload =
new QAction(
_(
"Unload"),
this);
862 unload_trans =
new QAction(
_(
"Unload All From Transporter"),
this);
869 upgrade =
new QAction(
_(
"Upgrade Unit"),
this);
875 unit_list_destroy(qunits);
883 struct unit_list *punits;
886 if (
punit ==
nullptr) {
890 punits = unit_list_new();
891 unit_list_append(punits,
punit);
893 unit_list_destroy(punits);
925 struct unit_list *qunits;
926 qunits = unit_list_new();
927 unit_list_append(qunits,
qunit);
929 unit_list_destroy(qunits);
982 QImage temp_img(unit_img.size(), QImage::Format_ARGB32_Premultiplied);
986 p.fillRect(0, 0, unit_img.width(), unit_img.height(),
987 QColor(palette().
color(QPalette::Highlight)));
988 p.drawImage(0, 0, unit_img);
991 setPixmap(QPixmap::fromImage(temp_img));
1010 p = parentWidget()->parentWidget()->pos();
1013 QWheelEvent new_event(QPoint(5, 5), p + QPoint(5,5),
event->pixelDelta(),
1014 event->angleDelta(),
1019 QWheelEvent new_event(QPoint(5, 5), p + QPoint(5,5),
event->pixelDelta(),
1020 event->angleDelta(),
1021 event->angleDelta().y(),
1022 Qt::Horizontal,
event->buttons(),
1025 QApplication::sendEvent(parentWidget()->parentWidget(),
1034 if (
event->button() == Qt::LeftButton) {
1057 layout =
new QHBoxLayout(
this);
1084 QSizePolicy size_fixed_policy(QSizePolicy::Fixed,
1085 QSizePolicy::MinimumExpanding,
1086 QSizePolicy::Slider);
1087 setSizePolicy(size_fixed_policy);
1098 p = parentWidget()->parentWidget()->pos();
1101 QWheelEvent new_event(QPoint(5, 5), p + QPoint(5,5),
event->pixelDelta(),
1102 event->angleDelta(),
1107 QWheelEvent new_event(QPoint(5, 5), p + QPoint(5,5),
event->pixelDelta(),
1108 event->angleDelta(),
1109 event->angleDelta().y(),
1110 Qt::Horizontal,
event->buttons(),
1113 QApplication::sendEvent(parentWidget(), &new_event);
1127 setUpdatesEnabled(
false);
1130 for (j = 0; j < i; j++) {
1132 layout->addWidget(ui, 0, Qt::AlignVCenter);
1149 parentWidget()->parentWidget()->setFixedHeight(0);
1152 setUpdatesEnabled(
true);
1165 setUpdatesEnabled(
false);
1166 setMouseTracking(
false);
1168 for (j = 0; j < i; j++) {
1170 layout->removeWidget(ui);
1178 setMouseTracking(
true);
1179 setUpdatesEnabled(
true);
1204 i = 1 + (num_citizens * 5 / 200);
1206 citnum =
event->pos().x() / w;
1235 view->map_pixmap.fill(Qt::black);
1240 setContextMenuPolicy(Qt::CustomContextMenu);
1241 connect(
this, SIGNAL(customContextMenuRequested(
const QPoint &)),
1262 painter.begin(
this);
1267 QBrush(QColor(60, 60 , 60 , 110)));
1268 painter.setPen(QColor(255, 255, 255));
1270 str = QString(
_(
"Governor %1"))
1308 Qt::KeepAspectRatio,
1309 Qt::SmoothTransformation);
1358 QAction *con_cultivate =
nullptr;
1359 QAction *con_irrig =
nullptr;
1360 QAction *con_plant =
nullptr;
1361 QAction *con_mine =
nullptr;
1362 QAction *con_road =
nullptr;
1363 QAction *con_trfrm =
nullptr;
1364 QAction *con_pollution =
nullptr;
1365 QAction *con_fallout =
nullptr;
1366 QAction *con_clear =
nullptr;
1368 QWidgetAction *wid_act;
1390 for_terr.
kind = VUT_TERRAIN;
1394 wid_act =
new QWidgetAction(
this);
1395 wid_act->setDefaultWidget(
new QLabel(
_(
"Autosettler activity:")));
1397 con_menu =
new QMenu(
this);
1398 con_menu->addAction(wid_act);
1402 con_plant = con_menu->addAction(
_(
"Plant"));
1405 con_mine = con_menu->addAction(
Q_(
"?act:Mine"));
1410 con_cultivate = con_menu->addAction(
_(
"Cultivate"));
1413 con_irrig = con_menu->addAction(
_(
"Irrigate"));
1419 con_trfrm = con_menu->addAction(
_(
"Transform"));
1423 con_road = con_menu->addAction(
_(
"Road"));
1428 con_pollution = con_menu->addAction(
_(
"Clean Pollution"));
1433 con_fallout = con_menu->addAction(
_(
"Clean Fallout"));
1436 if (ptask != NULL) {
1437 con_clear = con_menu->addAction(
_(
"Clear"));
1440 con_menu->setAttribute(Qt::WA_DeleteOnClose);
1441 connect(con_menu, &QMenu::triggered,
1443 bool target =
false;
1453 if (act == con_road) {
1456 }
else if (act == con_mine) {
1459 }
else if (act == con_plant) {
1461 }
else if (act == con_irrig) {
1464 }
else if (act == con_cultivate) {
1465 task.
activity = ACTIVITY_CULTIVATE;
1466 }
else if (act == con_trfrm) {
1467 task.
activity = ACTIVITY_TRANSFORM;
1468 }
else if (act == con_pollution) {
1469 task.
activity = ACTIVITY_POLLUTION;
1471 }
else if (act == con_fallout) {
1474 }
else if (act == con_clear) {
1509 con_menu->popup(mapToGlobal(point));
1517 QFont f = QApplication::font();
1520 QGridLayout *gridl, *slider_grid;
1521 QGroupBox *group_box, *map_box, *prod_options,
1522 *qgbox, *qgbprod, *qsliderbox, *result_box;
1523 QHBoxLayout *hbox, *hbox_layout, *prod_option_layout,
1525 QHeaderView *header;
1526 QLabel *lab2, *label, *ql, *some_label;
1527 QPushButton *qpush2;
1528 QScrollArea *scroll, *scroll2, *scroll3, *scroll_info, *scroll_unit;
1529 QSizePolicy size_expanding_policy(QSizePolicy::Expanding,
1530 QSizePolicy::Expanding);
1532 QStringList info_list, str_list;
1533 QVBoxLayout *lefttop_layout, *units_layout, *worklist_layout,
1534 *right_layout, *vbox, *vbox_layout, *zoom_vbox, *v_layout;
1535 QWidget *split_widget1, *split_widget2, *info_wdg, *curr_unit_wdg,
1536 *supp_unit_wdg, *curr_impr_wdg;
1538 int h = 2 * fm.height() + 2;
1551 setMouseTracking(
true);
1555 lcity_name->setToolTip(
_(
"Click to change city name"));
1559 size_expanding_policy.setHorizontalStretch(0);
1560 size_expanding_policy.setVerticalStretch(0);
1561 setSizePolicy(size_expanding_policy);
1565 map_box =
new QGroupBox(
this);
1568 info_wdg =
new QWidget(
this);
1573 info_wdg->setFont(*small_font);
1578 for (
enum city_info info_field = city_info_begin();
1579 info_field != city_info_end();
1580 info_field = city_info_next(info_field)) {
1582 ql =
new QLabel(
_(city_info_name(info_field)), info_wdg);
1583 ql->setFont(*small_font);
1586 qlt[info_field] =
new QLabel(info_wdg);
1587 qlt[info_field]->setFont(*small_font);
1605 zoom_vbox =
new QVBoxLayout();
1622 vbox_layout =
new QVBoxLayout;
1623 hbox_layout =
new QHBoxLayout;
1624 hbox_layout->addStretch(100);
1625 hbox_layout->addWidget(
view);
1626 hbox_layout->addStretch(100);
1627 hbox_layout->addLayout(zoom_vbox);
1628 vbox_layout->addLayout(hbox_layout);
1630 map_box->setLayout(vbox_layout);
1631 map_box->setTitle(
_(
"City map"));
1641 scroll =
new QScrollArea;
1642 scroll->setWidgetResizable(
true);
1644 + scroll->horizontalScrollBar()->height());
1645 scroll->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
1648 scroll2 =
new QScrollArea;
1649 scroll2->setWidgetResizable(
true);
1651 + scroll2->horizontalScrollBar()->height());
1652 scroll2->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
1656 scroll3 =
new QScrollArea;
1657 scroll3->setWidgetResizable(
true);
1659 + scroll3->horizontalScrollBar()->height());
1660 scroll3->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
1662 scroll->setProperty(
"city_scroll",
true);
1663 scroll2->setProperty(
"city_scroll",
true);
1664 scroll3->setProperty(
"city_scroll",
true);
1666 lefttop_layout =
new QVBoxLayout();
1667 worklist_layout =
new QVBoxLayout();
1668 right_layout =
new QVBoxLayout();
1670 units_layout =
new QVBoxLayout();
1675 prod_option_layout =
new QHBoxLayout;
1679 label =
new QLabel();
1681 label->setToolTip(
_(
"Show buildings"));
1683 prod_option_layout->addWidget(label, Qt::AlignLeft);
1684 prod_option_layout->addStretch(100);
1685 label =
new QLabel();
1687 label->setToolTip(
_(
"Show units"));
1691 prod_option_layout->addWidget(
show_units, Qt::AlignHCenter);
1692 prod_option_layout->addWidget(label, Qt::AlignHCenter);
1693 prod_option_layout->addStretch(100);
1694 label =
new QLabel();
1696 label->setToolTip(
_(
"Show wonders"));
1701 prod_option_layout->addWidget(label);
1702 prod_option_layout->addStretch(100);
1703 label =
new QLabel();
1705 label->setToolTip(
_(
"Show future targets"));
1710 prod_option_layout->addWidget(label, Qt::AlignRight);
1711 prod_options =
new QGroupBox(
this);
1712 prod_options->setLayout(prod_option_layout);
1713 prod_options->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
1716 button =
new QPushButton;
1718 button->setIconSize(QSize(56, 56));
1719 button->setToolTip(
_(
"Close city dialog"));
1720 connect(
button, &QAbstractButton::clicked,
this, &QWidget::hide);
1740 button->setFixedSize(64, 64);
1744 vbox_layout =
new QVBoxLayout;
1747 vbox_layout->addWidget(
button);
1749 hbox_layout =
new QHBoxLayout;
1751 hbox_layout->addLayout(vbox_layout, Qt::AlignLeft);
1752 hbox_layout->addWidget(info_wdg, Qt::AlignLeft);
1753 hbox_layout->addWidget(map_box, Qt::AlignCenter);
1757 lefttop_layout->addStretch(0);
1758 lefttop_layout->addLayout(hbox_layout);
1759 lefttop_layout->addStretch(50);
1762 curr_unit_wdg =
new QWidget();
1763 supp_unit_wdg =
new QWidget();
1764 curr_impr_wdg =
new QWidget();
1765 v_layout =
new QVBoxLayout;
1767 v_layout->addWidget(scroll3);
1768 v_layout->setContentsMargins(0 , 0 , 0, 0);
1769 v_layout->setSpacing(0);
1770 curr_impr_wdg->setLayout(v_layout);
1771 v_layout =
new QVBoxLayout;
1773 v_layout->addWidget(scroll2);
1774 v_layout->setContentsMargins(0 , 0 , 0, 0);
1775 v_layout->setSpacing(0);
1776 curr_unit_wdg->setLayout(v_layout);
1777 v_layout =
new QVBoxLayout;
1779 v_layout->addWidget(scroll);
1780 v_layout->setContentsMargins(0 , 0 , 0, 0);
1781 v_layout->setSpacing(0);
1782 supp_unit_wdg->setLayout(v_layout);
1784 units_layout->addWidget(curr_unit_wdg);
1785 units_layout->addWidget(supp_unit_wdg);
1786 units_layout->addWidget(curr_impr_wdg);
1787 units_layout->setSpacing(0);
1788 units_layout->setContentsMargins(0 , 0 , 0, 0);
1790 vbox =
new QVBoxLayout;
1791 vbox_layout =
new QVBoxLayout;
1792 qgbprod =
new QGroupBox;
1793 group_box =
new QGroupBox(
_(
"Worklist Option"));
1794 work_but_layout =
new QHBoxLayout;
1802 QStyle::SP_DialogDiscardButton),
"");
1811 r1 =
new QRadioButton(
_(
"Change"));
1812 r2 =
new QRadioButton(
_(
"Insert Before"));
1813 r3 =
new QRadioButton(
_(
"Insert After"));
1814 r4 =
new QRadioButton(
_(
"Add Last"));
1815 r4->setChecked(
true);
1816 group_box->setLayout(vbox);
1820 p_table_p->setProperty(
"showGrid",
"false");
1821 p_table_p->setProperty(
"selectionBehavior",
"SelectRows");
1822 p_table_p->setEditTriggers(QAbstractItemView::NoEditTriggers);
1823 p_table_p->verticalHeader()->setVisible(
false);
1824 p_table_p->horizontalHeader()->setVisible(
false);
1825 p_table_p->setSelectionMode(QAbstractItemView::SingleSelection);
1828 p_table_p->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContentsOnFirstShow);
1829 p_table_p->setContextMenuPolicy(Qt::CustomContextMenu);
1830 p_table_p->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
1832 header->setStretchLastSection(
true);
1834 qgbprod->setTitle(
_(
"Worklist"));
1835 vbox_layout->setSpacing(0);
1836 vbox_layout->addWidget(prod_options);
1839 vbox_layout->addLayout(work_but_layout);
1841 qgbprod->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
1842 qgbprod->setLayout(vbox_layout);
1844 worklist_layout->setSpacing(0);
1845 worklist_layout->addWidget(qgbprod);
1847 &QWidget::customContextMenuRequested,
this,
1855 &QTableWidget::itemDoubleClicked,
1858 SIGNAL(selectionChanged(
const QItemSelection &,
1859 const QItemSelection &)),
1861 const QItemSelection &)));
1863 gridl =
new QGridLayout;
1874 info_list <<
_(
"Cities:") <<
_(
"Luxuries:") <<
_(
"Buildings:")
1875 <<
_(
"Nationality:") <<
_(
"Units:") <<
_(
"Wonders:");
1877 for (
int i = 0; i < info_list.count(); i++) {
1879 gridl->addWidget(
lab_table[i], i, 1, 1, 1);
1880 lab2 =
new QLabel(
this);
1881 lab2->setFont(*small_font);
1883 lab2->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
1884 lab2->setText(info_list.at(i));
1885 gridl->addWidget(lab2, i, 0, 1, 1);
1888 gridl->setSpacing(0);
1898 qgbox =
new QGroupBox(
_(
"Presets:"));
1899 qsliderbox =
new QGroupBox(
_(
"Governor settings"));
1900 result_box =
new QGroupBox(
_(
"Results:"));
1901 hbox =
new QHBoxLayout;
1902 gridl =
new QGridLayout;
1903 slider_grid =
new QGridLayout;
1906 =
new QPushButton(style()->standardIcon(QStyle::SP_DialogSaveButton),
1915 cma_table->setProperty(
"showGrid",
"false");
1916 cma_table->setProperty(
"selectionBehavior",
"SelectRows");
1917 cma_table->setEditTriggers(QAbstractItemView::NoEditTriggers);
1918 cma_table->setSelectionMode(QAbstractItemView::SingleSelection);
1919 cma_table->setContextMenuPolicy(Qt::CustomContextMenu);
1920 cma_table->verticalHeader()->setVisible(
false);
1921 cma_table->horizontalHeader()->setVisible(
false);
1922 cma_table->horizontalHeader()->setSectionResizeMode(
1923 QHeaderView::Stretch);
1926 SIGNAL(selectionChanged(
const QItemSelection &,
1927 const QItemSelection &)),
1929 const QItemSelection &)));
1931 &QWidget::customContextMenuRequested,
this,
1933 connect(
cma_table, &QTableWidget::cellDoubleClicked,
this,
1935 gridl->addWidget(
cma_table, 0, 0, 1, 2);
1936 qgbox->setLayout(gridl);
1938 result_box->setLayout(hbox);
1939 str_list <<
_(
"Food") <<
_(
"Shield") <<
_(
"Trade") <<
_(
"Gold")
1940 <<
_(
"Luxury") <<
_(
"Science") <<
_(
"Celebrate")
1941 <<
_(
"Maximize growth");
1942 some_label =
new QLabel(
_(
"Minimal Surplus"));
1944 some_label->setAlignment(Qt::AlignRight);
1945 slider_grid->addWidget(some_label, 0, 0, 1, 3);
1946 some_label =
new QLabel(
_(
"Priority"));
1948 some_label->setAlignment(Qt::AlignCenter);
1949 slider_grid->addWidget(some_label, 0, 3, 1, 2);
1951 list_size = str_list.count();
1952 for (
int i = 0; i < list_size; i++) {
1953 some_label =
new QLabel(str_list.at(i));
1954 slider_grid->addWidget(some_label, i + 1, 0, 1, 1);
1955 some_label =
new QLabel(
"0");
1956 some_label->setMinimumWidth(25);
1958 if (i < list_size - 2) {
1959 slider =
new QSlider(Qt::Horizontal);
1960 slider->setPageStep(1);
1961 slider->setFocusPolicy(Qt::TabFocus);
1963 slider->setRange(-20, 20);
1964 slider->setSingleStep(1);
1965 slider_grid->addWidget(some_label, i + 1, 1, 1, 1);
1966 slider_grid->addWidget(slider, i + 1, 2, 1, 1);
1967 slider->setProperty(
"FC", QVariant::fromValue((
void *)some_label));
1970 }
else if (i == list_size - 2) {
1984 if (i <= list_size - 2) {
1985 some_label =
new QLabel(
"0");
1986 some_label->setMinimumWidth(25);
1987 slider =
new QSlider(Qt::Horizontal);
1988 slider->setFocusPolicy(Qt::TabFocus);
1989 slider->setRange(0, 25);
1991 slider->setProperty(
"FC", QVariant::fromValue((
void *)some_label));
1992 slider_grid->addWidget(some_label, i + 1, 3, 1, 1);
1993 slider_grid->addWidget(slider, i + 1, 4, 1, 1);
2002 slider_grid->addWidget(qpush2,
O_LAST + 4, 3, 1, 2);
2004 qsliderbox->setLayout(slider_grid);
2008 hbox =
new QHBoxLayout;
2009 QScrollArea *govA =
new QScrollArea();
2012 hbox->addStretch(10);
2013 govA->setWidget(qsliderbox);
2014 govA->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents);
2015 right_layout->addWidget(qgbox);
2016 right_layout->addLayout(hbox);
2017 right_layout->addWidget(govA);
2019 split_widget1 =
new QWidget;
2020 split_widget1->setLayout(worklist_layout);
2021 split_widget2 =
new QWidget;
2022 split_widget2->setLayout(units_layout);
2031 top_widget->setSizePolicy(QSizePolicy::Minimum,
2032 QSizePolicy::Minimum);
2033 scroll_info =
new QScrollArea();
2034 scroll_info->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents);
2035 scroll_unit =
new QScrollArea();
2037 scroll_info->setWidgetResizable(
true);
2041 QSizePolicy::MinimumExpanding);
2043 scroll_unit->setWidgetResizable(
true);
2051 split_widget1 =
new QWidget(
this);
2052 split_widget2 =
new QWidget(
this);
2054 split_widget2->setLayout(right_layout);
2061 setSizeGripEnabled(
true);
2064 installEventFilter(
this);
2077 int item, targets_used;
2078 QList<cid> prod_list;
2095 for (i = 0; i < prod_list.size(); i++) {
2096 if (prod_list.at(i) == cprod) {
2104 if (
pos == prod_list.size()) {
2108 pos = prod_list.size() - 1;
2131 setUpdatesEnabled(
false);
2136 Qt::FindDirectChildrenOnly);
2143 Qt::FindDirectChildrenOnly);
2149 setUpdatesEnabled(
true);
2169 view->setDisabled(
true);
2181 view->setEnabled(
true);
2206 if (
selected_row_p >= 0 && selected_row_p < p_table_p->rowCount()) {
2210 if (
selected_row_p >= 0 && selected_row_p < p_table_p->rowCount() - 1) {
2214 if (
selected_row_p > 0 && selected_row_p < p_table_p->rowCount()) {
2235 removeEventFilter(
this);
2251 gui()->qt_settings.city_geometry = saveGeometry();
2262 if (!
gui()->qt_settings.city_geometry.isNull()) {
2263 restoreGeometry(
gui()->qt_settings.city_geometry);
2268 QRect rect = QApplication::primaryScreen()->availableGeometry();
2270 resize((rect.width() * 4) / 5, (rect.height() * 5) / 6);
2279 gui()->qt_settings.city_geometry = saveGeometry();
2292 if (
event->type() == QEvent::KeyPress) {
2295 if (
event->type() == QEvent::ShortcutOverride) {
2296 QKeyEvent *key_event =
static_cast<QKeyEvent *
>(
event);
2297 if (key_event->key() == Qt::Key_Right) {
2299 event->setAccepted(
true);
2302 if (key_event->key() == Qt::Key_Left) {
2304 event->setAccepted(
true);
2307 if (key_event->key() == Qt::Key_Up) {
2309 event->setAccepted(
true);
2312 if (key_event->key() == Qt::Key_Down) {
2314 event->setAccepted(
true);
2319 return QObject::eventFilter(obj,
event);
2337 ask->setAttribute(Qt::WA_DeleteOnClose);
2338 connect(ask, &hud_message_box::accepted,
this, [=]() {
2340 QByteArray ask_bytes;
2386 _(
"Name new preset"),
2388 ask->setAttribute(Qt::WA_DeleteOnClose);
2389 connect(ask, &hud_message_box::accepted,
this,
2392 QByteArray ask_bytes = ask->
input_edit.text().toUtf8();
2393 QString text = ask_bytes.data();
2394 if (!text.isEmpty()) {
2395 param.allow_disorder = false;
2396 param.allow_specialists = true;
2397 param.require_happy = cma_celeb_checkbox->isChecked();
2398 param.max_growth = cma_max_growth->isChecked();
2399 param.happy_factor = slider_tab[2 * O_LAST + 1]->value();
2401 for (int i = O_FOOD; i < O_LAST; i++) {
2402 param.minimal_surplus[i] = slider_tab[2 * i]->value();
2403 param.factor[i] = slider_tab[2 * i + 1]->value();
2406 ask_bytes = text.toUtf8();
2473 const QItemSelection &ds)
2477 QModelIndexList indexes = sl.indexes();
2479 if (indexes.isEmpty() ||
cma_table->signalsBlocked()) {
2483 index = indexes.at(0);
2484 int ind = index.row();
2523 qvar =
slider_tab[2 * output + 1]->property(
"FC");
2524 label =
reinterpret_cast<QLabel *
>(qvar.value<
void *>());
2525 label->setText(QString::number(param.
factor[output]));
2527 qvar =
slider_tab[2 * output]->property(
"FC");
2528 label =
reinterpret_cast<QLabel *
>(qvar.value<
void *>());
2535 label =
reinterpret_cast<QLabel *
>(qvar.value<
void *>());
2557 QTableWidgetItem *
item;
2566 item =
new QTableWidgetItem;
2574 item =
new QTableWidgetItem;
2575 item->setText(
_(
"No governor defined"));
2582 pix = style()->standardPixmap(QStyle::SP_DialogApplyButton);
2583 pix = pix.scaled(2 * pix.width(), 2 * pix.height(),
2584 Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
2588 cma_result->setText(QString(
_(
"<h3>Governor Enabled<br>(%1)</h3>"))
2589 .arg(s.toHtmlEscaped()));
2592 pix = style()->standardPixmap(QStyle::SP_DialogCancelButton);
2593 pix = pix.scaled(1.6 * pix.width(), 1.6 * pix.height(),
2594 Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
2597 cma_result->setText(QString(
_(
"<h3>Governor Disabled</h3>")));
2598 cma_result->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
2605 if (i >= 0 && i < cma_table->rowCount()) {
2634 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
2635 ask->setDefaultButton(QMessageBox::Cancel);
2636 ask->setAttribute(Qt::WA_DeleteOnClose);
2637 connect(ask, &hud_message_box::accepted,
this,
2665 slider = qobject_cast<QSlider *>(sender());
2666 qvar = slider->property(
"FC");
2668 if (qvar.isNull() || !qvar.isValid()) {
2672 label =
reinterpret_cast<QLabel *
>(qvar.value<
void *>());
2673 label->setText(QString::number(value));
2686 bv_city_options new_options;
2690 if (allow_disband) {
2691 BV_SET(new_options, CITYO_DISBAND);
2693 BV_CLR(new_options, CITYO_DISBAND);
2707 QMenu *cma_menu =
new QMenu(
this);
2708 QAction *cma_del_item;
2710 cma_menu->setAttribute(Qt::WA_DeleteOnClose);
2711 cma_del_item = cma_menu->addAction(
_(
"Remove Governor"));
2712 connect(cma_menu, &QMenu::triggered,
this,
2714 if (act == cma_del_item) {
2719 cma_menu->popup(QCursor::pos());
2732 QMap<QString, cid>
list;
2733 QMap<QString, cid>::const_iterator map_iter;
2743 list_menu =
new QMenu(
this);
2744 change_menu = list_menu->addMenu(
_(
"Change worklist"));
2745 insert_menu = list_menu->addMenu(
_(
"Insert worklist"));
2746 wl_clear = list_menu->addAction(
_(
"Clear"));
2754 if (
list.count() == 0) {
2755 wl_empty =
change_menu->addAction(
_(
"(no worklists defined)"));
2756 insert_menu->addAction(wl_empty);
2759 map_iter =
list.constBegin();
2761 while (map_iter !=
list.constEnd()) {
2763 action->setData(map_iter.value());
2765 action = insert_menu->addAction(map_iter.key());
2766 action->setData(map_iter.value());
2771 wl_save = list_menu->addAction(
_(
"Save worklist"));
2774 disband =
options_menu->addAction(
_(
"Allow disbanding city"));
2775 disband->setCheckable(
true);
2777 connect(disband, &QAction::triggered,
this,
2780 connect(
change_menu, &QMenu::triggered,
this, [=](QAction *act) {
2781 QVariant
id = act->data();
2799 connect(insert_menu, &QMenu::triggered,
this,
2801 QVariant
id = act->data();
2819 list_menu->popup(QCursor::pos());
2834 str = QString(
PL_(
"Buy (%1 gold)",
"Buy (%1 gold)",
2835 value)).arg(QString::number(value));
2841 str = QString(
_(
"Buy"));
2860 i = 1 + (num_citizens * 5 / 200);
2862 QRect source_rect(0, 0, w, h);
2863 QRect dest_rect(0, 0, w, h);
2864 width = w * num_citizens;
2874 for (j = 0, i = 0; i < num_citizens; i++, j++) {
2875 dest_rect.moveTo(i * w, 0);
2878 p.drawPixmap(dest_rect, *pix, source_rect);
2894 for (j = 0, i = 0; i < num_citizens; i++, j++) {
2895 dest_rect.moveTo(i * w, 0);
2898 p.drawPixmap(dest_rect, *pix, source_rect);
2936 setUpdatesEnabled(
false);
2957 setUpdatesEnabled(
true);
2968 QFont f = QApplication::font();
2970 QPixmap *pix = NULL;
2973 QStringList info_list;
2974 QTableWidgetItem *
item;
2981 h = fm.height() + 6;
2985 info_list <<
_(
"#") <<
_(
"Flag") <<
_(
"Nation");
2992 item =
new QTableWidgetItem;
2998 if (nationality_i == 0) {
3001 fc_snprintf(buf,
sizeof(buf),
"%d", nationality_i);
3015 pix_scaled = pix->scaledToHeight(h);
3016 item->setData(Qt::DecorationRole, pix_scaled);
3018 item->setText(
"FLAG MISSING");
3053 buf_info[i][0] =
'\0';
3054 buf_tooltip[i][0] =
'\0';
3059 fc_snprintf(buf_info[INFO_CITIZEN],
sizeof(buf_info[INFO_CITIZEN]),
3061 fc_snprintf(buf_tooltip[INFO_CITIZEN],
sizeof(buf_tooltip[INFO_CITIZEN]),
3062 _(
"Population: %d, Specialists: %d"),
3103 if (granaryturns == 0) {
3114 PL_(
"%d turn",
"%d turns", abs(granaryturns)),
3134 "%5.1f%%", (
float) illness / 10.0);
3152 qlt[i]->setText(QString(buf_info[i]));
3154 if (buf_tooltip[i][0]) {
3155 qlt[i]->setToolTip(
"<pre>" + QString(buf_tooltip[i]).toHtmlEscaped()
3167 QIcon q_icon =::QIcon(q_pix);
3169 setContentsMargins(0, 0 ,0 ,0);
3170 setWindowIcon(q_icon);
3200 struct unit_list *units;
3223 n = unit_list_size(units);
3244 n = unit_list_size(units);
3256 const QItemSelection &ds)
3259 QModelIndexList indexes = sl.indexes();
3261 if (indexes.isEmpty()) {
3265 index = indexes.at(0);
3276 struct city *other_pcity = NULL;
3288 for (i = 0; i <
size; i++) {
3294 if (i >=
size - 1) {
3311 struct city *other_pcity = NULL;
3323 for (i = 0; i <
size; i++) {
3329 if (i == 0 || i ==
size) {
3374 char buf[1024], buf2[1024];
3386 "Treasury contains %d gold.",
3390 "Buy %s for %d gold?", value),
3393 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
3394 ask->setDefaultButton(QMessageBox::Cancel);
3395 ask->setAttribute(Qt::WA_DeleteOnClose);
3396 connect(ask, &hud_message_box::accepted,
this, [=]() {
3413 QFont f = QApplication::font();
3415 QPixmap *pix = NULL;
3418 QTableWidgetItem *qitem;
3420 int h,
cost,
item, targets_used, col, upkeep;
3430 h = fm.height() + 6;
3446 pix_scaled = pix->scaledToHeight(h);
3458 if (VUT_UTYPE == target.
kind) {
3463 direction8_invalid());
3477 for (col = 0; col < 3; col++) {
3478 qitem =
new QTableWidgetItem();
3485 pix_scaled = pix->scaledToHeight(h);
3486 qitem->setData(Qt::DecorationRole, pix_scaled);
3491 if (
str.contains(
'[') &&
str.contains(
']')) {
3494 ii =
str.lastIndexOf(
'[');
3495 ij =
str.lastIndexOf(
']');
3497 str =
str.remove(ii, ij - ii + 1);
3500 qitem->setText(
str);
3504 qitem->setTextAlignment(Qt::AlignRight);
3505 qitem->setText(QString::number(
cost));
3512 p_table_p->horizontalHeader()->setStretchLastSection(
false);
3515 p_table_p->horizontalHeader()->setStretchLastSection(
true);
3521 curr_impr->setText(QString(
_(
"Improvements - upkeep %1")).arg(upkeep));
3597 if (selected_row_p < 1 || selected_row_p >=
p_table_p->rowCount()) {
3618 QTableWidgetItem *
item;
3639 if (selected_row_p < 0 || selected_row_p >=
p_table_p->rowCount() - 1) {
3663 _(
"Save current worklist"),
3665 ask->setAttribute(Qt::WA_DeleteOnClose);
3666 connect(ask, &hud_message_box::accepted, [=]() {
3669 QByteArray ask_bytes;
3674 text = ask_bytes.data();
3675 if (!text.isEmpty()) {
3676 ask_bytes = text.toUtf8();
3694 .replace(
"&",
"&&"));
3714 setWindowTitle(buf);
3792 l =
city_dlg->findChildren<QLabel *>();
3796 for (
int i = 0; i < l.size(); ++i) {
3798 l.at(i)->setFont(*f);
3811 struct city *pcity_sup, *pcity_pre;
3842 QHelpEvent *help_event;
3843 QString item_tooltip;
3846 if (ev->type() == QEvent::ToolTip) {
3847 QAbstractItemView *
view = qobject_cast<QAbstractItemView *>(obj->parent());
3853 help_event =
static_cast<QHelpEvent *
>(ev);
3854 QPoint
pos = help_event->pos();
3855 QModelIndex index =
view->indexAt(
pos);
3858 if (!index.isValid()) {
3862 item_tooltip =
view->model()->data(index, Qt::ToolTipRole).toString();
3863 rect =
view->visualRect(index);
3865 hpos = help_event->globalPos();
3867 rect.setX(rect.x() + hpos.x());
3868 rect.setY(rect.y() + hpos.y());
3870 if (!item_tooltip.isEmpty()) {
3871 QToolTip::showText(help_event->globalPos(), item_tooltip,
view, rect);
3873 QToolTip::hideText();
3887 return QString(
"<b>" + text +
"</b>");
3899 QString s1, s2,
str;
3902 if (pcity !=
nullptr) {
3905 upkeep = QString::number(building->
upkeep);
3908 if (pobs->source.kind == VUT_ADVANCE) {
3914 str =
_(
"Obsolete by:");
3916 def_str =
"<p style='white-space:pre'><b>"
3919 if (pcity !=
nullptr) {
3920 def_str += QString(
_(
"Cost: %1, Upkeep: %2\n"))
3922 .arg(upkeep).toHtmlEscaped();
3926 def_str += QString(
_(
"Cost Estimate: %1, Upkeep: %2\n"))
3928 .arg(upkeep).toHtmlEscaped();
3930 if (s1.compare(s2) != 0) {
3931 def_str = def_str +
str.toHtmlEscaped() +
"\n";
3933 def_str = def_str +
"\n";
3942 def_str = def_str +
str.toHtmlEscaped();
3954 QString obsolete_str;
3965 obsolete_str = QString(
"</td></tr><tr><td colspan=\"3\">");
3969 obsolete_str = obsolete_str + QString(
_(
"Obsoleted by %1 (%2)."))
3973 obsolete_str = obsolete_str + QString(
_(
"Obsoleted by %1."))
3977 def_str +=
"<table width=\"100\%\"><tr><td>"
3978 +
bold(QString(
_(
"Attack:"))) +
" "
3980 + QString(
"</td><td>") +
bold(QString(
_(
"Defense:"))) +
" "
3982 + QString(
"</td><td>") +
bold(QString(
_(
"Move:"))) +
" "
3984 + QString(
"</td></tr><tr><td>")
3985 +
bold(QString(
_(
"Cost:"))) +
" "
3988 + QString(
"</td><td colspan=\"2\">")
3989 +
bold(QString(
_(
"Basic Upkeep:")))
3991 + QString(
"</td></tr><tr><td>")
3992 +
bold(QString(
_(
"Hitpoints:"))) +
" "
3993 + QString::number(utype->
hp).toHtmlEscaped()
3994 + QString(
"</td><td>") +
bold(QString(
_(
"Firepower:"))) +
" "
3995 + QString::number(utype->
firepower).toHtmlEscaped()
3996 + QString(
"</td><td>") +
bold(QString(
_(
"Vision:"))) +
" "
4000 + QString(
"</td></tr></table><p style='white-space:pre'>");
4010 str =
str.trimmed().toHtmlEscaped();
4011 def_str = def_str +
str;
4022 QString
str, def_str, ret_str;
4029 target =
reinterpret_cast<universal *
>(qvar.value<
void *>());
4031 if (target == NULL) {
4032 }
else if (VUT_UTYPE == target->
kind) {
4048 ret_str = ret_str.trimmed();
4049 ret_str = def_str + ret_str.toHtmlEscaped();
4060 : QItemDelegate(parent)
4071 const QStyleOptionViewItem &
option,
4072 const QModelIndex &index)
const
4082 bool useless =
false;
4083 bool is_coinage =
false;
4084 bool is_neutral =
false;
4085 bool is_sea =
false;
4086 bool is_flying =
false;
4087 bool is_unit =
true;
4088 QPixmap pix_dec(
option.rect.width(),
option.rect.height());
4089 QStyleOptionViewItem opt;
4091 QIcon icon =
current_app()->style()->standardIcon(QStyle::SP_DialogCancelButton);
4095 if (!
option.rect.isValid()) {
4099 qvar = index.data();
4101 if (!qvar.isValid()) {
4105 target =
reinterpret_cast<universal *
>(qvar.value<
void *>());
4107 if (target == NULL) {
4111 *
sprite->
pm = icon.pixmap(100, 100);
4114 }
else if (VUT_UTYPE == target->
kind) {
4142 direction8_invalid());
4153 pix_scaled = pix->scaledToHeight(
item_height - 2, Qt::SmoothTransformation);
4160 opt = QItemDelegate::setOptions(index,
option);
4162 opt.displayAlignment = Qt::AlignLeft;
4163 opt.textElideMode = Qt::ElideMiddle;
4164 QItemDelegate::drawBackground(painter, opt, index);
4166 rect1.setWidth(pix_scaled.width() + 4);
4168 rect2.setLeft(
option.rect.left() + rect1.width());
4169 rect2.setTop(rect2.top() + (rect2.height()
4170 - painter->fontMetrics().height()) / 2);
4171 QItemDelegate::drawDisplay(painter, opt, rect2,
name);
4175 pix_dec.fill(QColor(0, 0, 255, 80));
4176 }
else if (is_flying) {
4177 pix_dec.fill(QColor(220, 0, 0, 80));
4178 }
else if (is_neutral) {
4179 pix_dec.fill(QColor(0, 120, 0, 40));
4181 pix_dec.fill(QColor(0, 0, 150, 40));
4184 QItemDelegate::drawDecoration(painter,
option,
option.rect, pix_dec);
4188 pix_dec.fill(QColor(255, 255, 0, 70));
4189 QItemDelegate::drawDecoration(painter,
option,
option.rect, pix_dec);
4192 if (!pix_scaled.isNull()) {
4193 QItemDelegate::drawDecoration(painter, opt, rect1, pix_scaled);
4209 const QStyleOptionViewItem &
option,
4210 const QRect &rect)
const
4212 QPixmap pix(
option.rect.width(),
option.rect.height());
4214 if ((
option.state & QStyle::State_MouseOver) == 0 || !rect.isValid()) {
4218 pix.fill(QColor(50, 50, 50, 50));
4219 QItemDelegate::drawDecoration(painter,
option,
option.rect, pix);
4226 const QModelIndex &index)
const
4231 s.setHeight(
pd.y());
4239 QObject *parent): QObject()
4261 return QVariant::fromValue((
void *)
target);
4276 bool su,
bool sw,
bool sb,
4278 : QAbstractListModel(parent)
4302 if (!index.isValid()) {
4306 if (index.row() >= 0 && index.row() <
rowCount() && index.column() >= 0
4309 int r, c, t ,new_index;
4313 new_index = t / 3 +
rowCount() * c;
4316 new_index = t / 3 +
rowCount() * c - 1;
4318 if (role == Qt::ToolTipRole) {
4337 int item, targets_used;
4342 sh.setY(fm.height() * 2);
4357 if (VUT_UTYPE == renegade->
kind) {
4359 sh.setX(qMax(
sh.x(), fm.horizontalAdvance(
str)));
4369 sh.setX(qMax(
sh.x(), fm.horizontalAdvance(
str)));
4387 sh.setX(2 *
sh.y() +
sh.x());
4388 sh.setX(qMin(
sh.x(), 250));
4395 const QVariant &
value,
int role)
4397 if (!index.isValid() || role != Qt::DisplayRole || role != Qt::ToolTipRole)
4400 if (index.row() >= 0 && index.row() <
rowCount() && index.column() >= 0
4418 bool future,
int when,
int curr,
4419 bool show_units,
bool buy,
4421 bool show_buildings): QTableView()
4424 QRect rect = QApplication::primaryScreen()->availableGeometry();
4425 int desk_width = rect.width();
4426 int desk_height = rect.height();
4428 setAttribute(Qt::WA_DeleteOnClose);
4429 setWindowFlags(Qt::Popup);
4430 verticalHeader()->setVisible(
false);
4431 horizontalHeader()->setVisible(
false);
4432 setProperty(
"showGrid",
false);
4439 show_wonders, show_buildings,
this);
4442 setItemDelegate(
c_p_d);
4444 viewport()->installEventFilter(
fc_tt);
4445 installEventFilter(
this);
4446 connect(selectionModel(), SIGNAL(selectionChanged(
const QItemSelection &,
4447 const QItemSelection &)),
4449 const QItemSelection &)));
4450 resizeRowsToContents();
4451 resizeColumnsToContents();
4452 setFixedWidth(3 * sh.x() + 6);
4455 if (
width() > desk_width) {
4456 setFixedWidth(desk_width);
4457 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
4459 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
4462 if (
height() > desk_height) {
4463 setFixedHeight(desk_height);
4464 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
4466 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
4469 pos = QCursor::pos();
4471 if (
pos.x() +
width() > desk_width) {
4473 }
else if (
pos.x() -
width() < 0) {
4484 setMouseTracking(
true);
4493 if (
event->button() == Qt::RightButton) {
4498 QAbstractItemView::mousePressEvent(
event);
4512 if (ev->type() == QEvent::MouseButtonPress) {
4513 pw_rect.setTopLeft(
pos());
4516 pw_rect.setBottomRight(br);
4518 if (!pw_rect.contains(QCursor::pos())) {
4530 const QItemSelection &ds)
4532 QModelIndexList indexes = selectionModel()->selectedIndexes();
4541 index = indexes.at(0);
4542 qvar = index.data(Qt::UserRole);
4543 if (!qvar.isValid()) {
4546 target =
reinterpret_cast<universal *
>(qvar.value<
void *>());
4547 if (target != NULL) {
4606 viewport()->removeEventFilter(
fc_tt);
4607 removeEventFilter(
this);
const char * action_id_name_translation(action_id act_id)
#define action_id_univs_not_blocking(act_id, act_uni, tgt_uni)
QRect zealous_crop_rect(QImage &p)
void qtg_canvas_free(struct canvas *store)
struct canvas * qtg_canvas_create(int width, int height)
void qtg_canvas_copy(struct canvas *dest, struct canvas *src, int src_x, int src_y, int dest_x, int dest_y, int width, int height)
void pixmap_copy(QPixmap *dest, QPixmap *src, int src_x, int src_y, int dest_x, int dest_y, int width, int height)
static QFont * get_font(enum client_font font)
struct canvas int int struct sprite int int int int height
struct canvas int int canvas_y
struct canvas int canvas_x
struct canvas int int struct sprite int int int width
citizens citizens_nation_get(const struct city *pcity, const struct player_slot *pslot)
#define citizens_iterate_end
#define citizens_iterate(_pcity, _pslot, _nationality)
const char * city_improvement_name_translation(const struct city *pcity, const struct impr_type *pimprove)
int city_production_build_shield_cost(const struct city *pcity)
int city_granary_size(int city_size)
struct tile * city_map_to_tile(const struct civ_map *nmap, const struct tile *city_center, int city_radius_sq, int city_map_x, int city_map_y)
const char * city_name_get(const struct city *pcity)
int city_improvement_upkeep(const struct city *pcity, const struct impr_type *b)
bool is_city_option_set(const struct city *pcity, enum city_options option)
int city_population(const struct city *pcity)
int city_unit_unhappiness(const struct civ_map *nmap, struct unit *punit, int *free_unhappy)
bool city_unhappy(const struct city *pcity)
bool city_celebrating(const struct city *pcity)
int city_illness_calc(const struct city *pcity, int *ill_base, int *ill_size, int *ill_trade, int *ill_pollution)
bool city_happy(const struct city *pcity)
int city_map_radius_sq_get(const struct city *pcity)
int rs_max_city_radius_sq(void)
citizens city_specialists(const struct city *pcity)
bool can_city_build_now(const struct civ_map *nmap, const struct city *pcity, const struct universal *target)
int city_turns_to_grow(const struct city *pcity)
const char * city_production_name_translation(const struct city *pcity)
static citizens city_size_get(const struct city *pcity)
#define city_owner(_pcity_)
void qtg_popdown_city_dialog(struct city *pcity)
void qtg_real_city_dialog_refresh(struct city *pcity)
QString split_text(QString text, bool cut)
bool qtg_city_dialog_is_open(struct city *pcity)
QString get_tooltip(QVariant qvar)
void qtg_popdown_all_city_dialogs()
static city_dialog * city_dlg
void qtg_refresh_unit_city_dialogs(struct unit *punit)
static QString bold(QString text)
void qtg_real_city_dialog_popup(struct city *pcity)
QString get_tooltip_improvement(const impr_type *building, struct city *pcity, bool ext)
static bool city_dlg_created
static void pixmap_put_x(QPixmap *pix)
QString cut_helptext(QString text)
QString get_tooltip_unit(const struct unit_type *utype, bool ext)
void destroy_city_dialog()
void get_city_dialog_output_text(const struct city *pcity, Output_type_id otype, char *buf, size_t bufsz)
void get_city_dialog_production(struct city *pcity, char *buffer, size_t buffer_len)
int city_set_worklist(struct city *pcity, const struct worklist *pworklist)
int get_city_citizen_types(struct city *pcity, enum citizen_feeling idx, enum citizen_category *categories)
int city_buy_production(struct city *pcity)
bool city_queue_insert(struct city *pcity, int position, struct universal *item)
bool city_queue_insert_worklist(struct city *pcity, int position, const struct worklist *worklist)
int city_toggle_worker(struct city *pcity, int city_x, int city_y)
void get_city_dialog_airlift_text(const struct city *pcity, char *buf, size_t bufsz)
bool city_set_queue(struct city *pcity, const struct worklist *pqueue)
int city_change_production(struct city *pcity, struct universal *target)
void city_rotate_specialist(struct city *pcity, int citizen_index)
int get_citydlg_canvas_width(void)
bool canvas_to_city_pos(int *city_x, int *city_y, int city_radius_sq, int canvas_x, int canvas_y)
void get_city_dialog_airlift_value(const struct city *pcity, char *buf, size_t bufsz)
void city_get_queue(struct city *pcity, struct worklist *pqueue)
void city_dialog_redraw_map(struct city *pcity, struct canvas *pcanvas)
int city_sell_improvement(struct city *pcity, Impr_type_id sell_id)
void get_city_dialog_pollution_text(const struct city *pcity, char *buf, size_t bufsz)
void get_city_dialog_culture_text(const struct city *pcity, char *buf, size_t bufsz)
bool city_can_buy(const struct city *pcity)
int get_citydlg_canvas_height(void)
void get_city_dialog_illness_text(const struct city *pcity, char *buf, size_t bufsz)
city_label(int type, QWidget *parent=0)
void set_city(struct city *pcity)
void mousePressEvent(QMouseEvent *event)
void paintEvent(QPaintEvent *event)
void mousePressEvent(QMouseEvent *event)
void set_pixmap(struct city *pcity, float z)
void context_menu(QPoint point)
QSize minimumSizeHint() const
city_map(QWidget *parent)
city_production_delegate(QPoint sh, QObject *parent, struct city *city)
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
void drawFocus(QPainter *painter, const QStyleOptionViewItem &option, const QRect &rect) const
int rowCount(const QModelIndex &index=QModelIndex()) const
city_production_model(struct city *pcity, bool f, bool su, bool sw, bool sb, QObject *parent=0)
QList< production_item * > city_target_list
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::DisplayRole)
int columnCount(const QModelIndex &parent=QModelIndex()) const
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
static fc_font * instance()
QFont * get_font(QString name)
static fc_icons * instance()
int set_text_title(QString s1, QString s2, bool return_exec=false)
void add_item(impr_item *item)
void wheelEvent(QWheelEvent *event)
impr_info(QWidget *parent)
QList< impr_item * > impr_list
void mouseDoubleClickEvent(QMouseEvent *event)
impr_item(QWidget *parent, const struct impr_type *building, struct city *pcity)
void enterEvent(QEnterEvent *event)
struct canvas * impr_pixmap
const struct impr_type * impr
void leaveEvent(QEvent *event)
void wheelEvent(QWheelEvent *event)
struct universal * target
production_item(struct universal *ptarget, QObject *parent)
progress_bar(QWidget *parent)
void paintEvent(QPaintEvent *event)
void resizeEvent(QResizeEvent *event)
void set_pixmap(struct universal *target)
void timerEvent(QTimerEvent *event)
void wheelEvent(QWheelEvent *event)
void add_item(unit_item *item)
QList< unit_item * > unit_list
void enterEvent(QEnterEvent *event)
void contextMenuEvent(QContextMenuEvent *ev)
QAction * activate_and_close
void mousePressEvent(QMouseEvent *event)
void wheelEvent(QWheelEvent *event)
void leaveEvent(QEvent *event)
unit_item(QWidget *parent, struct unit *punit, bool supp=false, int happy_cost=0)
void activate_and_close_dialog()
bool client_is_observer(void)
bool can_client_issue_orders(void)
int collect_eventually_buildable_targets(struct universal *targets, struct city *pcity, bool advanced_tech)
void name_and_sort_items(struct universal *targets, int num_targets, struct item *items, bool show_cost, struct city *pcity)
cid cid_encode(struct universal target)
int collect_already_built_targets(struct universal *targets, struct city *pcity)
struct universal cid_decode(cid id)
#define MAX_NUM_PRODUCTION_TARGETS
static struct fc_sockaddr_list * list
void cm_copy_parameter(struct cm_parameter *dest, const struct cm_parameter *const src)
bool cma_is_city_under_agent(const struct city *pcity, struct cm_parameter *parameter)
void cma_put_city_under_agent(struct city *pcity, const struct cm_parameter *const parameter)
void cma_release_city(struct city *pcity)
char * cmafec_preset_get_descr(int idx)
const char * cmafec_get_short_descr_of_city(const struct city *pcity)
const struct cm_parameter * cmafec_preset_get_parameter(int idx)
void cmafec_preset_add(const char *descr_name, struct cm_parameter *pparam)
int cmafec_preset_get_index_of_parameter(const struct cm_parameter *const parameter)
void cmafec_preset_remove(int idx)
int cmafec_preset_num(void)
void cmafec_get_fe_parameter(struct city *pcity, struct cm_parameter *dest)
void request_unit_fortify(struct unit *punit)
struct unit * request_unit_unload_all(struct unit *punit)
void unit_focus_set(struct unit *punit)
void request_unit_change_homecity(struct unit *punit)
void request_unit_unload(struct unit *pcargo)
void request_unit_sentry(struct unit *punit)
#define can_unit_do_activity_client(_punit_, _act_)
bool qtg_request_transport(struct unit *pcargo, struct tile *ptile)
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int cost
int get_city_bonus(const struct city *pcity, enum effect_type effect_type)
const char * skip_intl_qualifier_prefix(const char *str)
#define PL_(String1, String2, n)
const char * population_to_text(int thousand_citizen)
struct city * game_city_by_number(int id)
struct global_worklist * global_worklist_by_id(int id)
bool global_worklist_set(struct global_worklist *pgwl, const struct worklist *pwl)
const char * global_worklist_name(const struct global_worklist *pgwl)
int global_worklist_id(const struct global_worklist *pgwl)
const struct worklist * global_worklist_get(const struct global_worklist *pgwl)
struct global_worklist * global_worklist_new(const char *name)
#define global_worklists_iterate(pgwl)
#define global_worklists_iterate_end
void canvas_free(struct canvas *store)
void popup_upgrade_dialog(struct unit_list *punits)
void popup_disband_dialog(struct unit_list *punits)
void free_sprite(struct sprite *s)
static GMenu * change_menu
QString get_tooltip_improvement(const impr_type *building, struct city *pcity=nullptr, bool ext=false)
QString get_tooltip(QVariant qvar)
#define CAPTURE_DEFAULT_THIS
QApplication * current_app()
char * helptext_unit_upkeep_str(const struct unit_type *utype)
char * helptext_building(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, const struct impr_type *pimprove)
char * helptext_unit(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, const struct unit_type *utype)
int impr_sell_gold(const struct impr_type *pimprove)
enum test_result test_player_sell_building_now(struct player *pplayer, struct city *pcity, const struct impr_type *pimprove)
bool is_special_improvement(const struct impr_type *pimprove)
bool is_improvement_redundant(const struct city *pcity, const struct impr_type *pimprove)
bool is_improvement(const struct impr_type *pimprove)
Impr_type_id improvement_number(const struct impr_type *pimprove)
int impr_build_shield_cost(const struct city *pcity, const struct impr_type *pimprove)
bool is_wonder(const struct impr_type *pimprove)
bool improvement_has_flag(const struct impr_type *pimprove, enum impr_flag_id flag)
const char * improvement_name_translation(const struct impr_type *pimprove)
int impr_estimate_build_shield_cost(const struct player *pplayer, const struct tile *ptile, const struct impr_type *pimprove)
#define fc_assert_ret(condition)
#define fc_assert(condition)
#define fc_assert_action(condition, action)
void put_unit(const struct unit *punit, struct canvas *pcanvas, float zoom, int canvas_x, int canvas_y)
void put_unit_city_overlays(struct unit *punit, struct canvas *pcanvas, int canvas_x, int canvas_y, int *upkeep_cost, int happy_cost)
void center_tile_mapcanvas(const struct tile *ptile)
const char * move_points_text(int mp, bool reduce)
const char *const default_font
const char *const notify_label
const char * nation_adjective_for_player(const struct player *pplayer)
struct nation_type * nation_of_player(const struct player *pplayer)
int send_packet_worker_task(struct connection *pc, const struct packet_worker_task *packet)
int dsend_packet_city_options_req(struct connection *pc, int city_id16, int city_id32, bv_city_options options)
const char * text_happiness_cities(const struct city *pcity)
struct unit * player_unit_by_number(const struct player *pplayer, int unit_id)
struct player * player_slot_get_player(const struct player_slot *pslot)
void qtg_free_sprite(struct sprite *s)
struct sprite * qtg_create_sprite(int width, int height, struct color *pcolor)
#define requirement_vector_iterate_end
#define requirement_vector_iterate(req_vec, preq)
void setup_ui(struct city *qcity)
city_label * citizens_label
void closeEvent(QCloseEvent *event)
void update_nation_table()
void hideEvent(QHideEvent *event)
QPushButton * work_next_but
progress_bar * production_combo_p
QTableWidget * nationality_table
void showEvent(QShowEvent *event)
QPushButton * happiness_button
void cma_double_clicked(int row, int column)
void display_worklist_menu(const QPoint &p)
QPushButton * next_city_but
QLabel * qlt[NUM_INFO_FIELDS]
QPushButton * work_prev_but
QHBoxLayout * single_page_layout
QHBoxLayout * leftbot_layout
QPushButton * zoom_in_button
QGridLayout * info_grid_layout
impr_info * city_buildings
city_label * lab_table[6]
unit_info * current_units
struct unit_node_vector supported_units
QPushButton * zoom_out_button
QPushButton * work_add_but
city_dialog(QWidget *parent=0)
QSplitter * central_left_splitter
void disband_state_changed(bool allow_disband)
QCheckBox * cma_celeb_checkbox
void dbl_click_p(QTableWidgetItem *item)
QPushButton * cma_enable_but
QSlider * slider_tab[2 *O_LAST+2]
bool eventFilter(QObject *obj, QEvent *event)
QSplitter * prod_unit_splitter
QVBoxLayout * left_layout
QPushButton * work_rem_but
QSplitter * central_splitter
QWidget * prod_happ_widget
void cma_toggle_changed(int val)
void update_happiness_button()
QPushButton * prev_city_but
void update_improvements()
QHBoxLayout * happiness_layout
QCheckBox * future_targets
void change_production(bool next)
void cma_selected(const QItemSelection &sl, const QItemSelection &ds)
QCheckBox * cma_max_growth
void item_selected(const QItemSelection &sl, const QItemSelection &ds)
void show_targets_worklist()
void cma_context_menu(const QPoint &p)
void production_changed(int index)
void update_prod_buttons()
QWidget * happiness_widget
QGroupBox * happiness_group
QCheckBox * show_buildings
struct worker_task_list * task_reqs
struct unit_list * info_units_present
struct unit_list * info_units_supported
struct universal production
struct unit_list * units_supported
struct city::@17::@20 client
struct packet_game_info info
int minimal_surplus[O_LAST]
struct requirement_vector obsolete_by
enum unit_activity activity
struct city_list * cities
struct player_economic economic
struct terrain * cultivate_result
struct terrain * plant_result
struct terrain * transform_result
const struct unit_type * obsoleted_by
struct advance * require_advance
struct universal entries[MAX_LEN_WORKLIST]
int fc_snprintf(char *str, size_t n, const char *format,...)
struct advance * advance_by_number(const Tech_type_id atype)
bool is_future_tech(Tech_type_id tech)
const char * advance_name_translation(const struct advance *padvance)
struct advance * valid_advance_by_number(const Tech_type_id id)
const char * text_happiness_nationality(const struct city *pcity)
const char * text_happiness_wonders(const struct city *pcity)
const char * text_happiness_units(const struct city *pcity)
const char * text_happiness_luxuries(const struct city *pcity)
const char * text_happiness_buildings(const struct city *pcity)
const char * unit_description(struct unit *punit)
struct city * tile_city(const struct tile *ptile)
#define tile_terrain(_tile)
int tileset_hex_width(const struct tileset *t)
struct sprite * get_building_sprite(const struct tileset *t, const struct impr_type *pimprove)
int tileset_unit_width(const struct tileset *t)
int tileset_unit_height(const struct tileset *t)
int tileset_small_sprite_width(const struct tileset *t)
struct tileset * get_tileset(void)
struct sprite * get_unittype_sprite(const struct tileset *t, const struct unit_type *punittype, enum direction8 facing)
struct tileset * unscaled_tileset
int tileset_unit_layout_offset_y(const struct tileset *t)
bool tileset_is_isometric(const struct tileset *t)
int tileset_small_sprite_height(const struct tileset *t)
struct sprite * get_icon_sprite(const struct tileset *t, enum icon_type icon)
int tileset_unit_with_upkeep_height(const struct tileset *t)
int tileset_hex_height(const struct tileset *t)
struct sprite * get_citizen_sprite(const struct tileset *t, enum citizen_category type, int citizen_index, const struct city *pcity)
struct sprite * get_nation_flag_sprite(const struct tileset *t, const struct nation_type *pnation)
struct sprite * get_tech_sprite(const struct tileset *t, Tech_type_id tech)
const struct unit_type * utype
const struct impr_type * building
bool can_unit_change_homecity(const struct civ_map *nmap, const struct unit *punit)
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
bool units_are_occupied(const struct unit_list *punits)
bool units_can_upgrade(const struct civ_map *nmap, const struct unit_list *punits)
bool units_can_unload(const struct unit_list *punits)
bool units_can_load(const struct unit_list *punits)
#define unit_list_iterate(unitlist, punit)
#define unit_list_iterate_end
int utype_build_shield_cost_base(const struct unit_type *punittype)
bool utype_is_consumed_by_action_result(enum action_result result, const struct unit_type *utype)
bool utype_can_do_action_result(const struct unit_type *putype, enum action_result result)
int utype_build_shield_cost(const struct city *pcity, const struct player *pplayer, const struct unit_type *punittype)
const char * utype_name_translation(const struct unit_type *punittype)
const char * utype_values_translation(const struct unit_type *punittype)
static bool uclass_has_flag(const struct unit_class *punitclass, enum unit_class_flag_id flag)
#define utype_fuel(ptype)
static bool utype_has_flag(const struct unit_type *punittype, int flag)
void worklist_init(struct worklist *pwl)
bool worklist_peek_ith(const struct worklist *pwl, struct universal *prod, int idx)
bool worklist_insert(struct worklist *pwl, const struct universal *prod, int idx)
void worklist_remove(struct worklist *pwl, int idx)
int worklist_length(const struct worklist *pwl)