]> sigrok.org Git - pulseview.git/blobdiff - pv/views/trace/flag.cpp
Session: Fix issue #67 by improving error handling
[pulseview.git] / pv / views / trace / flag.cpp
index ea3cd609854c813783ffe6e406143b887915693a..c356b15bf62bba31341b0f22f8a24a2ed5813dd1 100644 (file)
@@ -57,7 +57,11 @@ bool Flag::enabled() const
        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;
 
@@ -73,6 +77,20 @@ QString Flag::get_text() const
        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;
+       view_.time_item_appearance_changed(true, false);
+}
+
 QRectF Flag::label_rect(const QRectF &rect) const
 {
        QRectF r;
@@ -86,7 +104,7 @@ QRectF Flag::label_rect(const QRectF &rect) const
                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,
@@ -158,8 +176,7 @@ void Flag::on_delete()
 
 void Flag::on_text_changed(const QString &text)
 {
-       text_ = text;
-       view_.time_item_appearance_changed(true, false);
+       set_text(text);
 }
 
 } // namespace trace