diff src/MainWindow.cpp @ 296:d4530fab80bd

very simple, probably too simple implementation of select by move note
author matthiasm
date Thu, 12 Jun 2014 09:54:05 +0100
parents 59dff7e51db0
children a7792e252f92 2023d5dd6614
line wrap: on
line diff
--- a/src/MainWindow.cpp	Wed Jun 11 21:43:38 2014 +0100
+++ b/src/MainWindow.cpp	Thu Jun 12 09:54:05 2014 +0100
@@ -101,7 +101,8 @@
     m_rwdAction(0),
     m_intelligentActionOn(true), //GF: !!! temporary
     m_activityLog(new ActivityLog()),
-    m_keyReference(new KeyReference())
+    m_keyReference(new KeyReference()),
+    m_selectionAnchor(0)
 {
     setWindowTitle(QApplication::applicationName());
 
@@ -1088,41 +1089,41 @@
 MainWindow::moveOneNoteRight()
 {
     // cerr << "MainWindow::moveOneNoteRight" << endl;
-    moveByOneNote(true);
+    moveByOneNote(true, false);
 }
 
 void
 MainWindow::moveOneNoteLeft()
 {
     // cerr << "MainWindow::moveOneNoteLeft" << endl;
-    moveByOneNote(false);
+    moveByOneNote(false, false);
 }
 
 void
 MainWindow::selectOneNoteRight()
 {
-    int left = m_viewManager->getPlaybackFrame();
-    moveByOneNote(false);
-    int right = m_viewManager->getPlaybackFrame();    
+    moveByOneNote(true, true);
 }
 
 void
 MainWindow::selectOneNoteLeft()
 {
-    int right = m_viewManager->getPlaybackFrame();
-    moveByOneNote(false);
-    int left = m_viewManager->getPlaybackFrame();
+    moveByOneNote(false, true);
 }
 
 
 void
-MainWindow::moveByOneNote(bool right)
+MainWindow::moveByOneNote(bool right, bool doSelect)
 {
     // cerr << "MainWindow::moveByOneNote" << endl;
     int frame = m_viewManager->getPlaybackFrame();
     
     Pane *p = m_analyser->getPane();
 
+    if (!doSelect) {
+        m_selectionAnchor = frame;
+    }
+
     Layer *layer = m_analyser->getLayer(Analyser::Notes);
     if (!layer) return;
 
@@ -1156,6 +1157,15 @@
     }
     frame = *i2;
     m_viewManager->setPlaybackFrame(frame);
+    if (doSelect) {
+        Selection sel;
+        if (frame > m_selectionAnchor) {
+            sel = Selection(m_selectionAnchor, frame);
+        } else {
+            sel = Selection(frame, m_selectionAnchor);
+        }
+        m_viewManager->setSelection(sel);
+    }
 }
 
 void