X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=pv%2Fview%2Fview.cpp;h=e43522577e9c985e3808d5cf5edce5b5c4365017;hb=8914fe790fb677c56194a3ae4da06ba671fca78a;hp=c53c02e3abd44f8242dc7bd1ceaf3d43a38cf02b;hpb=6e2c3c855dff36f6e946e2a54d576bea699f4a61;p=pulseview.git diff --git a/pv/view/view.cpp b/pv/view/view.cpp index c53c02e..e435225 100644 --- a/pv/view/view.cpp +++ b/pv/view/view.cpp @@ -60,7 +60,6 @@ using pv::data::SignalData; using pv::data::Segment; using pv::util::format_time; -using std::back_inserter; using std::deque; using std::dynamic_pointer_cast; using std::list; @@ -105,6 +104,7 @@ View::View(Session &session, QWidget *parent) : tick_prefix_(0), show_cursors_(false), cursors_(new CursorPair(*this)), + next_flag_text_('A'), hover_point_(-1, -1) { connect(horizontalScrollBar(), SIGNAL(valueChanged(int)), @@ -121,11 +121,6 @@ View::View(Session &session, QWidget *parent) : connect(&session_, SIGNAL(frame_ended()), this, SLOT(data_updated())); - connect(cursors_->first().get(), SIGNAL(time_changed()), - this, SLOT(marker_time_changed())); - connect(cursors_->second().get(), SIGNAL(time_changed()), - this, SLOT(marker_time_changed())); - connect(header_, SIGNAL(signals_moved()), this, SLOT(on_signals_moved())); @@ -197,7 +192,8 @@ const Viewport* View::viewport() const vector< shared_ptr > View::time_items() const { - vector< shared_ptr > items; + const vector> f(flags()); + vector> items(f.begin(), f.end()); items.push_back(cursors_); items.push_back(cursors_->first()); items.push_back(cursors_->second()); @@ -369,6 +365,32 @@ std::shared_ptr View::cursors() const return cursors_; } +void View::add_flag(double time) +{ + flags_.push_back(shared_ptr(new Flag(*this, time, + QString("%1").arg(next_flag_text_)))); + next_flag_text_ = (next_flag_text_ >= 'Z') ? 'A' : + (next_flag_text_ + 1); + time_item_appearance_changed(true, true); +} + +void View::remove_flag(std::shared_ptr flag) +{ + flags_.remove(flag); + time_item_appearance_changed(true, true); +} + +vector< std::shared_ptr > View::flags() const +{ + vector< std::shared_ptr > flags(flags_.begin(), flags_.end()); + stable_sort(flags.begin(), flags.end(), + [](const shared_ptr &a, const shared_ptr &b) { + return a->time() < b->time(); + }); + + return flags; +} + const QPoint& View::hover_point() const { return hover_point_; @@ -615,6 +637,14 @@ void View::row_item_appearance_changed(bool label, bool content) viewport_->update(); } +void View::time_item_appearance_changed(bool label, bool content) +{ + if (label) + cursorheader_->update(); + if (content) + viewport_->update(); +} + void View::extents_changed(bool horz, bool vert) { sticky_events_ |= @@ -728,12 +758,6 @@ void View::data_updated() viewport_->update(); } -void View::marker_time_changed() -{ - cursorheader_->update(); - viewport_->update(); -} - void View::on_signals_moved() { update_scroll();