Changeset 561 for trunk/src/gui/widgets/qabstractspinbox.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/gui/widgets/qabstractspinbox.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 58 58 #include <qstylepainter.h> 59 59 #include <qdebug.h> 60 #ifndef QT_NO_ACCESSIBILITY 61 # include <qaccessible.h> 62 #endif 60 63 61 64 #if defined(Q_WS_X11) 62 65 #include <limits.h> 66 #endif 67 68 #if defined(Q_OS_SYMBIAN) 69 #include <W32STD.H> 70 #include <private/qt_s60_p.h> 63 71 #endif 64 72 … … 194 202 if (d->buttonSymbols != buttonSymbols) { 195 203 d->buttonSymbols = buttonSymbols; 204 d->updateEditFieldGeometry(); 196 205 update(); 197 206 } … … 660 669 661 670 d->edit->setFrame(false); 662 d->edit->setAttribute(Qt::WA_InputMethodEnabled, false);663 671 d->edit->setFocusProxy(this); 664 672 d->edit->setAcceptDrops(false); … … 689 697 Q_D(QAbstractSpinBox); 690 698 d->interpret(EmitIfChanged); 699 } 700 701 /* 702 Reimplemented in 4.6, so be careful. 703 */ 704 /*! 705 \reimp 706 */ 707 QVariant QAbstractSpinBox::inputMethodQuery(Qt::InputMethodQuery query) const 708 { 709 Q_D(const QAbstractSpinBox); 710 return d->edit->inputMethodQuery(query); 691 711 } 692 712 … … 925 945 926 946 int steps = 1; 947 bool isPgUpOrDown = false; 927 948 switch (event->key()) { 928 949 case Qt::Key_PageUp: 929 950 case Qt::Key_PageDown: 930 951 steps *= 10; 952 isPgUpOrDown = true; 931 953 case Qt::Key_Up: 932 954 case Qt::Key_Down: { … … 950 972 d->buttonState = (Keyboard | (up ? Up : Down)); 951 973 } 952 stepBy(steps); 974 if (d->spinClickTimerId == -1) 975 stepBy(steps); 976 if(event->isAutoRepeat() && !isPgUpOrDown) { 977 if(d->spinClickThresholdTimerId == -1 && d->spinClickTimerId == -1) { 978 d->updateState(up, true); 979 } 980 } 981 #ifndef QT_NO_ACCESSIBILITY 982 QAccessible::updateAccessibility(this, 0, QAccessible::ValueChanged); 983 #endif 953 984 return; 954 985 } … … 970 1001 case Qt::Key_Enter: 971 1002 case Qt::Key_Return: 972 d->edit->d_func()-> modifiedState = d->edit->d_func()->undoState = 0;1003 d->edit->d_func()->control->clearUndo(); 973 1004 d->interpret(d->keyboardTracking ? AlwaysEmit : EmitIfChanged); 974 1005 selectAll(); … … 1044 1075 Q_D(QAbstractSpinBox); 1045 1076 1046 if (d->buttonState & Keyboard && !event->isAutoRepeat() 1047 && style()->styleHint(QStyle::SH_SpinBox_AnimateButton, 0, this)) { 1077 if (d->buttonState & Keyboard && !event->isAutoRepeat()) { 1048 1078 d->reset(); 1049 1079 } else { … … 1131 1161 } 1132 1162 1163 1164 /*! 1165 \internal 1166 1167 Used when acceleration is turned on. We need to get the 1168 keyboard auto repeat rate from OS. This value is used as 1169 argument when starting acceleration related timers. 1170 1171 Every platform should, either, use native calls to obtain 1172 the value or hard code some reasonable rate. 1173 1174 Remember that time value should be given in msecs. 1175 */ 1176 static int getKeyboardAutoRepeatRate() { 1177 int ret = 30; 1178 #if defined(Q_OS_SYMBIAN) 1179 TTimeIntervalMicroSeconds32 initialTime; 1180 TTimeIntervalMicroSeconds32 time; 1181 S60->wsSession().GetKeyboardRepeatRate(initialTime, time); 1182 ret = time.Int() / 1000; // msecs 1183 #elif defined(Q_OS_WIN) && !defined(Q_OS_WINCE) 1184 DWORD time; 1185 if (SystemParametersInfo(SPI_GETKEYBOARDSPEED, 0, &time, 0) != FALSE) 1186 ret = static_cast<int>(1000 / static_cast<int>(time)); // msecs 1187 #endif 1188 return ret; // msecs 1189 } 1190 1133 1191 /*! 1134 1192 \reimp … … 1143 1201 killTimer(d->spinClickThresholdTimerId); 1144 1202 d->spinClickThresholdTimerId = -1; 1145 d->spinClickTimerId = startTimer(d->spinClickTimerInterval); 1203 d->effectiveSpinRepeatRate = d->buttonState & Keyboard 1204 ? getKeyboardAutoRepeatRate() 1205 : d->spinClickTimerInterval; 1206 d->spinClickTimerId = startTimer(d->effectiveSpinRepeatRate); 1146 1207 doStep = true; 1147 1208 } else if (event->timerId() == d->spinClickTimerId) { 1148 1209 if (d->accelerate) { 1149 d->acceleration = d->acceleration + (int)(d-> spinClickTimerInterval* 0.05);1150 if (d-> spinClickTimerInterval- d->acceleration >= 10) {1210 d->acceleration = d->acceleration + (int)(d->effectiveSpinRepeatRate * 0.05); 1211 if (d->effectiveSpinRepeatRate - d->acceleration >= 10) { 1151 1212 killTimer(d->spinClickTimerId); 1152 d->spinClickTimerId = startTimer(d-> spinClickTimerInterval- d->acceleration);1213 d->spinClickTimerId = startTimer(d->effectiveSpinRepeatRate - d->acceleration); 1153 1214 } 1154 1215 } … … 1291 1352 : edit(0), type(QVariant::Invalid), spinClickTimerId(-1), 1292 1353 spinClickTimerInterval(100), spinClickThresholdTimerId(-1), spinClickThresholdTimerInterval(-1), 1293 buttonState(None), cachedText(QLatin1String("\x01")), cachedState(QValidator::Invalid),1294 pendingEmit(false), readOnly(false), wrapping(false),1354 effectiveSpinRepeatRate(1), buttonState(None), cachedText(QLatin1String("\x01")), 1355 cachedState(QValidator::Invalid), pendingEmit(false), readOnly(false), wrapping(false), 1295 1356 ignoreCursorPositionChanged(false), frame(true), accelerate(false), keyboardTracking(true), 1296 1357 cleared(false), ignoreUpdateEdit(false), correctionMode(QAbstractSpinBox::CorrectToPreviousValue), … … 1537 1598 */ 1538 1599 1539 void QAbstractSpinBoxPrivate::updateState(bool up )1600 void QAbstractSpinBoxPrivate::updateState(bool up, bool fromKeyboard /* = false */) 1540 1601 { 1541 1602 Q_Q(QAbstractSpinBox); … … 1546 1607 : QAbstractSpinBox::StepDownEnabled))) { 1547 1608 spinClickThresholdTimerId = q->startTimer(spinClickThresholdTimerInterval); 1548 buttonState = (up ? (Mouse | Up) : (Mouse | Down));1609 buttonState = (up ? Up : Down) | (fromKeyboard ? Keyboard : Mouse); 1549 1610 q->stepBy(up ? 1 : -1); 1611 #ifndef QT_NO_ACCESSIBILITY 1612 QAccessible::updateAccessibility(q, 0, QAccessible::ValueChanged); 1613 #endif 1550 1614 } 1551 1615 } … … 1568 1632 option->activeSubControls = QStyle::SC_None; 1569 1633 option->buttonSymbols = d->buttonSymbols; 1570 option->subControls = QStyle::SC_SpinBoxFrame ;1634 option->subControls = QStyle::SC_SpinBoxFrame | QStyle::SC_SpinBoxEditField; 1571 1635 if (d->buttonSymbols != QAbstractSpinBox::NoButtons) { 1572 1636 option->subControls |= QStyle::SC_SpinBoxUp | QStyle::SC_SpinBoxDown; … … 1696 1760 void QAbstractSpinBoxPrivate::setRange(const QVariant &min, const QVariant &max) 1697 1761 { 1762 Q_Q(QAbstractSpinBox); 1763 1698 1764 clearCache(); 1699 1765 minimum = min; … … 1707 1773 updateEdit(); 1708 1774 } 1775 1776 q->updateGeometry(); 1709 1777 } 1710 1778 … … 1781 1849 QASBDEBUG() << "QAbstractSpinBoxPrivate::interpret() text '" 1782 1850 << edit->displayText() 1783 << "' >> '" << copy << "'"1784 << "' >> '" << tmp << "'";1851 << "' >> '" << copy << '\'' 1852 << "' >> '" << tmp << '\''; 1785 1853 1786 1854 doInterpret = tmp != copy && (q->validate(tmp, pos) == QValidator::Acceptable); … … 1832 1900 return QValidator::Acceptable; 1833 1901 1834 if (!dptr->prefix.isEmpty() && !input.startsWith(dptr->prefix)) 1902 if (!dptr->prefix.isEmpty() && !input.startsWith(dptr->prefix)) { 1835 1903 input.prepend(dptr->prefix); 1904 pos += dptr->prefix.length(); 1905 } 1836 1906 1837 1907 if (!dptr->suffix.isEmpty() && !input.endsWith(dptr->suffix))
Note:
See TracChangeset
for help on using the changeset viewer.