From b095541b487ee2faaca27ff226502acb2f81c7d4 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Thu, 14 Jan 2010 11:14:42 +0100 Subject: add tests for QFlags behavior in QtScript It's currently not even documented, but this test defines the current level of support. --- .../qscriptextqobject/tst_qscriptextqobject.cpp | 57 +++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp b/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp index 73e4fb6..3415163 100644 --- a/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp +++ b/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp @@ -112,6 +112,7 @@ class MyQObject : public QObject Q_PROPERTY(QKeySequence shortcut READ shortcut WRITE setShortcut) Q_PROPERTY(CustomType propWithCustomType READ propWithCustomType WRITE setPropWithCustomType) Q_PROPERTY(Policy enumProperty READ enumProperty WRITE setEnumProperty) + Q_PROPERTY(Ability flagsProperty READ flagsProperty WRITE setFlagsProperty) Q_ENUMS(Policy Strategy) Q_FLAGS(Ability) @@ -150,6 +151,7 @@ public: m_writeOnlyValue(789), m_readOnlyValue(987), m_enumValue(BarPolicy), + m_flagsValue(FooAbility), m_qtFunctionInvoked(-1) { } @@ -216,6 +218,11 @@ public: void setEnumProperty(Policy policy) { m_enumValue = policy; } + Ability flagsProperty() const + { return m_flagsValue; } + void setFlagsProperty(Ability ability) + { m_flagsValue = ability; } + int qtFunctionInvoked() const { return m_qtFunctionInvoked; } @@ -316,6 +323,10 @@ public: { m_qtFunctionInvoked = 56; return arg; } Q_INVOKABLE QObject* myInvokableReturningMyQObjectAsQObject() { m_qtFunctionInvoked = 57; return this; } + Q_INVOKABLE Ability myInvokableWithFlagsArg(Ability arg) + { m_qtFunctionInvoked = 58; m_actuals << int(arg); return arg; } + Q_INVOKABLE MyQObject::Ability myInvokableWithQualifiedFlagsArg(MyQObject::Ability arg) + { m_qtFunctionInvoked = 59; m_actuals << int(arg); return arg; } Q_INVOKABLE QObjectList findObjects() const { return findChildren(); } @@ -433,6 +444,7 @@ protected: QKeySequence m_shortcut; CustomType m_customType; Policy m_enumValue; + Ability m_flagsValue; int m_qtFunctionInvoked; QVariantList m_actuals; QByteArray m_connectedSignal; @@ -826,7 +838,7 @@ void tst_QScriptExtQObject::getSetStaticProperty() { QScriptValue val = m_engine->evaluate("myObject.enumProperty"); QVERIFY(val.isNumber()); - QCOMPARE(val.toInt32(), (int)MyQObject::BarPolicy); + QCOMPARE(val.toInt32(), int(MyQObject::BarPolicy)); } m_engine->evaluate("myObject.enumProperty = 2"); QCOMPARE(m_myObject->enumProperty(), MyQObject::BazPolicy); @@ -846,6 +858,25 @@ void tst_QScriptExtQObject::getSetStaticProperty() m_engine->evaluate("myObject.enumProperty = 'nada'"); QCOMPARE(m_myObject->enumProperty(), (MyQObject::Policy)-1); + // flags property + QCOMPARE(m_myObject->flagsProperty(), MyQObject::FooAbility); + { + QScriptValue val = m_engine->evaluate("myObject.flagsProperty"); + QVERIFY(val.isNumber()); + QCOMPARE(val.toInt32(), int(MyQObject::FooAbility)); + } + m_engine->evaluate("myObject.flagsProperty = 0x80"); + QCOMPARE(m_myObject->flagsProperty(), MyQObject::BarAbility); + m_engine->evaluate("myObject.flagsProperty = 0x81"); + QCOMPARE(m_myObject->flagsProperty(), MyQObject::Ability(MyQObject::FooAbility | MyQObject::BarAbility)); + m_engine->evaluate("myObject.flagsProperty = 123"); // bogus values are accepted + QCOMPARE(int(m_myObject->flagsProperty()), 123); + m_engine->evaluate("myObject.flagsProperty = 'BazAbility'"); + QCOMPARE(m_myObject->flagsProperty(), MyQObject::BazAbility); + m_engine->evaluate("myObject.flagsProperty = 'ScoobyDoo'"); + // ### ouch! Shouldn't QMetaProperty::write() rather not change the value...? + QCOMPARE(m_myObject->flagsProperty(), (MyQObject::Ability)-1); + // auto-dereferencing of pointers { QBrush b = QColor(0xCA, 0xFE, 0xBA, 0xBE); @@ -2017,6 +2048,7 @@ void tst_QScriptExtQObject::classEnums() QScriptValue myClass = m_engine->newQMetaObject(m_myObject->metaObject(), m_engine->undefinedValue()); m_engine->globalObject().setProperty("MyQObject", myClass); + QVERIFY(m_engine->evaluate("MyQObject.FooPolicy").isNumber()); // no strong typing QCOMPARE(static_cast(m_engine->evaluate("MyQObject.FooPolicy").toInt32()), MyQObject::FooPolicy); QCOMPARE(static_cast(m_engine->evaluate("MyQObject.BarPolicy").toInt32()), @@ -2031,6 +2063,7 @@ void tst_QScriptExtQObject::classEnums() QCOMPARE(static_cast(m_engine->evaluate("MyQObject.BazStrategy").toInt32()), MyQObject::BazStrategy); + QVERIFY(m_engine->evaluate("MyQObject.NoAbility").isNumber()); // no strong typing QCOMPARE(MyQObject::Ability(m_engine->evaluate("MyQObject.NoAbility").toInt32()), MyQObject::NoAbility); QCOMPARE(MyQObject::Ability(m_engine->evaluate("MyQObject.FooAbility").toInt32()), @@ -2042,6 +2075,9 @@ void tst_QScriptExtQObject::classEnums() QCOMPARE(MyQObject::Ability(m_engine->evaluate("MyQObject.AllAbility").toInt32()), MyQObject::AllAbility); + // Constructors for flags are not provided + QVERIFY(m_engine->evaluate("MyQObject.Ability").isUndefined()); + QScriptValue::PropertyFlags expectedEnumFlags = QScriptValue::ReadOnly | QScriptValue::Undeletable; QCOMPARE(myClass.propertyFlags("FooPolicy"), expectedEnumFlags); QCOMPARE(myClass.propertyFlags("BarPolicy"), expectedEnumFlags); @@ -2094,6 +2130,25 @@ void tst_QScriptExtQObject::classEnums() QCOMPARE(ret.isNumber(), true); } + m_myObject->resetQtFunctionInvoked(); + { + QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithFlagsArg(MyQObject.FooAbility)"); + QCOMPARE(m_myObject->qtFunctionInvoked(), 58); + QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); + QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), int(MyQObject::FooAbility)); + QCOMPARE(ret.isNumber(), true); + QCOMPARE(ret.toInt32(), int(MyQObject::FooAbility)); + } + m_myObject->resetQtFunctionInvoked(); + { + QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithQualifiedFlagsArg(MyQObject.BarAbility)"); + QCOMPARE(m_myObject->qtFunctionInvoked(), 59); + QCOMPARE(m_myObject->qtFunctionActuals().size(), 1); + QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), int(MyQObject::BarAbility)); + QCOMPARE(ret.isNumber(), true); + QCOMPARE(ret.toInt32(), int(MyQObject::BarAbility)); + } + // enum properties are not deletable or writable QVERIFY(!m_engine->evaluate("delete MyQObject.BazPolicy").toBool()); myClass.setProperty("BazPolicy", QScriptValue()); -- cgit v0.12 From e915c2408b2030b142dc309a9e4aba621341aa28 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Wed, 13 Jan 2010 14:06:56 +0100 Subject: File dialog mode is not correctly updated in Mac (Cocoa). QFileDialog shows a customized version of the native file dialog on Mac. When user changes the fileMode, the corresponding options needs to be updated in the native dialog as well. Some options like mode, filters, button text, dialog title etc needs to be updated for this. This patch also address the changing of 'acceptMode'. When user changes this, for e.g. the native dialog needs to switch from an open panel to save panel. It is easier to recreate the internal QNSOpenSavePanelDelegate than changing options individually. Task-number: QTBUG-7086 Reviewed-by: Richard Moe Gustavsen --- src/gui/dialogs/qfiledialog.cpp | 15 +++++++++------ src/gui/dialogs/qfiledialog_mac.mm | 7 +++++++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/gui/dialogs/qfiledialog.cpp b/src/gui/dialogs/qfiledialog.cpp index 3d59463..21650bb 100644 --- a/src/gui/dialogs/qfiledialog.cpp +++ b/src/gui/dialogs/qfiledialog.cpp @@ -1222,12 +1222,6 @@ QFileDialog::ViewMode QFileDialog::viewMode() const void QFileDialog::setFileMode(QFileDialog::FileMode mode) { Q_D(QFileDialog); - if (d->nativeDialogInUse){ - d->model->setFilter(d->filterForMode(filter())); - d->setFilter_sys(); - return; - } - d->fileMode = mode; d->retranslateWindowTitle(); @@ -1263,6 +1257,11 @@ void QFileDialog::setFileMode(QFileDialog::FileMode mode) } } setLabelText(Accept, buttonText); + if (d->nativeDialogInUse){ + d->setFilter_sys(); + return; + } + d->qFileDialogUi->fileTypeCombo->setEnabled(!testOption(ShowDirsOnly)); d->_q_updateOkButton(); } @@ -1300,6 +1299,10 @@ void QFileDialog::setAcceptMode(QFileDialog::AcceptMode mode) d->qFileDialogUi->lookInCombo->setEditable(false); } d->retranslateWindowTitle(); +#if defined(Q_WS_MAC) + d->deleteNativeDialog_sys(); + setAttribute(Qt::WA_DontShowOnScreen, false); +#endif } /* diff --git a/src/gui/dialogs/qfiledialog_mac.mm b/src/gui/dialogs/qfiledialog_mac.mm index db5c356..67daced 100644 --- a/src/gui/dialogs/qfiledialog_mac.mm +++ b/src/gui/dialogs/qfiledialog_mac.mm @@ -639,9 +639,16 @@ void QFileDialogPrivate::setFilter_sys() { #ifndef QT_MAC_USE_COCOA #else + Q_Q(QFileDialog); QMacCocoaAutoReleasePool pool; QNSOpenSavePanelDelegate *delegate = static_cast(mDelegate); *(delegate->mQDirFilter) = model->filter(); + delegate->mFileMode = fileMode; + [delegate->mSavePanel setTitle:qt_mac_QStringToNSString(q->windowTitle())]; + [delegate->mSavePanel setPrompt:[delegate strip:acceptLabel]]; + if (fileNameLabelExplicitlySat) + [delegate->mSavePanel setNameFieldLabel:[delegate strip:qFileDialogUi->fileNameLabel->text()]]; + [delegate updateProperties]; #endif } -- cgit v0.12 From f7767801f1d9455325351ec9bb590c6f7cd60e77 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Thu, 14 Jan 2010 11:18:35 +0100 Subject: network internals: fix uploading of data Reviewed-by: Markus Goetz --- src/network/access/qhttpnetworkconnectionchannel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index 39d09aa..1955dba 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -260,7 +260,7 @@ bool QHttpNetworkConnectionChannel::sendRequest() // ensure we try to receive a reply in all cases, even if _q_readyRead_ hat not been called // this is needed if the sends an reply before we have finished sending the request. In that // case receiveReply had been called before but ignored the server reply - QMetaObject::invokeMethod(connection, "_q_receiveReply", Qt::QueuedConnection); + QMetaObject::invokeMethod(this, "_q_receiveReply", Qt::QueuedConnection); break; } case QHttpNetworkConnectionChannel::ReadingState: -- cgit v0.12 From 1ca42be0498744dd1270241d2ccfe3d578d82a98 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 14 Jan 2010 13:14:12 +0100 Subject: Updated WebKit from /home/shausman/src/webkit/trunk to qtwebkit/qtwebkit-4.6 ( 8f6992f4e8f027818429d428393b08068eca9ffa ) Changes in WebKit/qt since the last update: ++ b/WebKit/qt/ChangeLog 2010-01-14 Simon Hausmann Reviewed by Kenneth Rohde Christiansen. [Qt] Update Symbian .def symbol export files after private API additions. * symbian/bwins/QtWebKitu.def: * symbian/eabi/QtWebKitu.def: --- src/3rdparty/webkit/VERSION | 2 +- src/3rdparty/webkit/WebKit/qt/ChangeLog | 9 +++++++++ src/3rdparty/webkit/WebKit/qt/symbian/bwins/QtWebKitu.def | 4 ++++ src/3rdparty/webkit/WebKit/qt/symbian/eabi/QtWebKitu.def | 4 ++++ 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index bc6d661..4f33e22 100644 --- a/src/3rdparty/webkit/VERSION +++ b/src/3rdparty/webkit/VERSION @@ -8,4 +8,4 @@ The commit imported was from the and has the sha1 checksum - 8b9165d3bc84d1c8cc7df49a191cc3857b5530d4 + 8f6992f4e8f027818429d428393b08068eca9ffa diff --git a/src/3rdparty/webkit/WebKit/qt/ChangeLog b/src/3rdparty/webkit/WebKit/qt/ChangeLog index 357b787..cd47982 100644 --- a/src/3rdparty/webkit/WebKit/qt/ChangeLog +++ b/src/3rdparty/webkit/WebKit/qt/ChangeLog @@ -1,3 +1,12 @@ +2010-01-14 Simon Hausmann + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Update Symbian .def symbol export files after private API additions. + + * symbian/bwins/QtWebKitu.def: + * symbian/eabi/QtWebKitu.def: + 2009-12-18 Joe Ligman Reviewed by Kenneth Rohde Christiansen. diff --git a/src/3rdparty/webkit/WebKit/qt/symbian/bwins/QtWebKitu.def b/src/3rdparty/webkit/WebKit/qt/symbian/bwins/QtWebKitu.def index e5631f8..086e986 100644 --- a/src/3rdparty/webkit/WebKit/qt/symbian/bwins/QtWebKitu.def +++ b/src/3rdparty/webkit/WebKit/qt/symbian/bwins/QtWebKitu.def @@ -620,4 +620,8 @@ EXPORTS ?staticMetaObject@QWebPage@@2UQMetaObject@@B @ 619 NONAME ; struct QMetaObject const QWebPage::staticMetaObject ?staticMetaObject@QWebView@@2UQMetaObject@@B @ 620 NONAME ; struct QMetaObject const QWebView::staticMetaObject ?attributeNames@QWebElement@@QBE?AVQStringList@@ABVQString@@@Z @ 621 NONAME ; class QStringList QWebElement::attributeNames(class QString const &) const + ?qt_networkAccessAllowed@@YAX_N@Z @ 622 NONAME ; void qt_networkAccessAllowed(bool) + ?qt_resumeActiveDOMObjects@@YAXPAVQWebFrame@@@Z @ 623 NONAME ; void qt_resumeActiveDOMObjects(class QWebFrame *) + ?qt_suspendActiveDOMObjects@@YAXPAVQWebFrame@@@Z @ 624 NONAME ; void qt_suspendActiveDOMObjects(class QWebFrame *) + ?qtwebkit_webframe_scrollRecursively@@YA_NPAVQWebFrame@@HH@Z @ 625 NONAME ; bool qtwebkit_webframe_scrollRecursively(class QWebFrame *, int, int) diff --git a/src/3rdparty/webkit/WebKit/qt/symbian/eabi/QtWebKitu.def b/src/3rdparty/webkit/WebKit/qt/symbian/eabi/QtWebKitu.def index 4aad884..5dd2e20 100644 --- a/src/3rdparty/webkit/WebKit/qt/symbian/eabi/QtWebKitu.def +++ b/src/3rdparty/webkit/WebKit/qt/symbian/eabi/QtWebKitu.def @@ -690,4 +690,8 @@ EXPORTS _ZThn8_N16QGraphicsWebView10itemChangeEN13QGraphicsItem18GraphicsItemChangeERK8QVariant @ 689 NONAME _ZThn8_NK16QGraphicsWebView16inputMethodQueryEN2Qt16InputMethodQueryE @ 690 NONAME _ZNK11QWebElement14attributeNamesERK7QString @ 691 NONAME + _Z23qt_networkAccessAllowedb @ 692 NONAME + _Z25qt_resumeActiveDOMObjectsP9QWebFrame @ 693 NONAME + _Z26qt_suspendActiveDOMObjectsP9QWebFrame @ 694 NONAME + _Z35qtwebkit_webframe_scrollRecursivelyP9QWebFrameii @ 695 NONAME -- cgit v0.12 From 88a07b4c0a3a87eeb47750640cb71a5a64e0573c Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 14 Jan 2010 16:13:10 +1000 Subject: Fix tst_qmlgraphicstext::letterSpacing tst_qmlgraphicstext::wordSpacing Sent for review into 4.6. Task-number: QTBUG-7326 Signed-off-by: Simon Hausmann --- src/gui/text/qfont.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index 4c57dff..bbd35f1 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -1614,7 +1614,11 @@ bool QFont::operator==(const QFont &f) const && f.d->overline == d->overline && f.d->strikeOut == d->strikeOut && f.d->kerning == d->kerning - && f.d->capital == d->capital)); + && f.d->capital == d->capital + && f.d->letterSpacingIsAbsolute == d->letterSpacingIsAbsolute + && f.d->letterSpacing == d->letterSpacing + && f.d->wordSpacing == d->wordSpacing + )); } @@ -1648,6 +1652,10 @@ bool QFont::operator<(const QFont &f) const #endif // Q_WS_X11 if (f.d->capital != d->capital) return f.d->capital < d->capital; + if (f.d->letterSpacingIsAbsolute != d->letterSpacingIsAbsolute) return f.d->letterSpacingIsAbsolute < d->letterSpacingIsAbsolute; + if (f.d->letterSpacing != d->letterSpacing) return f.d->letterSpacing < d->letterSpacing; + if (f.d->wordSpacing != d->wordSpacing) return f.d->wordSpacing < d->wordSpacing; + int f1attrs = (f.d->underline << 3) + (f.d->overline << 2) + (f.d->strikeOut<<1) + f.d->kerning; int f2attrs = (d->underline << 3) + (d->overline << 2) + (d->strikeOut<<1) + d->kerning; return f1attrs < f2attrs; -- cgit v0.12 From 2d0bd1a13328d5a5ed6c4d1e768937a6627f1086 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Tue, 12 Jan 2010 19:14:56 +0100 Subject: QFile::remove: don't fail for unrelated errors remove was checking for errors from close, but without clearing the error state beforehand it ended picking unrelated errors. Task-number: QTBUG-7285 Reviewed-by: qCaro --- src/corelib/io/qfile.cpp | 1 + tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp | 36 ++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp index 6395cc7..4c7f3f0 100644 --- a/src/corelib/io/qfile.cpp +++ b/src/corelib/io/qfile.cpp @@ -643,6 +643,7 @@ QFile::remove() qWarning("QFile::remove: Empty or null file name"); return false; } + unsetError(); close(); if(error() == QFile::NoError) { if(fileEngine()->remove()) { diff --git a/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp index c781108..1304f4e 100644 --- a/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp +++ b/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp @@ -95,6 +95,7 @@ private slots: void keepOpenMode(); void resetTemplateAfterError(); void setTemplateAfterOpen(); + void autoRemoveAfterFailedRename(); public: }; @@ -558,5 +559,40 @@ void tst_QTemporaryFile::setTemplateAfterOpen() QCOMPARE( temp.fileTemplate(), newTemplate ); } +void tst_QTemporaryFile::autoRemoveAfterFailedRename() +{ + struct CleanOnReturn + { + ~CleanOnReturn() + { + if (!tempName.isEmpty()) + QFile::remove(tempName); + } + + void reset() + { + tempName.clear(); + } + + QString tempName; + }; + + CleanOnReturn cleaner; + + { + QTemporaryFile file; + QVERIFY( file.open() ); + cleaner.tempName = file.fileName(); + + QVERIFY( QFile::exists(cleaner.tempName) ); + QVERIFY( !QFileInfo("i-do-not-exist").isDir() ); + QVERIFY( !file.rename("i-do-not-exist/file.txt") ); + QVERIFY( QFile::exists(cleaner.tempName) ); + } + + QVERIFY( !QFile::exists(cleaner.tempName) ); + cleaner.reset(); +} + QTEST_MAIN(tst_QTemporaryFile) #include "tst_qtemporaryfile.moc" -- cgit v0.12