12 #include <QAbstractItemView>
14 #include <QModelIndex>
28 extern QString
split_text(
const QString &text,
bool cut);
36 QHelpEvent *help_event;
40 if (ev->type() == QEvent::ToolTip) {
41 QAbstractItemView *
view =
42 qobject_cast<QAbstractItemView *>(obj->parent());
48 help_event =
static_cast<QHelpEvent *
>(ev);
49 QPoint pos = help_event->pos();
50 QModelIndex index =
view->indexAt(pos);
52 if (!index.isValid()) {
56 item_tooltip =
view->model()->data(index, Qt::ToolTipRole).toString();
57 rect =
view->visualRect(index);
58 rect.setX(rect.x() + help_event->globalPos().x());
59 rect.setY(rect.y() + help_event->globalPos().y());
61 if (!item_tooltip.isEmpty()) {
62 QToolTip::showText(help_event->globalPos(), item_tooltip,
view, rect);
76 QString
bold(
const QString &text) {
return QString(
"<b>" + text +
"</b>"); }
83 struct city *pcity,
bool ext)
90 if (pcity !=
nullptr) {
93 upkeep = QString::number(building->
upkeep);
97 if (pobs->source.kind == VUT_ADVANCE) {
104 str =
_(
"Obsolete by:");
105 str = str +
" " + s2;
106 def_str =
"<p style='white-space:pre'><b>"
109 if (pcity !=
nullptr) {
110 def_str += QString(
_(
"Cost: %1, Upkeep: %2\n"))
118 def_str += QString(
_(
"Cost Estimate: %1, Upkeep: %2\n"))
123 if (s1.compare(s2) != 0) {
124 def_str = def_str + str.toHtmlEscaped() +
"\n";
126 def_str = def_str +
"\n";
135 def_str = def_str + str.toHtmlEscaped();
147 QString obsolete_str;
157 obsolete_str = QStringLiteral(
"</td></tr><tr><td colspan=\"3\">");
161 obsolete_str = obsolete_str
162 + QString(
_(
"Obsoleted by %1 (%2)."))
167 obsolete_str = obsolete_str
168 + QString(
_(
"Obsoleted by %1."))
174 "<table width=\"100\%\"><tr><td>" +
bold(QString(
_(
"Attack:"))) +
" "
176 + QStringLiteral(
"</td><td>") +
bold(QString(
_(
"Defense:"))) +
" "
178 + QStringLiteral(
"</td><td>") +
bold(QString(
_(
"Move:"))) +
" "
180 + QStringLiteral(
"</td></tr><tr><td>") +
bold(QString(
_(
"Cost:")))
183 + QStringLiteral(
"</td><td colspan=\"2\">")
184 +
bold(QString(
_(
"Basic Upkeep:"))) +
" "
186 + QStringLiteral(
"</td></tr><tr><td>") +
bold(QString(
_(
"Hitpoints:")))
187 +
" " + QString::number(utype->
hp).toHtmlEscaped()
188 + QStringLiteral(
"</td><td>") +
bold(QString(
_(
"FirePower:"))) +
" "
189 + QString::number(utype->
firepower).toHtmlEscaped()
190 + QStringLiteral(
"</td><td>") +
bold(QString(
_(
"Vision:"))) +
" "
191 + QString::number(
static_cast<int>(sqrt(
195 + QStringLiteral(
"</td></tr></table><p style='white-space:pre'>");
205 str = str.trimmed().toHtmlEscaped();
206 def_str = def_str + str;
217 QString str, def_str, ret_str;
224 target =
reinterpret_cast<universal *
>(qvar.value<
void *>());
226 if (target ==
nullptr) {
227 }
else if (VUT_UTYPE == target->
kind) {
244 ret_str = ret_str.trimmed();
245 ret_str = def_str + ret_str.toHtmlEscaped();
int city_improvement_upkeep(const struct city *pcity, const struct impr_type *b)
Return the upkeep (gold) needed each turn to upkeep the given improvement in the given city.
struct nation_set * client_current_nation_set()
Returns the nation set in use.
const char * skip_intl_qualifier_prefix(const char *str)
Some strings are ambiguous for translation.
char * helptext_unit(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, const struct unit_type *utype, const nation_set *nations_to_show)
Append misc dynamic text for units.
char * helptext_unit_upkeep_str(const struct unit_type *utype)
Returns pointer to static string with eg: "1 shield, 1 unhappy".
char * helptext_building(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, const struct impr_type *pimprove, const nation_set *nations_to_show)
FIXME: Also, in principle these could be auto-generated once, inserted into pitem->text,...
int impr_build_shield_cost(const struct city *pcity, const struct impr_type *pimprove)
Returns the number of shields it takes to build this improvement.
bool improvement_has_flag(const struct impr_type *pimprove, enum impr_flag_id flag)
Return TRUE if the impr has this flag otherwise FALSE.
const char * improvement_name_translation(const struct impr_type *pimprove)
Return the (translated) name of the given improvement.
int impr_estimate_build_shield_cost(const struct player *pplayer, const struct tile *ptile, const struct impr_type *pimprove)
Returns estimate of the number of shields it takes to build this improvement.
const char * move_points_text(int mp, bool reduce)
Simple version of move_points_text_full() – render positive movement points as text without any prefi...
#define requirement_vector_iterate_end
#define requirement_vector_iterate(req_vec, preq)
struct requirement_vector obsolete_by
const struct unit_type * obsoleted_by
struct advance * require_advance
struct advance * advance_by_number(const Tech_type_id atype)
Return the advance for the given advance index.
const char * advance_name_translation(const struct advance *padvance)
Return the (translated) name of the given advance/technology.
const struct unit_type * utype
const struct impr_type * building
int utype_build_shield_cost_base(const struct unit_type *punittype)
Returns the number of shields this unit type represents.
const char * utype_name_translation(const struct unit_type *punittype)
Return the (translated) name of the unit type.