+void TimecodeDisplay::slotCursorPositionChanged(int oldPos, int newPos)
+{
+ if (!lineEdit()->hasFocus()) return;
+ lineEdit()->blockSignals(true);
+ QString text = lineEdit()->text();
+
+ if (newPos < text.size() && !text.at(newPos).isDigit()) {
+ // char at newPos is a separator (':' or ';')
+
+ // make it possible move the cursor backwards at separators
+ if (newPos == oldPos - 1)
+ lineEdit()->setSelection(newPos, -1);
+ else
+ lineEdit()->setSelection(newPos + 2, -1);
+ } else if (newPos < text.size()) {
+ lineEdit()->setSelection(newPos + 1, -1);
+ } else {
+ lineEdit()->setSelection(newPos, -1);
+ }
+
+ lineEdit()->blockSignals(false);
+}
+
+void TimecodeDisplay::slotEditingFinished()
+{
+ clearFocus();
+ lineEdit()->deselect();
+ emit editingFinished();
+}
+