|
From: Tapio V. <aa...@us...> - 2011-02-02 14:30:56
|
Module: editor
Branch: master
Commit: 7f5566f975e9d2c61c5a2b5636c64f8bf8a2c12d
Author: Tapio Vierros <tap...@gm...>
Date: Wed Feb 2 16:23:37 2011 +0200
Fix and greatly simplify selectNextSyllable and selectNextSentenceStart.
---
notegraphwidget.cc | 30 +++++++++++-------------------
notegraphwidget.hh | 2 +-
2 files changed, 12 insertions(+), 20 deletions(-)
diff --git a/notegraphwidget.cc b/notegraphwidget.cc
index c4bf321..6a35ee2 100644
--- a/notegraphwidget.cc
+++ b/notegraphwidget.cc
@@ -281,30 +281,22 @@ void NoteGraphWidget::timeSentence()
selectNextSentenceStart();
}
-void NoteGraphWidget::selectNextSyllable()
-{
- bool currentFound = (m_selectedNote ? false : true);
- if (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) currentFound = true;
- else if (currentFound && (*it)->x() > m_seekHandle.curx()) {
- selectNote(*it); break;
- }
- }
- }
+void NoteGraphWidget::selectNextSyllable(bool backwards)
+{
+ int i = getNoteLabelId(m_selectedNote);
+ if (!backwards && i < m_notes.size()-1)
+ selectNote(m_notes[i+1]);
+ else if (backwards && i > 1)
+ selectNote(m_notes[i-1]);
}
void NoteGraphWidget::selectNextSentenceStart()
{
- bool currentFound = (m_selectedNote ? false : true);
- NoteLabel *prev = NULL;
- if (m_notes.size() > 1 && m_selectedNote != m_notes.back()) {
- for (NoteLabels::iterator it = m_notes.begin(); it != m_notes.end(); prev = *it, ++it) {
- if (m_selectedNote == *it) currentFound = true;
- else if (currentFound && (*it)->x() > m_seekHandle.curx()
- && prev && prev->note().lineBreak) {
- selectNote(*it); break;
- }
+ // Start looking for the sentance start from the next NoteLabel
+ for (int i = getNoteLabelId(m_selectedNote) + 1; i < m_notes.size(); ++i) {
+ if (m_notes[i]->note().lineBreak) {
+ selectNote(m_notes[i]);
+ break;
}
}
}
diff --git a/notegraphwidget.hh b/notegraphwidget.hh
index 8837198..5b65cfe 100644
--- a/notegraphwidget.hh
+++ b/notegraphwidget.hh
@@ -68,7 +68,7 @@ public:
public slots:
void timeSyllable();
void timeSentence();
- void selectNextSyllable();
+ void selectNextSyllable(bool backwards = false);
void selectNextSentenceStart();
signals:
|