color_(color),
time_(time),
value_action_(nullptr),
- value_widget_(nullptr),
- updating_value_widget_(false)
+ value_widget_(nullptr)
{
}
time_ = time;
if (value_widget_) {
- updating_value_widget_ = true;
+ QSignalBlocker blocker(value_widget_);
value_widget_->setValue(view_.ruler()->get_ruler_time_from_absolute_time(time));
- updating_value_widget_ = false;
}
view_.time_item_appearance_changed(true, true);
void TimeMarker::on_value_changed(const pv::util::Timestamp& value)
{
- if (!updating_value_widget_)
- set_time(view_.ruler()->get_absolute_time_from_ruler_time(value));
+ set_time(view_.ruler()->get_absolute_time_from_ruler_time(value));
}
} // namespace trace
, stepsize_("1e-6")
{
connect(this, SIGNAL(editingFinished()), this, SLOT(on_editingFinished()));
+ connect(lineEdit(), SIGNAL(editingFinished()), this, SLOT(on_editingFinished()));
updateEdit();
}
void TimestampSpinBox::on_editingFinished()
{
- if (!lineEdit()->isModified())
- return;
- lineEdit()->setModified(false);
-
QRegExp re(R"(\s*([-+]?)\s*([0-9]+\.?[0-9]*).*)");
if (re.exactMatch(text())) {
captures.removeFirst(); // remove entire match
QString str = captures.join("");
setValue(pv::util::Timestamp(str.toStdString()));
+
} else {
// replace the malformed entered string with the old value
updateEdit();
{
QString newtext = pv::util::format_time_si(
value_, pv::util::SIPrefix::none, precision_);
+ const QSignalBlocker blocker(lineEdit());
+ // Keep cursor position
+ int cursor = lineEdit()->cursorPosition();
lineEdit()->setText(newtext);
+ lineEdit()->setCursorPosition(cursor);
}
} // namespace widgets