![]() |
Freeciv21
Develop your civilization from humble roots to a global empire
|
Helper class to safely sell a city improvement. More...
#include <improvement_seller.h>
Public Member Functions | |
| improvement_seller (QWidget *parent, int city_id, int improvement_id) | |
| Constructor. More... | |
| void | operator() () |
| Asks for confirmation then sells the improvement. More... | |
Static Public Member Functions | |
| static QAction * | add_to_menu (QWidget *parent, QMenu *menu, const city *city, int improvement_id) |
| Adds a menu item to sell an improvement in a city. More... | |
Private Attributes | |
| int | m_city |
| int | m_improvement |
| QWidget * | m_parent |
Helper class to safely sell a city improvement.
This class adds an action to a menu (via add_to_menu) to sell a city improvement. When the item is activated, the potential gain is displayed and the user is prompted for confirmation. If the user confirms, the improvement is sold.
The seller can also be used directly with its operator().
This class handles all corner cases where the city may be disbanded or the improvement disappear for some reason.
Definition at line 16 of file improvement_seller.h.
| freeciv::improvement_seller::improvement_seller | ( | QWidget * | parent, |
| int | city_id, | ||
| int | improvement_id | ||
| ) |
|
static |
Adds a menu item to sell an improvement in a city.
The parent parameter is used as the parent for the confirmation popup. It may not be null. The parent must outlive the menu.
Definition at line 100 of file improvement_seller.cpp.
Referenced by freeciv::upkeep_widget::contextMenuEvent().
| void freeciv::improvement_seller::operator() | ( | ) |
Asks for confirmation then sells the improvement.
Definition at line 50 of file improvement_seller.cpp.
|
private |
Definition at line 26 of file improvement_seller.h.
Referenced by operator()().
|
private |
Definition at line 26 of file improvement_seller.h.
Referenced by operator()().
|
private |
Definition at line 27 of file improvement_seller.h.
Referenced by operator()().