equal
deleted
inserted
replaced
136 |
136 |
137 \sa insert() |
137 \sa insert() |
138 */ |
138 */ |
139 void QLineControl::paste() |
139 void QLineControl::paste() |
140 { |
140 { |
141 insert(QApplication::clipboard()->text(QClipboard::Clipboard)); |
141 QString clip = QApplication::clipboard()->text(QClipboard::Clipboard); |
|
142 if (!clip.isEmpty() || hasSelectedText()) { |
|
143 separate(); //make it a separate undo/redo command |
|
144 insert(clip); |
|
145 separate(); |
|
146 } |
142 } |
147 } |
143 |
148 |
144 #endif // !QT_NO_CLIPBOARD |
149 #endif // !QT_NO_CLIPBOARD |
145 |
150 |
146 /*! |
151 /*! |
399 control |
404 control |
400 */ |
405 */ |
401 void QLineControl::processInputMethodEvent(QInputMethodEvent *event) |
406 void QLineControl::processInputMethodEvent(QInputMethodEvent *event) |
402 { |
407 { |
403 int priorState = 0; |
408 int priorState = 0; |
404 bool isGettingInput = !event->commitString().isEmpty() || !event->preeditString().isEmpty() |
409 bool isGettingInput = !event->commitString().isEmpty() |
|
410 || event->preeditString() != preeditAreaText() |
405 || event->replacementLength() > 0; |
411 || event->replacementLength() > 0; |
406 bool cursorPositionChanged = false; |
412 bool cursorPositionChanged = false; |
407 |
413 |
408 if (isGettingInput) { |
414 if (isGettingInput) { |
409 // If any text is being input, remove selected text. |
415 // If any text is being input, remove selected text. |
411 removeSelectedText(); |
417 removeSelectedText(); |
412 } |
418 } |
413 |
419 |
414 |
420 |
415 int c = m_cursor; // cursor position after insertion of commit string |
421 int c = m_cursor; // cursor position after insertion of commit string |
416 if (event->replacementStart() <= 0) |
422 if (event->replacementStart() == 0) |
417 c += event->commitString().length() + qMin(-event->replacementStart(), event->replacementLength()); |
423 c += event->commitString().length() + qMin(-event->replacementStart(), event->replacementLength()); |
418 |
424 |
419 m_cursor += event->replacementStart(); |
425 m_cursor += event->replacementStart(); |
420 |
426 |
421 // insert commit string |
427 // insert commit string |
445 m_selstart = m_selend = 0; |
451 m_selstart = m_selend = 0; |
446 } |
452 } |
447 cursorPositionChanged = true; |
453 cursorPositionChanged = true; |
448 } |
454 } |
449 } |
455 } |
450 |
456 #ifndef QT_NO_IM |
451 setPreeditArea(m_cursor, event->preeditString()); |
457 setPreeditArea(m_cursor, event->preeditString()); |
|
458 #endif //QT_NO_IM |
452 m_preeditCursor = event->preeditString().length(); |
459 m_preeditCursor = event->preeditString().length(); |
453 m_hideCursor = false; |
460 m_hideCursor = false; |
454 QList<QTextLayout::FormatRange> formats; |
461 QList<QTextLayout::FormatRange> formats; |
455 for (int i = 0; i < event->attributes().size(); ++i) { |
462 for (int i = 0; i < event->attributes().size(); ++i) { |
456 const QInputMethodEvent::Attribute &a = event->attributes().at(i); |
463 const QInputMethodEvent::Attribute &a = event->attributes().at(i); |
1507 } |
1514 } |
1508 } |
1515 } |
1509 } |
1516 } |
1510 #endif // QT_NO_COMPLETER |
1517 #endif // QT_NO_COMPLETER |
1511 |
1518 |
|
1519 if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) { |
|
1520 if (hasAcceptableInput() || fixup()) { |
|
1521 emit accepted(); |
|
1522 emit editingFinished(); |
|
1523 } |
|
1524 if (inlineCompletionAccepted) |
|
1525 event->accept(); |
|
1526 else |
|
1527 event->ignore(); |
|
1528 return; |
|
1529 } |
|
1530 |
1512 if (echoMode() == QLineEdit::PasswordEchoOnEdit |
1531 if (echoMode() == QLineEdit::PasswordEchoOnEdit |
1513 && !passwordEchoEditing() |
1532 && !passwordEchoEditing() |
1514 && !isReadOnly() |
1533 && !isReadOnly() |
1515 && !event->text().isEmpty() |
1534 && !event->text().isEmpty() |
1516 #ifdef QT_KEYPAD_NAVIGATION |
1535 #ifdef QT_KEYPAD_NAVIGATION |
1527 // "left" or "right" it clears? |
1546 // "left" or "right" it clears? |
1528 updatePasswordEchoEditing(true); |
1547 updatePasswordEchoEditing(true); |
1529 clear(); |
1548 clear(); |
1530 } |
1549 } |
1531 |
1550 |
1532 if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) { |
|
1533 if (hasAcceptableInput() || fixup()) { |
|
1534 emit accepted(); |
|
1535 emit editingFinished(); |
|
1536 } |
|
1537 if (inlineCompletionAccepted) |
|
1538 event->accept(); |
|
1539 else |
|
1540 event->ignore(); |
|
1541 return; |
|
1542 } |
|
1543 bool unknown = false; |
1551 bool unknown = false; |
1544 |
1552 |
1545 if (false) { |
1553 if (false) { |
1546 } |
1554 } |
1547 #ifndef QT_NO_SHORTCUT |
1555 #ifndef QT_NO_SHORTCUT |
1576 copy(); |
1584 copy(); |
1577 del(); |
1585 del(); |
1578 } |
1586 } |
1579 } |
1587 } |
1580 #endif //QT_NO_CLIPBOARD |
1588 #endif //QT_NO_CLIPBOARD |
1581 else if (event == QKeySequence::MoveToStartOfLine) { |
1589 else if (event == QKeySequence::MoveToStartOfLine || event == QKeySequence::MoveToStartOfBlock) { |
1582 home(0); |
1590 home(0); |
1583 } |
1591 } |
1584 else if (event == QKeySequence::MoveToEndOfLine) { |
1592 else if (event == QKeySequence::MoveToEndOfLine || event == QKeySequence::MoveToEndOfBlock) { |
1585 end(0); |
1593 end(0); |
1586 } |
1594 } |
1587 else if (event == QKeySequence::SelectStartOfLine) { |
1595 else if (event == QKeySequence::SelectStartOfLine || event == QKeySequence::SelectStartOfBlock) { |
1588 home(1); |
1596 home(1); |
1589 } |
1597 } |
1590 else if (event == QKeySequence::SelectEndOfLine) { |
1598 else if (event == QKeySequence::SelectEndOfLine || event == QKeySequence::SelectEndOfBlock) { |
1591 end(1); |
1599 end(1); |
1592 } |
1600 } |
1593 else if (event == QKeySequence::MoveToNextChar) { |
1601 else if (event == QKeySequence::MoveToNextChar) { |
1594 #if !defined(Q_WS_WIN) || defined(QT_NO_COMPLETER) |
1602 #if !defined(Q_WS_WIN) || defined(QT_NO_COMPLETER) |
1595 if (hasSelectedText()) { |
1603 if (hasSelectedText()) { |
1661 del(); |
1669 del(); |
1662 } |
1670 } |
1663 } |
1671 } |
1664 #endif // QT_NO_SHORTCUT |
1672 #endif // QT_NO_SHORTCUT |
1665 else { |
1673 else { |
|
1674 bool handled = false; |
1666 #ifdef Q_WS_MAC |
1675 #ifdef Q_WS_MAC |
1667 if (event->key() == Qt::Key_Up || event->key() == Qt::Key_Down) { |
1676 if (event->key() == Qt::Key_Up || event->key() == Qt::Key_Down) { |
1668 Qt::KeyboardModifiers myModifiers = (event->modifiers() & ~Qt::KeypadModifier); |
1677 Qt::KeyboardModifiers myModifiers = (event->modifiers() & ~Qt::KeypadModifier); |
1669 if (myModifiers & Qt::ShiftModifier) { |
1678 if (myModifiers & Qt::ShiftModifier) { |
1670 if (myModifiers == (Qt::ControlModifier|Qt::ShiftModifier) |
1679 if (myModifiers == (Qt::ControlModifier|Qt::ShiftModifier) |
1678 || myModifiers == Qt::AltModifier |
1687 || myModifiers == Qt::AltModifier |
1679 || myModifiers == Qt::NoModifier)) { |
1688 || myModifiers == Qt::NoModifier)) { |
1680 event->key() == Qt::Key_Up ? home(0) : end(0); |
1689 event->key() == Qt::Key_Up ? home(0) : end(0); |
1681 } |
1690 } |
1682 } |
1691 } |
|
1692 handled = true; |
1683 } |
1693 } |
1684 #endif |
1694 #endif |
1685 if (event->modifiers() & Qt::ControlModifier) { |
1695 if (event->modifiers() & Qt::ControlModifier) { |
1686 switch (event->key()) { |
1696 switch (event->key()) { |
1687 case Qt::Key_Backspace: |
1697 case Qt::Key_Backspace: |
1710 del(); |
1720 del(); |
1711 } |
1721 } |
1712 break; |
1722 break; |
1713 #endif |
1723 #endif |
1714 default: |
1724 default: |
1715 unknown = true; |
1725 if (!handled) |
|
1726 unknown = true; |
1716 } |
1727 } |
1717 } else { // ### check for *no* modifier |
1728 } else { // ### check for *no* modifier |
1718 switch (event->key()) { |
1729 switch (event->key()) { |
1719 case Qt::Key_Backspace: |
1730 case Qt::Key_Backspace: |
1720 if (!isReadOnly()) { |
1731 if (!isReadOnly()) { |
1743 } |
1754 } |
1744 break; |
1755 break; |
1745 #endif |
1756 #endif |
1746 |
1757 |
1747 default: |
1758 default: |
1748 unknown = true; |
1759 if (!handled) |
|
1760 unknown = true; |
1749 } |
1761 } |
1750 } |
1762 } |
1751 } |
1763 } |
1752 |
1764 |
1753 if (event->key() == Qt::Key_Direction_L || event->key() == Qt::Key_Direction_R) { |
1765 if (event->key() == Qt::Key_Direction_L || event->key() == Qt::Key_Direction_R) { |