diff layer/NoteLayer.cpp @ 70:bf306158803d

* Add stub for item-edit dialog (for editing properties of an item on double- click) -- doesn't actually do anything yet * Add code to invoke said non-working item-edit dialog on double-click in time-value, time-instants and note layers * Add overlay mode (no text, basic text, all text)
author Chris Cannam
date Thu, 30 Mar 2006 15:00:22 +0000
parents e9eac9368e29
children 45ba0b381c5d
line wrap: on
line diff
--- a/layer/NoteLayer.cpp	Thu Mar 30 13:18:11 2006 +0000
+++ b/layer/NoteLayer.cpp	Thu Mar 30 15:00:22 2006 +0000
@@ -23,6 +23,8 @@
 
 #include "model/NoteModel.h"
 
+#include "widgets/ItemEditDialog.h"
+
 #include "SpectrogramLayer.h" // for optional frequency alignment
 
 #include <QPainter>
@@ -626,6 +628,46 @@
 }
 
 void
+NoteLayer::editOpen(View *v, QMouseEvent *e)
+{
+    if (!m_model) return;
+
+    NoteModel::PointList points = getLocalPoints(v, e->x());
+    if (points.empty()) return;
+
+    NoteModel::Point note = *points.begin();
+
+    ItemEditDialog *dialog = new ItemEditDialog
+        (m_model->getSampleRate(),
+         ItemEditDialog::ShowTime |
+         ItemEditDialog::ShowDuration |
+         ItemEditDialog::ShowValue |
+         ItemEditDialog::ShowText);
+
+    dialog->setFrameTime(note.frame);
+    dialog->setValue(note.value);
+    dialog->setFrameDuration(note.duration);
+    dialog->setText(note.label);
+
+    if (dialog->exec() == QDialog::Accepted) {
+
+        NoteModel::Point newNote = note;
+        newNote.frame = dialog->getFrameTime();
+        newNote.value = dialog->getValue();
+        newNote.duration = dialog->getFrameDuration();
+        newNote.label = dialog->getText();
+        
+        NoteModel::EditCommand *command = new NoteModel::EditCommand
+            (m_model, tr("Edit Point"));
+        command->deletePoint(note);
+        command->addPoint(newNote);
+        command->finish();
+    }
+
+    delete dialog;
+}
+
+void
 NoteLayer::moveSelection(Selection s, size_t newStartFrame)
 {
     NoteModel::EditCommand *command =