]> sigrok.org Git - pulseview.git/blobdiff - pv/views/trace/timemarker.hpp
TimeMarker: Automatically deselect item when popup closes
[pulseview.git] / pv / views / trace / timemarker.hpp
index 24ba9b0341bb331b4026f2285a08f423a5aa2059..f67a0f17a1e36567bb050afa23d6ecedaccdbb2c 100644 (file)
@@ -17,8 +17,8 @@
  * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef PULSEVIEW_PV_VIEWS_TRACEVIEW_MARKER_HPP
-#define PULSEVIEW_PV_VIEWS_TRACEVIEW_MARKER_HPP
+#ifndef PULSEVIEW_PV_VIEWS_TRACE_TIMEMARKER_HPP
+#define PULSEVIEW_PV_VIEWS_TRACE_TIMEMARKER_HPP
 
 #include <QColor>
 #include <QDoubleSpinBox>
@@ -41,6 +41,10 @@ namespace trace {
 
 class View;
 
+/**
+ * The TimeMarker class represents items on the @ref Ruler that highlight a
+ * single point in time to the user. Aside from this, it is generic in nature.
+ */
 class TimeMarker : public TimeItem
 {
        Q_OBJECT
@@ -52,16 +56,16 @@ protected:
        /**
         * Constructor.
         * @param view A reference to the view that owns this marker.
-        * @param colour A reference to the colour of this cursor.
+        * @param color A reference to the color of this cursor.
         * @param time The time to set the flag to.
         */
-       TimeMarker(View &view, const QColor &colour, const pv::util::Timestamp& time);
+       TimeMarker(View &view, const QColor &color, const pv::util::Timestamp& time);
 
 public:
        /**
         * Gets the time of the marker.
         */
-       const pv::util::Timestamp& time() const;
+       virtual const pv::util::Timestamp time() const override;
 
        /**
         * Sets the time of the marker.
@@ -91,10 +95,21 @@ public:
        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;
 
+       /**
+        * Sets the text to show in the marker.
+        */
+       virtual void set_text(const QString &text);
+
        /**
         * Paints the marker's label to the ruler.
         * @param p The painter to draw with.
@@ -113,10 +128,12 @@ public:
        virtual pv::widgets::Popup* create_popup(QWidget *parent) override;
 
 private Q_SLOTS:
+       void on_popup_closed();
+
        void on_value_changed(const pv::util::Timestamp& value);
 
 protected:
-       const QColor &colour_;
+       const QColor &color_;
 
        pv::util::Timestamp time_;
 
@@ -124,11 +141,10 @@ protected:
 
        QWidgetAction *value_action_;
        pv::widgets::TimestampSpinBox *value_widget_;
-       bool updating_value_widget_;
 };
 
 } // namespace trace
 } // namespace views
 } // namespace pv
 
-#endif // PULSEVIEW_PV_VIEWS_TRACEVIEW_MARKER_HPP
+#endif // PULSEVIEW_PV_VIEWS_TRACE_TIMEMARKER_HPP