Freeciv21
Develop your civilization from humble roots to a global empire
freeciv::upkeep_widget Class Reference

Displays the list of items supported by a city (improvements and units). More...

#include <upkeep_widget.h>

+ Inheritance diagram for freeciv::upkeep_widget:
+ Collaboration diagram for freeciv::upkeep_widget:

Public Member Functions

 upkeep_widget (QWidget *parent=nullptr)
 Constructor. More...
 
void refresh ()
 Updates the widget from the city. More...
 
void set_city (int city_id)
 Changes the city displayed by this widget. More...
 
QSize viewportSizeHint () const override
 Reimplemented to provide a meaningful size hint. More...
 
QSize minimumSizeHint () const override
 Reimplemented to allow for tiny tilesets. More...
 

Protected Member Functions

void contextMenuEvent (QContextMenuEvent *event) override
 Reimplemented to provide the improvement and unit actions. More...
 
bool event (QEvent *event) override
 Reimplemented to handle tileset changes. More...
 

Private Member Functions

void item_double_clicked (const QModelIndex &index)
 Called when an item is double clicked. More...
 

Private Attributes

int m_city = -1
 
QStandardItemModel * m_model
 

Detailed Description

Displays the list of items supported by a city (improvements and units).

Definition at line 14 of file upkeep_widget.h.

Constructor & Destructor Documentation

◆ upkeep_widget()

freeciv::upkeep_widget::upkeep_widget ( QWidget *  parent = nullptr)
explicit

Constructor.

Definition at line 50 of file upkeep_widget.cpp.

Member Function Documentation

◆ contextMenuEvent()

void freeciv::upkeep_widget::contextMenuEvent ( QContextMenuEvent *  event)
overrideprotected

Reimplemented to provide the improvement and unit actions.

Definition at line 176 of file upkeep_widget.cpp.

◆ event()

bool freeciv::upkeep_widget::event ( QEvent *  event)
overrideprotected

Reimplemented to handle tileset changes.

Definition at line 223 of file upkeep_widget.cpp.

Referenced by contextMenuEvent().

◆ item_double_clicked()

void freeciv::upkeep_widget::item_double_clicked ( const QModelIndex &  index)
private

Called when an item is double clicked.

Sells improvements and activates units.

Definition at line 236 of file upkeep_widget.cpp.

Referenced by upkeep_widget().

◆ minimumSizeHint()

QSize freeciv::upkeep_widget::minimumSizeHint ( ) const
override

Reimplemented to allow for tiny tilesets.

Definition at line 171 of file upkeep_widget.cpp.

◆ refresh()

void freeciv::upkeep_widget::refresh ( )

Updates the widget from the city.

Definition at line 69 of file upkeep_widget.cpp.

Referenced by event(), and set_city().

◆ set_city()

void freeciv::upkeep_widget::set_city ( int  city_id)

Changes the city displayed by this widget.

Definition at line 147 of file upkeep_widget.cpp.

◆ viewportSizeHint()

QSize freeciv::upkeep_widget::viewportSizeHint ( ) const
override

Reimplemented to provide a meaningful size hint.

Definition at line 158 of file upkeep_widget.cpp.

Member Data Documentation

◆ m_city

int freeciv::upkeep_widget::m_city = -1
private

Definition at line 34 of file upkeep_widget.h.

Referenced by contextMenuEvent(), item_double_clicked(), refresh(), and set_city().

◆ m_model

QStandardItemModel* freeciv::upkeep_widget::m_model
private