|
From: Tapio V. <aa...@us...> - 2011-02-02 08:11:32
|
Module: editor
Branch: master
Commit: b022143ab8d9d1192e91b7e17db41cf144602018
Author: Tapio Vierros <tap...@gm...>
Date: Wed Feb 2 09:35:50 2011 +0200
Ctrl+A for select all.
---
notegraphwidget.cc | 34 ++++++++++++++++++++--------------
1 files changed, 20 insertions(+), 14 deletions(-)
diff --git a/notegraphwidget.cc b/notegraphwidget.cc
index eddefc5..e8ae7c1 100644
--- a/notegraphwidget.cc
+++ b/notegraphwidget.cc
@@ -523,44 +523,50 @@ void NoteGraphWidget::mouseMoveEvent(QMouseEvent *event)
void NoteGraphWidget::keyPressEvent(QKeyEvent *event)
{
- switch (event->key()) {
- case Qt::Key_Return: // Edit lyric
+ int k = event->key(), m = event->modifiers();
+
+ if (k == Qt::Key_A && (m & Qt::ControlModifier)) { // Select all
+ selectNote(NULL); // Clear previous
+ for (int i = m_notes.size()-1; i >= 0; --i) // Traverse in reverse order to get the first note first
+ selectNote(m_notes[i], false);
+
+ } else if (k == Qt::Key_Return) { // Edit lyric
editLyric(m_selectedNote);
- break;
- case Qt::Key_Left: // Select note on the left
+
+ } else if (k == Qt::Key_Left) { // Select note on the left
if (m_selectedNote && m_notes.size() > 1 && m_selectedNote != m_notes.front()) {
for (NoteLabels::iterator it = m_notes.begin(); it != m_notes.end(); ++it) {
if (m_selectedNote == *it) { selectNote(*(--it)); break; }
}
}
- break;
- case Qt::Key_Right: // Select note on the right
+
+ } else if (k == Qt::Key_Right) { // Select note on the right
if (m_selectedNote && m_notes.size() > 1 && m_selectedNote != m_notes.back()) {
for (NoteLabels::iterator it = m_notes.begin(); it != m_notes.end(); ++it) {
if (m_selectedNote == *it) { selectNote(*(++it)); break; }
}
}
- break;
- case Qt::Key_Up: // Move note up
+
+ } else if (k == Qt::Key_Up) { // Move note up
if (m_selectedNote) {
Operation op("MOVE");
op << getNoteLabelId(m_selectedNote);
op << m_selectedNote->x() << int(round(px2n(m_selectedNote->y() + m_noteHalfHeight))) + 1;
doOperation(op);
}
- break;
- case Qt::Key_Down: // Move note down
+
+ } else if (k == Qt::Key_Down) { // Move note down
if (m_selectedNote) {
Operation op("MOVE");
op << getNoteLabelId(m_selectedNote);
op << m_selectedNote->x() << int(round(px2n(m_selectedNote->y() + m_noteHalfHeight))) - 1;
doOperation(op);
}
- break;
- case Qt::Key_Delete: // Delete selected note
+
+ } else if (k == Qt::Key_Delete) { // Delete selected note
del(m_selectedNote);
- break;
- default:
+
+ } else {
QWidget::keyPressEvent(event);
}
}
|