|
From: Tapio V. <aa...@us...> - 2011-01-27 10:23:41
|
Module: editor
Branch: master
Commit: 3595ea7bc6e8c946aad0ced466560198f75e33db
Author: Tapio Vierros <tap...@gm...>
Date: Thu Jan 27 12:20:08 2011 +0200
Split notes with middle click.
---
notegraphwidget.cc | 13 ++++++++-----
notegraphwidget.hh | 2 +-
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/notegraphwidget.cc b/notegraphwidget.cc
index 46da372..650ef15 100644
--- a/notegraphwidget.cc
+++ b/notegraphwidget.cc
@@ -320,6 +320,10 @@ void NoteGraphWidget::mousePressEvent(QMouseEvent *event)
}
child->createPixmap(child->size());
+ // Middle Click
+ } else if (event->button() == Qt::MiddleButton) {
+ split(child, float(hotSpot.x()) / child->width());
+
// Right Click
} else if (event->button() == Qt::RightButton) {
event->ignore();
@@ -370,19 +374,18 @@ void NoteGraphWidget::mouseDoubleClickEvent(QMouseEvent *event)
editLyric(child);
}
-void NoteGraphWidget::split(NoteLabel *note)
+void NoteGraphWidget::split(NoteLabel *note, float ratio)
{
if (!note) return;
if (m_selectedNote == note)
m_selectedNote = NULL;
- // Cut the text in half
- float relRatio = 0.5; //float(hotSpot.x()) / note->width();
- int cutpos = int(std::ceil(note->lyric().length() * relRatio));
+ // Cut the text
+ int cutpos = int(std::ceil(note->lyric().length() * ratio));
QString firstst = note->lyric().left(cutpos);
QString secondst = note->lyric().right(note->lyric().length() - cutpos);
- int w1 = relRatio * note->width();
+ int w1 = ratio * note->width();
// Create operations for adding the new labels and deleting the old one
int id = getNoteLabelId(note);
diff --git a/notegraphwidget.hh b/notegraphwidget.hh
index efa312e..eedaf14 100644
--- a/notegraphwidget.hh
+++ b/notegraphwidget.hh
@@ -44,7 +44,7 @@ public:
void selectNote(NoteLabel *note);
NoteLabel* selectedNote() const { return m_selectedNote; }
- void split(NoteLabel *note);
+ void split(NoteLabel *note, float ratio = 0.5f);
void del(NoteLabel *note);
void editLyric(NoteLabel *note);
void setFloating(NoteLabel *note, bool state);
|