|
From: Tapio V. <aa...@us...> - 2011-02-02 11:40:24
|
Module: editor
Branch: master
Commit: 108bcf0725a2f29cf8753d28b92be4ad72a72176
Author: Tapio Vierros <tap...@gm...>
Date: Wed Feb 2 13:39:54 2011 +0200
Buggy first version of multi-note mouse moving.
---
notegraphwidget.cc | 12 ++++--------
notelabel.cc | 8 ++++++--
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/notegraphwidget.cc b/notegraphwidget.cc
index f1ab117..6948f61 100644
--- a/notegraphwidget.cc
+++ b/notegraphwidget.cc
@@ -336,20 +336,16 @@ void NoteGraphWidget::mousePressEvent(QMouseEvent *event)
// Determine if it is drag or resize
if (hotSpot.x() < NoteLabel::resize_margin || hotSpot.x() > child->width() - NoteLabel::resize_margin) {
// Start a resize
- selectNote(child);
+ selectNote(child); // Resizing will deselect everything but one
m_selectedAction = RESIZE;
child->startResizing( (hotSpot.x() < NoteLabel::resize_margin) ? -1 : 1 );
} else {
// Ctrl allows selecting multiple notes for dragging
selectNote(child, !(event->modifiers() & Qt::ControlModifier));
- // FIXME: Drag disabled for multiple notes
- if (m_selectedNote && !m_selectedNote->nextSelected) {
- // Start a drag
- m_selectedAction = MOVE;
- child->startDragging(hotSpot);
-
- }
+ m_selectedAction = MOVE;
+ for (NoteLabel *n = m_selectedNote; n; n = n->nextSelected)
+ n->startDragging(hotSpot);
}
child->createPixmap(child->size());
diff --git a/notelabel.cc b/notelabel.cc
index 031a0a2..224b7f1 100644
--- a/notelabel.cc
+++ b/notelabel.cc
@@ -122,9 +122,13 @@ void NoteLabel::mouseMoveEvent(QMouseEvent *event)
} else if (!m_hotspot.isNull()) {
// Moving
QPoint newpos = pos() + event->pos() - m_hotspot;
- move(newpos);
+ int dx = newpos.x() - pos().x(), dy = newpos.y() - pos().y();
if (ngw) {
- move(x(), ngw->n2px(int(round(ngw->px2n(y() + height() / 2)))) - height() / 2);
+ NoteLabel *n = this;
+ // Pick first note in the selection chain
+ while (n->prevSelected) n = n->prevSelected;
+ for (n; n; n = n->nextSelected)
+ n->move(n->x() + dx, ngw->n2px(int(round(ngw->px2n(n->y() + dy + height() / 2)))) - height() / 2);
ngw->updateNotes((event->pos() - m_hotspot).x() < 0);
}
// Check if we need a new hotspot, because the note was constrained
|