Before, get_text() would return the delta time to a selected flag, so if one was selected as the session was saved, this delta time would be saved as the name.
const float x = get_x();
QFontMetrics m(QApplication::font());
- QSize text_size = m.boundingRect(get_text()).size();
+ QSize text_size = m.boundingRect(get_display_text()).size();
const QSizeF label_size(
text_size.width() + LabelPadding.width() * 2,
return true;
}
-QString Flag::get_text() const
+/**
+ * Returns the text used to display this flag item. This is not necessarily the
+ * name that the user has given it.
+ */
+QString Flag::get_display_text() const
{
QString s;
return s;
}
+/**
+ * Returns the text of this flag item, i.e. the user-editable name.
+ */
+QString Flag::get_text() const
+{
+ return text_;
+}
+
void Flag::set_text(const QString &text)
{
text_ = text;
const float x = get_x();
QFontMetrics m(QApplication::font());
- QSize text_size = m.boundingRect(get_text()).size();
+ QSize text_size = m.boundingRect(get_display_text()).size();
const QSizeF label_size(
text_size.width() + LabelPadding.width() * 2,
virtual bool enabled() const override;
/**
- * Gets the text to show in the marker.
+ * Gets the current text to show in the marker - this may be dynamic.
+ */
+ virtual QString get_display_text() const override;
+
+ /**
+ * Gets the default text used to show the marker - e.g. the user-editable
+ * name.
*/
virtual QString get_text() const override;
{
QFontMetrics m(QApplication::font());
const QSizeF text_size(
- max(m.boundingRect(get_text()).size().width(), ArrowSize),
+ max(m.boundingRect(get_display_text()).size().width(), ArrowSize),
m.height());
const QSizeF label_size(text_size + LabelPadding * 2);
const float top = rect.height() - label_size.height() -
return QRectF(x - h / 2.0f, pp.top(), h, pp.height());
}
+QString TimeMarker::get_display_text() const
+{
+ return get_text();
+}
+
void TimeMarker::set_text(const QString &text)
{
(void)text;
p.drawPolygon(points, countof(points));
p.setPen(select_text_color(color_));
- p.drawText(r, Qt::AlignCenter | Qt::AlignVCenter, get_text());
+ p.drawText(r, Qt::AlignCenter | Qt::AlignVCenter, get_display_text());
}
void TimeMarker::paint_fore(QPainter &p, ViewItemPaintParams &pp)
QRectF hit_box_rect(const ViewItemPaintParams &pp) const override;
/**
- * Gets the text to show in the marker.
+ * Gets the current text to show in the marker - this may be dynamic.
+ */
+ virtual QString get_display_text() const;
+
+ /**
+ * Gets the default text used to show the marker - e.g. the user-editable
+ * name.
*/
virtual QString get_text() const = 0;