summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Alpert <alan.alpert@nokia.com>2009-07-14 00:44:05 (GMT)
committerAlan Alpert <alan.alpert@nokia.com>2009-07-14 00:44:05 (GMT)
commit2718577ecf7a4a5c9fc619a46ee79a468044b4d7 (patch)
treee4b4ff2942562579d6ca356bf5d16d27dd593c5a
parent61084f0e8dcbd9b7ecaa250c74cd53ba042210e1 (diff)
downloadQt-2718577ecf7a4a5c9fc619a46ee79a468044b4d7.zip
Qt-2718577ecf7a4a5c9fc619a46ee79a468044b4d7.tar.gz
Qt-2718577ecf7a4a5c9fc619a46ee79a468044b4d7.tar.bz2
Move some keypad navigation code back out of QLineControl
-rw-r--r--src/gui/widgets/qlinecontrol.cpp46
-rw-r--r--src/gui/widgets/qlineedit.cpp52
2 files changed, 48 insertions, 50 deletions
diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp
index fc0a173..dd3c057 100644
--- a/src/gui/widgets/qlinecontrol.cpp
+++ b/src/gui/widgets/qlinecontrol.cpp
@@ -1212,44 +1212,6 @@ void QLineControl::timerEvent ( QTimerEvent * event )
bool QLineControl::processEvent(QEvent* ev)
{
-#ifdef QT_KEYPAD_NAVIGATION
- if (QApplication::keypadNavigationEnabled()) {
- if ((ev->type() == QEvent::KeyPress) || (ev->type() == QEvent::KeyRelease)) {
- QKeyEvent *ke = (QKeyEvent *)ev;
- if (ke->key() == Qt::Key_Back) {
- if (ke->isAutoRepeat()) {
- // Swallow it. We don't want back keys running amok.
- ke->accept();
- return true;
- }
- if ((ev->type() == QEvent::KeyRelease)
- && !isReadOnly()
- && deleteAllTimer) {
- killTimer(m_deleteAllTimer);
- m_deleteAllTimer = 0;
- backspace();
- ke->accept();
- return true;
- }
- }
- } else if (e->type() == QEvent::EnterEditFocus) {
- end(false);
- int cft = QApplication::cursorFlashTime();
- control->setCursorBlinkPeriod(cft/2);
- } else if (e->type() == QEvent::LeaveEditFocus) {
- d->setCursorVisible(false);//!!!
- control->setCursorBlinkPeriod(0);
- if (!m_emitingEditingFinished) {
- if (hasAcceptableInput() || fixup()) {
- m_emitingEditingFinished = true;
- emit editingFinished();
- m_emitingEditingFinished = false;
- }
- }
- }
- return;
- }
-#endif
switch(ev->type()){
#ifndef QT_NO_GRAPHICSVIEW
case QEvent::GraphicsSceneMouseMove:
@@ -1332,14 +1294,6 @@ void QLineControl::processMouseEvent(QMouseEvent* ev)
}
if (ev->button() == Qt::RightButton)
return;
-#ifdef QT_KEYPAD_NAVIGATION
- if (QApplication::keypadNavigationEnabled() && !hasEditFocus()) {
- setEditFocus(true);
- // Get the completion list to pop up.
- if (m_completer)
- m_completer->complete();
- }
-#endif
bool mark = ev->modifiers() & Qt::ShiftModifier;
int cursor = xToPos(ev->pos().x());
diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp
index 977d00c..b0c48b0 100644
--- a/src/gui/widgets/qlineedit.cpp
+++ b/src/gui/widgets/qlineedit.cpp
@@ -1361,7 +1361,45 @@ void QLineEdit::paste()
bool QLineEdit::event(QEvent * e)
{
Q_D(QLineEdit);
- if (e->type() == QEvent::Timer) {
+#ifdef QT_KEYPAD_NAVIGATION
+ if (QApplication::keypadNavigationEnabled()) {
+ if ((ev->type() == QEvent::KeyPress) || (ev->type() == QEvent::KeyRelease)) {
+ QKeyEvent *ke = (QKeyEvent *)ev;
+ if (ke->key() == Qt::Key_Back) {
+ if (ke->isAutoRepeat()) {
+ // Swallow it. We don't want back keys running amok.
+ ke->accept();
+ return true;
+ }
+ if ((ev->type() == QEvent::KeyRelease)
+ && !isReadOnly()
+ && deleteAllTimer) {
+ killTimer(m_deleteAllTimer);
+ m_deleteAllTimer = 0;
+ backspace();
+ ke->accept();
+ return true;
+ }
+ }
+ } else if (e->type() == QEvent::EnterEditFocus) {
+ end(false);
+ int cft = QApplication::cursorFlashTime();
+ control->setCursorBlinkPeriod(cft/2);
+ } else if (e->type() == QEvent::LeaveEditFocus) {
+ d->setCursorVisible(false);//!!!
+ control->setCursorBlinkPeriod(0);
+ if (!m_emitingEditingFinished) {
+ if (hasAcceptableInput() || fixup()) {
+ m_emitingEditingFinished = true;
+ emit editingFinished();
+ m_emitingEditingFinished = false;
+ }
+ }
+ }
+ return;
+ }
+#endif
+ if (e->type() == QEvent::Timer) {
// should be timerEvent, is here for binary compatibility
int timerId = ((QTimerEvent*)e)->timerId();
if (false) {
@@ -1442,9 +1480,7 @@ void QLineEdit::mouseMoveEvent(QMouseEvent * e)
d->drag();
} else
#endif
- {
d->control->moveCursor(d->xToPos(e->pos().x()), true);
- }
}
}
@@ -1463,10 +1499,18 @@ void QLineEdit::mouseReleaseEvent(QMouseEvent* e)
d->drag();
} else
#endif
- {
d->control->moveCursor(d->xToPos(e->pos().x()), true);
+ }
+#ifndef QT_NO_CLIPBOARD
+ if (QApplication::clipboard()->supportsSelection()) {
+ if (e->button() == Qt::LeftButton) {
+ d->control->copy(QClipboard::Selection);
+ } else if (!d->control->isReadOnly() && e->button() == Qt::MidButton) {
+ deselect();
+ insert(QApplication::clipboard()->text(QClipboard::Selection));
}
}
+#endif
}
/*! \reimp