MarginWidget(parent),
textHeight_(calculateTextHeight())
{
- setMouseTracking(true);
}
QSize CursorHeader::sizeHint() const
view_.add_flag(view_.offset() + ((double)e->x() + 0.5) * view_.scale());
}
+void CursorHeader::keyPressEvent(QKeyEvent *e)
+{
+ assert(e);
+
+ if (e->key() == Qt::Key_Delete)
+ {
+ const vector< shared_ptr<TimeItem> > items(view_.time_items());
+ for (auto &i : items)
+ if (i->selected())
+ i->delete_pressed();
+ }
+}
+
} // namespace view
} // namespace pv
void mouseDoubleClickEvent(QMouseEvent *e);
+ void keyPressEvent(QKeyEvent *e);
+
+private:
int calculateTextHeight();
std::shared_ptr<TimeItem> mouse_down_item_;
}
Flag::Flag(const Flag &flag) :
- TimeMarker(flag.view_, FillColour, flag.time_)
+ TimeMarker(flag.view_, FillColour, flag.time_),
+ std::enable_shared_from_this<pv::view::Flag>(flag)
{
}
return popup;
}
+void Flag::delete_pressed()
+{
+ view_.remove_flag(shared_ptr<Flag>(shared_from_this()));
+}
+
void Flag::on_text_changed(const QString &text)
{
text_ = text;
#ifndef PULSEVIEW_PV_VIEW_FLAG_H
#define PULSEVIEW_PV_VIEW_FLAG_H
+#include <memory>
+
#include "timemarker.hpp"
namespace pv {
namespace view {
-class Flag : public TimeMarker
+class Flag : public TimeMarker,
+ public std::enable_shared_from_this<pv::view::Flag>
{
Q_OBJECT
pv::widgets::Popup* create_popup(QWidget *parent);
+ void delete_pressed();
+
private Q_SLOTS:
void on_text_changed(const QString &text);
Header::Header(View &parent) :
MarginWidget(parent)
{
- setFocusPolicy(Qt::ClickFocus);
- setMouseTracking(true);
-
connect(&view_, SIGNAL(signals_moved()),
this, SLOT(on_signals_moved()));
}
dragging_(false)
{
setAttribute(Qt::WA_NoSystemBackground, true);
+ setFocusPolicy(Qt::ClickFocus);
+ setMouseTracking(true);
}
void MarginWidget::clear_selection()
class View;
class TimeItem : public ViewItem
+
{
Q_OBJECT