diff options
-rw-r--r-- | qmake/generators/win32/winmakefile.cpp | 10 | ||||
-rw-r--r-- | src/gui/widgets/qabstractslider_p.h | 2 | ||||
-rw-r--r-- | src/gui/widgets/qdial.cpp | 15 | ||||
-rw-r--r-- | src/script/api/qscriptengine.cpp | 4 | ||||
-rw-r--r-- | tests/auto/qdial/tst_qdial.cpp | 64 | ||||
-rw-r--r-- | tests/auto/qscriptvalue/tst_qscriptvalue.cpp | 4 |
6 files changed, 95 insertions, 4 deletions
diff --git a/qmake/generators/win32/winmakefile.cpp b/qmake/generators/win32/winmakefile.cpp index 5f56d66..8cf970e 100644 --- a/qmake/generators/win32/winmakefile.cpp +++ b/qmake/generators/win32/winmakefile.cpp @@ -78,8 +78,14 @@ Win32MakefileGenerator::findHighestVersion(const QString &d, const QString &stem int biggest=-1; if(!project->isActiveConfig("no_versionlink")) { - QDir dir(bd); - QStringList entries = dir.entryList(); + static QHash<QString, QStringList> dirEntryListCache; + QStringList entries = dirEntryListCache.value(bd); + if (entries.isEmpty()) { + QDir dir(bd); + entries = dir.entryList(); + dirEntryListCache.insert(bd, entries); + } + QRegExp regx(QString("((lib)?%1([0-9]*)).(%2|prl)$").arg(dllStem).arg(ext), Qt::CaseInsensitive); for(QStringList::Iterator it = entries.begin(); it != entries.end(); ++it) { if(regx.exactMatch((*it))) { diff --git a/src/gui/widgets/qabstractslider_p.h b/src/gui/widgets/qabstractslider_p.h index 19d1fca..d044131 100644 --- a/src/gui/widgets/qabstractslider_p.h +++ b/src/gui/widgets/qabstractslider_p.h @@ -117,7 +117,7 @@ public: ; } - inline int bound(int val) const { return qMax(minimum, qMin(maximum, val)); } + virtual int bound(int val) const { return qMax(minimum, qMin(maximum, val)); } inline int overflowSafeAdd(int add) const { int newValue = value + add; diff --git a/src/gui/widgets/qdial.cpp b/src/gui/widgets/qdial.cpp index a8d739f..bca5019 100644 --- a/src/gui/widgets/qdial.cpp +++ b/src/gui/widgets/qdial.cpp @@ -83,6 +83,7 @@ public: int valueFromPoint(const QPoint &) const; double angle(const QPoint &, const QPoint &) const; void init(); + virtual int bound(int val) const; }; void QDialPrivate::init() @@ -97,6 +98,20 @@ void QDialPrivate::init() #endif } +int QDialPrivate::bound(int val) const +{ + if (wrapping) { + if ((val >= minimum) && (val <= maximum)) + return val; + val = minimum + ((val - minimum) % (maximum - minimum)); + if (val < minimum) + val += maximum - minimum; + return val; + } else { + return QAbstractSliderPrivate::bound(val); + } +} + /*! Initialize \a option with the values from this QDial. This method is useful for subclasses when they need a QStyleOptionSlider, but don't want diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index 69abcad..1fcbd73 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -1744,7 +1744,9 @@ QVariant QScriptEnginePrivate::toVariant(JSC::ExecState *exec, JSC::JSValue valu else if (QScriptDeclarativeClass *dc = declarativeClass(value)) return dc->toVariant(declarativeObject(value)); return variantMapFromObject(exec, JSC::asObject(value)); - } else if (value.isNumber()) { + } else if (value.isInt32()) { + return QVariant(toInt32(exec, value)); + } else if (value.isDouble()) { return QVariant(toNumber(exec, value)); } else if (value.isString()) { return QVariant(toString(exec, value)); diff --git a/tests/auto/qdial/tst_qdial.cpp b/tests/auto/qdial/tst_qdial.cpp index 2428eae..92c2964 100644 --- a/tests/auto/qdial/tst_qdial.cpp +++ b/tests/auto/qdial/tst_qdial.cpp @@ -54,6 +54,7 @@ private slots: void getSetCheck(); void valueChanged(); void sliderMoved(); + void wrappingCheck(); }; // Testing get/set functions @@ -143,5 +144,68 @@ void tst_QDial::sliderMoved() } +void tst_QDial::wrappingCheck() +{ + //This tests if dial will wrap past the maximum value back to the minimum + //and vice versa when changing the value with a keypress + QDial dial; + dial.setMinimum(0); + dial.setMaximum(100); + dial.setSingleStep(1); + dial.setWrapping(true); + dial.setValue(99); + dial.show(); + + { //set value to maximum but do not wrap + QTest::keyPress(&dial, Qt::Key_Up); + QCOMPARE( dial.value(), 100); + } + + { //step up once more and wrap clockwise to minimum + 1 + QTest::keyPress(&dial, Qt::Key_Up); + QCOMPARE( dial.value(), 1); + } + + { //step down once, and wrap anti-clockwise to minimum, then again to maximum - 1 + QTest::keyPress(&dial, Qt::Key_Down); + QCOMPARE( dial.value(), 0); + + QTest::keyPress(&dial, Qt::Key_Down); + QCOMPARE( dial.value(), 99); + } + + { //when wrapping property is false no wrapping will occur + dial.setWrapping(false); + dial.setValue(100); + + QTest::keyPress(&dial, Qt::Key_Up); + QCOMPARE( dial.value(), 100); + + dial.setValue(0); + QTest::keyPress(&dial, Qt::Key_Down); + QCOMPARE( dial.value(), 0); + } + + { //When the step is really big or small, wrapping should still behave + dial.setWrapping(true); + dial.setValue(dial.minimum()); + dial.setSingleStep(305); + + QTest::keyPress(&dial, Qt::Key_Up); + QCOMPARE( dial.value(), 5); + + dial.setValue(dial.minimum()); + QTest::keyPress(&dial, Qt::Key_Down); + QCOMPARE( dial.value(), 95); + + dial.setMinimum(-30); + dial.setMaximum(-4); + dial.setSingleStep(200); + dial.setValue(dial.minimum()); + QTest::keyPress(&dial, Qt::Key_Down); + QCOMPARE( dial.value(), -22); + } +} + QTEST_MAIN(tst_QDial) #include "tst_qdial.moc" diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp index 97bbf26..5a50e49 100644 --- a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp +++ b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp @@ -1254,6 +1254,10 @@ void tst_QScriptValue::toVariant() QCOMPARE(number.toVariant(), QVariant(123.0)); QCOMPARE(qscriptvalue_cast<QVariant>(number), QVariant(123.0)); + QScriptValue intNumber = QScriptValue(&eng, (qint32)123); + QCOMPARE(intNumber.toVariant().type(), QVariant((qint32)123).type()); + QCOMPARE((qscriptvalue_cast<QVariant>(number)).type(), QVariant((qint32)123).type()); + QScriptValue falskt = QScriptValue(&eng, false); QCOMPARE(falskt.toVariant(), QVariant(false)); QCOMPARE(qscriptvalue_cast<QVariant>(falskt), QVariant(false)); |