void DecodeTrace::on_new_decode_data()
{
if (_owner)
- _owner->update_viewport();
+ _owner->appearance_changed(false, true);
}
void DecodeTrace::delete_pressed()
assert(index < (int)_decoder_forms.size());
_decoder_forms[index]->set_decoder_visible(show);
- _owner->update_viewport();
+ if (_owner)
+ _owner->appearance_changed(false, true);
}
} // namespace view
update();
}
-void Header::signals_updated()
-{
- for (shared_ptr<RowItem> r : _view) {
- assert(r);
- connect(r.get(), SIGNAL(appearance_changed()),
- this, SLOT(on_trace_changed()));
- }
-}
-
void Header::show_popup(const shared_ptr<RowItem> &item)
{
using pv::widgets::Popup;
update();
}
-void Header::on_trace_changed()
-{
- update();
- geometry_updated();
-}
-
} // namespace view
} // namespace pv
*/
static const int BaselineOffset;
- void signals_updated();
-
private:
std::shared_ptr<pv::view::RowItem> get_mouse_over_row_item(
const QPoint &pt);
private Q_SLOTS:
void on_signals_moved();
- void on_trace_changed();
-
Q_SIGNALS:
void signals_moved();
return;
_layout_v_offset = v_offset;
+
+ if (_owner)
+ _owner->extents_changed(false, true);
}
int RowItem::visual_v_offset() const
void RowItem::set_visual_v_offset(int v_offset)
{
_visual_v_offset = v_offset;
+
+ if (_owner)
+ _owner->appearance_changed(true, true);
}
void RowItem::force_to_v_offset(int v_offset)
public:
virtual void hover_point_changed();
-Q_SIGNALS:
- void appearance_changed();
-
protected:
pv::view::RowItemOwner *_owner;
assert(!item->owner());
item->set_owner(this);
_items.push_back(item);
+
+ extents_changed(true, true);
}
void RowItemOwner::remove_child_item(std::shared_ptr<RowItem> item)
auto iter = std::find(_items.begin(), _items.end(), item);
assert(iter != _items.end());
_items.erase(iter);
+
+ extents_changed(true, true);
}
RowItemOwner::iterator RowItemOwner::begin()
*/
std::pair<int, int> v_extents() const;
- virtual void update_viewport() = 0;
+public:
+ virtual void appearance_changed(bool label, bool content) = 0;
+
+ virtual void extents_changed(bool horz, bool vert) = 0;
private:
item_list _items;
void Signal::enable(bool enable)
{
_channel->set_enabled(enable);
- appearance_changed();
+
+ if (_owner)
+ _owner->extents_changed(true, true);
}
shared_ptr<Channel> Signal::channel() const
void Trace::on_text_changed(const QString &text)
{
set_name(text);
- appearance_changed();
+
+ if (_owner)
+ _owner->extents_changed(true, false);
}
void Trace::on_colour_changed(const QColor &colour)
{
set_colour(colour);
- appearance_changed();
+
+ if (_owner)
+ _owner->appearance_changed(true, false);
}
} // namespace view
return _owner ? layout_v_offset() + _owner->owner_v_offset() : 0;
}
-void TraceGroup::update_viewport()
-{
- if (_owner)
- _owner->update_viewport();
-}
-
void TraceGroup::on_ungroup()
{
const vector< shared_ptr<RowItem> > items(
_owner->add_child_item(r);
_owner->remove_child_item(shared_from_this());
- appearance_changed();
+}
+
+void TraceGroup::appearance_changed(bool label, bool content)
+{
+ if (_owner)
+ _owner->appearance_changed(label, content);
+}
+
+void TraceGroup::extents_changed(bool horz, bool vert)
+{
+ if (_owner)
+ _owner->extents_changed(horz, vert);
}
} // namespace view
*/
int owner_v_offset() const;
- void update_viewport();
+public:
+ void appearance_changed(bool label, bool content);
+
+ void extents_changed(bool horz, bool vert);
private Q_SLOTS:
void on_ungroup();
connect(_cursors.second().get(), SIGNAL(time_changed()),
this, SLOT(marker_time_changed()));
- connect(_header, SIGNAL(geometry_updated()),
- this, SLOT(on_geometry_updated()));
connect(_header, SIGNAL(signals_moved()),
this, SLOT(on_signals_moved()));
connect(this, SIGNAL(hover_point_changed()),
this, SLOT(on_hover_point_changed()));
+ connect(&_lazy_event_handler, SIGNAL(timeout()),
+ this, SLOT(process_sticky_events()));
+ _lazy_event_handler.setSingleShot(true);
+
setViewport(_viewport);
_viewport->installEventFilter(this);
update_layout();
}
+void View::appearance_changed(bool label, bool content)
+{
+ if (label)
+ _header->update();
+ if (content)
+ _viewport->update();
+}
+
+void View::extents_changed(bool horz, bool vert)
+{
+ _sticky_events |=
+ (horz ? SelectableItemHExtentsChanged : 0) |
+ (vert ? SelectableItemVExtentsChanged : 0);
+ _lazy_event_handler.start();
+}
+
void View::h_scroll_value_changed(int value)
{
if (_updating_scroll)
}
update_layout();
-
- // Update the child widgets
- _header->signals_updated();
- _viewport->signals_updated();
}
void View::data_updated()
signals_moved();
}
-void View::on_geometry_updated()
+void View::process_sticky_events()
{
- update_layout();
+ if (_sticky_events & SelectableItemHExtentsChanged)
+ update_layout();
+ if (_sticky_events & SelectableItemVExtentsChanged) {
+ _viewport->update();
+ _header->update();
+ }
+
+ // Clear the sticky events
+ _sticky_events = 0;
}
void View::on_hover_point_changed()
#include <QAbstractScrollArea>
#include <QSizeF>
+#include <QTimer>
#include <pv/data/signaldata.h>
class View : public QAbstractScrollArea, public RowItemOwner {
Q_OBJECT
+private:
+ enum StickyEvents {
+ SelectableItemHExtentsChanged = 1,
+ SelectableItemVExtentsChanged = 2
+ };
+
private:
static const double MaxScale;
static const double MinScale;
void resizeEvent(QResizeEvent *e);
+public:
+ void appearance_changed(bool label, bool content);
+
+ void extents_changed(bool horz, bool vert);
+
private Q_SLOTS:
void h_scroll_value_changed(int value);
void on_signals_moved();
- void on_geometry_updated();
+ void process_sticky_events();
void on_hover_point_changed();
CursorPair _cursors;
QPoint _hover_point;
+
+ unsigned int _sticky_events;
+ QTimer _lazy_event_handler;
};
} // namespace view
this, SLOT(on_signals_moved()));
}
-void Viewport::signals_updated()
-{
- for (shared_ptr<RowItem> r : _view) {
- assert(r);
- connect(r.get(), SIGNAL(appearance_changed()),
- this, SLOT(update()));
- }
-}
-
void Viewport::paintEvent(QPaintEvent*)
{
vector< shared_ptr<RowItem> > row_items(_view.begin(), _view.end());
public:
explicit Viewport(View &parent);
- void signals_updated();
-
protected:
void paintEvent(QPaintEvent *event);