void ScrollLine::mouseReleaseEvent( QMouseEvent *event ) { mClicked = false; GlobalConfigWidget::setClipboard( selectedText() ); setCursorPosition( cursorPositionAt( event->pos() ) ); QLineEdit::mouseReleaseEvent( event ); }
void ScrollLine::mousePressEvent( QMouseEvent *event ) { mClicked = true; QString dragFileName( mpDragInfo->filePath() ); if( dragFileName.isEmpty() ) { setCursorPosition( cursorPositionAt( event->pos() ) ); QLineEdit::mousePressEvent( event ); } else { QDrag *drag = mpDragInfo->createDrag(); drag->exec( Qt::CopyAction, Qt::CopyAction ); mClicked = false; } }
void LineEditWidget::dropEvent(QDropEvent *event) { if (m_selectionStart >= 0) { const int selectionEnd(m_selectionStart + event->mimeData()->text().length()); int dropPosition(cursorPositionAt(event->pos())); if (dropPosition < m_selectionStart || dropPosition > selectionEnd) { if (dropPosition > selectionEnd) { dropPosition -= event->mimeData()->text().length(); } setSelection(m_selectionStart, event->mimeData()->text().length()); del(); setCursorPosition(dropPosition); insert(event->mimeData()->text()); } } else if (m_dropMode == ReplaceDropMode || m_dropMode == ReplaceAndNotifyDropMode) { selectAll(); del(); insert(event->mimeData()->text()); if (m_dropMode == ReplaceAndNotifyDropMode) { emit textDropped(event->mimeData()->text()); } } else { QLineEdit::dropEvent(event); } }
void QcNumberBox::mouseDoubleClickEvent ( QMouseEvent * event ) { Q_UNUSED( event ); setCursorPosition( cursorPositionAt( event->pos() ) ); setLocked( false ); }
bool PhTimeCodeEdit::eventFilter(QObject *, QEvent *event) { switch (event->type()) { case QEvent::KeyPress: { QKeyEvent *keyEvent = (QKeyEvent*)event; switch (keyEvent->key()) { case Qt::Key_0: case Qt::Key_1: case Qt::Key_2: case Qt::Key_3: case Qt::Key_4: case Qt::Key_5: case Qt::Key_6: case Qt::Key_7: case Qt::Key_8: case Qt::Key_9: _addedNumbers.push(keyEvent->key()); compute(true); return true; case Qt::Key_Backspace: if(_addedNumbers.length()) { _addedNumbers.pop(); compute(false); } return true; case Qt::Key_Escape: case Qt::Key_Enter: case Qt::Key_Return: return false; default: return true; } } case QEvent::MouseButtonPress: QApplication::setOverrideCursor(Qt::SizeVerCursor); _mousePressed = true; _mousePressedLocation = static_cast<QMouseEvent *>(event)->pos(); _selectedIndex = (cursorPositionAt(_mousePressedLocation) / 3) * 3; return true; case QEvent::MouseButtonRelease: QApplication::setOverrideCursor(Qt::ArrowCursor); _mousePressed = false; return true; case QEvent::MouseMove: { if(_mousePressed) { int y = static_cast<QMouseEvent *>(event)->pos().y(); PhFrame currentFrame = PhTimeCode::frameFromString(this->text(), _tcType); PhFrame fps = PhTimeCode::getFps(_tcType); PhFrame offset = 0; switch(_selectedIndex) { case 0: offset = fps * 60 * 60; break; case 3: offset = fps * 60; break; case 6: offset = fps; break; case 9: offset = 1; break; } if(_mousePressedLocation.y() > y) currentFrame += offset; else currentFrame -= offset; _mousePressedLocation.setY(y); this->setText(PhTimeCode::stringFromFrame(currentFrame, _tcType)); if(text().contains("-")) setSelection(_selectedIndex + 1, 2); else setSelection(_selectedIndex, 2); return true; } return false; } default: return false; } }
void ScrollLine::mouseDoubleClickEvent( QMouseEvent *event ) { mClicked = true; setCursorPosition( cursorPositionAt( event->pos() ) ); QLineEdit::mouseDoubleClickEvent( event ); }