projects
/
pulseview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
View: Determine time unit and use it in other classes
[pulseview.git]
/
pv
/
view
/
viewwidget.cpp
diff --git
a/pv/view/viewwidget.cpp
b/pv/view/viewwidget.cpp
index 816fbf513db042fa48dd6edd48fe7c68bd869453..600dd621a20b6073b09f45552e86ffd0b3a89ab8 100644
(file)
--- a/
pv/view/viewwidget.cpp
+++ b/
pv/view/viewwidget.cpp
@@
-51,6
+51,11
@@
void ViewWidget::clear_selection()
update();
}
update();
}
+void ViewWidget::item_hover(const shared_ptr<ViewItem> &item)
+{
+ (void)item;
+}
+
void ViewWidget::item_clicked(const shared_ptr<ViewItem> &item)
{
(void)item;
void ViewWidget::item_clicked(const shared_ptr<ViewItem> &item)
{
(void)item;
@@
-74,7
+79,7
@@
bool ViewWidget::accept_drag() const
if (r->dragging()) {
if (!item_owner)
item_owner = r->owner();
if (r->dragging()) {
if (!item_owner)
item_owner = r->owner();
- else if(item_owner != r->owner())
+ else if
(item_owner != r->owner())
return false;
}
return false;
}
@@
-85,7
+90,8
@@
bool ViewWidget::accept_drag() const
return true;
}
return true;
}
- return false;
+ // A background drag is beginning
+ return true;
}
bool ViewWidget::mouse_down() const
}
bool ViewWidget::mouse_down() const
@@
-96,6
+102,8
@@
bool ViewWidget::mouse_down() const
void ViewWidget::drag_items(const QPoint &delta)
{
void ViewWidget::drag_items(const QPoint &delta)
{
+ bool item_dragged = false;
+
// Drag the row items
RowItemOwner *item_owner = nullptr;
for (std::shared_ptr<RowItem> r : view_)
// Drag the row items
RowItemOwner *item_owner = nullptr;
for (std::shared_ptr<RowItem> r : view_)
@@
-108,6
+116,7
@@
void ViewWidget::drag_items(const QPoint &delta)
}
if (item_owner) {
}
if (item_owner) {
+ item_dragged = true;
item_owner->restack_items();
for (const auto &r : *item_owner)
r->animate_to_layout_v_offset();
item_owner->restack_items();
for (const auto &r : *item_owner)
r->animate_to_layout_v_offset();
@@
-116,8
+125,27
@@
void ViewWidget::drag_items(const QPoint &delta)
// Drag the time items
const vector< shared_ptr<TimeItem> > items(view_.time_items());
for (auto &i : items)
// Drag the time items
const vector< shared_ptr<TimeItem> > items(view_.time_items());
for (auto &i : items)
- if (i->dragging())
+ if (i->dragging())
{
i->drag_by(delta);
i->drag_by(delta);
+ item_dragged = true;
+ }
+
+ // Do the background drag
+ if (!item_dragged)
+ drag_by(delta);
+}
+
+void ViewWidget::drag()
+{
+}
+
+void ViewWidget::drag_by(const QPoint &delta)
+{
+ (void)delta;
+}
+
+void ViewWidget::drag_release()
+{
}
void ViewWidget::mouse_left_press_event(QMouseEvent *event)
}
void ViewWidget::mouse_left_press_event(QMouseEvent *event)
@@
-141,10
+169,17
@@
void ViewWidget::mouse_left_press_event(QMouseEvent *event)
}
// Save the offsets of any signals which will be dragged
}
// Save the offsets of any signals which will be dragged
+ bool item_dragged = false;
const auto items = this->items();
for (auto &i : items)
const auto items = this->items();
for (auto &i : items)
- if (i->selected())
+ if (i->selected()) {
+ item_dragged = true;
i->drag();
i->drag();
+ }
+
+ // Do the background drag
+ if (!item_dragged)
+ drag();
selection_changed();
update();
selection_changed();
update();
@@
-226,26
+261,32
@@
void ViewWidget::mouseReleaseEvent(QMouseEvent *event)
mouse_down_item_ = nullptr;
}
mouse_down_item_ = nullptr;
}
-void ViewWidget::mouseMoveEvent(QMouseEvent *e
vent
)
+void ViewWidget::mouseMoveEvent(QMouseEvent *e)
{
{
- assert(e
vent
);
- mouse_point_ = e
vent
->pos();
+ assert(e);
+ mouse_point_ = e->pos();
- if (!(event->buttons() & Qt::LeftButton))
- return;
+ if (!e->buttons())
+ item_hover(get_mouse_over_item(e->pos()));
+ else if (e->buttons() & Qt::LeftButton)
+ {
+ if (!item_dragging_)
+ {
+ if ((e->pos() - mouse_down_point_).manhattanLength() <
+ QApplication::startDragDistance())
+ return;
- if ((event->pos() - mouse_down_point_).manhattanLength() <
- QApplication::startDragDistance())
- return;
+ if (!accept_drag())
+ return;
- if (!accept_drag())
- return;
+ item_dragging_ = true;
+ }
- // Do the drag
- item_dragging_ = true;
- drag_items(event->pos() - mouse_down_point_);
+ // Do the drag
+ drag_items(e->pos() - mouse_down_point_);
- update();
+ update();
+ }
}
void ViewWidget::leaveEvent(QEvent*)
}
void ViewWidget::leaveEvent(QEvent*)