25 #include <QFormLayout> 28 #include <QApplication> 30 #include <libsigrokcxx/libsigrokcxx.hpp> 34 using std::enable_shared_from_this;
35 using std::shared_ptr;
51 enable_shared_from_this<
Flag>(flag)
70 if (!ref_item || (ref_item.get() ==
this))
74 ref_item->time(), ref_item->delta(
time_),
100 if (!ref_item || (ref_item.get() ==
this)) {
106 QFontMetrics
m(QApplication::font());
109 const QSizeF label_size(
113 const float height = label_size.height();
120 r = QRectF(x, top, label_size.width(), height);
122 r = QRectF(x - label_size.width(), top, label_size.width(), height);
133 popup->set_position(parent->mapToGlobal(
136 QFormLayout *
const form = (QFormLayout*)popup->layout();
138 QLineEdit *
const text_edit =
new QLineEdit(popup);
139 text_edit->setText(
text_);
141 connect(text_edit, SIGNAL(textChanged(
const QString&)),
144 form->insertRow(0, tr(
"Text"), text_edit);
151 QMenu *
const menu =
new QMenu(parent);
153 QAction *
const del =
new QAction(tr(
"Delete"),
this);
154 del->setShortcuts(QKeySequence::Delete);
155 connect(del, SIGNAL(triggered()),
this, SLOT(
on_delete()));
156 menu->addAction(del);
158 QAction *
const snap_disable =
new QAction(tr(
"Disable snapping"),
this);
159 snap_disable->setCheckable(
true);
161 connect(snap_disable, &QAction::toggled,
this, [=](
bool checked){
snapping_disabled_ = checked;});
162 menu->addAction(snap_disable);
const Ruler * ruler() const
shared_ptr< TimeItem > get_reference_item() const
util::TimeUnit time_unit() const
pv::util::Timestamp time_
pv::util::SIPrefix tick_prefix() const
virtual QString get_display_text() const override
virtual bool enabled() const override
float get_x() const override
void time_item_appearance_changed(bool label, bool content)
Flag(View &view, const pv::util::Timestamp &time, const QString &text)
static const QSizeF LabelPadding
QRectF label_rect(const QRectF &rect) const override
QRectF label_rect(const QRectF &rect) const override
void remove_flag(shared_ptr< Flag > flag)
virtual pv::widgets::Popup * create_popup(QWidget *parent) override
virtual QString get_text() const override
void on_text_changed(const QString &text)
static QString format_time_with_distance(const pv::util::Timestamp &distance, const pv::util::Timestamp &t, pv::util::SIPrefix prefix=pv::util::SIPrefix::unspecified, pv::util::TimeUnit unit=pv::util::TimeUnit::Time, unsigned precision=0, bool sign=true)
QPoint drag_point(const QRect &rect) const override
virtual void set_text(const QString &text) override
x y t t *t x y t t t x y t t t x *y t *t t x *y t *t t x y t t t x y t t t x(y+z)
boost::multiprecision::number< boost::multiprecision::cpp_dec_float< 24 >, boost::multiprecision::et_off > Timestamp
Timestamp type providing yoctosecond resolution.
virtual const pv::util::Timestamp delta(const pv::util::Timestamp &other) const
static const QColor FillColor
virtual pv::widgets::Popup * create_popup(QWidget *parent) override
static const int ArrowSize
virtual QMenu * create_header_context_menu(QWidget *parent) override
virtual void delete_pressed() override
unsigned int tick_precision() const