Freeciv-3.1: /fast/freeciv/nightly/S3_1/client/gui-qt/cityrep.cpp Source File

Freeciv-3.1

Loading...
Searching...
No Matches
cityrep.cpp
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18// Qt
19#include <QApplication>
20#include <QHeaderView>
21#include <QVBoxLayout>
22
23// client
24#include "client_main.h"
25
26// gui-qt
27#include "cityrep.h"
28#include "fc_client.h"
29#include "gui_main.h"
30#include "hudwidget.h"
31
32/***********************************************************************/
35 bool city_sort_model::lessThan(const QModelIndex &left,
36 const QModelIndex &right) const
37{
38 QVariant qleft;
39 QVariant qright;
40 int i;
41 QByteArray l_bytes;
42 QByteArray r_bytes;
43
44 qleft = sourceModel()->data(left);
45 qright = sourceModel()->data(right);
46 l_bytes = qleft.toString().toUtf8();
47 r_bytes = qright.toString().toUtf8();
48 i = cityrepfield_compare(l_bytes.data(), r_bytes.data());
49
50 if (i >= 0) {
51 return true;
52 } else {
53 return false;
54 }
55}
56
57
58/***********************************************************************/
61city_item_delegate::city_item_delegate(QObject *parent)
62 :QItemDelegate(parent)
63{
64 QFont f = QApplication::font();
65 QFontMetrics fm(f);
66
67 item_height = fm.height() + 4;
68}
69
70/***********************************************************************/
73 void city_item_delegate::paint(QPainter *painter,
74 const QStyleOptionViewItem &option,
75 const QModelIndex &index) const
76{
77 QStyleOptionViewItem opt = QItemDelegate::setOptions(index, option);
78 QString txt;
79 QFont font;
80 QPalette palette;
81 struct city_report_spec *spec;
82 spec = city_report_specs + index.column();
83 txt = spec->tagname;
84 if (txt == "cityname") {
85 font.setCapitalization(QFont::SmallCaps);
86 font.setBold(true);
87 opt.font = font;
88 }
89 if (txt == "hstate_verbose") {
90 font.setItalic(true);
91 opt.font = font;
92 }
93 if (txt == "prodplus") {
94 txt = index.data().toString();
95 if (txt.toInt() < 0) {
96 font.setBold(true);
97 palette.setColor(QPalette::Text, QColor(255, 0, 0));
98 opt.font = font;
99 opt.palette = palette;
100 }
101 }
102
103 QItemDelegate::paint(painter, opt, index);
104}
105
106/***********************************************************************/
109QSize city_item_delegate::sizeHint(const QStyleOptionViewItem &option,
110 const QModelIndex &index) const
111{
112 QSize s = QItemDelegate::sizeHint(option, index);
113
114 s.setHeight(item_height + 4);
115 return s;
116}
117
118/***********************************************************************/
121city_item::city_item(city *pcity): QObject()
122{
123 i_city = pcity;
124}
125
126/***********************************************************************/
129 city *city_item::get_city()
130{
131 return i_city;
132}
133
134/***********************************************************************/
137 bool city_item::setData(int column, const QVariant &value, int role)
138{
139 return false;
140}
141
142/***********************************************************************/
145QVariant city_item::data(int column, int role) const
146{
147 struct city_report_spec *spec;
148 char buf[64];
149
150 if (role == Qt::UserRole && column == 0) {
151 return QVariant::fromValue((void *)i_city);
152 }
153 if (role != Qt::DisplayRole) {
154 return QVariant();
155 }
156 spec = city_report_specs+column;
157 fc_snprintf(buf, sizeof(buf), "%*s", NEG_VAL(spec->width),
158 spec->func(i_city, spec->data));
159 return QString(buf).trimmed();
160}
161
162/***********************************************************************/
165city_model::city_model(QObject *parent): QAbstractListModel(parent)
166{
167 populate();
168}
169
170/***********************************************************************/
173city_model::~city_model()
174{
175 qDeleteAll(city_list);
176 city_list.clear();
177}
178
179/***********************************************************************/
182 void city_model::notify_city_changed(int row)
183{
184 emit dataChanged(index(row, 0), index(row, columnCount() - 1));
185}
186
187/***********************************************************************/
190QVariant city_model::data(const QModelIndex &index, int role) const
191{
192 if (!index.isValid()) {
193 return QVariant();
194 }
195 if (index.row() >= 0 && index.row() < rowCount() && index.column() >= 0
196 && index.column() < columnCount()) {
197 return city_list[index.row()]->data(index.column(), role);
198 }
199 return QVariant();
200}
201
202/***********************************************************************/
205 bool city_model::setData(const QModelIndex &index, const QVariant &value,
206 int role)
207{
208 if (!index.isValid() || role != Qt::DisplayRole) {
209 return false;
210 }
211 if (index.row() >= 0 && index.row() < rowCount() && index.column() >= 0
212 && index.column() < columnCount()) {
213 bool change = city_list[index.row()]->setData(index.column(), value, role);
214
215 if (change) {
216 notify_city_changed(index.row());
217 }
218 return change;
219 }
220 return false;
221}
222
223/***********************************************************************/
226QVariant city_model::headerData(int section, Qt::Orientation orientation,
227 int role) const
228{
229 char buf[64];
230 struct city_report_spec *spec;
231
232 if (orientation == Qt::Horizontal && section < NUM_CREPORT_COLS) {
233 if (role == Qt::DisplayRole) {
234 spec = city_report_specs + section;
235 fc_snprintf(buf, sizeof(buf), "%*s\n%*s",
236 NEG_VAL(spec->width), spec->title1 ? spec->title1 : "",
237 NEG_VAL(spec->width), spec->title2 ? spec->title2 : "");
238 return QString(buf).trimmed();
239 }
240 if (role == Qt::ToolTipRole) {
241 spec = city_report_specs + section;
242 return QString(spec->explanation);
243 }
244 }
245 return QVariant();
246}
247
248/***********************************************************************/
251QVariant city_model::menu_data(int section) const
252{
253 struct city_report_spec *spec;
254
255 if (section < NUM_CREPORT_COLS) {
256 spec = city_report_specs + section;
257 return QString(spec->explanation);
258 }
259 return QVariant();
260}
261
262/***********************************************************************/
265QVariant city_model::hide_data(int section) const
266{
267 struct city_report_spec *spec;
268
269 if (section < NUM_CREPORT_COLS) {
270 spec = city_report_specs + section;
271 return spec->show;
272 }
273 return QVariant();
274}
275
276/***********************************************************************/
279 void city_model::populate()
280{
281 city_item *ci;
282
283 if (client_has_player()) {
284 city_list_iterate(client_player()->cities, pcity) {
285 ci = new city_item(pcity);
286 city_list << ci;
287 } city_list_iterate_end;
288 } else {
289 cities_iterate(pcity) {
290 ci = new city_item(pcity);
291 city_list << ci;
292 } cities_iterate_end;
293 }
294}
295
296/***********************************************************************/
299 void city_model::city_changed(struct city *pcity)
300{
301 city_item *item;
302
303 beginResetModel();
304 endResetModel();
305 for (int i = 0; i < city_list.count(); i++) {
306 item = city_list.at(i);
307 if (pcity == item->get_city()) {
308 notify_city_changed(i);
309 }
310 }
311}
312
313/***********************************************************************/
316 void city_model::all_changed()
317{
318 city_list.clear();
319 beginResetModel();
320 populate();
321 endResetModel();
322}
323
324/***********************************************************************/
327 void city_widget::restore_selection()
328{
329 QItemSelection selection;
330 QModelIndex i;
331 struct city *pcity;
332 QVariant qvar;
333
334 if (selected_cities.isEmpty()) {
335 return;
336 }
337 for (int j = 0; j < filter_model->rowCount(); j++) {
338 i = filter_model->index(j, 0);
339 qvar = i.data(Qt::UserRole);
340 if (qvar.isNull()) {
341 continue;
342 }
343 pcity = reinterpret_cast< city *>(qvar.value<void *>());
344 if (selected_cities.contains(pcity)) {
345 selection.append(QItemSelectionRange(i));
346 }
347 }
348 selectionModel()->select(selection, QItemSelectionModel::Rows
349 | QItemSelectionModel::SelectCurrent);
350}
351
352/***********************************************************************/
355city_widget::city_widget(city_report *ctr): QTreeView()
356{
357 cr = ctr;
358 c_i_d = new city_item_delegate(this);
359 setItemDelegate(c_i_d);
360 list_model = new city_model(this);
361 filter_model = new city_sort_model();
362 filter_model->setDynamicSortFilter(true);
363 filter_model->setSourceModel(list_model);
364 filter_model->setFilterRole(Qt::DisplayRole);
365 setModel(filter_model);
366 setRootIsDecorated(false);
367 setAllColumnsShowFocus(true);
368 setSortingEnabled(true);
369 setSelectionMode(QAbstractItemView::ExtendedSelection);
370 setSelectionBehavior(QAbstractItemView::SelectRows);
371 setItemsExpandable(false);
372 setAutoScroll(true);
373 setProperty("uniformRowHeights", "true");
374 setAlternatingRowColors(true);
375 header()->setContextMenuPolicy(Qt::CustomContextMenu);
376 header()->setMinimumSectionSize(10);
377 setContextMenuPolicy(Qt::CustomContextMenu);
378 hide_columns();
379 connect(header(), &QWidget::customContextMenuRequested,
380 this, &city_widget::display_header_menu);
381 connect(selectionModel(),
382 SIGNAL(selectionChanged(const QItemSelection &,
383 const QItemSelection &)),
384 SLOT(cities_selected(const QItemSelection &,
385 const QItemSelection &)));
386 connect(this, &QAbstractItemView::doubleClicked, this,
387 &city_widget::city_doubleclick);
388 connect(this, &QWidget::customContextMenuRequested,
389 this, &city_widget::display_list_menu);
390}
391
392/***********************************************************************/
395 void city_widget::city_doubleclick(const QModelIndex& index)
396{
397 city_view();
398}
399
400/***********************************************************************/
403 void city_widget::city_view()
404{
405 struct city *pcity;
406
407 if (selected_cities.isEmpty()) {
408 return;
409 }
410 pcity = selected_cities[0];
411
412 Q_ASSERT(pcity != NULL);
413 if (gui_options.center_when_popup_city) {
414 center_tile_mapcanvas(pcity->tile);
415 }
416 qtg_real_city_dialog_popup(pcity);
417}
418
419/***********************************************************************/
422 void city_widget::clear_worlist()
423{
424 struct worklist empty;
425 worklist_init(&empty);
426 struct city *pcity;
427
428 foreach(pcity, selected_cities) {
429 Q_ASSERT(pcity != NULL);
430 city_set_worklist(pcity, &empty);
431 }
432}
433
434/***********************************************************************/
437 void city_widget::buy()
438{
439 struct city *pcity;
440
441 foreach(pcity, selected_cities) {
442 Q_ASSERT(pcity != NULL);
443 cityrep_buy(pcity);
444 }
445}
446
447/***********************************************************************/
450 void city_widget::center()
451{
452 struct city *pcity;
453
454 if (selected_cities.isEmpty()) {
455 return;
456 }
457 pcity = selected_cities[0];
458 Q_ASSERT(pcity != NULL);
459 center_tile_mapcanvas(pcity->tile);
460 gui()->game_tab_widget->setCurrentIndex(0);
461}
462
463/***********************************************************************/
466 void city_widget::display_list_menu(const QPoint &)
467{
468 QMap<QString, cid> custom_labels;
469 QMap<QString, int> cma_labels;
470 QMenu *some_menu;
471 QMenu *tmp2_menu;
472 QMenu *tmp_menu;
473 struct city *pcity_outer;
474 QMenu *list_menu;
475
476 QAction wl_clear(_("Clear"), 0);
477 QAction wl_empty(_("(no worklists defined)"), 0);
478 bool worklist_defined = true;
479
480 if (!can_client_issue_orders()) {
481 return;
482 }
483 list_menu = new QMenu(this);
484 if (!selected_cities.isEmpty()) {
485 some_menu = list_menu->addMenu(_("Production"));
486 tmp_menu = some_menu->addMenu(_("Change"));
487 fill_production_menus(CHANGE_PROD_NOW, custom_labels, can_city_build_now,
488 tmp_menu);
489 tmp_menu = some_menu->addMenu(_("Add next"));
490 fill_production_menus(CHANGE_PROD_NEXT, custom_labels, can_city_build_now,
491 tmp_menu);
492 tmp_menu = some_menu->addMenu(_("Add before last"));
493 fill_production_menus(CHANGE_PROD_BEF_LAST, custom_labels,
494 can_city_build_now, tmp_menu);
495 tmp_menu = some_menu->addMenu(_("Add last"));
496 fill_production_menus(CHANGE_PROD_LAST, custom_labels, can_city_build_now,
497 tmp_menu);
498
499 tmp_menu = some_menu->addMenu(_("Worklist"));
500 tmp_menu->addAction(&wl_clear);
501 connect(&wl_clear, &QAction::triggered, this, &city_widget::clear_worlist);
502 tmp2_menu = tmp_menu->addMenu(_("Add"));
503 gen_worklist_labels(cma_labels);
504 if (cma_labels.count() == 0) {
505 tmp2_menu->addAction(&wl_empty);
506 worklist_defined = false;
507 }
508 fill_data(WORKLIST_ADD, cma_labels, tmp2_menu);
509 tmp2_menu = tmp_menu->addMenu(_("Change"));
510 if (cma_labels.count() == 0) {
511 tmp2_menu->addAction(&wl_empty);
512 worklist_defined = false;
513 }
514 fill_data(WORKLIST_CHANGE, cma_labels, tmp2_menu);
515 some_menu = list_menu->addMenu(_("Governor"));
516 gen_cma_labels(cma_labels);
517 fill_data(CMA, cma_labels, some_menu);
518 some_menu = list_menu->addMenu(_("Sell"));
519 gen_production_labels(SELL, custom_labels, false, false,
520 can_city_sell_universal);
521 fill_data(SELL, custom_labels, some_menu);
522 }
523 some_menu = list_menu->addMenu(_("Select"));
524 gen_select_labels(some_menu);
525 if (!selected_cities.isEmpty()) {
526 char buy_costs_label[200];
527 int buy_costs = 0;
528
529 some_menu = list_menu->addMenu(_("City/Buy"));
530 if (selected_cities.count() == 1) {
531 connect(some_menu->addAction(_("View")), &QAction::triggered, this,
532 &city_widget::city_view);
533 connect(some_menu->addAction(_("Center")), &QAction::triggered, this,
534 &city_widget::center);
535 }
536
537 foreach(pcity_outer, selected_cities) {
538 buy_costs = buy_costs + pcity_outer->client.buy_cost;
539 }
540 fc_snprintf(buy_costs_label, sizeof(buy_costs_label),
541 _("Buy ( Cost: %d )"), buy_costs);
542 connect(some_menu->addAction(buy_costs_label), &QAction::triggered, this,
543 &city_widget::buy);
544 }
545
546 list_menu->setAttribute(Qt::WA_DeleteOnClose);
547 connect(list_menu, &QMenu::triggered, this,
548 CAPTURE_DEFAULT_THIS (QAction *act) {
549 QVariant qvar, qvar2;
550 enum menu_labels m_state;
551 cid id;
552 struct universal target;
553 char buf[200];
554 const char *imprname;
555 const struct impr_type *building_outer;
556 Impr_type_id impr_id;
557 struct city *pcity_mid;
558 int city_id;
559 bool need_clear = true;
560 bool sell_ask = true;
561
562 if (!act) {
563 return;
564 }
565
566 qvar2 = act->property("FC");
567 m_state = static_cast< menu_labels>(qvar2.toInt());
568 qvar = act->data();
569 id = qvar.toInt();
570 target = cid_decode(id);
571
572 city_list_iterate(client_player()->cities, iter_city) {
573 if (NULL != iter_city) {
574 switch (m_state) {
575 case SELECT_IMPR:
576 if (need_clear) {
577 clearSelection();
578 }
579 need_clear = false;
580 if (city_building_present(iter_city, &target)) {
581 select_city(iter_city);
582 }
583 break;
584 case SELECT_WONDERS:
585 if (need_clear) {
586 clearSelection();
587 }
588 need_clear = false;
589 if (city_building_present(iter_city, &target)) {
590 select_city(iter_city);
591 }
592 break;
593 case SELECT_SUPP_UNITS:
594 if (need_clear) {
595 clearSelection();
596 }
597 need_clear = false;
598 if (city_unit_supported(iter_city, &target)) {
599 select_city(iter_city);
600 }
601 break;
602 case SELECT_PRES_UNITS:
603 if (need_clear) {
604 clearSelection();
605 }
606 need_clear = false;
607 if (city_unit_present(iter_city, &target)) {
608 select_city(iter_city);
609 }
610 break;
611 case SELECT_AVAIL_UNITS:
612 if (need_clear) {
613 clearSelection();
614 }
615 need_clear = false;
616 if (can_city_build_now(iter_city, &target)) {
617 select_city(iter_city);
618 }
619 break;
620 case SELECT_AVAIL_IMPR:
621 if (need_clear) {
622 clearSelection();
623 }
624 need_clear = false;
625 if (can_city_build_now(iter_city, &target)) {
626 select_city(iter_city);
627 }
628 break;
629 case SELECT_AVAIL_WONDERS:
630 if (need_clear) {
631 clearSelection();
632 }
633 need_clear = false;
634 if (can_city_build_now(iter_city, &target)) {
635 select_city(iter_city);
636 }
637 break;
638 default:
639 break;
640 }
641 }
642 } city_list_iterate_end;
643
644 foreach (pcity_mid, selected_cities) {
645 if (nullptr != pcity_mid) {
646 switch (m_state) {
647 case CHANGE_PROD_NOW:
648 city_change_production(pcity_mid, &target);
649 break;
650 case CHANGE_PROD_NEXT:
651 city_queue_insert(pcity_mid, 1, &target);
652 break;
653 case CHANGE_PROD_BEF_LAST:
654 city_queue_insert(pcity_mid, worklist_length(&pcity_mid->worklist),
655 &target);
656 break;
657 case CHANGE_PROD_LAST:
658 city_queue_insert(pcity_mid, -1, &target);
659 break;
660 case SELL:
661 building_outer = target.value.building;
662 if (sell_ask) {
663 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
664
665 imprname = improvement_name_translation(building_outer);
666 fc_snprintf(buf, sizeof(buf),
667 _("Are you sure you want to sell those %s?"),
668 imprname);
669 sell_ask = false;
670 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
671 ask->setDefaultButton(QMessageBox::Cancel);
672 ask->set_text_title(buf, _("Sell?"));
673 ask->setAttribute(Qt::WA_DeleteOnClose);
674 city_id = pcity_mid->id;
675 impr_id = improvement_number(building_outer);
676 connect(ask, &hud_message_box::accepted, this, [=]() {
677 struct city *pcity = game_city_by_number(city_id);
678 struct impr_type *building = improvement_by_number(impr_id);
679
680 if (!pcity || !building) {
681 return;
682 }
683 if (!pcity->did_sell && city_has_building(pcity, building)) {
684 city_sell_improvement(pcity, impr_id);
685 }
686 });
687 ask->show();
688 }
689 break;
690 case CMA:
691 if (NULL != pcity_mid) {
692 if (CMA_NONE == id) {
693 cma_release_city(pcity_mid);
694 } else {
695 cma_put_city_under_agent(pcity_mid,
696 cmafec_preset_get_parameter(id));
697 }
698 }
699
700 break;
701 case WORKLIST_ADD:
702 if (worklist_defined) {
703 city_queue_insert_worklist(pcity_mid, -1,
704 global_worklist_get(global_worklist_by_id(id)));
705 }
706 break;
707
708 case WORKLIST_CHANGE:
709 if (worklist_defined) {
710 city_set_queue(pcity_mid,
711 global_worklist_get(global_worklist_by_id(id)));
712 }
713 break;
714 case BUY:
715 if (NULL != pcity_mid) {
716 if (city_can_buy(pcity_mid)) {
717 city_buy_production(pcity_mid);
718 }
719 }
720 break;
721 default:
722 break;
723 }
724 }
725 }
726 });
727 list_menu->popup(QCursor::pos());
728}
729
730/***********************************************************************/
733 void city_widget::fill_production_menus(city_widget::menu_labels what,
734 QMap<QString, cid> &custom_labels,
735 TestCityFunc test_func, QMenu *menu)
736{
737 QMenu *m1, *m2, *m3;
738
739 m1 = menu->addMenu(_("Buildings"));
740 m2 = menu->addMenu(_("Units"));
741 m3 = menu->addMenu(_("Wonders"));
742 gen_production_labels(what, custom_labels, false, false, test_func);
743 fill_data(what, custom_labels, m1);
744 gen_production_labels(what, custom_labels, true, false, test_func);
745 fill_data(what, custom_labels, m2);
746 gen_production_labels(what, custom_labels, false, true, test_func);
747 fill_data(what, custom_labels, m3);
748}
749
750
751/***********************************************************************/
754 void city_widget::fill_data(menu_labels which,
755 QMap<QString, cid> &custom_labels, QMenu *menu)
756{
757 QAction *action;
758 QMap<QString, cid>::const_iterator map_iter;
759
760 map_iter = custom_labels.constBegin();
761 while (map_iter != custom_labels.constEnd()) {
762 action = menu->addAction(map_iter.key());
763 action->setData(map_iter.value());
764 action->setProperty("FC", which);
765 map_iter++;
766 }
767 if (custom_labels.isEmpty()) {
768 menu->setDisabled(true);
769 }
770}
771
772/***********************************************************************/
775 void city_widget::select_all()
776{
777 selectAll();
778}
779
780/***********************************************************************/
783 void city_widget::select_none()
784{
785 clearSelection();
786}
787
788/***********************************************************************/
791 void city_widget::invert_selection()
792{
793 QItemSelection selection;
794 QModelIndex i;
795 struct city *pcity;
796 QVariant qvar;
797
798
799 for (int j = 0; j < filter_model->rowCount(); j++) {
800 i = filter_model->index(j, 0);
801 qvar = i.data(Qt::UserRole);
802 if (qvar.isNull()) {
803 continue;
804 }
805 pcity = reinterpret_cast< city *>(qvar.value<void *>());
806 if (!selected_cities.contains(pcity)) {
807 selection.append(QItemSelectionRange(i));
808 }
809 }
810 clearSelection();
811 selectionModel()->select(selection, QItemSelectionModel::Rows
812 | QItemSelectionModel::SelectCurrent);
813
814}
815
816/***********************************************************************/
819 void city_widget::select_city(city *spcity)
820{
821 QItemSelection selection;
822 QModelIndex i;
823 struct city *pcity;
824 QVariant qvar;
825
826 for (int j = 0; j < filter_model->rowCount(); j++) {
827 i = filter_model->index(j, 0);
828 qvar = i.data(Qt::UserRole);
829 if (qvar.isNull()) {
830 continue;
831 }
832 pcity = reinterpret_cast< city *>(qvar.value<void *>());
833 if (pcity == spcity) {
834 selection.append(QItemSelectionRange(i));
835 }
836 }
837 selectionModel()->select(selection, QItemSelectionModel::Rows
838 | QItemSelectionModel::Select);
839
840}
841
842/***********************************************************************/
845 void city_widget::select_coastal()
846{
847 QItemSelection selection;
848 QModelIndex i;
849 struct city *pcity;
850 QVariant qvar;
851
852 clearSelection();
853 for (int j = 0; j < filter_model->rowCount(); j++) {
854 i = filter_model->index(j, 0);
855 qvar = i.data(Qt::UserRole);
856 if (qvar.isNull()) {
857 continue;
858 }
859 pcity = reinterpret_cast< city *>(qvar.value<void *>());
860 if (pcity != nullptr
861 && is_terrain_class_near_tile(&(wld.map), pcity->tile, TC_OCEAN)) {
862 selection.append(QItemSelectionRange(i));
863 }
864 }
865 selectionModel()->select(selection, QItemSelectionModel::Rows
866 | QItemSelectionModel::SelectCurrent);
867}
868
869/***********************************************************************/
872 void city_widget::select_same_island()
873{
874 QItemSelection selection;
875 QModelIndex i;
876 struct city *pcity;
877 struct city *pscity;
878 QVariant qvar;
879
880 for (int j = 0; j < filter_model->rowCount(); j++) {
881 i = filter_model->index(j, 0);
882 qvar = i.data(Qt::UserRole);
883 if (qvar.isNull()) {
884 continue;
885 }
886 pcity = reinterpret_cast< city *>(qvar.value<void *>());
887 foreach (pscity, selected_cities) {
888 if (NULL != pcity
889 && (tile_continent(pcity->tile)
890 == tile_continent(pscity->tile))) {
891 selection.append(QItemSelectionRange(i));
892 }
893 }
894 }
895 selectionModel()->select(selection, QItemSelectionModel::Rows
896 | QItemSelectionModel::SelectCurrent);
897}
898
899/***********************************************************************/
903 void city_widget::select_building_something()
904{
905 QItemSelection selection;
906 QModelIndex i;
907 struct city *pcity;
908 QVariant qvar;
909 QAction *act;
910 QString str;
911
912 clearSelection();
913 for (int j = 0; j < filter_model->rowCount(); j++) {
914 i = filter_model->index(j, 0);
915 qvar = i.data(Qt::UserRole);
916 if (qvar.isNull()) {
917 continue;
918 }
919 pcity = reinterpret_cast< city *>(qvar.value<void *>());
920 act = qobject_cast<QAction *>(sender());
921 qvar = act->data();
922 str = qvar.toString();
923 if (NULL != pcity) {
924 if (str == "impr" && VUT_IMPROVEMENT == pcity->production.kind
925 && !is_wonder(pcity->production.value.building)
926 && !improvement_has_flag(pcity->production.value.building,
927 IF_GOLD)) {
928 selection.append(QItemSelectionRange(i));
929 } else if (str == "unit" && VUT_UTYPE == pcity->production.kind) {
930 selection.append(QItemSelectionRange(i));
931 } else if (str == "wonder"
932 && VUT_IMPROVEMENT == pcity->production.kind
933 && is_wonder(pcity->production.value.building)) {
934 selection.append(QItemSelectionRange(i));
935 }
936 }
937 }
938 selectionModel()->select(selection, QItemSelectionModel::Rows
939 | QItemSelectionModel::SelectCurrent);
940}
941
942/***********************************************************************/
945 void city_widget::gen_cma_labels(QMap<QString, int> &list)
946{
947 list.clear();
948 for (int i = 0; i < cmafec_preset_num(); i++) {
949 list.insert(cmafec_preset_get_descr(i), i);
950 }
951}
952
953/***********************************************************************/
956 void city_widget::gen_select_labels(QMenu *menu)
957{
958 QAction *act;
959 QMenu *tmp_menu;
960 QMap<QString, cid> custom_labels;
961
962 act = menu->addAction(_("All Cities"));
963 connect(act, &QAction::triggered, this, &city_widget::select_all);
964 act = menu->addAction(_("No Cities"));
965 connect(act, &QAction::triggered, this, &city_widget::select_none);
966 act = menu->addAction(_("Invert Selection"));
967 connect(act, &QAction::triggered, this, &city_widget::invert_selection);
968 menu->addSeparator();
969 act = menu->addAction(_("Coastal Cities"));
970 connect(act, &QAction::triggered, this, &city_widget::select_coastal);
971 act = menu->addAction(_("Same Island"));
972 connect(act, &QAction::triggered, this, &city_widget::select_same_island);
973 if (selected_cities.isEmpty()) {
974 act->setDisabled(true);
975 }
976 menu->addSeparator();
977 act = menu->addAction(_("Building Units"));
978 act->setData("unit");
979 connect(act, &QAction::triggered, this, &city_widget::select_building_something);
980 act = menu->addAction(_("Building Improvements"));
981 act->setData("impr");
982 connect(act, &QAction::triggered, this, &city_widget::select_building_something);
983 act = menu->addAction(_("Building Wonders"));
984 act->setData("wonder");
985 connect(act, &QAction::triggered, this, &city_widget::select_building_something);
986 menu->addSeparator();
987 tmp_menu = menu->addMenu(_("Improvements in City"));
988 gen_production_labels(SELECT_IMPR, custom_labels, false, false,
989 city_building_present, true);
990 fill_data(SELECT_IMPR, custom_labels, tmp_menu);
991 tmp_menu = menu->addMenu(_("Wonders in City"));
992 gen_production_labels(SELECT_WONDERS, custom_labels, false, true,
993 city_building_present, true);
994 fill_data(SELECT_WONDERS, custom_labels, tmp_menu);
995 menu->addSeparator();
996 tmp_menu = menu->addMenu(_("Supported Units"));
997 gen_production_labels(SELECT_SUPP_UNITS, custom_labels, true, false,
998 city_unit_supported, true);
999 fill_data(SELECT_SUPP_UNITS, custom_labels, tmp_menu);
1000 tmp_menu = menu->addMenu(_("Units Present"));
1001 gen_production_labels(SELECT_PRES_UNITS, custom_labels, true, false,
1002 city_unit_present, true);
1003 fill_data(SELECT_PRES_UNITS, custom_labels, tmp_menu);
1004 menu->addSeparator();
1005 tmp_menu = menu->addMenu(_("Available Units"));
1006 gen_production_labels(SELECT_AVAIL_UNITS, custom_labels, true, false,
1007 can_city_build_now, true);
1008 fill_data(SELECT_AVAIL_UNITS, custom_labels, tmp_menu);
1009 tmp_menu = menu->addMenu(_("Available Improvements"));
1010 gen_production_labels(SELECT_AVAIL_IMPR, custom_labels, false, false,
1011 can_city_build_now, true);
1012 fill_data(SELECT_AVAIL_IMPR, custom_labels, tmp_menu);
1013 tmp_menu = menu->addMenu(_("Available Wonders"));
1014 gen_production_labels(SELECT_AVAIL_WONDERS, custom_labels, false, true,
1015 can_city_build_now, true);
1016 fill_data(SELECT_AVAIL_WONDERS, custom_labels, tmp_menu);
1017
1018}
1019
1020/***********************************************************************/
1023 void city_widget::gen_worklist_labels(QMap<QString, int> &list)
1024{
1025 list.clear();
1026 global_worklists_iterate(pgwl) {
1027 list.insert(global_worklist_name(pgwl), global_worklist_id(pgwl));
1028 } global_worklists_iterate_end;
1029}
1030
1031/***********************************************************************/
1034 void city_widget::gen_production_labels(city_widget::menu_labels what,
1035 QMap<QString, cid> &list,
1036 bool append_units,
1037 bool append_wonders,
1038 TestCityFunc test_func,
1039 bool global)
1040{
1041 struct universal targets[MAX_NUM_PRODUCTION_TARGETS];
1042 struct item items[MAX_NUM_PRODUCTION_TARGETS];
1043 int i, item, targets_used;
1044 QString str;
1045 char *row[4];
1046 char buf[4][64];
1047 struct city **city_data;
1048 int num_sel = 0;
1049
1050 if (global) {
1051 num_sel = list_model->rowCount();
1052 } else {
1053 num_sel = selected_cities.count();
1054 }
1055 city_data = (struct city **)fc_malloc(sizeof(struct city *) * num_sel);
1056
1057 if (global) {
1058 i = 0;
1059 city_list_iterate(client.conn.playing->cities, pcity) {
1060 city_data[i] = pcity;
1061 i++;
1062 } city_list_iterate_end;
1063 } else {
1064 for (i = 0; i < num_sel; i++) {
1065 city_data[i] = selected_cities.at(i);
1066 }
1067 }
1068 targets_used
1069 = collect_production_targets(targets, city_data, num_sel, append_units,
1070 append_wonders, true, test_func);
1071 free(city_data);
1072 name_and_sort_items(targets, targets_used, items, true, NULL);
1073 for (i = 0; i < 4; i++) {
1074 row[i] = buf[i];
1075 }
1076 list.clear();
1077 for (item = 0; item < targets_used; item++) {
1078 struct universal target = items[item].item;
1079 char txt[256];
1080
1081 str.clear();
1082 get_city_dialog_production_row(row, sizeof(buf[0]), &target, NULL);
1083 fc_snprintf(txt, ARRAY_SIZE(txt), "%s ", row[0]);
1084 str = str + QString(txt);
1085 list.insert(str, cid_encode(target));
1086 }
1087}
1088
1089/***********************************************************************/
1092 void city_widget::update_city(city *pcity)
1093{
1094 list_model->city_changed(pcity);
1095 restore_selection();
1096}
1097
1098/***********************************************************************/
1101 void city_widget::update_model()
1102{
1103 QFont f = QApplication::font();
1104 QFontMetrics fm(f);
1105 QStringList sl;
1106 QString s, str;
1107 int width;
1108
1109 setUpdatesEnabled(false);
1110 list_model->all_changed();
1111 restore_selection();
1112 header()->resizeSections(QHeaderView::ResizeToContents);
1113 for (int j = 0; j < filter_model->columnCount(); j++) {
1114 str = list_model->headerData(j, Qt::Horizontal, Qt::DisplayRole).toString();
1115 if (str.contains('\n')) {
1116 sl = str.split('\n');
1117 width = 0;
1118 foreach (s, sl) {
1119 width = qMax(width, fm.horizontalAdvance(s));
1120 }
1121 header()->resizeSection(j, width + 10);
1122 }
1123 }
1124 setUpdatesEnabled(true);
1125}
1126
1127/***********************************************************************/
1130 void city_widget::display_header_menu(const QPoint &)
1131{
1132 QMenu *hideshow_column = new QMenu(this);
1133 QList<QAction *> actions;
1134
1135 hideshow_column->setTitle(_("Column visibility"));
1136 for (int i = 0; i < list_model->columnCount(); i++) {
1137 QAction *myAct = hideshow_column->addAction(
1138 list_model->menu_data(i).toString());
1139 myAct->setCheckable(true);
1140 myAct->setChecked(!isColumnHidden(i));
1141 actions.append(myAct);
1142 }
1143 hideshow_column->setAttribute(Qt::WA_DeleteOnClose);
1144 connect(hideshow_column, &QMenu::triggered, this,
1145 CAPTURE_DEFAULT_THIS (QAction *act) {
1146 int col;
1147 struct city_report_spec *spec;
1148 if (!act) {
1149 return;
1150 }
1151
1152 col = actions.indexOf(act);
1153 fc_assert_ret(col >= 0);
1154 setColumnHidden(col, !isColumnHidden(col));
1155 spec = city_report_specs + col;
1156 spec->show = !spec->show;
1157 if (!isColumnHidden(col) && columnWidth(col) <= 5)
1158 setColumnWidth(col, 100);
1159 });
1160 hideshow_column->popup(QCursor::pos());
1161}
1162
1163/***********************************************************************/
1166 void city_widget::hide_columns()
1167{
1168 int col;
1169
1170 for (col = 0; col < list_model->columnCount(); col++) {
1171 if (!list_model->hide_data(col).toBool()) {
1172 setColumnHidden(col, !isColumnHidden(col));
1173 }
1174 }
1175}
1176
1177/***********************************************************************/
1181 void city_widget::cities_selected(const QItemSelection &sl,
1182 const QItemSelection &ds)
1183{
1184 QModelIndexList indexes = selectionModel()->selectedIndexes();
1185 QModelIndex i;
1186 QVariant qvar;
1187 struct city *pcity;
1188
1189 selected_cities.clear();
1190
1191 if (indexes.isEmpty()) {
1192 return;
1193 }
1194 foreach(i,indexes) {
1195 qvar = i.data(Qt::UserRole);
1196 if (qvar.isNull()) {
1197 continue;
1198 }
1199 pcity = reinterpret_cast< city *>(qvar.value<void *>());
1200 selected_cities << pcity;
1201 }
1202}
1203
1204/***********************************************************************/
1207 city_model *city_widget::get_model() const
1208{
1209 return list_model;
1210}
1211
1212/***********************************************************************/
1215city_widget::~city_widget()
1216{
1217 delete c_i_d;
1218 delete list_model;
1219 delete filter_model;
1220 gui()->qt_settings.city_repo_sort_col = header()->sortIndicatorSection();
1221 gui()->qt_settings.city_report_sort = header()->sortIndicatorOrder();
1222}
1223
1224/***********************************************************************/
1227city_report::city_report(): QWidget()
1228{
1229 layout = new QVBoxLayout;
1230 city_wdg = new city_widget(this);
1231 if (gui()->qt_settings.city_repo_sort_col != -1) {
1232 city_wdg->sortByColumn(gui()->qt_settings.city_repo_sort_col,
1233 gui()->qt_settings.city_report_sort);
1234 }
1235 layout->addWidget(city_wdg);
1236 setLayout(layout);
1237}
1238
1239/***********************************************************************/
1242city_report::~city_report()
1243{
1244 gui()->remove_repo_dlg("CTS");
1245}
1246
1247/***********************************************************************/
1250 void city_report::init()
1251{
1252 gui()->gimme_place(this, "CTS");
1253 index = gui()->add_game_tab(this);
1254 gui()->game_tab_widget->setCurrentIndex(index);
1255}
1256
1257/***********************************************************************/
1260 void city_report::update_report()
1261{
1262 city_wdg->update_model();
1263}
1264
1265/***********************************************************************/
1268 void city_report::update_city(struct city *pcity)
1269{
1270 city_wdg->update_city(pcity);
1271}
1272
1273/***********************************************************************/
1276 void city_report_dialog_popup(bool raise)
1277{
1278 int i;
1279 city_report *cr;
1280 QWidget *w;
1281
1282 if (!gui()->is_repo_dlg_open("CTS")) {
1283 cr = new city_report;
1284 cr->init();
1285 cr->update_report();
1286 } else {
1287 i = gui()->gimme_index_of("CTS");
1288 fc_assert(i != -1);
1289 w = gui()->game_tab_widget->widget(i);
1290 if (w->isVisible()) {
1291 gui()->game_tab_widget->setCurrentIndex(0);
1292 return;
1293 }
1294 cr = reinterpret_cast< city_report*>(w);
1295 gui()->game_tab_widget->setCurrentWidget(cr);
1296 cr->update_report();
1297 }
1298}
1299
1300/***********************************************************************/
1303 void real_city_report_dialog_update(void *unused)
1304{
1305 int i;
1306 city_report *cr;
1307 QWidget *w;
1308
1309 if (gui()->is_repo_dlg_open("CTS")) {
1310 i = gui()->gimme_index_of("CTS");
1311 if (gui()->game_tab_widget->currentIndex() == i) {
1312 w = gui()->game_tab_widget->widget(i);
1313 cr = reinterpret_cast< city_report *>(w);
1314 cr->update_report();
1315 }
1316 }
1317}
1318
1319/***********************************************************************/
1322 void real_city_report_update_city(struct city *pcity)
1323{
1324 int i;
1325 city_report *cr;
1326 QWidget *w;
1327
1328 if (gui()->is_repo_dlg_open("CTS")) {
1329 i = gui()->gimme_index_of("CTS");
1330 if (gui()->game_tab_widget->currentIndex() == i) {
1331 w = gui()->game_tab_widget->widget(i);
1332 cr = reinterpret_cast< city_report *>(w);
1333 cr->update_city(pcity);
1334 }
1335 }
1336}
1337
1338/***********************************************************************/
1341 void popdown_city_report()
1342{
1343 int i;
1344 city_report *cr;
1345 QWidget *w;
1346
1347 if (gui()->is_repo_dlg_open("CTS")) {
1348 i = gui()->gimme_index_of("CTS");
1349 fc_assert(i != -1);
1350 w = gui()->game_tab_widget->widget(i);
1351 cr = reinterpret_cast< city_report *>(w);
1352 cr->deleteLater();
1353 }
1354}
1355
1356/***********************************************************************/
1361 void hilite_cities_from_canvas(void)
1362{
1363 /* PORTME */
1364}
1365
1366/***********************************************************************/
1369 void toggle_city_hilite(struct city *pcity, bool on_off)
1370{
1371 /* PORTME */
1372}
actions
static struct action * actions[MAX_NUM_ACTIONS]
Definition actions.c:96
str
#define str
Definition astring.c:76
width
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
can_city_build_now
bool can_city_build_now(const struct city *pcity, const struct universal *target)
Definition city.c:989
city_has_building
bool city_has_building(const struct city *pcity, const struct impr_type *pimprove)
Definition city.c:1212
cities_iterate_end
#define cities_iterate_end
Definition city.h:497
city_list_iterate
#define city_list_iterate(citylist, pcity)
Definition city.h:488
cities_iterate
#define cities_iterate(pcity)
Definition city.h:492
city_list_iterate_end
#define city_list_iterate_end
Definition city.h:490
qtg_real_city_dialog_popup
void qtg_real_city_dialog_popup(struct city *pcity)
Definition citydlg.cpp:3706
get_city_dialog_production_row
void get_city_dialog_production_row(char *buf[], size_t column_size, struct universal *target, struct city *pcity)
Definition citydlg_common.c:364
city_set_worklist
int city_set_worklist(struct city *pcity, const struct worklist *pworklist)
Definition citydlg_common.c:1273
city_buy_production
int city_buy_production(struct city *pcity)
Definition citydlg_common.c:1525
city_queue_insert
bool city_queue_insert(struct city *pcity, int position, struct universal *item)
Definition citydlg_common.c:1384
city_queue_insert_worklist
bool city_queue_insert_worklist(struct city *pcity, int position, const struct worklist *worklist)
Definition citydlg_common.c:1412
city_set_queue
bool city_set_queue(struct city *pcity, const struct worklist *pqueue)
Definition citydlg_common.c:1459
city_change_production
int city_change_production(struct city *pcity, struct universal *target)
Definition citydlg_common.c:1261
city_sell_improvement
int city_sell_improvement(struct city *pcity, Impr_type_id sell_id)
Definition citydlg_common.c:1517
city_can_buy
bool city_can_buy(const struct city *pcity)
Definition citydlg_common.c:1497
real_city_report_dialog_update
void real_city_report_dialog_update(void *unused)
Definition cityrep.cpp:1303
real_city_report_update_city
void real_city_report_update_city(struct city *pcity)
Definition cityrep.cpp:1322
toggle_city_hilite
void toggle_city_hilite(struct city *pcity, bool on_off)
Definition cityrep.cpp:1369
hilite_cities_from_canvas
void hilite_cities_from_canvas(void)
Definition cityrep.cpp:1361
city_report_dialog_popup
void city_report_dialog_popup(bool raise)
Definition cityrep.cpp:1276
popdown_city_report
void popdown_city_report()
Definition cityrep.cpp:1341
can_city_sell_universal
bool can_city_sell_universal(const struct city *pcity, const struct universal *target)
Definition cityrepdata.c:1104
city_report_specs
struct city_report_spec * city_report_specs
Definition cityrepdata.c:798
cityrepfield_compare
int cityrepfield_compare(const char *str1, const char *str2)
Definition cityrepdata.c:1077
NUM_CREPORT_COLS
#define NUM_CREPORT_COLS
Definition cityrepdata.h:25
city_item_delegate
Definition cityrep.h:69
city_item_delegate::item_height
int item_height
Definition cityrep.h:80
city_item_delegate::sizeHint
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
Definition cityrep.cpp:109
city_item_delegate::paint
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
Definition cityrep.cpp:73
city_item_delegate::city_item_delegate
city_item_delegate(QObject *parent)
Definition cityrep.cpp:61
city_item
Definition cityrep.h:86
city_item::get_city
struct city * get_city()
Definition cityrep.cpp:129
city_item::data
QVariant data(int column, int role=Qt::DisplayRole) const
Definition cityrep.cpp:145
city_item::i_city
struct city * i_city
Definition cityrep.h:96
city_item::city_item
city_item(struct city *pcity)
Definition cityrep.cpp:121
city_item::setData
bool setData(int column, const QVariant &value, int role=Qt::DisplayRole)
Definition cityrep.cpp:137
city_model
Definition cityrep.h:103
city_model::city_changed
void city_changed(struct city *pcity)
Definition cityrep.cpp:299
city_model::headerData
QVariant headerData(int section, Qt::Orientation orientation, int role) const
Definition cityrep.cpp:226
city_model::hide_data
QVariant hide_data(int section) const
Definition cityrep.cpp:265
city_model::populate
void populate()
Definition cityrep.cpp:279
city_model::columnCount
int columnCount(const QModelIndex &parent=QModelIndex()) const
Definition cityrep.h:112
city_model::menu_data
QVariant menu_data(int section) const
Definition cityrep.cpp:251
city_model::data
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
Definition cityrep.cpp:190
city_model::all_changed
void all_changed()
Definition cityrep.cpp:316
city_model::~city_model
~city_model()
Definition cityrep.cpp:173
city_model::city_list
QList< city_item * > city_list
Definition cityrep.h:129
city_model::setData
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::DisplayRole)
Definition cityrep.cpp:205
city_model::city_model
city_model(QObject *parent=0)
Definition cityrep.cpp:165
city_model::rowCount
int rowCount(const QModelIndex &index=QModelIndex()) const
Definition cityrep.h:108
city_model::notify_city_changed
void notify_city_changed(int row)
Definition cityrep.cpp:182
city_report
Definition cityrep.h:203
city_report::city_report
city_report()
Definition cityrep.cpp:1227
city_report::index
int index
Definition cityrep.h:214
city_report::init
void init()
Definition cityrep.cpp:1250
city_report::layout
QVBoxLayout * layout
Definition cityrep.h:206
city_report::~city_report
~city_report()
Definition cityrep.cpp:1242
city_report::update_report
void update_report()
Definition cityrep.cpp:1260
city_report::city_wdg
city_widget * city_wdg
Definition cityrep.h:205
city_report::update_city
void update_city(struct city *pcity)
Definition cityrep.cpp:1268
city_sort_model
Definition cityrep.h:62
city_sort_model::lessThan
bool lessThan(const QModelIndex &left, const QModelIndex &right) const
Definition cityrep.cpp:35
city_widget
Definition cityrep.h:136
city_widget::city_view
void city_view()
Definition cityrep.cpp:403
city_widget::buy
void buy()
Definition cityrep.cpp:437
city_widget::select_city
void select_city(struct city *pcity)
Definition cityrep.cpp:819
city_widget::city_widget
city_widget(city_report *ctr)
Definition cityrep.cpp:355
city_widget::fill_data
void fill_data(menu_labels which, QMap< QString, cid > &custom_labels, QMenu *menu)
Definition cityrep.cpp:754
city_widget::city_doubleclick
void city_doubleclick(const QModelIndex &index)
Definition cityrep.cpp:395
city_widget::center
void center()
Definition cityrep.cpp:450
city_widget::update_model
void update_model()
Definition cityrep.cpp:1101
city_widget::c_i_d
city_item_delegate * c_i_d
Definition cityrep.h:140
city_widget::filter_model
QSortFilterProxyModel * filter_model
Definition cityrep.h:139
city_widget::fill_production_menus
void fill_production_menus(city_widget::menu_labels what, QMap< QString, cid > &custom_labels, TestCityFunc test_func, QMenu *menu)
Definition cityrep.cpp:733
city_widget::cr
city_report * cr
Definition cityrep.h:141
city_widget::select_coastal
void select_coastal()
Definition cityrep.cpp:845
city_widget::gen_production_labels
void gen_production_labels(menu_labels which, QMap< QString, cid > &list, bool append_units, bool append_wonders, TestCityFunc test_func, bool global=false)
Definition cityrep.cpp:1034
city_widget::select_building_something
void select_building_something()
Definition cityrep.cpp:903
city_widget::display_header_menu
void display_header_menu(const QPoint &)
Definition cityrep.cpp:1130
city_widget::hide_columns
void hide_columns()
Definition cityrep.cpp:1166
city_widget::clear_worlist
void clear_worlist()
Definition cityrep.cpp:422
city_widget::update_city
void update_city(struct city *pcity)
Definition cityrep.cpp:1092
city_widget::list_model
city_model * list_model
Definition cityrep.h:138
city_widget::select_all
void select_all()
Definition cityrep.cpp:775
city_widget::select_none
void select_none()
Definition cityrep.cpp:783
city_widget::display_list_menu
void display_list_menu(const QPoint &)
Definition cityrep.cpp:466
city_widget::gen_worklist_labels
void gen_worklist_labels(QMap< QString, int > &list)
Definition cityrep.cpp:1023
city_widget::cities_selected
void cities_selected(const QItemSelection &sl, const QItemSelection &ds)
Definition cityrep.cpp:1181
city_widget::gen_cma_labels
void gen_cma_labels(QMap< QString, int > &list)
Definition cityrep.cpp:945
city_widget::~city_widget
~city_widget()
Definition cityrep.cpp:1215
city_widget::get_model
city_model * get_model() const
Definition cityrep.cpp:1207
city_widget::selected_cities
QList< city * > selected_cities
Definition cityrep.h:164
city_widget::restore_selection
void restore_selection()
Definition cityrep.cpp:327
city_widget::invert_selection
void invert_selection()
Definition cityrep.cpp:791
city_widget::gen_select_labels
void gen_select_labels(QMenu *menu)
Definition cityrep.cpp:956
city_widget::select_same_island
void select_same_island()
Definition cityrep.cpp:872
city_widget::menu_labels
menu_labels
Definition cityrep.h:142
city_widget::CHANGE_PROD_BEF_LAST
@ CHANGE_PROD_BEF_LAST
Definition cityrep.h:146
city_widget::SELECT_AVAIL_UNITS
@ SELECT_AVAIL_UNITS
Definition cityrep.h:155
city_widget::SELL
@ SELL
Definition cityrep.h:148
city_widget::SELECT_AVAIL_WONDERS
@ SELECT_AVAIL_WONDERS
Definition cityrep.h:157
city_widget::SELECT_SUPP_UNITS
@ SELECT_SUPP_UNITS
Definition cityrep.h:153
city_widget::CHANGE_PROD_NOW
@ CHANGE_PROD_NOW
Definition cityrep.h:143
city_widget::CHANGE_PROD_LAST
@ CHANGE_PROD_LAST
Definition cityrep.h:145
city_widget::SELECT_AVAIL_IMPR
@ SELECT_AVAIL_IMPR
Definition cityrep.h:156
city_widget::CMA
@ CMA
Definition cityrep.h:147
city_widget::WORKLIST_CHANGE
@ WORKLIST_CHANGE
Definition cityrep.h:150
city_widget::WORKLIST_ADD
@ WORKLIST_ADD
Definition cityrep.h:149
city_widget::SELECT_WONDERS
@ SELECT_WONDERS
Definition cityrep.h:152
city_widget::SELECT_IMPR
@ SELECT_IMPR
Definition cityrep.h:151
city_widget::CHANGE_PROD_NEXT
@ CHANGE_PROD_NEXT
Definition cityrep.h:144
city_widget::SELECT_PRES_UNITS
@ SELECT_PRES_UNITS
Definition cityrep.h:154
city_widget::BUY
@ BUY
Definition cityrep.h:158
hud_message_box
Definition hudwidget.h:56
hud_message_box::set_text_title
int set_text_title(QString s1, QString s2, bool return_exec=false)
Definition hudwidget.cpp:126
client
struct civclient client
Definition client_main.c:149
can_client_issue_orders
bool can_client_issue_orders(void)
Definition client_main.c:1265
client_has_player
bool client_has_player(void)
Definition client_main.c:1365
client_main.h
client_player
#define client_player()
Definition client_main.h:106
city_unit_supported
bool city_unit_supported(const struct city *pcity, const struct universal *target)
Definition climisc.c:537
cityrep_buy
void cityrep_buy(struct city *pcity)
Definition climisc.c:1137
name_and_sort_items
void name_and_sort_items(struct universal *targets, int num_targets, struct item *items, bool show_cost, struct city *pcity)
Definition climisc.c:633
cid_encode
cid cid_encode(struct universal target)
Definition climisc.c:475
city_building_present
bool city_building_present(const struct city *pcity, const struct universal *target)
Definition climisc.c:575
cid_decode
struct universal cid_decode(cid id)
Definition climisc.c:518
city_unit_present
bool city_unit_present(const struct city *pcity, const struct universal *target)
Definition climisc.c:556
collect_production_targets
int collect_production_targets(struct universal *targets, struct city **selected_cities, int num_selected_cities, bool append_units, bool append_wonders, bool change_prod, TestCityFunc test_func)
Definition climisc.c:683
MAX_NUM_PRODUCTION_TARGETS
#define MAX_NUM_PRODUCTION_TARGETS
Definition climisc.h:87
cid
int cid
Definition climisc.h:31
TestCityFunc
bool(* TestCityFunc)(const struct city *, const struct universal *)
Definition climisc.h:85
list
static struct fc_sockaddr_list * list
Definition clinet.c:102
cma_put_city_under_agent
void cma_put_city_under_agent(struct city *pcity, const struct cm_parameter *const parameter)
Definition cma_core.c:522
cma_release_city
void cma_release_city(struct city *pcity)
Definition cma_core.c:540
cmafec_preset_get_descr
char * cmafec_preset_get_descr(int idx)
Definition cma_fec.c:169
cmafec_preset_get_parameter
const struct cm_parameter * cmafec_preset_get_parameter(int idx)
Definition cma_fec.c:182
cmafec_preset_num
int cmafec_preset_num(void)
Definition cma_fec.c:213
id
int int id
Definition editgui_g.h:28
fc_client.h
Impr_type_id
int Impr_type_id
Definition fc_types.h:346
_
#define _(String)
Definition fcintl.h:67
wld
struct world wld
Definition game.c:58
game_city_by_number
struct city * game_city_by_number(int id)
Definition game.c:102
global_worklist_by_id
struct global_worklist * global_worklist_by_id(int id)
Definition global_worklist.c:298
global_worklist_name
const char * global_worklist_name(const struct global_worklist *pgwl)
Definition global_worklist.c:323
global_worklist_id
int global_worklist_id(const struct global_worklist *pgwl)
Definition global_worklist.c:288
global_worklist_get
const struct worklist * global_worklist_get(const struct global_worklist *pgwl)
Definition global_worklist.c:276
global_worklists_iterate
#define global_worklists_iterate(pgwl)
Definition global_worklist.h:65
global_worklists_iterate_end
#define global_worklists_iterate_end
Definition global_worklist.h:68
CMA_NONE
#define CMA_NONE
Definition cityrep.h:49
NEG_VAL
#define NEG_VAL(x)
Definition cityrep.h:48
CAPTURE_DEFAULT_THIS
#define CAPTURE_DEFAULT_THIS
Definition gui_main.h:23
cityrep.h
gui_main.h
hudwidget.h
improvement_by_number
struct impr_type * improvement_by_number(const Impr_type_id id)
Definition improvement.c:192
improvement_number
Impr_type_id improvement_number(const struct impr_type *pimprove)
Definition improvement.c:182
is_wonder
bool is_wonder(const struct impr_type *pimprove)
Definition improvement.c:341
improvement_has_flag
bool improvement_has_flag(const struct impr_type *pimprove, enum impr_flag_id flag)
Definition improvement.c:381
improvement_name_translation
const char * improvement_name_translation(const struct impr_type *pimprove)
Definition improvement.c:241
fc_assert_ret
#define fc_assert_ret(condition)
Definition log.h:191
fc_assert
#define fc_assert(condition)
Definition log.h:176
center_tile_mapcanvas
void center_tile_mapcanvas(const struct tile *ptile)
Definition mapview_common.c:1222
fc_malloc
#define fc_malloc(sz)
Definition mem.h:34
gui
static mpgui * gui
Definition mpgui_qt.cpp:52
gui_options
struct client_options gui_options
Definition options.c:71
cities
struct city_list * cities
Definition packhand.c:117
ARRAY_SIZE
#define ARRAY_SIZE(x)
Definition shared.h:85
action
Definition actions.h:379
city_report_spec
Definition cityrepdata.h:27
city_report_spec::tagname
const char * tagname
Definition cityrepdata.h:35
city_report_spec::func
const char *(* func)(const struct city *pcity, const void *data)
Definition cityrepdata.h:34
city_report_spec::width
int width
Definition cityrepdata.h:29
city_report_spec::title2
const char * title2
Definition cityrepdata.h:31
city_report_spec::data
void * data
Definition cityrepdata.h:33
city_report_spec::show
bool show
Definition cityrepdata.h:28
city_report_spec::explanation
const char * explanation
Definition cityrepdata.h:32
city_report_spec::title1
const char * title1
Definition cityrepdata.h:30
city
Definition city.h:309
city::did_sell
bool did_sell
Definition city.h:367
city::id
int id
Definition city.h:315
city::worklist
struct worklist worklist
Definition city.h:387
city::production
struct universal production
Definition city.h:382
city::buy_cost
int buy_cost
Definition city.h:449
city::tile
struct tile * tile
Definition city.h:311
city::client
struct city::@17::@20 client
civclient::conn
struct connection conn
Definition client_main.h:96
client_options::center_when_popup_city
bool center_when_popup_city
Definition options.h:154
connection::playing
struct player * playing
Definition connection.h:156
impr_type
Definition improvement.h:68
item
Definition climisc.h:80
item::item
struct universal item
Definition climisc.h:81
option
Definition options.c:454
player::cities
struct city_list * cities
Definition player.h:281
section
Definition section_file.h:28
test_func
Definition mapgen.c:679
universal
Definition fc_types.h:756
universal::kind
enum universals_n kind
Definition fc_types.h:758
universal::value
universals_u value
Definition fc_types.h:757
worklist
Definition worklist.h:28
world::map
struct civ_map map
Definition world_object.h:38
fc_snprintf
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:969
is_terrain_class_near_tile
bool is_terrain_class_near_tile(const struct civ_map *nmap, const struct tile *ptile, enum terrain_class tclass)
Definition terrain.c:600
tile_continent
#define tile_continent(_tile)
Definition tile.h:91
universals_u::building
const struct impr_type * building
Definition fc_types.h:598
worklist_init
void worklist_init(struct worklist *pwl)
Definition worklist.c:38
worklist_length
int worklist_length(const struct worklist *pwl)
Definition worklist.c:57