13 #include <QApplication>
15 #include <QHBoxLayout>
16 #include <QHeaderView>
19 #include <QPushButton>
20 #include <QTableWidget>
40 QStringList headers_lst;
44 headers_lst << QString(
_(
"City")) << QString(
_(
"Nation"))
45 << QString(
_(
"Airlift"));
60 goto_tab->setProperty(
"showGrid",
"false");
61 goto_tab->setSelectionBehavior(QAbstractItemView::SelectRows);
62 goto_tab->setEditTriggers(QAbstractItemView::NoEditTriggers);
63 goto_tab->verticalHeader()->setVisible(
false);
64 goto_tab->horizontalHeader()->setVisible(
true);
65 goto_tab->setSelectionMode(QAbstractItemView::SingleSelection);
67 goto_tab->setHorizontalHeaderLabels(headers_lst);
69 goto_tab->horizontalHeader()->setSectionResizeMode(
70 QHeaderView::ResizeToContents);
73 layout->addItem(hb, 4, 0, 1, 2);
78 setFixedWidth(
goto_tab->horizontalHeader()->width());
79 connect(
close_but, &QAbstractButton::clicked,
this,
81 connect(
goto_city, &QAbstractButton::clicked,
this,
85 connect(
show_all, &QCheckBox::stateChanged,
this,
87 connect(
goto_tab->selectionModel(), &QItemSelectionModel::selectionChanged,
129 const QItemSelection &ds)
135 QModelIndexList indexes = sl.indexes();
136 QTableWidgetItem *
item;
140 if (indexes.isEmpty()) {
143 index = indexes.at(0);
146 city_id =
item->data(Qt::UserRole).toInt();
169 goto_tab->sortByColumn(0, Qt::AscendingOrder);
179 p = parentWidget()->mapFromGlobal(p);
182 if (p.x() + width() > parentWidget()->width()) {
183 final_p.setX(parentWidget()->width() - width());
185 if (p.y() - height() < 0) {
186 final_p.setY(height());
188 move(final_p.x(), final_p.y() - height());
207 goto_tab->horizontalHeader()->setStretchLastSection(
false);
209 goto_tab->horizontalHeader()->setStretchLastSection(
true);
220 QFont f = QApplication::font();
223 QTableWidgetItem *
item;
230 for (
int j = 0; j < 3; j++) {
231 item =
new QTableWidgetItem;
239 if (sprite !=
nullptr) {
240 item->setData(Qt::DecorationRole, sprite->scaledToHeight(h));
247 str = QStringLiteral(
"-");
249 item->setTextAlignment(Qt::AlignHCenter);
253 item->setData(Qt::UserRole, pcity->id);
317 painter->setBrush(QColor(0, 0, 30, 85));
318 painter->drawRect(0, 0, width(), height());
319 painter->setBrush(QColor(0, 0, 0, 85));
320 painter->drawRect(5, 5, width() - 10, height() - 10);
350 if (
queen()->gtd !=
nullptr) {
struct tile * city_tile(const struct city *pcity)
Return the tile location of the city.
const char * city_name_get(const struct city *pcity)
Return the name of the city.
#define city_list_iterate(citylist, pcity)
#define city_list_iterate_end
void sort_def()
Sorts dialog by default column (0)
void go_to_city()
Slot for goto for city.
void update_dlg()
Updates table in widget.
void init()
Sets variables which must be destroyed later.
void close_dlg()
Slot for hiding dialog.
struct tile * original_tile
~goto_dialog() override
Destructor for goto dialog.
goto_dialog(QWidget *parent=0)
Constructor for goto_dialog.
void checkbox_changed(int state)
Slot for checkbox 'all nations'.
void paint(QPainter *painter, QPaintEvent *event)
Paints rectangles for goto_dialog.
QPushButton * airlift_city
void airlift_to()
Slot for airlifting unit.
void show_me()
Shows and moves widget.
void paintEvent(QPaintEvent *event) override
Paint event for goto_dialog.
void item_selected(const QItemSelection &sl, const QItemSelection &ds)
User has chosen some city on table.
void fill_tab(struct player *pplayer)
Helper for function for filling table.
void center_on_tile(tile *tile, bool animate=true)
Centers the view on a tile.
enum client_states client_state()
Return current client state.
bool client_has_player()
Either controlling or observing.
struct player * client_player()
Either controlling or observing.
void request_unit_airlift(struct unit *punit, struct city *pcity)
Send unit airlift request to server.
std::vector< unit * > & get_units_in_focus()
Returns list of units currently in focus.
int get_num_units_in_focus()
Return the number of units currently in focus (0 or more).
struct city * game_city_by_number(int id)
Often used function to get a city pointer from a city ID.
bool send_goto_tile(struct unit *punit, struct tile *ptile)
Send orders for the unit to move it to the arbitrary tile.
void popup_goto_dialog(void)
const char * nation_adjective_translation(const struct nation_type *pnation)
Return the (translated) adjective for the given nation.
struct nation_type * nation_of_player(const struct player *pplayer)
Return the nation of a player.
pageGame * queen()
Return game instandce.
#define players_iterate_end
#define players_iterate(_pplayer)
struct city_list * cities
const QString get_airlift_text(const std::vector< unit * > &units, const struct city *pdest)
Describe the airlift capacity of a city for the given units (from their current positions).
void tile_virtual_destroy(struct tile *vtile)
Frees all memory used by the virtual tile, including freeing virtual units in the tile's unit list an...
struct tile * tile_virtual_new(const struct tile *ptile)
Returns a virtual tile.
const QPixmap * get_nation_flag_sprite(const struct tileset *t, const struct nation_type *pnation)
Return the sprite for the nation.
bool unit_can_airlift_to(const struct unit *punit, const struct city *pdest_city)
Determines if punit can be airlifted to dest_city now! So punit needs to be in a city now.
struct tile * get_center_tile_mapcanvas()
Finds the current center tile of the mapcanvas.