changeset 757:2cd6d2d17437 tony_integration

Merge
author Chris Cannam
date Wed, 02 Apr 2014 08:53:32 +0100
parents 9cfcb2924ee3 (diff) efbb6b8f943b (current diff)
children 410816717c2c
files
diffstat 6 files changed, 133 insertions(+), 126 deletions(-) [+]
line wrap: on
line diff
--- a/layer/FlexiNoteLayer.cpp	Mon Mar 31 13:00:42 2014 +0100
+++ b/layer/FlexiNoteLayer.cpp	Wed Apr 02 08:53:32 2014 +0100
@@ -1043,7 +1043,7 @@
     m_originalPoint = FlexiNote(m_editingPoint);
     
     if (m_editMode == RightBoundary) {
-        m_dragPointX =   v->getXForFrame(m_editingPoint.frame + m_editingPoint.duration);
+        m_dragPointX = v->getXForFrame(m_editingPoint.frame + m_editingPoint.duration);
     } else {
         m_dragPointX = v->getXForFrame(m_editingPoint.frame);
     }
@@ -1079,7 +1079,7 @@
             break;
         }
     }
-    std::cerr << "note frame: " << onset << ", left boundary: " << m_greatestLeftNeighbourFrame << ", right boundary: " << m_smallestRightNeighbourFrame << std::endl;
+    std::cerr << "editStart: mode is " << m_editMode << ", note frame: " << onset << ", left boundary: " << m_greatestLeftNeighbourFrame << ", right boundary: " << m_smallestRightNeighbourFrame << std::endl;
 }
 
 void
@@ -1216,41 +1216,50 @@
 
     long frame = v->getFrameForX(e->x());
 
-    splitNotesAt(v, frame);
+    splitNotesAt(v, frame, e);
 }
 
 void
 FlexiNoteLayer::splitNotesAt(View *v, int frame)
 {
+    splitNotesAt(v, frame, 0);
+}
+
+void
+FlexiNoteLayer::splitNotesAt(View *v, int frame, QMouseEvent *e)
+{
     FlexiNoteModel::PointList onPoints = m_model->getPoints(frame);
     if (onPoints.empty()) return;
     
     FlexiNote note(*onPoints.begin());
 
-    int gap = 0; // MM: I prefer a gap of 0, but we can decide later
-    
-    FlexiNote newNote1(note.frame, note.value, 
-                       frame - note.frame - gap, 
-                       note.level, note.label);
-    
-    FlexiNote newNote2(frame, note.value, 
-                       note.duration - newNote1.duration, 
-                       note.level, note.label);
-
     FlexiNoteModel::EditCommand *command = new FlexiNoteModel::EditCommand
         (m_model, tr("Edit Point"));
     command->deletePoint(note);
+
+    if (!e || !(e->modifiers() & Qt::ShiftModifier)) {
+
+        int gap = 0; // MM: I prefer a gap of 0, but we can decide later
+    
+        FlexiNote newNote1(note.frame, note.value, 
+                           frame - note.frame - gap, 
+                           note.level, note.label);
+    
+        FlexiNote newNote2(frame, note.value, 
+                           note.duration - newNote1.duration, 
+                           note.level, note.label);
                        
-    if (m_intelligentActions) {
-        if (updateNoteValue(v, newNote1)) {
+        if (m_intelligentActions) {
+            if (updateNoteValue(v, newNote1)) {
+                command->addPoint(newNote1);
+            }
+            if (updateNoteValue(v, newNote2)) {
+                command->addPoint(newNote2);
+            }
+        } else {
             command->addPoint(newNote1);
-        }
-        if (updateNoteValue(v, newNote2)) {
             command->addPoint(newNote2);
         }
-    } else {
-        command->addPoint(newNote1);
-        command->addPoint(newNote2);
     }
 
     finish(command);
--- a/layer/FlexiNoteLayer.h	Mon Mar 31 13:00:42 2014 +0100
+++ b/layer/FlexiNoteLayer.h	Wed Apr 02 08:53:32 2014 +0100
@@ -175,6 +175,7 @@
     void getRelativeMousePosition(View *v, FlexiNoteModel::Point &note, int x, int y, bool &closeToLeft, bool &closeToRight, bool &closeToTop, bool &closeToBottom) const;
     SparseTimeValueModel *getAssociatedPitchModel(View *v) const;
     bool updateNoteValue(View *v, FlexiNoteModel::Point &note) const;
+    void splitNotesAt(View *v, int frame, QMouseEvent *e);
 
     FlexiNoteModel *m_model;
     bool m_editing;
--- a/view/Pane.cpp	Mon Mar 31 13:00:42 2014 +0100
+++ b/view/Pane.cpp	Wed Apr 02 08:53:32 2014 +0100
@@ -344,10 +344,10 @@
     }
 
     if (layer == getSelectedLayer() &&
-    !shouldIlluminateLocalSelection(discard, b0, b1)) {
-
-    pos = m_identifyPoint;
-    return m_identifyFeatures;
+        !shouldIlluminateLocalSelection(discard, b0, b1)) {
+
+        pos = m_identifyPoint;
+        return m_identifyFeatures;
     }
 
     return false;
@@ -364,17 +364,17 @@
         !m_manager->getSelections().empty() &&
         !selectionIsBeingEdited()) {
 
-    Selection s(getSelectionAt(m_identifyPoint.x(),
-                   closeToLeft, closeToRight));
-
-    if (!s.isEmpty()) {
-        if (getSelectedLayer() && getSelectedLayer()->isLayerEditable()) {
-        
-        pos = m_identifyPoint;
-        return true;
+        Selection s(getSelectionAt(m_identifyPoint.x(),
+                                   closeToLeft, closeToRight));
+
+        if (!s.isEmpty()) {
+            if (getSelectedLayer() && getSelectedLayer()->isLayerEditable()) {
+            
+                pos = m_identifyPoint;
+                return true;
+            }
         }
     }
-    }
 
     return false;
 }
@@ -1233,47 +1233,18 @@
                         tr("Double-click middle button to relocate with any tool"));
     kr.registerShortcut(tr("Menu"), tr("Right"),
                         tr("Show pane context menu"));
-    
-    kr.setCategory(tr("Navigate Tool Mouse Actions"));
-    
-    kr.registerShortcut(tr("Navigate"), tr("Left"), 
-                        tr("Click left button and drag to move around"));
-    kr.registerShortcut(tr("Zoom to Area"), tr("Shift+Left"), 
-                        tr("Shift-click left button and drag to zoom to a rectangular area"));
-    kr.registerShortcut(tr("Relocate"), tr("Double-Click Left"), 
-                        tr("Double-click left button to jump to clicked location"));
-    kr.registerShortcut(tr("Edit"), tr("Double-Click Left"), 
-                        tr("Double-click left button on an item to edit it"));
-        
-    kr.setCategory(tr("Select Tool Mouse Actions"));
-    kr.registerShortcut(tr("Select"), tr("Left"), 
-                        tr("Click left button and drag to select region; drag region edge to resize"));
-    kr.registerShortcut(tr("Multi Select"), tr("Ctrl+Left"), 
-#ifdef Q_OS_MAC
-                        tr("Cmd-click left button and drag to select an additional region"));
-#else
-                        tr("Ctrl-click left button and drag to select an additional region"));
-#endif
-    kr.registerShortcut(tr("Fine Select"), tr("Shift+Left"), 
-                        tr("Shift-click left button and drag to select without snapping to items or grid"));
-    
-    kr.setCategory(tr("Edit Tool Mouse Actions"));
-    kr.registerShortcut(tr("Move"), tr("Left"), 
-                        tr("Click left button on an item or selected region and drag to move"));
-    kr.registerShortcut(tr("Edit"), tr("Double-Click Left"), 
-                        tr("Double-click left button on an item to edit it"));
-    
-    kr.setCategory(tr("Draw Tool Mouse Actions"));
-    kr.registerShortcut(tr("Draw"), tr("Left"), 
-                        tr("Click left button and drag to create new item"));
-
-    kr.setCategory(tr("Measure Tool Mouse Actions"));
-    kr.registerShortcut(tr("Measure Area"), tr("Left"), 
-                        tr("Click left button and drag to measure a rectangular area"));
-    kr.registerShortcut(tr("Measure Item"), tr("Double-Click Left"), 
-                        tr("Click left button and drag to measure extents of an item or shape"));
-    kr.registerShortcut(tr("Zoom to Area"), tr("Shift+Left"), 
-                        tr("Shift-click left button and drag to zoom to a rectangular area"));
+}
+
+Layer *
+Pane::getTopFlexiNoteLayer()
+{
+    for (int i = int(m_layers.size()) - 1; i >= 0; --i) {
+        if (LayerFactory::getInstance()->getLayerType(m_layers[i]) ==
+            LayerFactory::FlexiNotes) {
+            return m_layers[i];
+        }
+    }
+    return 0;
 }
 
 void
@@ -1387,8 +1358,8 @@
     } else if (mode == ViewManager::NoteEditMode) {
 
         std::cerr << "mouse pressed in note edit mode" << std::endl;
-        Layer *layer = getSelectedLayer();
-        if (layer && layer->isLayerEditable()) {
+        Layer *layer = getTopFlexiNoteLayer();
+        if (layer) {
             layer->splitStart(this, e); 
         }
 
@@ -1502,11 +1473,22 @@
     } else if (mode == ViewManager::NoteEditMode) {
     
         //GF: handle mouse release for NoteEditMode (note: works but will need to re-think this a bit later)
-        Layer *layer = getSelectedLayer();
-        if (layer && layer->isLayerEditable()) {
+        Layer *layer = getTopFlexiNoteLayer();
+
+        if (layer) {
             layer->splitEnd(this, e);
-            update(); }
-
+            update();
+
+            if (m_editing) {
+                if (!editSelectionEnd(e)) {
+                    layer->editEnd(this, e);
+                    update();
+                }
+            }
+        } 
+
+    } else if (mode == ViewManager::EditMode) {
+        
         if (m_editing) {
             if (!editSelectionEnd(e)) {
                 Layer *layer = getSelectedLayer();
@@ -1517,19 +1499,6 @@
             }
         } 
 
-    } else if (mode == ViewManager::EditMode) {
-        
-        // GF: edited this previously, but restored to original state
-        if (m_editing) {
-            if (!editSelectionEnd(e)) {
-                Layer *layer = getSelectedLayer();
-                if (layer && layer->isLayerEditable()) {
-                    layer->editEnd(this, e);
-                    update();
-                }
-            }
-        } 
-
     } else if (mode == ViewManager::MeasureMode) {
 
         Layer *layer = getTopLayer();
@@ -1580,10 +1549,12 @@
     
         // GF: handle mouse move for context sensitive cursor switching in NoteEditMode.
         // GF: Propagate the event to FlexiNoteLayer. I somehow feel it's best handeled there rather than here, but perhaps not if this will be needed elsewhere too.
-        if (mode == ViewManager::NoteEditMode && LayerFactory::getInstance()->getLayerType(getTopLayer()) == LayerFactory::FlexiNotes) {
-        
-            dynamic_cast<FlexiNoteLayer *>(getTopLayer())->mouseMoveEvent(this, e);
-
+        if (mode == ViewManager::NoteEditMode) {
+            FlexiNoteLayer *layer = qobject_cast<FlexiNoteLayer *>(getTopFlexiNoteLayer());
+            if (layer) {
+                layer->mouseMoveEvent(this, e); //!!! ew
+                return;
+            }
         }   
     
         if (mode == ViewManager::SelectMode && hasTopLayerTimeXAxis()) {
@@ -1692,8 +1663,8 @@
                                        e->modifiers());
 
                 if (!editSelectionStart(&clickEvent)) {
-                    Layer *layer = getSelectedLayer();
-                    if (layer && layer->isLayerEditable()) {
+                    Layer *layer = getTopFlexiNoteLayer();
+                    if (layer) {
                         std::cerr << "calling edit start" << std::endl;
                         layer->editStart(this, &clickEvent);
                     }
--- a/view/Pane.h	Mon Mar 31 13:00:42 2014 +0100
+++ b/view/Pane.h	Wed Apr 02 08:53:32 2014 +0100
@@ -136,6 +136,8 @@
     void updateContextHelp(const QPoint *pos);
     void edgeScrollMaybe(int x);
 
+    Layer *getTopFlexiNoteLayer();
+
     bool m_identifyFeatures;
     QPoint m_identifyPoint;
     QPoint m_clickPos;
--- a/widgets/ActivityLog.cpp	Mon Mar 31 13:00:42 2014 +0100
+++ b/widgets/ActivityLog.cpp	Wed Apr 02 08:53:32 2014 +0100
@@ -25,6 +25,13 @@
 
 #include <iostream>
 
+#include "base/Debug.h"
+
+using std::cerr;
+using std::endl;
+
+#define PRINT_ACTIVITY 1
+
 ActivityLog::ActivityLog() : QDialog()
 {
     setWindowTitle(tr("Activity Log"));
@@ -53,9 +60,16 @@
 ActivityLog::activityHappened(QString name)
 {
     name = name.replace("&", "");
-//    SVDEBUG << "ActivityLog::activityHappened(" << name << ")" << endl;
+
+#ifdef PRINT_ACTIVITY
+    cerr << "ActivityLog: " << name;
     if (name == m_prevName) {
-//        cerr << "(ignoring duplicate)" << endl;
+        cerr << " (duplicate)";
+    }
+    cerr << endl;
+#endif
+
+    if (name == m_prevName) {
         return;
     }
     m_prevName = name;
--- a/widgets/CommandHistory.cpp	Mon Mar 31 13:00:42 2014 +0100
+++ b/widgets/CommandHistory.cpp	Wed Apr 02 08:53:32 2014 +0100
@@ -37,7 +37,7 @@
 
 #include <typeinfo>
 
-//#define DEBUG_COMMAND_HISTORY 1
+#define DEBUG_COMMAND_HISTORY 1
 
 CommandHistory *CommandHistory::m_instance = 0;
 
@@ -101,7 +101,7 @@
 CommandHistory::clear()
 {
 #ifdef DEBUG_COMMAND_HISTORY
-    SVDEBUG << "CommandHistory::clear()" << endl;
+    cerr << "CommandHistory::clear()" << endl;
 #endif
     closeBundle();
     m_savedAt = -1;
@@ -143,7 +143,7 @@
     if (!command) return;
 
 #ifdef DEBUG_COMMAND_HISTORY
-    SVDEBUG << "CommandHistory::addCommand: " << command->getName() << " of type " << typeid(*command).name() << " at " << command << ": execute = " << execute << ", bundle = " << bundle << " (m_currentCompound = " << m_currentCompound << ", m_currentBundle = " << m_currentBundle << ")" << endl;
+    cerr << "CommandHistory::addCommand: " << command->getName() << " of type " << typeid(*command).name() << " at " << command << ": execute = " << execute << ", bundle = " << bundle << " (m_currentCompound = " << m_currentCompound << ", m_currentBundle = " << m_currentBundle << ")" << endl;
 #endif
 
     if (m_currentCompound) {
@@ -160,7 +160,7 @@
 
 #ifdef DEBUG_COMMAND_HISTORY
     if (!m_redoStack.empty()) {
-        SVDEBUG << "CommandHistory::clearing redo stack" << endl;
+        cerr << "CommandHistory::clearing redo stack" << endl;
     }
 #endif
 
@@ -192,8 +192,8 @@
     if (m_currentBundle) {
 	if (!command || (command->getName() != m_currentBundleName)) {
 #ifdef DEBUG_COMMAND_HISTORY
-            SVDEBUG << "CommandHistory::addToBundle: "
-                      << command->getName()                      << ": closing current bundle" << endl;
+            cerr << "CommandHistory::addToBundle: " << command->getName()
+                 << ": closing current bundle" << endl;
 #endif
 	    closeBundle();
 	}
@@ -204,8 +204,8 @@
     if (!m_currentBundle) {
 
 #ifdef DEBUG_COMMAND_HISTORY
-        SVDEBUG << "CommandHistory::addToBundle: "
-                  << command->getName()                  << ": creating new bundle" << endl;
+        cerr << "CommandHistory::addToBundle: " << command->getName()
+             << ": creating new bundle" << endl;
 #endif
 
 	// need to addCommand before setting m_currentBundle, as addCommand
@@ -219,8 +219,8 @@
     }
 
 #ifdef DEBUG_COMMAND_HISTORY
-    SVDEBUG << "CommandHistory::addToBundle: "
-              << command->getName()              << ": adding to bundle" << endl;
+    cerr << "CommandHistory::addToBundle: " << command->getName()
+         << ": adding to bundle" << endl;
 #endif
 
     if (execute) command->execute();
@@ -242,11 +242,12 @@
 void
 CommandHistory::closeBundle()
 {
+    if (m_currentBundle) {
 #ifdef DEBUG_COMMAND_HISTORY
-    SVDEBUG << "CommandHistory::closeBundle" << endl;
+        cerr << "CommandHistory::closeBundle" << endl;
 #endif
-
-    if (m_currentBundle) emit activity(m_currentBundle->getName());
+        emit activity(m_currentBundle->getName());
+    }
     m_currentBundle = 0;
     m_currentBundleName = "";
 }
@@ -255,7 +256,7 @@
 CommandHistory::bundleTimerTimeout()
 {
 #ifdef DEBUG_COMMAND_HISTORY
-    SVDEBUG << "CommandHistory::bundleTimerTimeout: bundle is " << m_currentBundle << endl;
+    cerr << "CommandHistory::bundleTimerTimeout: bundle is " << m_currentBundle << endl;
 #endif
 
     closeBundle();
@@ -264,14 +265,15 @@
 void
 CommandHistory::addToCompound(Command *command, bool execute)
 {
-#ifdef DEBUG_COMMAND_HISTORY
-    SVDEBUG << "CommandHistory::addToCompound: " << command->getName() << endl;
-#endif
     if (!m_currentCompound) {
-	SVDEBUG << "CommandHistory::addToCompound: ERROR: no compound operation in progress!" << endl;
+	cerr << "CommandHistory::addToCompound: ERROR: no compound operation in progress!" << endl;
         return;
     }
 
+#ifdef DEBUG_COMMAND_HISTORY
+    cerr << "CommandHistory::addToCompound[" << m_currentCompound->getName() << "]: " << command->getName() << " (exec: " << execute << ")" << endl;
+#endif
+
     if (execute) command->execute();
     m_currentCompound->addCommand(command);
 }
@@ -280,13 +282,17 @@
 CommandHistory::startCompoundOperation(QString name, bool execute)
 {
     if (m_currentCompound) {
-	SVDEBUG << "CommandHistory::startCompoundOperation: ERROR: compound operation already in progress!" << endl;
+	cerr << "CommandHistory::startCompoundOperation: ERROR: compound operation already in progress!" << endl;
 	cerr << "(name is " << m_currentCompound->getName() << ")" << endl;
         return;
     }
  
+#ifdef DEBUG_COMMAND_HISTORY
+    cerr << "CommandHistory::startCompoundOperation: " << name << " (exec: " << execute << ")" << endl;
+#endif
+   
     closeBundle();
-   
+
     m_currentCompound = new MacroCommand(name);
     m_executeCompound = execute;
 }
@@ -295,9 +301,13 @@
 CommandHistory::endCompoundOperation()
 {
     if (!m_currentCompound) {
-	SVDEBUG << "CommandHistory::endCompoundOperation: ERROR: no compound operation in progress!" << endl;
+	cerr << "CommandHistory::endCompoundOperation: ERROR: no compound operation in progress!" << endl;
         return;
     }
+ 
+#ifdef DEBUG_COMMAND_HISTORY
+    cerr << "CommandHistory::endCompoundOperation: " << m_currentCompound->getName() << endl;
+#endif
 
     MacroCommand *toAdd = m_currentCompound;
     m_currentCompound = 0;
@@ -329,7 +339,7 @@
     if (m_undoStack.empty()) return;
 
 #ifdef DEBUG_COMMAND_HISTORY
-    SVDEBUG << "CommandHistory::undo()" << endl;
+    cerr << "CommandHistory::undo()" << endl;
 #endif
 
     closeBundle();
@@ -355,7 +365,7 @@
     if (m_redoStack.empty()) return;
 
 #ifdef DEBUG_COMMAND_HISTORY
-    SVDEBUG << "CommandHistory::redo()" << endl;
+    cerr << "CommandHistory::redo()" << endl;
 #endif
 
     closeBundle();
@@ -436,7 +446,7 @@
 	for (i = 0; i < limit; ++i) {
 #ifdef DEBUG_COMMAND_HISTORY
 	    Command *command = stack.top();
-	    SVDEBUG << "CommandHistory::clipStack: Saving recent command: " << command->getName() << " at " << command << endl;
+	    cerr << "CommandHistory::clipStack: Saving recent command: " << command->getName() << " at " << command << endl;
 #endif
 	    tempStack.push(stack.top());
 	    stack.pop();
@@ -458,7 +468,7 @@
 	Command *command = stack.top();
 	// Not safe to call getName() on a command about to be deleted
 #ifdef DEBUG_COMMAND_HISTORY
-	SVDEBUG << "CommandHistory::clearStack: About to delete command " << command << endl;
+	cerr << "CommandHistory::clearStack: About to delete command " << command << endl;
 #endif
 	delete command;
 	stack.pop();