TimeMarker::TimeMarker(View &view, const QColor &colour, double time) :
_view(view),
_colour(colour),
- _time(time)
+ _time(time),
+ _value_action(&view),
+ _value_widget(&view),
+ _updating_value_widget(false)
{
+ _value_action.setDefaultWidget(&_value_widget);
+
+ _value_widget.setValue(time);
+ _value_widget.setDecimals(6);
+ _value_widget.setSuffix("s");
+ _value_widget.setSingleStep(1e-6);
+
+ connect(&_value_widget, SIGNAL(valueChanged(double)),
+ this, SLOT(on_value_changed(double)));
}
double TimeMarker::time() const
void TimeMarker::set_time(double time)
{
_time = time;
+ _updating_value_widget = true;
+ _value_widget.setValue(time);
+ _updating_value_widget = false;
time_changed();
}
const list<QAction*> TimeMarker::get_context_bar_actions()
{
list<QAction*> actions;
+ actions.push_back(&_value_action);
return actions;
}
+void TimeMarker::on_value_changed(double value)
+{
+ if (!_updating_value_widget) {
+ _time = value;
+ time_changed();
+ }
+}
+
} // namespace view
} // namespace pv
#define PULSEVIEW_PV_VIEW_MARKER_H
#include <QColor>
+#include <QDoubleSpinBox>
#include <QObject>
#include <QRectF>
+#include <QWidgetAction>
#include "selectableitem.h"
*/
const std::list<QAction*> get_context_bar_actions();
+private slots:
+ void on_value_changed(double value);
+
signals:
void time_changed();
double _time;
QSizeF _text_size;
+
+ QWidgetAction _value_action;
+ QDoubleSpinBox _value_widget;
+ bool _updating_value_widget;
};
} // namespace view