From 6b366d4f26ed088f7edcc4b74f56cdbdc7a15024 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Mon, 22 Mar 2010 16:40:45 +1000 Subject: Fixed inconsistent test naming. TARGET and test class name should always match. Backport 91ebcc413f0650ab235b93689776d4457bdbc80e from 4.7 --- tests/auto/qfiledialog2/tst_qfiledialog2.cpp | 76 +++++----- .../tst_qtconcurrentiteratekernel.cpp | 22 +-- tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp | 62 ++++---- tests/auto/qtconcurrentrun/tst_qtconcurrentrun.cpp | 22 +-- .../tst_qtconcurrentthreadengine.cpp | 24 +-- tests/auto/qvectornd/tst_qvectornd.cpp | 166 ++++++++++----------- .../tst_xmlpatternsdiagnosticsts.cpp | 10 +- 7 files changed, 191 insertions(+), 191 deletions(-) diff --git a/tests/auto/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/qfiledialog2/tst_qfiledialog2.cpp index f2e1dbd..6bfa8be 100644 --- a/tests/auto/qfiledialog2/tst_qfiledialog2.cpp +++ b/tests/auto/qfiledialog2/tst_qfiledialog2.cpp @@ -87,13 +87,13 @@ public: } }; -class tst_QFiledialog : public QObject +class tst_QFileDialog2 : public QObject { Q_OBJECT public: - tst_QFiledialog(); - virtual ~tst_QFiledialog(); + tst_QFileDialog2(); + virtual ~tst_QFileDialog2(); public slots: void init(); @@ -138,18 +138,18 @@ private: QByteArray userSettings; }; -tst_QFiledialog::tst_QFiledialog() +tst_QFileDialog2::tst_QFileDialog2() { #if defined(Q_OS_WINCE) qApp->setAutoMaximizeThreshold(-1); #endif } -tst_QFiledialog::~tst_QFiledialog() +tst_QFileDialog2::~tst_QFileDialog2() { } -void tst_QFiledialog::init() +void tst_QFileDialog2::init() { // Save the developers settings so they don't get mad when their sidebar folders are gone. QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); @@ -164,14 +164,14 @@ void tst_QFiledialog::init() #endif } -void tst_QFiledialog::cleanup() +void tst_QFileDialog2::cleanup() { QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); settings.beginGroup(QLatin1String("Qt")); settings.setValue(QLatin1String("filedialog"), userSettings); } -void tst_QFiledialog::listRoot() +void tst_QFileDialog2::listRoot() { #if defined QT_BUILD_INTERNAL QFileInfoGatherer fileInfoGatherer; @@ -193,7 +193,7 @@ void tst_QFiledialog::listRoot() #endif } -void tst_QFiledialog::heapCorruption() +void tst_QFileDialog2::heapCorruption() { QVector dialogs; for (int i=0; i < 10; i++) { @@ -205,12 +205,12 @@ void tst_QFiledialog::heapCorruption() struct FriendlyQFileDialog : public QNonNativeFileDialog { - friend class tst_QFileDialog; + friend class tst_QFileDialog2; Q_DECLARE_PRIVATE(QFileDialog) }; -void tst_QFiledialog::deleteDirAndFiles() +void tst_QFileDialog2::deleteDirAndFiles() { #if defined QT_BUILD_INTERNAL QString tempPath = QDir::tempPath() + '/' + "QFileDialogTestDir4FullDelete"; @@ -242,7 +242,7 @@ void tst_QFiledialog::deleteDirAndFiles() #endif } -void tst_QFiledialog::filter() +void tst_QFileDialog2::filter() { QNonNativeFileDialog fd; QAction *hiddenAction = qFindChild(&fd, "qt_show_hidden_action"); @@ -255,7 +255,7 @@ void tst_QFiledialog::filter() QVERIFY(hiddenAction->isChecked()); } -void tst_QFiledialog::showNameFilterDetails() +void tst_QFileDialog2::showNameFilterDetails() { QNonNativeFileDialog fd; QComboBox *filters = qFindChild(&fd, "fileTypeCombo"); @@ -280,7 +280,7 @@ void tst_QFiledialog::showNameFilterDetails() QCOMPARE(filters->itemText(2), filterChoices.at(2)); } -void tst_QFiledialog::unc() +void tst_QFileDialog2::unc() { #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) // Only test UNC on Windows./ @@ -295,7 +295,7 @@ void tst_QFiledialog::unc() QCOMPARE(model->index(fd.directory().absolutePath()), model->index(dir)); } -void tst_QFiledialog::emptyUncPath() +void tst_QFileDialog2::emptyUncPath() { QNonNativeFileDialog fd; fd.show(); @@ -308,7 +308,7 @@ void tst_QFiledialog::emptyUncPath() QVERIFY(model); } -void tst_QFiledialog::task178897_minimumSize() +void tst_QFileDialog2::task178897_minimumSize() { QNonNativeFileDialog fd; QSize oldMs = fd.layout()->minimumSize(); @@ -322,7 +322,7 @@ void tst_QFiledialog::task178897_minimumSize() QVERIFY(ms.width() <= oldMs.width()); } -void tst_QFiledialog::task180459_lastDirectory_data() +void tst_QFileDialog2::task180459_lastDirectory_data() { QTest::addColumn("path"); QTest::addColumn("directory"); @@ -345,7 +345,7 @@ void tst_QFiledialog::task180459_lastDirectory_data() } -void tst_QFiledialog::task180459_lastDirectory() +void tst_QFileDialog2::task180459_lastDirectory() { //first visit the temp directory and close the dialog QNonNativeFileDialog *dlg = new QNonNativeFileDialog(0, "", QDir::tempPath()); @@ -449,7 +449,7 @@ QString &dir, const QString &filter) } }; -void tst_QFiledialog::task227304_proxyOnFileDialog() +void tst_QFileDialog2::task227304_proxyOnFileDialog() { #if defined QT_BUILD_INTERNAL QNonNativeFileDialog fd(0, "", QDir::currentPath(), 0); @@ -488,7 +488,7 @@ void tst_QFiledialog::task227304_proxyOnFileDialog() #endif } -void tst_QFiledialog::task227930_correctNavigationKeyboardBehavior() +void tst_QFileDialog2::task227930_correctNavigationKeyboardBehavior() { QDir current = QDir::currentPath(); current.mkdir("test"); @@ -527,7 +527,7 @@ void tst_QFiledialog::task227930_correctNavigationKeyboardBehavior() } #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) -void tst_QFiledialog::task226366_lowerCaseHardDriveWindows() +void tst_QFileDialog2::task226366_lowerCaseHardDriveWindows() { QNonNativeFileDialog fd; fd.setDirectory(QDir::root().path()); @@ -553,7 +553,7 @@ void tst_QFiledialog::task226366_lowerCaseHardDriveWindows() } #endif -void tst_QFiledialog::completionOnLevelAfterRoot() +void tst_QFileDialog2::completionOnLevelAfterRoot() { QNonNativeFileDialog fd; #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) @@ -592,7 +592,7 @@ void tst_QFiledialog::completionOnLevelAfterRoot() #endif } -void tst_QFiledialog::task233037_selectingDirectory() +void tst_QFileDialog2::task233037_selectingDirectory() { QDir current = QDir::currentPath(); current.mkdir("test"); @@ -615,7 +615,7 @@ void tst_QFiledialog::task233037_selectingDirectory() current.rmdir("test"); } -void tst_QFiledialog::task235069_hideOnEscape() +void tst_QFileDialog2::task235069_hideOnEscape() { QDir current = QDir::currentPath(); QNonNativeFileDialog fd; @@ -637,7 +637,7 @@ void tst_QFiledialog::task235069_hideOnEscape() QCOMPARE(fd2.isVisible(), false); } -void tst_QFiledialog::task236402_dontWatchDeletedDir() +void tst_QFileDialog2::task236402_dontWatchDeletedDir() { #if defined QT_BUILD_INTERNAL //THIS TEST SHOULD NOT DISPLAY WARNINGS @@ -662,7 +662,7 @@ void tst_QFiledialog::task236402_dontWatchDeletedDir() #endif } -void tst_QFiledialog::task203703_returnProperSeparator() +void tst_QFileDialog2::task203703_returnProperSeparator() { QDir current = QDir::currentPath(); current.mkdir("aaaaaaaaaaaaaaaaaa"); @@ -687,7 +687,7 @@ void tst_QFiledialog::task203703_returnProperSeparator() current.rmdir("aaaaaaaaaaaaaaaaaa"); } -void tst_QFiledialog::task228844_ensurePreviousSorting() +void tst_QFileDialog2::task228844_ensurePreviousSorting() { QDir current = QDir::currentPath(); current.mkdir("aaaaaaaaaaaaaaaaaa"); @@ -789,7 +789,7 @@ void tst_QFiledialog::task228844_ensurePreviousSorting() } -void tst_QFiledialog::task239706_editableFilterCombo() +void tst_QFileDialog2::task239706_editableFilterCombo() { QNonNativeFileDialog d; d.setNameFilter("*.cpp *.h"); @@ -812,7 +812,7 @@ void tst_QFiledialog::task239706_editableFilterCombo() QTest::keyPress(filterCombo, Qt::Key_Enter); // should not trigger assertion failure } -void tst_QFiledialog::task218353_relativePaths() +void tst_QFileDialog2::task218353_relativePaths() { QDir appDir = QDir::current(); QVERIFY(appDir.cdUp() != false); @@ -829,7 +829,7 @@ void tst_QFiledialog::task218353_relativePaths() appDir.rmdir("test"); } -void tst_QFiledialog::task251321_sideBarHiddenEntries() +void tst_QFileDialog2::task251321_sideBarHiddenEntries() { #if defined QT_BUILD_INTERNAL QNonNativeFileDialog fd; @@ -889,7 +889,7 @@ public : }; #endif -void tst_QFiledialog::task251341_sideBarRemoveEntries() +void tst_QFileDialog2::task251341_sideBarRemoveEntries() { #if defined QT_BUILD_INTERNAL QNonNativeFileDialog fd; @@ -954,7 +954,7 @@ void tst_QFiledialog::task251341_sideBarRemoveEntries() #endif } -void tst_QFiledialog::task254490_selectFileMultipleTimes() +void tst_QFileDialog2::task254490_selectFileMultipleTimes() { QString tempPath = QDir::tempPath(); QTemporaryFile *t; @@ -986,7 +986,7 @@ void tst_QFiledialog::task254490_selectFileMultipleTimes() t->deleteLater(); } -void tst_QFiledialog::task257579_sideBarWithNonCleanUrls() +void tst_QFileDialog2::task257579_sideBarWithNonCleanUrls() { #if defined QT_BUILD_INTERNAL QDir tempDir = QDir::temp(); @@ -1012,7 +1012,7 @@ void tst_QFiledialog::task257579_sideBarWithNonCleanUrls() #endif } -void tst_QFiledialog::task259105_filtersCornerCases() +void tst_QFileDialog2::task259105_filtersCornerCases() { QNonNativeFileDialog fd(0, "TestFileDialog"); fd.setNameFilter(QLatin1String("All Files! (*);;Text Files (*.txt)")); @@ -1056,7 +1056,7 @@ void tst_QFiledialog::task259105_filtersCornerCases() QCOMPARE(filters->currentText(), QLatin1String("Text Files")); } -void tst_QFiledialog::QTBUG4419_lineEditSelectAll() +void tst_QFileDialog2::QTBUG4419_lineEditSelectAll() { QString tempPath = QDir::tempPath(); QTemporaryFile *t; @@ -1082,7 +1082,7 @@ void tst_QFiledialog::QTBUG4419_lineEditSelectAll() QCOMPARE(tempPath + QChar('/') + lineEdit->selectedText(), t->fileName()); } -void tst_QFiledialog::QTBUG6558_showDirsOnly() +void tst_QFileDialog2::QTBUG6558_showDirsOnly() { const QString tempPath = QDir::tempPath(); QDir dirTemp(tempPath); @@ -1148,7 +1148,7 @@ void tst_QFiledialog::QTBUG6558_showDirsOnly() dirTemp.rmdir(tempName); } -void tst_QFiledialog::QTBUG4842_selectFilterWithHideNameFilterDetails() +void tst_QFileDialog2::QTBUG4842_selectFilterWithHideNameFilterDetails() { QStringList filtersStr; filtersStr << "Images (*.png *.xpm *.jpg)" << "Text files (*.txt)" << "XML files (*.xml)"; @@ -1188,5 +1188,5 @@ void tst_QFiledialog::QTBUG4842_selectFilterWithHideNameFilterDetails() } -QTEST_MAIN(tst_QFiledialog) +QTEST_MAIN(tst_QFileDialog2) #include "tst_qfiledialog2.moc" diff --git a/tests/auto/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp b/tests/auto/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp index 29cb341..4f7822d 100644 --- a/tests/auto/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp +++ b/tests/auto/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp @@ -90,7 +90,7 @@ int distance(TestIterator &a, TestIterator &b) using namespace QtConcurrent; -class tst_iteratekernel: public QObject +class tst_QtConcurrentIterateKernel: public QObject { Q_OBJECT private slots: @@ -149,13 +149,13 @@ public: }; -void tst_iteratekernel::instantiate() +void tst_QtConcurrentIterateKernel::instantiate() { startThreadEngine(new PrintFor(0, 40)).startBlocking(); QCOMPARE((int)iterations, 40); } -void tst_iteratekernel::cancel() +void tst_QtConcurrentIterateKernel::cancel() { { QFuture f = startThreadEngine(new SleepPrintFor(0, 40)).startAsynchronously(); @@ -182,7 +182,7 @@ public: } }; -void tst_iteratekernel::stresstest() +void tst_QtConcurrentIterateKernel::stresstest() { const int iterations = 1000; const int times = 50; @@ -194,7 +194,7 @@ void tst_iteratekernel::stresstest() } } -void tst_iteratekernel::noIterations() +void tst_QtConcurrentIterateKernel::noIterations() { const int times = 20000; for (int i = 0; i < times; ++i) @@ -242,7 +242,7 @@ public: bool throttling; }; -void tst_iteratekernel::throttling() +void tst_QtConcurrentIterateKernel::throttling() { const int totalIterations = 400; iterations = 0; @@ -271,7 +271,7 @@ public: } }; -void tst_iteratekernel::blockSize() +void tst_QtConcurrentIterateKernel::blockSize() { #ifdef QT_NO_STL QSKIP("Missing stl iterators prevent correct block size calculation", SkipAll); @@ -296,7 +296,7 @@ public: }; -void tst_iteratekernel::multipleResults() +void tst_QtConcurrentIterateKernel::multipleResults() { #ifdef QT_NO_STL QSKIP("Missing stl iterators prevent correct summation", SkipAll); @@ -320,7 +320,7 @@ public: } }; -void tst_iteratekernel::instantiateWhile() +void tst_QtConcurrentIterateKernel::instantiateWhile() { PrintWhile w; w.startBlocking(); @@ -339,7 +339,7 @@ public: } }; -void tst_iteratekernel::stresstestWhile() +void tst_QtConcurrentIterateKernel::stresstestWhile() { int iterations = 100000; StressWhile w(iterations); @@ -348,7 +348,7 @@ void tst_iteratekernel::stresstestWhile() } #endif -QTEST_MAIN(tst_iteratekernel) +QTEST_MAIN(tst_QtConcurrentIterateKernel) #include "tst_qtconcurrentiteratekernel.moc" diff --git a/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp b/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp index d3417b1..894bac4 100644 --- a/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp +++ b/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp @@ -56,7 +56,7 @@ Q_DECLARE_METATYPE(QList); Q_DECLARE_METATYPE(QList); Q_DECLARE_METATYPE(QList); -class tst_map: public QObject +class tst_QtConcurrentMap: public QObject { Q_OBJECT private slots: @@ -114,7 +114,7 @@ public: Q_DECLARE_METATYPE(QList); -void tst_map::map() +void tst_QtConcurrentMap::map() { // functors take arguments by reference, modifying the sequence in place { @@ -246,7 +246,7 @@ void tst_map::map() #endif } -void tst_map::blocking_map() +void tst_QtConcurrentMap::blocking_map() { // functors take arguments by reference, modifying the sequence in place { @@ -428,7 +428,7 @@ public: } }; -void tst_map::mapped() +void tst_QtConcurrentMap::mapped() { QList list; list << 1 << 2 << 3; @@ -790,7 +790,7 @@ void tst_map::mapped() } } -void tst_map::blocking_mapped() +void tst_QtConcurrentMap::blocking_mapped() { QList list; list << 1 << 2 << 3; @@ -1244,7 +1244,7 @@ public: } }; -void tst_map::mappedReduced() +void tst_QtConcurrentMap::mappedReduced() { QList list; list << 1 << 2 << 3; @@ -1625,7 +1625,7 @@ void tst_map::mappedReduced() // ### the same as above, with an initial result value } -void tst_map::blocking_mappedReduced() +void tst_QtConcurrentMap::blocking_mappedReduced() { QList list; list << 1 << 2 << 3; @@ -2010,7 +2010,7 @@ int sleeper(int val) return val; } -void tst_map::assignResult() +void tst_QtConcurrentMap::assignResult() { const QList startList = QList() << 0 << 1 << 2; QList list = QtConcurrent::blockingMapped(startList, sleeper); @@ -2077,7 +2077,7 @@ public: Q_DECLARE_METATYPE(QVector); Q_DECLARE_METATYPE(QList); -void tst_map::functionOverloads() +void tst_QtConcurrentMap::functionOverloads() { QList intList; const QList constIntList; @@ -2159,7 +2159,7 @@ void fastReduce(int &result, const InstanceCounter&) ++result; } -void tst_map::throttling() +void tst_QtConcurrentMap::throttling() { const int itemcount = 100; const int allowedTemporaries = QThread::idealThreadCount() * 40; @@ -2208,7 +2208,7 @@ void throwMapper(int &e) throw QtConcurrent::Exception(); } -void tst_map::exceptions() +void tst_QtConcurrentMap::exceptions() { bool caught = false; try { @@ -2228,7 +2228,7 @@ int mapper(const int &i) return i; } -void tst_map::incrementalResults() +void tst_QtConcurrentMap::incrementalResults() { const int count = 200; QList ints; @@ -2256,7 +2256,7 @@ void tst_map::incrementalResults() Test that mapped does not cause deep copies when holding references to Qt containers. */ -void tst_map::noDetatch() +void tst_QtConcurrentMap::noDetatch() { { QList l = QList() << 1; @@ -2299,7 +2299,7 @@ void tst_map::noDetatch() } -void tst_map::stlContainers() +void tst_QtConcurrentMap::stlContainers() { #ifdef QT_NO_STL QSKIP("Qt compiled without STL support", SkipAll); @@ -2331,7 +2331,7 @@ InstanceCounter ic_fn(const InstanceCounter & ic) // Verify that held results are deleted when a future is // assigned over with operator == -void tst_map::qFutureAssignmentLeak() +void tst_QtConcurrentMap::qFutureAssignmentLeak() { currentInstanceCount = 0; peakInstanceCount = 0; @@ -2370,7 +2370,7 @@ void add(int &result, const int &sum) result += sum; } -void tst_map::stressTest() +void tst_QtConcurrentMap::stressTest() { const int listSize = 1000; const int sum = (listSize - 1) * (listSize / 2); @@ -2399,26 +2399,26 @@ void tst_map::stressTest() } } -QTEST_MAIN(tst_map) +QTEST_MAIN(tst_QtConcurrentMap) #else -void tst_map::map() {} -void tst_map::blocking_map() {} -void tst_map::mapped() {} -void tst_map::blocking_mapped() {} -void tst_map::mappedReduced() {} -void tst_map::blocking_mappedReduced() {} -void tst_map::assignResult() {} -void tst_map::functionOverloads() {} +void tst_QtConcurrentMap::map() {} +void tst_QtConcurrentMap::blocking_map() {} +void tst_QtConcurrentMap::mapped() {} +void tst_QtConcurrentMap::blocking_mapped() {} +void tst_QtConcurrentMap::mappedReduced() {} +void tst_QtConcurrentMap::blocking_mappedReduced() {} +void tst_QtConcurrentMap::assignResult() {} +void tst_QtConcurrentMap::functionOverloads() {} #ifndef QT_NO_EXCEPTIONS -void tst_map::exceptions() {} +void tst_QtConcurrentMap::exceptions() {} #endif -void tst_map::incrementalResults() {} -void tst_map::stressTest() {} -void tst_map::throttling() {} -void tst_map::stlContainers() {} -void tst_map::noDetatch() {} +void tst_QtConcurrentMap::incrementalResults() {} +void tst_QtConcurrentMap::stressTest() {} +void tst_QtConcurrentMap::throttling() {} +void tst_QtConcurrentMap::stlContainers() {} +void tst_QtConcurrentMap::noDetatch() {} QTEST_NOOP_MAIN diff --git a/tests/auto/qtconcurrentrun/tst_qtconcurrentrun.cpp b/tests/auto/qtconcurrentrun/tst_qtconcurrentrun.cpp index b9ab6d3..8fdc50c 100644 --- a/tests/auto/qtconcurrentrun/tst_qtconcurrentrun.cpp +++ b/tests/auto/qtconcurrentrun/tst_qtconcurrentrun.cpp @@ -49,7 +49,7 @@ using namespace QtConcurrent; -class TestRunFunction: public QObject +class tst_QtConcurrentRun: public QObject { Q_OBJECT private slots: @@ -73,7 +73,7 @@ private slots: #endif -QTEST_MAIN(TestRunFunction) +QTEST_MAIN(tst_QtConcurrentRun) void light() { @@ -91,7 +91,7 @@ void heavy() } -void TestRunFunction::runLightFunction() +void tst_QtConcurrentRun::runLightFunction() { qDebug("starting function"); QFuture future = run(F(light)); @@ -100,7 +100,7 @@ void TestRunFunction::runLightFunction() qDebug("done"); } -void TestRunFunction::runHeavyFunction() +void tst_QtConcurrentRun::runHeavyFunction() { qDebug("starting function"); QFuture future = run(F(heavy)); @@ -141,7 +141,7 @@ public: int operator()(int in) const { return in; } }; -void TestRunFunction::returnValue() +void tst_QtConcurrentRun::returnValue() { QFuture f; @@ -217,7 +217,7 @@ struct TestConstClass void fooInt(int) const { }; }; -void TestRunFunction::functionObject() +void tst_QtConcurrentRun::functionObject() { QFuture f; TestClass c; @@ -235,7 +235,7 @@ void TestRunFunction::functionObject() } -void TestRunFunction::memberFunctions() +void tst_QtConcurrentRun::memberFunctions() { TestClass c; @@ -278,7 +278,7 @@ void stringIntFunction(QString) } -void TestRunFunction::implicitConvertibleTypes() +void tst_QtConcurrentRun::implicitConvertibleTypes() { double d; run(F(doubleFunction), d).waitForFinished(); @@ -294,7 +294,7 @@ void TestRunFunction::implicitConvertibleTypes() void fn() { } -void TestRunFunction::runWaitLoop() +void tst_QtConcurrentRun::runWaitLoop() { for (int i = 0; i < 1000; ++i) run(fn).waitForFinished(); @@ -324,7 +324,7 @@ int recursiveResult(int level) return 1; } -void TestRunFunction::recursive() +void tst_QtConcurrentRun::recursive() { int levels = 15; @@ -375,7 +375,7 @@ int fn2(double, int *) } #if 0 -void TestRunFunction::createFunctor() +void tst_QtConcurrentRun::createFunctor() { e = 0; ::QtConcurrent::createFunctor(vfn0)(); diff --git a/tests/auto/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp b/tests/auto/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp index 6f586d7..23fd19b 100644 --- a/tests/auto/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp +++ b/tests/auto/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp @@ -48,7 +48,7 @@ using namespace QtConcurrent; -class tst_threadengine: public QObject +class tst_QtConcurrentThreadEngine: public QObject { Q_OBJECT public: @@ -79,7 +79,7 @@ public: } }; -void tst_threadengine::runDirectly() +void tst_QtConcurrentThreadEngine::runDirectly() { { PrintUser engine; @@ -120,7 +120,7 @@ public: bool done; }; -void tst_threadengine::result() +void tst_QtConcurrentThreadEngine::result() { StringResultUser engine; QCOMPARE(*engine.startBlocking(), QString("Foo")); @@ -147,7 +147,7 @@ public: bool done; }; -void tst_threadengine::runThroughStarter() +void tst_QtConcurrentThreadEngine::runThroughStarter() { { ThreadEngineStarter starter = startThreadEngine(new StringResultUser()); @@ -180,7 +180,7 @@ public: } }; -void tst_threadengine::cancel() +void tst_QtConcurrentThreadEngine::cancel() { { CancelUser *engine = new CancelUser(); @@ -234,7 +234,7 @@ public: // Test that a user task with a thread function that always // want to be throttled still completes. The thread engine // should make keep one thread running at all times. -void tst_threadengine::throttle() +void tst_QtConcurrentThreadEngine::throttle() { const int repeats = 10; for (int i = 0; i < repeats; ++i) { @@ -280,7 +280,7 @@ public: bool finishing; }; -void tst_threadengine::threadCount() +void tst_QtConcurrentThreadEngine::threadCount() { const int repeats = 10; for (int i = 0; i < repeats; ++i) { @@ -320,7 +320,7 @@ public: }; -void tst_threadengine::multipleResults() +void tst_QtConcurrentThreadEngine::multipleResults() { MultipleResultsUser *engine = new MultipleResultsUser(); QFuture f = engine->startAsynchronously(); @@ -351,7 +351,7 @@ public: } }; -void tst_threadengine::stresstest() +void tst_QtConcurrentThreadEngine::stresstest() { const int times = 20000; @@ -379,7 +379,7 @@ public: ThreadFunctionResult threadFunction() { QTest::qSleep(sleepTime); return ThreadFinished; } }; -void tst_threadengine::cancelQueuedSlowUser() +void tst_QtConcurrentThreadEngine::cancelQueuedSlowUser() { const int times = 100; @@ -436,7 +436,7 @@ public: QThread *blockThread; }; -void tst_threadengine::exceptions() +void tst_QtConcurrentThreadEngine::exceptions() { // Asynchronous mode: { @@ -527,7 +527,7 @@ void tst_threadengine::exceptions() #endif -QTEST_MAIN(tst_threadengine) +QTEST_MAIN(tst_QtConcurrentThreadEngine) #include "tst_qtconcurrentthreadengine.moc" diff --git a/tests/auto/qvectornd/tst_qvectornd.cpp b/tests/auto/qvectornd/tst_qvectornd.cpp index 2be7264..2850f32 100644 --- a/tests/auto/qvectornd/tst_qvectornd.cpp +++ b/tests/auto/qvectornd/tst_qvectornd.cpp @@ -45,12 +45,12 @@ #include #include -class tst_QVector : public QObject +class tst_QVectorND : public QObject { Q_OBJECT public: - tst_QVector() {} - ~tst_QVector() {} + tst_QVectorND() {} + ~tst_QVectorND() {} private slots: void create2(); @@ -155,7 +155,7 @@ static bool fuzzyCompare(qreal x, qreal y) // Test the creation of QVector2D objects in various ways: // construct, copy, and modify. -void tst_QVector::create2() +void tst_QVectorND::create2() { QVector2D null; QCOMPARE(null.x(), (qreal)0.0f); @@ -244,7 +244,7 @@ void tst_QVector::create2() // Test the creation of QVector3D objects in various ways: // construct, copy, and modify. -void tst_QVector::create3() +void tst_QVectorND::create3() { QVector3D null; QCOMPARE(null.x(), (qreal)0.0f); @@ -370,7 +370,7 @@ void tst_QVector::create3() // Test the creation of QVector4D objects in various ways: // construct, copy, and modify. -void tst_QVector::create4() +void tst_QVectorND::create4() { QVector4D null; QCOMPARE(null.x(), (qreal)0.0f); @@ -556,7 +556,7 @@ void tst_QVector::create4() } // Test vector length computation for 2D vectors. -void tst_QVector::length2_data() +void tst_QVectorND::length2_data() { QTest::addColumn("x"); QTest::addColumn("y"); @@ -569,7 +569,7 @@ void tst_QVector::length2_data() QTest::newRow("-1y") << (qreal)0.0f << (qreal)-1.0f << (qreal)1.0f; QTest::newRow("two") << (qreal)2.0f << (qreal)-2.0f << (qreal)qSqrt(8.0f); } -void tst_QVector::length2() +void tst_QVectorND::length2() { QFETCH(qreal, x); QFETCH(qreal, y); @@ -581,7 +581,7 @@ void tst_QVector::length2() } // Test vector length computation for 3D vectors. -void tst_QVector::length3_data() +void tst_QVectorND::length3_data() { QTest::addColumn("x"); QTest::addColumn("y"); @@ -597,7 +597,7 @@ void tst_QVector::length3_data() QTest::newRow("-1z") << (qreal)0.0f << (qreal)0.0f << (qreal)-1.0f << (qreal)1.0f; QTest::newRow("two") << (qreal)2.0f << (qreal)-2.0f << (qreal)2.0f << (qreal)qSqrt(12.0f); } -void tst_QVector::length3() +void tst_QVectorND::length3() { QFETCH(qreal, x); QFETCH(qreal, y); @@ -610,7 +610,7 @@ void tst_QVector::length3() } // Test vector length computation for 4D vectors. -void tst_QVector::length4_data() +void tst_QVectorND::length4_data() { QTest::addColumn("x"); QTest::addColumn("y"); @@ -629,7 +629,7 @@ void tst_QVector::length4_data() QTest::newRow("-1w") << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)-1.0f << (qreal)1.0f; QTest::newRow("two") << (qreal)2.0f << (qreal)-2.0f << (qreal)2.0f << (qreal)2.0f << (qreal)qSqrt(16.0f); } -void tst_QVector::length4() +void tst_QVectorND::length4() { QFETCH(qreal, x); QFETCH(qreal, y); @@ -643,12 +643,12 @@ void tst_QVector::length4() } // Test the unit vector conversion for 2D vectors. -void tst_QVector::normalized2_data() +void tst_QVectorND::normalized2_data() { // Use the same test data as the length test. length2_data(); } -void tst_QVector::normalized2() +void tst_QVectorND::normalized2() { QFETCH(qreal, x); QFETCH(qreal, y); @@ -665,12 +665,12 @@ void tst_QVector::normalized2() } // Test the unit vector conversion for 3D vectors. -void tst_QVector::normalized3_data() +void tst_QVectorND::normalized3_data() { // Use the same test data as the length test. length3_data(); } -void tst_QVector::normalized3() +void tst_QVectorND::normalized3() { QFETCH(qreal, x); QFETCH(qreal, y); @@ -689,12 +689,12 @@ void tst_QVector::normalized3() } // Test the unit vector conversion for 4D vectors. -void tst_QVector::normalized4_data() +void tst_QVectorND::normalized4_data() { // Use the same test data as the length test. length4_data(); } -void tst_QVector::normalized4() +void tst_QVectorND::normalized4() { QFETCH(qreal, x); QFETCH(qreal, y); @@ -715,12 +715,12 @@ void tst_QVector::normalized4() } // Test the unit vector conversion for 2D vectors. -void tst_QVector::normalize2_data() +void tst_QVectorND::normalize2_data() { // Use the same test data as the length test. length2_data(); } -void tst_QVector::normalize2() +void tst_QVectorND::normalize2() { QFETCH(qreal, x); QFETCH(qreal, y); @@ -735,12 +735,12 @@ void tst_QVector::normalize2() } // Test the unit vector conversion for 3D vectors. -void tst_QVector::normalize3_data() +void tst_QVectorND::normalize3_data() { // Use the same test data as the length test. length3_data(); } -void tst_QVector::normalize3() +void tst_QVectorND::normalize3() { QFETCH(qreal, x); QFETCH(qreal, y); @@ -756,12 +756,12 @@ void tst_QVector::normalize3() } // Test the unit vector conversion for 4D vectors. -void tst_QVector::normalize4_data() +void tst_QVectorND::normalize4_data() { // Use the same test data as the length test. length4_data(); } -void tst_QVector::normalize4() +void tst_QVectorND::normalize4() { QFETCH(qreal, x); QFETCH(qreal, y); @@ -778,7 +778,7 @@ void tst_QVector::normalize4() } // Test the comparison operators for 2D vectors. -void tst_QVector::compare2() +void tst_QVectorND::compare2() { QVector2D v1(1, 2); QVector2D v2(1, 2); @@ -791,7 +791,7 @@ void tst_QVector::compare2() } // Test the comparison operators for 3D vectors. -void tst_QVector::compare3() +void tst_QVectorND::compare3() { QVector3D v1(1, 2, 4); QVector3D v2(1, 2, 4); @@ -806,7 +806,7 @@ void tst_QVector::compare3() } // Test the comparison operators for 4D vectors. -void tst_QVector::compare4() +void tst_QVectorND::compare4() { QVector4D v1(1, 2, 4, 8); QVector4D v2(1, 2, 4, 8); @@ -823,7 +823,7 @@ void tst_QVector::compare4() } // Test vector addition for 2D vectors. -void tst_QVector::add2_data() +void tst_QVectorND::add2_data() { QTest::addColumn("x1"); QTest::addColumn("y1"); @@ -852,7 +852,7 @@ void tst_QVector::add2_data() << (qreal)4.0f << (qreal)5.0f << (qreal)5.0f << (qreal)7.0f; } -void tst_QVector::add2() +void tst_QVectorND::add2() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -876,7 +876,7 @@ void tst_QVector::add2() } // Test vector addition for 3D vectors. -void tst_QVector::add3_data() +void tst_QVectorND::add3_data() { QTest::addColumn("x1"); QTest::addColumn("y1"); @@ -913,7 +913,7 @@ void tst_QVector::add3_data() << (qreal)4.0f << (qreal)5.0f << (qreal)-6.0f << (qreal)5.0f << (qreal)7.0f << (qreal)-3.0f; } -void tst_QVector::add3() +void tst_QVectorND::add3() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -941,7 +941,7 @@ void tst_QVector::add3() } // Test vector addition for 4D vectors. -void tst_QVector::add4_data() +void tst_QVectorND::add4_data() { QTest::addColumn("x1"); QTest::addColumn("y1"); @@ -986,7 +986,7 @@ void tst_QVector::add4_data() << (qreal)4.0f << (qreal)5.0f << (qreal)-6.0f << (qreal)9.0f << (qreal)5.0f << (qreal)7.0f << (qreal)-3.0f << (qreal)17.0f; } -void tst_QVector::add4() +void tst_QVectorND::add4() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1018,12 +1018,12 @@ void tst_QVector::add4() } // Test vector subtraction for 2D vectors. -void tst_QVector::subtract2_data() +void tst_QVectorND::subtract2_data() { // Use the same test data as the add test. add2_data(); } -void tst_QVector::subtract2() +void tst_QVectorND::subtract2() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1055,12 +1055,12 @@ void tst_QVector::subtract2() } // Test vector subtraction for 3D vectors. -void tst_QVector::subtract3_data() +void tst_QVectorND::subtract3_data() { // Use the same test data as the add test. add3_data(); } -void tst_QVector::subtract3() +void tst_QVectorND::subtract3() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1097,12 +1097,12 @@ void tst_QVector::subtract3() } // Test vector subtraction for 4D vectors. -void tst_QVector::subtract4_data() +void tst_QVectorND::subtract4_data() { // Use the same test data as the add test. add4_data(); } -void tst_QVector::subtract4() +void tst_QVectorND::subtract4() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1144,7 +1144,7 @@ void tst_QVector::subtract4() } // Test component-wise vector multiplication for 2D vectors. -void tst_QVector::multiply2_data() +void tst_QVectorND::multiply2_data() { QTest::addColumn("x1"); QTest::addColumn("y1"); @@ -1173,7 +1173,7 @@ void tst_QVector::multiply2_data() << (qreal)4.0f << (qreal)5.0f << (qreal)4.0f << (qreal)10.0f; } -void tst_QVector::multiply2() +void tst_QVectorND::multiply2() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1197,7 +1197,7 @@ void tst_QVector::multiply2() } // Test component-wise vector multiplication for 3D vectors. -void tst_QVector::multiply3_data() +void tst_QVectorND::multiply3_data() { QTest::addColumn("x1"); QTest::addColumn("y1"); @@ -1234,7 +1234,7 @@ void tst_QVector::multiply3_data() << (qreal)4.0f << (qreal)5.0f << (qreal)-6.0f << (qreal)4.0f << (qreal)10.0f << (qreal)-18.0f; } -void tst_QVector::multiply3() +void tst_QVectorND::multiply3() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1262,7 +1262,7 @@ void tst_QVector::multiply3() } // Test component-wise vector multiplication for 4D vectors. -void tst_QVector::multiply4_data() +void tst_QVectorND::multiply4_data() { QTest::addColumn("x1"); QTest::addColumn("y1"); @@ -1307,7 +1307,7 @@ void tst_QVector::multiply4_data() << (qreal)4.0f << (qreal)5.0f << (qreal)-6.0f << (qreal)9.0f << (qreal)4.0f << (qreal)10.0f << (qreal)-18.0f << (qreal)72.0f; } -void tst_QVector::multiply4() +void tst_QVectorND::multiply4() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1339,7 +1339,7 @@ void tst_QVector::multiply4() } // Test vector multiplication by a factor for 2D vectors. -void tst_QVector::multiplyFactor2_data() +void tst_QVectorND::multiplyFactor2_data() { QTest::addColumn("x1"); QTest::addColumn("y1"); @@ -1372,7 +1372,7 @@ void tst_QVector::multiplyFactor2_data() << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; } -void tst_QVector::multiplyFactor2() +void tst_QVectorND::multiplyFactor2() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1395,7 +1395,7 @@ void tst_QVector::multiplyFactor2() } // Test vector multiplication by a factor for 3D vectors. -void tst_QVector::multiplyFactor3_data() +void tst_QVectorND::multiplyFactor3_data() { QTest::addColumn("x1"); QTest::addColumn("y1"); @@ -1435,7 +1435,7 @@ void tst_QVector::multiplyFactor3_data() << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; } -void tst_QVector::multiplyFactor3() +void tst_QVectorND::multiplyFactor3() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1461,7 +1461,7 @@ void tst_QVector::multiplyFactor3() } // Test vector multiplication by a factor for 4D vectors. -void tst_QVector::multiplyFactor4_data() +void tst_QVectorND::multiplyFactor4_data() { QTest::addColumn("x1"); QTest::addColumn("y1"); @@ -1508,7 +1508,7 @@ void tst_QVector::multiplyFactor4_data() << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; } -void tst_QVector::multiplyFactor4() +void tst_QVectorND::multiplyFactor4() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1537,12 +1537,12 @@ void tst_QVector::multiplyFactor4() } // Test vector division by a factor for 2D vectors. -void tst_QVector::divide2_data() +void tst_QVectorND::divide2_data() { // Use the same test data as the multiply test. multiplyFactor2_data(); } -void tst_QVector::divide2() +void tst_QVectorND::divide2() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1567,12 +1567,12 @@ void tst_QVector::divide2() } // Test vector division by a factor for 3D vectors. -void tst_QVector::divide3_data() +void tst_QVectorND::divide3_data() { // Use the same test data as the multiply test. multiplyFactor3_data(); } -void tst_QVector::divide3() +void tst_QVectorND::divide3() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1600,12 +1600,12 @@ void tst_QVector::divide3() } // Test vector division by a factor for 4D vectors. -void tst_QVector::divide4_data() +void tst_QVectorND::divide4_data() { // Use the same test data as the multiply test. multiplyFactor4_data(); } -void tst_QVector::divide4() +void tst_QVectorND::divide4() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1636,12 +1636,12 @@ void tst_QVector::divide4() } // Test vector negation for 2D vectors. -void tst_QVector::negate2_data() +void tst_QVectorND::negate2_data() { // Use the same test data as the add test. add2_data(); } -void tst_QVector::negate2() +void tst_QVectorND::negate2() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1653,12 +1653,12 @@ void tst_QVector::negate2() } // Test vector negation for 3D vectors. -void tst_QVector::negate3_data() +void tst_QVectorND::negate3_data() { // Use the same test data as the add test. add3_data(); } -void tst_QVector::negate3() +void tst_QVectorND::negate3() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1671,12 +1671,12 @@ void tst_QVector::negate3() } // Test vector negation for 4D vectors. -void tst_QVector::negate4_data() +void tst_QVectorND::negate4_data() { // Use the same test data as the add test. add4_data(); } -void tst_QVector::negate4() +void tst_QVectorND::negate4() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1690,7 +1690,7 @@ void tst_QVector::negate4() } // Test the computation of vector cross-products. -void tst_QVector::crossProduct_data() +void tst_QVectorND::crossProduct_data() { QTest::addColumn("x1"); QTest::addColumn("y1"); @@ -1721,7 +1721,7 @@ void tst_QVector::crossProduct_data() << (qreal)-3.0f << (qreal)6.0f << (qreal)-3.0f << (qreal)32.0f; } -void tst_QVector::crossProduct() +void tst_QVectorND::crossProduct() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1751,12 +1751,12 @@ void tst_QVector::crossProduct() } // Test the computation of normals. -void tst_QVector::normal_data() +void tst_QVectorND::normal_data() { // Use the same test data as the crossProduct test. crossProduct_data(); } -void tst_QVector::normal() +void tst_QVectorND::normal() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1780,7 +1780,7 @@ void tst_QVector::normal() } // Test distance to plane calculations. -void tst_QVector::distanceToPlane_data() +void tst_QVectorND::distanceToPlane_data() { QTest::addColumn("x1"); // Point on plane QTest::addColumn("y1"); @@ -1823,7 +1823,7 @@ void tst_QVector::distanceToPlane_data() << (qreal)0.0f << (qreal)2.0f << (qreal)0.0f << (qreal)-2.0f; } -void tst_QVector::distanceToPlane() +void tst_QVectorND::distanceToPlane() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1853,7 +1853,7 @@ void tst_QVector::distanceToPlane() } // Test distance to line calculations. -void tst_QVector::distanceToLine_data() +void tst_QVectorND::distanceToLine_data() { QTest::addColumn("x1"); // Point on line QTest::addColumn("y1"); @@ -1896,7 +1896,7 @@ void tst_QVector::distanceToLine_data() << (qreal)0.0f << (qreal)5.0f << (qreal)0.0f << (qreal)5.0f; } -void tst_QVector::distanceToLine() +void tst_QVectorND::distanceToLine() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1917,7 +1917,7 @@ void tst_QVector::distanceToLine() } // Test the computation of dot products for 2D vectors. -void tst_QVector::dotProduct2_data() +void tst_QVectorND::dotProduct2_data() { QTest::addColumn("x1"); QTest::addColumn("y1"); @@ -1940,7 +1940,7 @@ void tst_QVector::dotProduct2_data() << (qreal)4.0f << (qreal)5.0f << (qreal)14.0f; } -void tst_QVector::dotProduct2() +void tst_QVectorND::dotProduct2() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1960,12 +1960,12 @@ void tst_QVector::dotProduct2() } // Test the computation of dot products for 3D vectors. -void tst_QVector::dotProduct3_data() +void tst_QVectorND::dotProduct3_data() { // Use the same test data as the crossProduct test. crossProduct_data(); } -void tst_QVector::dotProduct3() +void tst_QVectorND::dotProduct3() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1994,7 +1994,7 @@ void tst_QVector::dotProduct3() } // Test the computation of dot products for 4D vectors. -void tst_QVector::dotProduct4_data() +void tst_QVectorND::dotProduct4_data() { QTest::addColumn("x1"); QTest::addColumn("y1"); @@ -2021,7 +2021,7 @@ void tst_QVector::dotProduct4_data() << (qreal)4.0f << (qreal)5.0f << (qreal)6.0f << (qreal)7.0f << (qreal)60.0f; } -void tst_QVector::dotProduct4() +void tst_QVectorND::dotProduct4() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -2044,14 +2044,14 @@ void tst_QVector::dotProduct4() QCOMPARE(QVector4D::dotProduct(v1, v2), d); } -class tst_QVectorProperties : public QObject +class tst_QVectorNDProperties : public QObject { Q_OBJECT Q_PROPERTY(QVector2D vector2D READ vector2D WRITE setVector2D) Q_PROPERTY(QVector3D vector3D READ vector3D WRITE setVector3D) Q_PROPERTY(QVector4D vector4D READ vector4D WRITE setVector4D) public: - tst_QVectorProperties(QObject *parent = 0) : QObject(parent) {} + tst_QVectorNDProperties(QObject *parent = 0) : QObject(parent) {} QVector2D vector2D() const { return v2; } void setVector2D(const QVector2D& value) { v2 = value; } @@ -2069,9 +2069,9 @@ private: }; // Test getting and setting vector properties via the metaobject system. -void tst_QVector::properties() +void tst_QVectorND::properties() { - tst_QVectorProperties obj; + tst_QVectorNDProperties obj; obj.setVector2D(QVector2D(1.0f, 2.0f)); obj.setVector3D(QVector3D(3.0f, 4.0f, 5.0f)); @@ -2115,7 +2115,7 @@ void tst_QVector::properties() QCOMPARE(v4.w(), (qreal)-9.0f); } -void tst_QVector::metaTypes() +void tst_QVectorND::metaTypes() { QVERIFY(QMetaType::type("QVector2D") == QMetaType::QVector2D); QVERIFY(QMetaType::type("QVector3D") == QMetaType::QVector3D); @@ -2137,6 +2137,6 @@ void tst_QVector::metaTypes() QVERIFY(qMetaTypeId() == QMetaType::QVector4D); } -QTEST_APPLESS_MAIN(tst_QVector) +QTEST_APPLESS_MAIN(tst_QVectorND) #include "tst_qvectornd.moc" diff --git a/tests/auto/xmlpatternsdiagnosticsts/tst_xmlpatternsdiagnosticsts.cpp b/tests/auto/xmlpatternsdiagnosticsts/tst_xmlpatternsdiagnosticsts.cpp index 4a11404..f4f6181 100644 --- a/tests/auto/xmlpatternsdiagnosticsts/tst_xmlpatternsdiagnosticsts.cpp +++ b/tests/auto/xmlpatternsdiagnosticsts/tst_xmlpatternsdiagnosticsts.cpp @@ -52,25 +52,25 @@ \since 4.5 \brief Test QtXmlPatterns test suite driver in tests/auto/xmlpatternsxqts/lib/. */ -class tst_XmlPatternsXSLTS : public tst_SuiteTest +class tst_XmlPatternsDiagnosticsTS : public tst_SuiteTest { Q_OBJECT public: - tst_XmlPatternsXSLTS(); + tst_XmlPatternsDiagnosticsTS(); protected: virtual void catalogPath(QString &write) const; }; -tst_XmlPatternsXSLTS::tst_XmlPatternsXSLTS() : tst_SuiteTest(tst_SuiteTest::XQuerySuite, true) +tst_XmlPatternsDiagnosticsTS::tst_XmlPatternsDiagnosticsTS() : tst_SuiteTest(tst_SuiteTest::XQuerySuite, true) { } -void tst_XmlPatternsXSLTS::catalogPath(QString &write) const +void tst_XmlPatternsDiagnosticsTS::catalogPath(QString &write) const { write = QLatin1String("TestSuite/DiagnosticsCatalog.xml"); } -QTEST_MAIN(tst_XmlPatternsXSLTS) +QTEST_MAIN(tst_XmlPatternsDiagnosticsTS) #include "tst_xmlpatternsdiagnosticsts.moc" #else -- cgit v0.12 From 00d25e88ba57241d840ec4d81d75a3853520ba37 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Mon, 22 Mar 2010 09:42:40 +0000 Subject: Updated dist/changes-4.6.3 --- dist/changes-4.6.3 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dist/changes-4.6.3 b/dist/changes-4.6.3 index 57cc453..d8e9fb4 100644 --- a/dist/changes-4.6.3 +++ b/dist/changes-4.6.3 @@ -138,6 +138,14 @@ Qt for Windows CE - +Qt for Symbian +-------------- + + - [QT-567] Implementation of QtMultimedia QAudio* APIs + - [QTBUG-8919] Modified Phonon MMF backend to support video playback on + platforms which use graphics surfaces (i.e. platforms using the + New Graphics Architecture a.k.a. ScreenPlay) + **************************************************************************** * Tools * **************************************************************************** -- cgit v0.12 From 28d469475ccb708ab3f141d9e3c48a24dff4b5e1 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 22 Mar 2010 12:43:51 +0100 Subject: Updated WebKit from /home/shausman/src/webkit/trunk to qtwebkit/qtwebkit-4.6 ( d95c54951e7af2aa7def4346a142b2162bd89bbd ) Changes in WebKit/qt since the last update: https://bugs.webkit.org/show_bug.cgi?id=33408 -- Add flag IGNORE_FIXED_BACKGROUNDS (disabled by default) to ignore fixed background images and accelerate web page scrolling on low-powered/mobile devices https://bugs.webkit.org/show_bug.cgi?id=34168 -- [Qt] Enable FAST_MOBILE_SCROLLING on Qt embedded platforms https://bugs.webkit.org/show_bug.cgi?id=33150 -- Do not render the full frame when there is some elements with fixed positioning --- src/3rdparty/webkit/VERSION | 2 +- src/3rdparty/webkit/WebCore/ChangeLog | 46 +++++++++++++ src/3rdparty/webkit/WebCore/WebCore.pro | 4 ++ src/3rdparty/webkit/WebCore/page/FrameView.cpp | 75 +++++++++++++++++++++- src/3rdparty/webkit/WebCore/page/FrameView.h | 7 ++ .../webkit/WebCore/platform/ScrollView.cpp | 7 +- src/3rdparty/webkit/WebCore/platform/ScrollView.h | 3 + .../webkit/WebCore/rendering/RenderBlock.h | 1 + .../webkit/WebCore/rendering/RenderBox.cpp | 10 +++ .../WebCore/rendering/RenderBoxModelObject.cpp | 11 ++++ .../webkit/WebCore/rendering/RenderObject.cpp | 15 +++-- 11 files changed, 174 insertions(+), 7 deletions(-) diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index a2d5f37..def66ef 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 - 266a6c4f1938dd9edf4a8125faf91c62495e3ce2 + d95c54951e7af2aa7def4346a142b2162bd89bbd diff --git a/src/3rdparty/webkit/WebCore/ChangeLog b/src/3rdparty/webkit/WebCore/ChangeLog index a3f70d3..869e225 100644 --- a/src/3rdparty/webkit/WebCore/ChangeLog +++ b/src/3rdparty/webkit/WebCore/ChangeLog @@ -1,3 +1,49 @@ +2010-01-31 Benjamin Poulain + + Reviewed by Eric Seidel. + + [Qt] Enable FAST_MOBILE_SCROLLING on Qt embedded platforms + https://bugs.webkit.org/show_bug.cgi?id=34168 + + Enable FAST_MOBILE_SCROLLING for Qt on Maemo 5, Linux embedded + and Symbian + + * WebCore.pro: + +2010-01-19 Daniel Bates + + Reviewed by Adam Treat. + + https://bugs.webkit.org/show_bug.cgi?id=33408 + + Implements an optimization to ignore fixed background images + (i.e. background-attachment: fixed) when a page does not contain + any fixed position elements so as to allow fast repaints (via bit + blit) when scrolling a page. + + Currently, if a page has elements that specify either a fixed + background or a fixed position then we perform a slow repaint + (i.e disable blitting) so as to avoid rendering artifacts. + However, on low-powered/mobile devices slow repaints can cause + noticeable delays when scrolling a page with a fixed background + image. By sacrificing support for fixed background images when + there are no fixed elements on the page and with come care, we + don't need to force slow repaints and can avoid rendering artifacts. + Hence, on such devices we can improve the responsiveness of + scrolling a page with a fixed background image. + + Note, this optimization is only enabled if the WebKit is built + with FAST_MOBILE_SCROLLING enabled. + + Tests: fast/fast-mobile-scrolling/fixed-position-element.html + fast/fast-mobile-scrolling/no-fixed-position-elements.html + + * rendering/RenderBoxModelObject.cpp: + (WebCore::RenderBoxModelObject::calculateBackgroundImageGeometry): + Disable fixed background attachment if we can blit on scroll. + * rendering/RenderObject.cpp: + (WebCore::RenderObject::styleWillChange): + 2010-03-11 Simon Hausmann Reviewed by Tor Arne Vestbø. diff --git a/src/3rdparty/webkit/WebCore/WebCore.pro b/src/3rdparty/webkit/WebCore/WebCore.pro index 5654a18..735c8ef 100644 --- a/src/3rdparty/webkit/WebCore/WebCore.pro +++ b/src/3rdparty/webkit/WebCore/WebCore.pro @@ -162,6 +162,10 @@ contains(DEFINES, ENABLE_SINGLE_THREADED=1) { DEFINES += ENABLE_SVG_FONTS=0 ENABLE_SVG_FOREIGN_OBJECT=0 ENABLE_SVG_ANIMATION=0 ENABLE_SVG_AS_IMAGE=0 ENABLE_SVG_USE=0 } +mameo5|symbian|embedded { + DEFINES += ENABLE_FAST_MOBILE_SCROLLING=1 +} + # HTML5 ruby support !contains(DEFINES, ENABLE_RUBY=.): DEFINES += ENABLE_RUBY=1 diff --git a/src/3rdparty/webkit/WebCore/page/FrameView.cpp b/src/3rdparty/webkit/WebCore/page/FrameView.cpp index bc4e4f2..4c3a0ab 100644 --- a/src/3rdparty/webkit/WebCore/page/FrameView.cpp +++ b/src/3rdparty/webkit/WebCore/page/FrameView.cpp @@ -106,6 +106,7 @@ struct ScheduledEvent { FrameView::FrameView(Frame* frame) : m_frame(frame) , m_slowRepaintObjectCount(0) + , m_fixedObjectCount(0) , m_layoutTimer(this, &FrameView::layoutTimerFired) , m_layoutRoot(0) , m_postLayoutTasksTimer(this, &FrameView::postLayoutTimerFired) @@ -735,7 +736,7 @@ String FrameView::mediaType() const bool FrameView::useSlowRepaints() const { - return m_useSlowRepaints || m_slowRepaintObjectCount > 0 || m_isOverlapped || !m_contentIsOpaque; + return m_useSlowRepaints || m_slowRepaintObjectCount > 0 || (platformWidget() && m_fixedObjectCount > 0) || m_isOverlapped || !m_contentIsOpaque; } void FrameView::setUseSlowRepaints() @@ -759,6 +760,78 @@ void FrameView::removeSlowRepaintObject() setCanBlitOnScroll(!useSlowRepaints()); } +void FrameView::addFixedObject() +{ + if (!m_fixedObjectCount && platformWidget()) + setCanBlitOnScroll(false); + ++m_fixedObjectCount; +} + +void FrameView::removeFixedObject() +{ + ASSERT(m_fixedObjectCount > 0); + m_fixedObjectCount--; + if (!m_fixedObjectCount) + setCanBlitOnScroll(!useSlowRepaints()); +} + +void FrameView::scrollContentsFastPath(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect) +{ + const size_t fixedObjectThreshold = 5; + + ListHashSet* positionedObjects = 0; + if (RenderView* root = m_frame->contentRenderer()) + positionedObjects = root->positionedObjects(); + + if (!positionedObjects || positionedObjects->isEmpty()) { + hostWindow()->scroll(scrollDelta, rectToScroll, clipRect); + return; + } + + // Get the rects of the fixed objects visible in the rectToScroll + Vector subRectToUpdate; + bool updateInvalidatedSubRect = true; + ListHashSet::const_iterator end = positionedObjects->end(); + for (ListHashSet::const_iterator it = positionedObjects->begin(); it != end; ++it) { + RenderBox* renderBox = *it; + if (renderBox->style()->position() != FixedPosition) + continue; + IntRect topLevelRect; + IntRect updateRect = renderBox->paintingRootRect(topLevelRect); + updateRect.move(-scrollX(), -scrollY()); + updateRect.intersect(rectToScroll); + if (!updateRect.isEmpty()) { + if (subRectToUpdate.size() >= fixedObjectThreshold) { + updateInvalidatedSubRect = false; + break; + } + subRectToUpdate.append(updateRect); + } + } + + // Scroll the view + if (updateInvalidatedSubRect) { + // 1) scroll + hostWindow()->scroll(scrollDelta, rectToScroll, clipRect); + + // 2) update the area of fixed objets that has been invalidated + size_t fixObjectsCount = subRectToUpdate.size(); + for (size_t i = 0; i < fixObjectsCount; ++i) { + IntRect updateRect = subRectToUpdate[i]; + IntRect scrolledRect = updateRect; + scrolledRect.move(scrollDelta); + updateRect.unite(scrolledRect); + updateRect.intersect(rectToScroll); + hostWindow()->repaint(updateRect, true, false, true); + } + } else { + // the number of fixed objects exceed the threshold, so we repaint everything. + IntRect updateRect = clipRect; + updateRect.intersect(rectToScroll); + hostWindow()->repaint(updateRect, true, false, true); + } +} + void FrameView::setIsOverlapped(bool isOverlapped) { if (isOverlapped == m_isOverlapped) diff --git a/src/3rdparty/webkit/WebCore/page/FrameView.h b/src/3rdparty/webkit/WebCore/page/FrameView.h index 3d17d2c..5243c02 100644 --- a/src/3rdparty/webkit/WebCore/page/FrameView.h +++ b/src/3rdparty/webkit/WebCore/page/FrameView.h @@ -143,6 +143,9 @@ public: void addSlowRepaintObject(); void removeSlowRepaintObject(); + void addFixedObject(); + void removeFixedObject(); + void beginDeferredRepaints(); void endDeferredRepaints(); void checkStopDelayingDeferredRepaints(); @@ -196,6 +199,9 @@ public: bool isFrameViewScrollCorner(RenderScrollbarPart* scrollCorner) const { return m_scrollCorner == scrollCorner; } void invalidateScrollCorner(); +protected: + virtual void scrollContentsFastPath(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect); + private: FrameView(Frame*); @@ -261,6 +267,7 @@ private: bool m_isOverlapped; bool m_contentIsOpaque; unsigned m_slowRepaintObjectCount; + unsigned m_fixedObjectCount; int m_borderX, m_borderY; diff --git a/src/3rdparty/webkit/WebCore/platform/ScrollView.cpp b/src/3rdparty/webkit/WebCore/platform/ScrollView.cpp index e67daf9..9e15c43 100644 --- a/src/3rdparty/webkit/WebCore/platform/ScrollView.cpp +++ b/src/3rdparty/webkit/WebCore/platform/ScrollView.cpp @@ -509,7 +509,7 @@ void ScrollView::scrollContents(const IntSize& scrollDelta) if (canBlitOnScroll()) { // The main frame can just blit the WebView window // FIXME: Find a way to blit subframes without blitting overlapping content - hostWindow()->scroll(-scrollDelta, scrollViewRect, clipRect); + scrollContentsFastPath(-scrollDelta, scrollViewRect, clipRect); } else { // We need to go ahead and repaint the entire backing store. Do it now before moving the // windowed plugins. @@ -524,6 +524,11 @@ void ScrollView::scrollContents(const IntSize& scrollDelta) hostWindow()->paint(); } +void ScrollView::scrollContentsFastPath(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect) +{ + hostWindow()->scroll(scrollDelta, rectToScroll, clipRect); +} + IntPoint ScrollView::windowToContents(const IntPoint& windowPoint) const { IntPoint viewPoint = convertFromContainingWindow(windowPoint); diff --git a/src/3rdparty/webkit/WebCore/platform/ScrollView.h b/src/3rdparty/webkit/WebCore/platform/ScrollView.h index 5dacff5..7060d07 100644 --- a/src/3rdparty/webkit/WebCore/platform/ScrollView.h +++ b/src/3rdparty/webkit/WebCore/platform/ScrollView.h @@ -244,6 +244,9 @@ protected: IntRect scrollCornerRect() const; virtual void updateScrollCorner(); virtual void paintScrollCorner(GraphicsContext*, const IntRect& cornerRect); + + // Scroll the content by blitting the pixels + virtual void scrollContentsFastPath(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect); private: RefPtr m_horizontalScrollbar; diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderBlock.h b/src/3rdparty/webkit/WebCore/rendering/RenderBlock.h index 7ba5fce..3300d01 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderBlock.h +++ b/src/3rdparty/webkit/WebCore/rendering/RenderBlock.h @@ -75,6 +75,7 @@ public: void insertPositionedObject(RenderBox*); void removePositionedObject(RenderBox*); void removePositionedObjects(RenderBlock*); + ListHashSet* positionedObjects() const { return m_positionedObjects; } void addPercentHeightDescendant(RenderBox*); static void removePercentHeightDescendant(RenderBox*); diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderBox.cpp b/src/3rdparty/webkit/WebCore/rendering/RenderBox.cpp index 1df82a4..7ca2ff8 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderBox.cpp +++ b/src/3rdparty/webkit/WebCore/rendering/RenderBox.cpp @@ -145,6 +145,16 @@ void RenderBox::styleWillChange(StyleDifference diff, const RenderStyle* newStyl removeFloatingOrPositionedChildFromBlockLists(); } } + if (FrameView *frameView = view()->frameView()) { + bool newStyleIsFixed = newStyle && newStyle->position() == FixedPosition; + bool oldStyleIsFixed = style() && style()->position() == FixedPosition; + if (newStyleIsFixed != oldStyleIsFixed) { + if (newStyleIsFixed) + frameView->addFixedObject(); + else + frameView->removeFixedObject(); + } + } RenderBoxModelObject::styleWillChange(diff, newStyle); } diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderBoxModelObject.cpp b/src/3rdparty/webkit/WebCore/rendering/RenderBoxModelObject.cpp index 23dad2d..9d0f1ed 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderBoxModelObject.cpp +++ b/src/3rdparty/webkit/WebCore/rendering/RenderBoxModelObject.cpp @@ -557,6 +557,17 @@ void RenderBoxModelObject::calculateBackgroundImageGeometry(const FillLayer* fil // Determine the background positioning area and set destRect to the background painting area. // destRect will be adjusted later if the background is non-repeating. bool fixedAttachment = fillLayer->attachment() == FixedBackgroundAttachment; + +#if ENABLE(FAST_MOBILE_SCROLLING) + if (view()->frameView() && view()->frameView()->canBlitOnScroll()) { + // As a side effect of an optimization to blit on scroll, we do not honor the CSS + // property "background-attachment: fixed" because it may result in rendering + // artifacts. Note, these artifacts only appear if we are blitting on scroll of + // a page that has fixed background images. + fixedAttachment = false; + } +#endif + if (!fixedAttachment) { destRect = IntRect(tx, ty, w, h); diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderObject.cpp b/src/3rdparty/webkit/WebCore/rendering/RenderObject.cpp index a10ffd9..199de4a 100644 --- a/src/3rdparty/webkit/WebCore/rendering/RenderObject.cpp +++ b/src/3rdparty/webkit/WebCore/rendering/RenderObject.cpp @@ -1591,10 +1591,17 @@ void RenderObject::styleWillChange(StyleDifference diff, const RenderStyle* newS s_affectsParentBlock = false; if (view()->frameView()) { - // FIXME: A better solution would be to only invalidate the fixed regions when scrolling. It's overkill to - // prevent the entire view from blitting on a scroll. - bool newStyleSlowScroll = newStyle && (newStyle->position() == FixedPosition || newStyle->hasFixedBackgroundImage()); - bool oldStyleSlowScroll = m_style && (m_style->position() == FixedPosition || m_style->hasFixedBackgroundImage()); + bool shouldBlitOnFixedBackgroundImage = false; +#if ENABLE(FAST_MOBILE_SCROLLING) + // On low-powered/mobile devices, preventing blitting on a scroll can cause noticeable delays + // when scrolling a page with a fixed background image. As an optimization, assuming there are + // no fixed positoned elements on the page, we can acclerate scrolling (via blitting) if we + // ignore the CSS property "background-attachment: fixed". + shouldBlitOnFixedBackgroundImage = true; +#endif + + bool newStyleSlowScroll = newStyle && !shouldBlitOnFixedBackgroundImage && newStyle->hasFixedBackgroundImage(); + bool oldStyleSlowScroll = m_style && !shouldBlitOnFixedBackgroundImage && m_style->hasFixedBackgroundImage(); if (oldStyleSlowScroll != newStyleSlowScroll) { if (oldStyleSlowScroll) view()->frameView()->removeSlowRepaintObject(); -- cgit v0.12 From 22993cbada46fb9e170d4ac7a08413c968fce2a2 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Mon, 22 Mar 2010 13:06:29 +0100 Subject: Stop QHostInfo thread pool when application is about to exit Ensure that the threadpool QHostInfo uses internally has cleanup its threads when the application exits. This avoids the warning from QWaitCondition on Windows (which happens due to thread termination at application exit). Task-number: QTBUG-7691 Reviewed-by: mgoetz --- src/network/kernel/qhostinfo.cpp | 1 + src/network/kernel/qhostinfo_p.h | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp index 7150fb7..6894978 100644 --- a/src/network/kernel/qhostinfo.cpp +++ b/src/network/kernel/qhostinfo.cpp @@ -479,6 +479,7 @@ void QHostInfoRunnable::run() QHostInfoLookupManager::QHostInfoLookupManager() : mutex(QMutex::Recursive), wasDeleted(false) { moveToThread(QCoreApplicationPrivate::mainThread()); + connect(QCoreApplication::instance(), SIGNAL(destroyed()), SLOT(waitForThreadPoolDone()), Qt::DirectConnection); threadPool.setMaxThreadCount(5); // do 5 DNS lookups in parallel } diff --git a/src/network/kernel/qhostinfo_p.h b/src/network/kernel/qhostinfo_p.h index 2b26b07..4fc74e9 100644 --- a/src/network/kernel/qhostinfo_p.h +++ b/src/network/kernel/qhostinfo_p.h @@ -184,6 +184,9 @@ protected: QMutex mutex; bool wasDeleted; + +private slots: + void waitForThreadPoolDone() { threadPool.waitForDone(); } }; #endif -- cgit v0.12 From 6da8cec6042823da5622d048bb66ca7c40aed9b3 Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Mon, 22 Mar 2010 14:55:40 +0200 Subject: Adding custom pixel metrics requires cleaning and rebuilding of QtGui This is due that the size of the pixel metrics table is stored in some object file and the file is not updated, even if we increase the table size integer. Removing direct calls from internal methods to member variable data[] removes the need to do whole rebuild when adding values. Relates to task #9247. Task-number: QTBUG-9247 Reviewed-by: Alessandro Portale --- src/gui/styles/qs60style_s60.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index 14782d8..bb862a3 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -1096,7 +1096,7 @@ void QS60StylePrivate::setActiveLayout() activeLayoutIndex += (!landscape) ? 1 : 0; } - m_pmPointer = data[activeLayoutIndex]; + setCurrentLayout(activeLayoutIndex); } Q_GLOBAL_STATIC(QList, m_animations) -- cgit v0.12 From c3dd4b356e277c8ec2a2634dbae04cdc7e798ca9 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 22 Mar 2010 13:40:54 +0100 Subject: Recommit 1ebeb971d3382aec0fff927 This reverts commit 725c2c29c192349016b1332824a7716bbb992f31 which reverted the original commit because of a test failure on qws. This recommit adds a test for whether the metrics from QFontEngine::boundingBox() are valid, which is required for the bearings to be calculated. This test was also in the original logic. --- src/gui/text/qfontengine.cpp | 15 +++++++++++++++ src/gui/text/qfontengine_p.h | 3 +++ src/gui/text/qfontengine_win.cpp | 24 ++++++++++++++++++++++++ src/gui/text/qfontengine_win_p.h | 2 ++ src/gui/text/qfontmetrics.cpp | 21 +++++++++++++-------- src/gui/text/qtextlayout.cpp | 6 +++--- 6 files changed, 60 insertions(+), 11 deletions(-) diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index c000457..629db66 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -379,6 +379,15 @@ void QFontEngine::getGlyphPositions(const QGlyphLayout &glyphs, const QTransform Q_ASSERT(positions.size() == glyphs_out.size()); } +void QFontEngine::getGlyphBearings(glyph_t glyph, qreal *leftBearing, qreal *rightBearing) +{ + glyph_metrics_t gi = boundingBox(glyph); + bool isValid = gi.isValid(); + if (leftBearing != 0) + *leftBearing = isValid ? gi.x.toReal() : 0.0; + if (rightBearing != 0) + *rightBearing = isValid ? (gi.xoff - gi.x - gi.width).toReal() : 0.0; +} glyph_metrics_t QFontEngine::tightBoundingBox(const QGlyphLayout &glyphs) { @@ -1385,6 +1394,12 @@ glyph_metrics_t QFontEngineMulti::boundingBox(const QGlyphLayout &glyphs) return overall; } +void QFontEngineMulti::getGlyphBearings(glyph_t glyph, qreal *leftBearing, qreal *rightBearing) +{ + int which = highByte(glyph); + engine(which)->getGlyphBearings(stripped(glyph), leftBearing, rightBearing); +} + void QFontEngineMulti::addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyphs, QPainterPath *path, QTextItem::RenderFlags flags) { diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h index 71ab5a5..e645caf 100644 --- a/src/gui/text/qfontengine_p.h +++ b/src/gui/text/qfontengine_p.h @@ -206,6 +206,8 @@ public: virtual qreal minLeftBearing() const { return qreal(); } virtual qreal minRightBearing() const { return qreal(); } + virtual void getGlyphBearings(glyph_t glyph, qreal *leftBearing = 0, qreal *rightBearing = 0); + virtual const char *name() const = 0; virtual bool canRender(const QChar *string, int len) = 0; @@ -374,6 +376,7 @@ public: virtual void recalcAdvances(QGlyphLayout *, QTextEngine::ShaperFlags) const; virtual void doKerning(QGlyphLayout *, QTextEngine::ShaperFlags) const; virtual void addOutlineToPath(qreal, qreal, const QGlyphLayout &, QPainterPath *, QTextItem::RenderFlags flags); + virtual void getGlyphBearings(glyph_t glyph, qreal *leftBearing = 0, qreal *rightBearing = 0); virtual QFixed ascent() const; virtual QFixed descent() const; diff --git a/src/gui/text/qfontengine_win.cpp b/src/gui/text/qfontengine_win.cpp index 1a815d3..a133b48 100644 --- a/src/gui/text/qfontengine_win.cpp +++ b/src/gui/text/qfontengine_win.cpp @@ -649,6 +649,30 @@ static const ushort char_table[] = { static const int char_table_entries = sizeof(char_table)/sizeof(ushort); +void QFontEngineWin::getGlyphBearings(glyph_t glyph, qreal *leftBearing, qreal *rightBearing) +{ + HDC hdc = shared_dc(); + SelectObject(hdc, hfont); + +#ifndef Q_WS_WINCE + if (ttf) +#endif + + { + ABC abcWidths; + GetCharABCWidthsI(hdc, glyph, 1, 0, &abcWidths); + if (leftBearing) + *leftBearing = abcWidths.abcA; + if (rightBearing) + *rightBearing = abcWidths.abcC; + } + +#ifndef Q_WS_WINCE + else { + QFontEngine::getGlyphBearings(glyph, leftBearing, rightBearing); + } +#endif +} qreal QFontEngineWin::minLeftBearing() const { diff --git a/src/gui/text/qfontengine_win_p.h b/src/gui/text/qfontengine_win_p.h index f9d8f8b..f19e48e 100644 --- a/src/gui/text/qfontengine_win_p.h +++ b/src/gui/text/qfontengine_win_p.h @@ -106,6 +106,8 @@ public: virtual QImage alphaMapForGlyph(glyph_t, const QTransform &xform); virtual QImage alphaRGBMapForGlyph(glyph_t t, int margin, const QTransform &xform); + virtual void getGlyphBearings(glyph_t glyph, qreal *leftBearing = 0, qreal *rightBearing = 0); + int getGlyphIndexes(const QChar *ch, int numChars, QGlyphLayout *glyphs, bool mirrored) const; void getCMap(); diff --git a/src/gui/text/qfontmetrics.cpp b/src/gui/text/qfontmetrics.cpp index 41d0af1..44a18de 100644 --- a/src/gui/text/qfontmetrics.cpp +++ b/src/gui/text/qfontmetrics.cpp @@ -472,8 +472,9 @@ int QFontMetrics::leftBearing(QChar ch) const int nglyphs = 9; engine->stringToCMap(&ch, 1, &glyphs, &nglyphs, 0); // ### can nglyphs != 1 happen at all? Not currently I think - glyph_metrics_t gi = engine->boundingBox(glyphs.glyphs[0]); - return qRound(gi.x); + qreal lb; + engine->getGlyphBearings(glyphs.glyphs[0], &lb); + return qRound(lb); } /*! @@ -506,8 +507,9 @@ int QFontMetrics::rightBearing(QChar ch) const int nglyphs = 9; engine->stringToCMap(&ch, 1, &glyphs, &nglyphs, 0); // ### can nglyphs != 1 happen at all? Not currently I think - glyph_metrics_t gi = engine->boundingBox(glyphs.glyphs[0]); - return qRound(gi.xoff - gi.x - gi.width); + qreal rb; + engine->getGlyphBearings(glyphs.glyphs[0], 0, &rb); + return qRound(rb); } /*! @@ -1317,8 +1319,9 @@ qreal QFontMetricsF::leftBearing(QChar ch) const int nglyphs = 9; engine->stringToCMap(&ch, 1, &glyphs, &nglyphs, 0); // ### can nglyphs != 1 happen at all? Not currently I think - glyph_metrics_t gi = engine->boundingBox(glyphs.glyphs[0]); - return gi.x.toReal(); + qreal lb; + engine->getGlyphBearings(glyphs.glyphs[0], &lb); + return lb; } /*! @@ -1351,8 +1354,10 @@ qreal QFontMetricsF::rightBearing(QChar ch) const int nglyphs = 9; engine->stringToCMap(&ch, 1, &glyphs, &nglyphs, 0); // ### can nglyphs != 1 happen at all? Not currently I think - glyph_metrics_t gi = engine->boundingBox(glyphs.glyphs[0]); - return (gi.xoff - gi.x - gi.width).toReal(); + qreal rb; + engine->getGlyphBearings(glyphs.glyphs[0], 0, &rb); + return rb; + } /*! diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 204effa..3c0e85e 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -1688,9 +1688,9 @@ namespace { if (currentPosition <= 0) return; - glyph_metrics_t gi = fontEngine->boundingBox(currentGlyph()); - if (gi.isValid()) - rightBearing = qMin(QFixed(), gi.xoff - gi.x - gi.width); + qreal rb; + fontEngine->getGlyphBearings(currentGlyph(), 0, &rb); + rightBearing = qMin(QFixed(), QFixed::fromReal(rb)); } inline void resetRightBearing() -- cgit v0.12 From 669c8042fa78c539cdefec87c85bce91e561871d Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Mon, 22 Mar 2010 14:59:25 +0200 Subject: Custom pixel metric values cannot be inquired from outside the class This is due that a) custom values are internal and not exposed b) values use different format - they are indexes for internal data[] table and not according to QStyle documentation for pixel metrics. Task-number: QTBUG-9247 Reviewed-by: Alessandro Portale --- src/gui/styles/qs60style.cpp | 7 +++++++ src/gui/styles/qs60style.h | 9 +++++++++ src/gui/styles/qs60style_p.h | 3 +++ 3 files changed, 19 insertions(+) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 750e19f..ed2074a 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -307,6 +307,13 @@ void QS60StylePrivate::drawSkinPart(QS60StyleEnums::SkinParts part, short QS60StylePrivate::pixelMetric(int metric) { + //If it is a custom value, need to strip away the base to map to internal + //pixel metric value table + if (metric & QStyle::PM_CustomBase) { + metric -= QStyle::PM_CustomBase; + metric += MAX_NON_CUSTOM_PIXELMETRICS - 1; + } + Q_ASSERT(metric < MAX_PIXELMETRICS); const short returnValue = m_pmPointer[metric]; return returnValue; diff --git a/src/gui/styles/qs60style.h b/src/gui/styles/qs60style.h index 82cc21c..af17843 100644 --- a/src/gui/styles/qs60style.h +++ b/src/gui/styles/qs60style.h @@ -52,6 +52,15 @@ QT_MODULE(Gui) #if !defined(QT_NO_STYLE_S60) +//Public custom pixel metrics values. +//These can be used to fetch custom pixel metric value from outside QS60Style. +enum { + PM_FrameCornerWidth = QStyle::PM_CustomBase + 1, + PM_FrameCornerHeight, + PM_BoldLineWidth, + PM_ThinLineWidth + }; + class QS60StylePrivate; class Q_GUI_EXPORT QS60Style : public QCommonStyle diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h index 16d82e7..84f50ea 100644 --- a/src/gui/styles/qs60style_p.h +++ b/src/gui/styles/qs60style_p.h @@ -61,12 +61,15 @@ QT_BEGIN_NAMESPACE const int MAX_NON_CUSTOM_PIXELMETRICS = 92; const int CUSTOMVALUESCOUNT = 4; + +//internal custom pixel metrics values, these map to entry in data[] table enum { PM_Custom_FrameCornerWidth = MAX_NON_CUSTOM_PIXELMETRICS, PM_Custom_FrameCornerHeight, PM_Custom_BoldLineWidth, PM_Custom_ThinLineWidth }; + const int MAX_PIXELMETRICS = MAX_NON_CUSTOM_PIXELMETRICS + CUSTOMVALUESCOUNT; typedef struct { -- cgit v0.12 From c1e23f855826942d7d3821a944c35272d9ecffb4 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Mon, 22 Mar 2010 14:00:02 +0100 Subject: Reset history states when (re)starting state machine State saved in QHistoryState should not be persistent between state machine starts/stops. Task-number: QTBUG-8842 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/corelib/statemachine/qstatemachine.cpp | 11 +++++ src/corelib/statemachine/qstatemachine_p.h | 2 + tests/auto/qstatemachine/tst_qstatemachine.cpp | 59 ++++++++++++++++++++++++++ 3 files changed, 72 insertions(+) diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp index bd7e626..9d5c49f 100644 --- a/src/corelib/statemachine/qstatemachine.cpp +++ b/src/corelib/statemachine/qstatemachine.cpp @@ -1175,6 +1175,16 @@ void QStateMachinePrivate::removeStartState() _startState = 0; } +void QStateMachinePrivate::clearHistory() +{ + Q_Q(QStateMachine); + QList historyStates = qFindChildren(q); + for (int i = 0; i < historyStates.size(); ++i) { + QHistoryState *h = historyStates.at(i); + QHistoryStatePrivate::get(h)->configuration.clear(); + } +} + void QStateMachinePrivate::_q_start() { Q_Q(QStateMachine); @@ -1186,6 +1196,7 @@ void QStateMachinePrivate::_q_start() internalEventQueue.clear(); qDeleteAll(externalEventQueue); externalEventQueue.clear(); + clearHistory(); #ifdef QSTATEMACHINE_DEBUG qDebug() << q << ": starting"; diff --git a/src/corelib/statemachine/qstatemachine_p.h b/src/corelib/statemachine/qstatemachine_p.h index 0fead5d..5e1015f 100644 --- a/src/corelib/statemachine/qstatemachine_p.h +++ b/src/corelib/statemachine/qstatemachine_p.h @@ -126,6 +126,8 @@ public: QState *startState(); void removeStartState(); + void clearHistory(); + void microstep(QEvent *event, const QList &transitionList); bool isPreempted(const QAbstractState *s, const QSet &transitions) const; QSet selectTransitions(QEvent *event) const; diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp index 90b5a22..2bf76e7 100644 --- a/tests/auto/qstatemachine/tst_qstatemachine.cpp +++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp @@ -155,6 +155,7 @@ private slots: void clearError(); void historyStateHasNowhereToGo(); void historyStateAsInitialState(); + void historyStateAfterRestart(); void brokenStateIsNeverEntered(); void customErrorStateNotInGraph(); void transitionToStateNotInGraph(); @@ -906,6 +907,64 @@ void tst_QStateMachine::historyStateHasNowhereToGo() QCOMPARE(machine.errorString(), QString::fromLatin1("Missing default state in history state 'historyState'")); } +void tst_QStateMachine::historyStateAfterRestart() +{ + // QTBUG-8842 + QStateMachine machine; + + QState *s1 = new QState(&machine); + machine.setInitialState(s1); + QState *s2 = new QState(&machine); + QState *s21 = new QState(s2); + QState *s22 = new QState(s2); + QHistoryState *s2h = new QHistoryState(s2); + s2h->setDefaultState(s21); + s1->addTransition(new EventTransition(QEvent::User, s2h)); + s21->addTransition(new EventTransition(QEvent::User, s22)); + s2->addTransition(new EventTransition(QEvent::User, s1)); + + for (int x = 0; x < 2; ++x) { + QSignalSpy startedSpy(&machine, SIGNAL(started())); + machine.start(); + QTRY_COMPARE(startedSpy.count(), 1); + QCOMPARE(machine.configuration().count(), 1); + QVERIFY(machine.configuration().contains(s1)); + + // s1 -> s2h -> s21 (default state) + machine.postEvent(new QEvent(QEvent::User)); + QCoreApplication::processEvents(); + QCOMPARE(machine.configuration().count(), 2); + QVERIFY(machine.configuration().contains(s2)); + // This used to fail on the 2nd run because the + // history had not been cleared. + QVERIFY(machine.configuration().contains(s21)); + + // s21 -> s22 + machine.postEvent(new QEvent(QEvent::User)); + QCoreApplication::processEvents(); + QCOMPARE(machine.configuration().count(), 2); + QVERIFY(machine.configuration().contains(s2)); + QVERIFY(machine.configuration().contains(s22)); + + // s2 -> s1 (s22 saved in s2h) + machine.postEvent(new QEvent(QEvent::User)); + QCoreApplication::processEvents(); + QCOMPARE(machine.configuration().count(), 1); + QVERIFY(machine.configuration().contains(s1)); + + // s1 -> s2h -> s22 (saved state) + machine.postEvent(new QEvent(QEvent::User)); + QCoreApplication::processEvents(); + QCOMPARE(machine.configuration().count(), 2); + QVERIFY(machine.configuration().contains(s2)); + QVERIFY(machine.configuration().contains(s22)); + + QSignalSpy stoppedSpy(&machine, SIGNAL(stopped())); + machine.stop(); + QTRY_COMPARE(stoppedSpy.count(), 1); + } +} + void tst_QStateMachine::brokenStateIsNeverEntered() { QStateMachine machine; -- cgit v0.12 From 781e4d6190362818482864947a90d230fd700b06 Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Mon, 22 Mar 2010 15:07:51 +0200 Subject: QS60Style: Housekeeping Remove unnecessary #include, remove unnecessary integer, correct spelling issues in comments and replace tabs with spaces. Reviewed-by: Alessandro Portale --- src/gui/styles/qs60style.cpp | 12 +++++------- src/gui/styles/qs60style_p.h | 2 +- src/gui/styles/qs60style_s60.cpp | 4 ++-- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index ed2074a..ec8b468 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -61,7 +61,6 @@ #include "qscrollarea.h" #include "qscrollbar.h" #include "qtabbar.h" -#include "qtablewidget.h" #include "qtableview.h" #include "qtextedit.h" #include "qtoolbar.h" @@ -1009,7 +1008,6 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom QS60StylePrivate::SE_SliderGrooveVertical; QS60StylePrivate::drawSkinElement(grooveElement, painter, sliderGroove, flags); } else { - const QRect sliderGroove = subControlRect(control, optionSlider, SC_SliderGroove, widget); const QPoint sliderGrooveCenter = sliderGroove.center(); const bool horizontal = optionSlider->orientation == Qt::Horizontal; painter->save(); @@ -1136,7 +1134,7 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom drawPrimitive(pe, &toolButton, painter, widget); } - if (toolBtn->text.length()>0 || + if (toolBtn->text.length() > 0 || !toolBtn->icon.isNull()) { const int frameWidth = pixelMetric(PM_DefaultFrameWidth, option, widget); toolButton.rect = button.adjusted(frameWidth, frameWidth, -frameWidth, -frameWidth); @@ -2316,7 +2314,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti (option->state & State_Open) ? QS60StyleEnums::SP_QgnIndiHlColSuper : QS60StyleEnums::SP_QgnIndiHlExpSuper; int minDimension = qMin(option->rect.width(), option->rect.height()); QRect iconRect(option->rect.topLeft(), QSize(minDimension, minDimension)); - const int magicTweak = 3; + const int magicTweak = 3; int resizeValue = minDimension >> 1; if (!QS60StylePrivate::isTouchSupported()) { minDimension += resizeValue; // Adjust the icon bigger because of empty space in svg icon. @@ -2461,9 +2459,9 @@ QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt, #ifndef QT_NO_COMBOBOX case CT_ComboBox: { // Fixing Ui design issues with too wide QComboBoxes and greedy SizeHints - // Make sure, that the combobox says within the screen. + // Make sure, that the combobox stays within the screen. const QSize desktopContentSize = QApplication::desktop()->availableGeometry().size() - -QSize(pixelMetric(PM_LayoutLeftMargin) + pixelMetric(PM_LayoutRightMargin), 0); + - QSize(pixelMetric(PM_LayoutLeftMargin) + pixelMetric(PM_LayoutRightMargin), 0); sz = QCommonStyle::sizeFromContents(ct, opt, csz, widget). boundedTo(desktopContentSize); } @@ -3249,7 +3247,7 @@ bool QS60Style::eventFilter(QObject *object, QEvent *event) /*! \internal - Handle the timer \a event. + Handle the timer \a event. */ void QS60Style::timerEvent(QTimerEvent *event) { diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h index 84f50ea..df6f582 100644 --- a/src/gui/styles/qs60style_p.h +++ b/src/gui/styles/qs60style_p.h @@ -428,7 +428,7 @@ public: SE_ToolBarButton, SE_ToolBarButtonPressed, SE_PanelBackground, - SE_ScrollBarHandlePressedHorizontal, //only for 5.0+ + SE_ScrollBarHandlePressedHorizontal, SE_ScrollBarHandlePressedVertical, SE_ButtonInactive, SE_Editor, diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index bb862a3..0f014c1 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -755,7 +755,7 @@ QPixmap QS60StyleModeSpecifics::createSkinnedGraphicsLX( if (drawn) result = fromFbsBitmap(background, NULL, flags, targetSize); - // if drawing fails in skin server, just ignore the background (probably OOM occured) + // if drawing fails in skin server, just ignore the background (probably OOM case) CleanupStack::PopAndDestroy(4, background); //background, dev, gc, bgContext // QS60WindowSurface::lockBitmapHeap(); @@ -787,7 +787,7 @@ QPixmap QS60StyleModeSpecifics::createSkinnedGraphicsLX( const int currentFrame = QS60StylePrivate::currentAnimationFrame(part); if (constructedFromTheme && aknAnimation && aknAnimation->BitmapAnimData()->FrameArray().Count() > 0) { - //Animation was created succesfully and contains frames, just fetch current frame + //Animation was created successfully and contains frames, just fetch current frame if(currentFrame >= aknAnimation->BitmapAnimData()->FrameArray().Count()) User::Leave(KErrOverflow); const CBitmapFrameData* frameData = aknAnimation->BitmapAnimData()->FrameArray().At(currentFrame); -- cgit v0.12 From 97701a9e002593b0cc17afc6ce32925464f8b2fc Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Mon, 22 Mar 2010 16:17:18 +0200 Subject: Fixed table formatting in QSound documentation Added the missing \row tag Reviewed-by: TrustMe --- src/gui/kernel/qsound.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qsound.cpp b/src/gui/kernel/qsound.cpp index 165e6ce..9d8ffa5 100644 --- a/src/gui/kernel/qsound.cpp +++ b/src/gui/kernel/qsound.cpp @@ -147,12 +147,13 @@ public: supports WAVE and AU files. \row \o Mac OS X - \o NSSound is used. All formats that NSSound supports, including QuickTime formats, + \o NSSound is used. All formats that NSSound supports, including QuickTime formats, are supported by Qt for Mac OS X. \row \o Qt for Embedded Linux \o A built-in mixing sound server is used, accessing \c /dev/dsp directly. Only the WAVE format is supported. + \row \o Symbian \o CMdaAudioPlayerUtility is used. All formats that Symbian OS or devices support are supported also by Qt. -- cgit v0.12 From fec5410f350e4d67b7991f15da94775f97bce0bb Mon Sep 17 00:00:00 2001 From: Jason Barron Date: Mon, 22 Mar 2010 16:41:42 +0100 Subject: Fix #ifdef logic for Symbian conversion functions in QVGPixmapData. The previous #ifdef logic had the entire body of fromNativeType() and toNativeType() #ifdef'ed out meaning that the OpenVG graphics system could not convert CFbsBitmap instances to VGImage instances. This was obviously incorrect because this code has no dependancy on RSgImage (or EGL) and should therefore be outside of the #ifdef. Reviewed-by: TrustMe --- src/openvg/qpixmapdata_vg.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/openvg/qpixmapdata_vg.cpp b/src/openvg/qpixmapdata_vg.cpp index cb5255d..d602790 100644 --- a/src/openvg/qpixmapdata_vg.cpp +++ b/src/openvg/qpixmapdata_vg.cpp @@ -464,8 +464,8 @@ void QVGPixmapData::cleanup() void QVGPixmapData::fromNativeType(void* pixmap, NativeType type) { -#if defined(QT_SYMBIAN_SUPPORTS_SGIMAGE) && !defined(QT_NO_EGL) if (type == QPixmapData::SgImage && pixmap) { +#if defined(QT_SYMBIAN_SUPPORTS_SGIMAGE) && !defined(QT_NO_EGL) RSgImage *sgImage = reinterpret_cast(pixmap); destroyImages(); @@ -536,6 +536,7 @@ void QVGPixmapData::fromNativeType(void* pixmap, NativeType type) // release stuff eglDestroyImageKHR(QEglContext::display(), eglImage); driver.Close(); +#endif } else if (type == QPixmapData::FbsBitmap) { CFbsBitmap *bitmap = reinterpret_cast(pixmap); @@ -581,16 +582,12 @@ void QVGPixmapData::fromNativeType(void* pixmap, NativeType type) if(deleteSourceBitmap) delete bitmap; } -#else - Q_UNUSED(pixmap); - Q_UNUSED(type); -#endif } void* QVGPixmapData::toNativeType(NativeType type) { -#if defined(QT_SYMBIAN_SUPPORTS_SGIMAGE) && !defined(QT_NO_EGL) if (type == QPixmapData::SgImage) { +#if defined(QT_SYMBIAN_SUPPORTS_SGIMAGE) && !defined(QT_NO_EGL) toVGImage(); if (!isValid() || vgImage == VG_INVALID_HANDLE) @@ -657,6 +654,7 @@ void* QVGPixmapData::toNativeType(NativeType type) eglDestroyImageKHR(QEglContext::display(), eglImage); driver.Close(); return reinterpret_cast(sgImage); +#endif } else if (type == QPixmapData::FbsBitmap) { CFbsBitmap *bitmap = q_check_ptr(new CFbsBitmap); @@ -678,10 +676,7 @@ void* QVGPixmapData::toNativeType(NativeType type) return reinterpret_cast(bitmap); } -#else - Q_UNUSED(type); return 0; -#endif } #endif //Q_OS_SYMBIAN -- cgit v0.12 From a260a77d9d6b7856278e2ee9b42623c469479d4e Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Mon, 22 Mar 2010 21:14:39 +0100 Subject: Fixing keypad navigation focus frame The QFocusFrame drawing code in QS60Style incorrectly assumed that PM_LayoutSpacing is always equal to PM_FocusFrameMargin. When these values diverged, the focus frame broke as described in task QTBUG-8036. The fix makes the drawing more robust. The focus frame width is never thicker than PM_LayoutSpacing and PM_FocusFrameMargin. And instead of drawing a roundRect with calculated pen width, we are now filling a roundRect. That makes the focusFrame more apparent. Task-number: QTBUG-8036 Reviewed-by: Sami Merila --- src/gui/styles/qs60style.cpp | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 750e19f..86812a6 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -1964,11 +1964,6 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, case CE_MenuScroller: break; case CE_FocusFrame: { - // The pen width should nearly fill the layoutspacings around the widget - const int penWidth = - qMin(pixelMetric(QS60Style::PM_LayoutVerticalSpacing), pixelMetric(QS60Style::PM_LayoutHorizontalSpacing)) - - 2; // But keep 1 pixel distance to the focus widget and 1 pixel to the adjacent widgets - #ifdef QT_KEYPAD_NAVIGATION bool editFocus = false; if (const QFocusFrame *focusFrame = qobject_cast(widget)) { @@ -1979,25 +1974,27 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, #else const qreal opacity = 0.5; #endif - // Because of Qts coordinate system, we need to tweak the rect by .5 pixels, otherwise it gets blurred. - const qreal rectAdjustment = (penWidth % 2) ? -.5 : 0; - - // Make sure that the pen stroke is inside the rect - const QRectF adjustedRect = - QRectF(option->rect).adjusted( - rectAdjustment + penWidth, - rectAdjustment + penWidth, - -rectAdjustment - penWidth, - -rectAdjustment - penWidth - ); - - const qreal roundRectRadius = penWidth * goldenRatio; + // We need to reduce the focus frame size if LayoutSpacing is smaller than FocusFrameMargin + // Otherwise, we would overlay adjacent widgets. + const int frameHeightReduction = + qMin(0, pixelMetric(QStyle::PM_LayoutVerticalSpacing) + - pixelMetric(QStyle::PM_FocusFrameVMargin)); + const int frameWidthReduction = + qMin(0, pixelMetric(QStyle::PM_LayoutHorizontalSpacing) + - pixelMetric(QStyle::PM_FocusFrameHMargin)); + const int rounding = + qMin(pixelMetric(QStyle::PM_FocusFrameVMargin), + pixelMetric(QStyle::PM_LayoutVerticalSpacing)); + const QRect frameRect = + option->rect.adjusted(-frameWidthReduction, -frameHeightReduction, + frameWidthReduction, frameHeightReduction); + QPainterPath framePath; + framePath.addRoundedRect(frameRect, rounding, rounding); painter->save(); painter->setRenderHint(QPainter::Antialiasing); painter->setOpacity(opacity); - painter->setPen(QPen(option->palette.color(QPalette::Text), penWidth)); - painter->drawRoundedRect(adjustedRect, roundRectRadius, roundRectRadius); + painter->fillPath(framePath, option->palette.color(QPalette::Text)); painter->restore(); } break; -- cgit v0.12 From 9b363e44f372fee183290e010ceecf9e75282ce2 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Mon, 22 Mar 2010 21:36:54 +0100 Subject: Increase KeypadNavigation focus visibility The focus frame was drawn with a low opacity. That was intended meant to increase aesthetics but in reality decreased usability. Now, the opacity is higher. But still with a difference between navigation mode and edit mode. Task-number: QT-826 Reviewed-by: Sami Merila --- src/gui/styles/qs60style.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 86812a6..6448417 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -1970,9 +1970,9 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, if (focusFrame->widget() && focusFrame->widget()->hasEditFocus()) editFocus = true; } - const qreal opacity = editFocus ? 0.65 : 0.45; // Trial and error factors. Feel free to improve. + const qreal opacity = editFocus ? 1 : 0.75; // Trial and error factors. Feel free to improve. #else - const qreal opacity = 0.5; + const qreal opacity = 0.85; #endif // We need to reduce the focus frame size if LayoutSpacing is smaller than FocusFrameMargin // Otherwise, we would overlay adjacent widgets. -- cgit v0.12 From 253d075996818ba6d42e0caf9e03271e386621d0 Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Mon, 22 Mar 2010 09:48:37 +0200 Subject: Fixed left softkey regression caused by 7829fe15 in Symbian. Dialogs are always responsible for setting all of their softkeys by themselves, that's why this qmenubar hack can be removed. When "Options" menu support was moved from QMainWindow to QMenuBar, it appeared that some dialogs did had "Options" in LSK even it should have had dialog specific softkey. This commit removes the year old hack made to qdialogs softkey implementation. Reviewed-By: Sami Merila --- src/gui/dialogs/qdialog.cpp | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/gui/dialogs/qdialog.cpp b/src/gui/dialogs/qdialog.cpp index d8ac9a8..25ba016 100644 --- a/src/gui/dialogs/qdialog.cpp +++ b/src/gui/dialogs/qdialog.cpp @@ -69,7 +69,6 @@ extern bool qt_wince_is_smartphone(); //is defined in qguifunctions_wce.cpp # include "qfontdialog.h" # include "qcolordialog.h" # include "qwizard.h" -# include "qmenubar.h" #endif #if defined(Q_WS_S60) @@ -529,12 +528,6 @@ int QDialog::exec() #endif //Q_WS_WINCE_WM #ifdef Q_OS_SYMBIAN -#ifndef QT_NO_MENUBAR - QMenuBar *menuBar = 0; - if (!findChild()) - menuBar = new QMenuBar(this); -#endif - if (qobject_cast(this) || qobject_cast(this) || qobject_cast(this) || qobject_cast(this)) showMaximized(); @@ -566,13 +559,6 @@ int QDialog::exec() delete menuBar; #endif //QT_NO_MENUBAR #endif //Q_WS_WINCE_WM -#ifdef Q_OS_SYMBIAN -#ifndef QT_NO_MENUBAR - else if (menuBar) - delete menuBar; -#endif //QT_NO_MENUBAR -#endif //Q_OS_SYMBIAN - return res; } -- cgit v0.12 From ae3d95f872c8bd2e192c58d7c7c830a3d2e4bc43 Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Mon, 22 Mar 2010 10:17:17 +0200 Subject: Fixed 'fullsreen with softkeys' mode not to expand under softkey area. availableGeometry returns incorrect area after cba is made invisible, it seems that this happens because CAknToolbar is not made invisible. Fixed the problem by reverting back to SetExtentToWholeScreen usage when the widget is really fullscreen, i.e. Qt::WindowSoftkeysVisibleHint is not set. Task-number: QTBUG-9038 Reviewed-by: Miikka Heikkinen --- src/gui/kernel/qapplication_s60.cpp | 45 +++++++++++++++++++------------------ src/gui/kernel/qt_s60_p.h | 1 + src/gui/kernel/qwidget_s60.cpp | 8 ++++--- 3 files changed, 29 insertions(+), 25 deletions(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index e7a7093..37d1b62 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -1004,16 +1004,32 @@ void QSymbianControl::FocusChanged(TDrawNow /* aDrawNow */) // else { We don't touch the active window unless we were explicitly activated or deactivated } } +void QSymbianControl::handleClientAreaChange() +{ + const bool cbaVisibilityHint = qwidget->windowFlags() & Qt::WindowSoftkeysVisibleHint; + if (qwidget->isFullScreen() && !cbaVisibilityHint) { + SetExtentToWholeScreen(); + } else if (qwidget->isMaximized() || (qwidget->isFullScreen() && cbaVisibilityHint)) { + TRect r = static_cast(S60->appUi())->ClientRect(); + SetExtent(r.iTl, r.Size()); + } else if (!qwidget->isMinimized()) { // Normal geometry + if (!qwidget->testAttribute(Qt::WA_Resized)) { + qwidget->adjustSize(); + qwidget->setAttribute(Qt::WA_Resized, false); //not a user resize + } + if (!qwidget->testAttribute(Qt::WA_Moved) && qwidget->windowType() != Qt::Dialog) { + TRect r = static_cast(S60->appUi())->ClientRect(); + SetPosition(r.iTl); + qwidget->setAttribute(Qt::WA_Moved, false); // not really an explicit position + } + } +} + void QSymbianControl::HandleResourceChange(int resourceType) { switch (resourceType) { case KInternalStatusPaneChange: - if (qwidget->isFullScreen()) { - SetExtentToWholeScreen(); - } else if (qwidget->isMaximized()) { - TRect r = static_cast(S60->appUi())->ClientRect(); - SetExtent(r.iTl, r.Size()); - } + handleClientAreaChange(); if (IsFocused() && IsVisible()) { qwidget->d_func()->setWindowIcon_sys(true); qwidget->d_func()->setWindowTitle_sys(qwidget->windowTitle()); @@ -1025,22 +1041,7 @@ void QSymbianControl::HandleResourceChange(int resourceType) #ifdef Q_WS_S60 case KEikDynamicLayoutVariantSwitch: { - if (qwidget->isFullScreen()) { - SetExtentToWholeScreen(); - } else if (qwidget->isMaximized()) { - TRect r = static_cast(S60->appUi())->ClientRect(); - SetExtent(r.iTl, r.Size()); - } else if (!qwidget->isMinimized()){ // Normal geometry - if (!qwidget->testAttribute(Qt::WA_Resized)) { - qwidget->adjustSize(); - qwidget->setAttribute(Qt::WA_Resized, false); //not a user resize - } - if (!qwidget->testAttribute(Qt::WA_Moved) && qwidget->windowType() != Qt::Dialog) { - TRect r = static_cast(S60->appUi())->ClientRect(); - SetPosition(r.iTl); - qwidget->setAttribute(Qt::WA_Moved, false); // not really an explicit position - } - } + handleClientAreaChange(); break; } #endif diff --git a/src/gui/kernel/qt_s60_p.h b/src/gui/kernel/qt_s60_p.h index cedede1..7c6b754 100644 --- a/src/gui/kernel/qt_s60_p.h +++ b/src/gui/kernel/qt_s60_p.h @@ -212,6 +212,7 @@ private: #ifdef QT_SYMBIAN_SUPPORTS_ADVANCED_POINTER void translateAdvancedPointerEvent(const TAdvancedPointerEvent *event); #endif + void handleClientAreaChange(); private: static QSymbianControl *lastFocusedControl; diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index 79702af..bfa7050 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -1109,9 +1109,11 @@ void QWidget::setWindowState(Qt::WindowStates newstate) QTLWExtra *top = d->topData(); const QRect normalGeometry = (top->normalGeometry.width() < 0) ? geometry() : top->normalGeometry; - if (newstate & Qt::WindowFullScreen) - setGeometry(qApp->desktop()->availableGeometry(this)); - else if (newstate & Qt::WindowMaximized) + + const bool cbaVisibilityHint = windowFlags() & Qt::WindowSoftkeysVisibleHint; + if (newstate & Qt::WindowFullScreen && !cbaVisibilityHint) + setGeometry(qApp->desktop()->screenGeometry(this)); + else if (newstate & Qt::WindowMaximized || ((newstate & Qt::WindowFullScreen) && cbaVisibilityHint)) setGeometry(qApp->desktop()->availableGeometry(this)); else setGeometry(normalGeometry); -- cgit v0.12 From 262e98f9a29385f99cd6f768632264e0b621dc01 Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Tue, 23 Mar 2010 10:36:22 +0200 Subject: Fixed S60 softkey implementation to use popup/modal dialog softkeys. Previously softkey implementation assumed that source for softkey actions is focused widget or activewindow if there is no focused widget. Since for example pop-up menu does not take focus immediately in touch enabled devices, the underlying widget softkeys were visible and usable when menu was open. This lead to problem that underlying widget could be interacted via softkeys when popup menu was open. For example as reported in QTBUG-8688, it was possible to close the underlying filedialog from which the currently active context menu was launched. It was also possible to open "Options" menu of underlying widget when context menu was open, leading to situation where several context menus could be launched via "Actions" item of "Options" menu. This was reported as an issue: QTBUG-6167 In addition when user started navigating in context menu via keypad, the menu got focus and softkeys changed to partially correct. Only partially correct, since context menu "Select" action and "Options" action had same priority and both associated to LSK. In addition the context menu action "Cancel" associated to RSK was set to invisible, meaning that it was also disabled and appeared in sofkeys as dimmed. All of these issues were fixed by making making the popup and modal dialogs highest priority softkey source. In case the focused widget is inside popup or modal dialog it is being used as an initial softkey source. In addition the softkeys created with QSoftKeyManager::createAction or QSoftKeyManager::createKeyedAction are now by default invisible i.e. not visible in context menu and have special property set to make them still normally enabled in softkeys. Task-number: QTBUG-6167 Task-number: QTBUG-8688 Task-number: QTBUG-9144 Reviewed-by: Sami Merila --- src/gui/kernel/qsoftkeymanager.cpp | 60 ++++++++++++++++++++++++++++++---- src/gui/kernel/qsoftkeymanager_p.h | 5 ++- src/gui/kernel/qsoftkeymanager_s60.cpp | 7 ++-- src/gui/widgets/qmenu.cpp | 4 +-- src/gui/widgets/qmenubar.cpp | 1 - 5 files changed, 61 insertions(+), 16 deletions(-) diff --git a/src/gui/kernel/qsoftkeymanager.cpp b/src/gui/kernel/qsoftkeymanager.cpp index c9a94ee..d324c76 100644 --- a/src/gui/kernel/qsoftkeymanager.cpp +++ b/src/gui/kernel/qsoftkeymanager.cpp @@ -115,6 +115,8 @@ QAction *QSoftKeyManager::createAction(StandardSoftKey standardKey, QWidget *act break; } action->setSoftKeyRole(softKeyRole); + action->setVisible(false); + setForceEnabledInSoftkeys(action); return action; } @@ -168,25 +170,55 @@ bool QSoftKeyManager::appendSoftkeys(const QWidget &source, int level) { Q_D(QSoftKeyManager); bool ret = false; - QList actions = source.actions(); - for (int i = 0; i < actions.count(); ++i) { - if (actions.at(i)->softKeyRole() != QAction::NoSoftKey) { - d->requestedSoftKeyActions.insert(level, actions.at(i)); + foreach(QAction *action, source.actions()) { + if (action->softKeyRole() != QAction::NoSoftKey + && (action->isVisible() || isForceEnabledInSofkeys(action))) { + d->requestedSoftKeyActions.insert(level, action); ret = true; } } return ret; } + +static bool isChildOf(const QWidget *c, const QWidget *p) +{ + while (c) { + if (c == p) + return true; + c = c->parentWidget(); + } + return false; +} + QWidget *QSoftKeyManager::softkeySource(QWidget *previousSource, bool& recursiveMerging) { Q_D(QSoftKeyManager); QWidget *source = NULL; if (!previousSource) { // Initial source is primarily focuswidget and secondarily activeWindow - source = QApplication::focusWidget(); - if (!source) - source = QApplication::activeWindow(); + const QWidget *focus = QApplication::focusWidget(); + const QWidget *popup = QApplication::activePopupWidget(); + if (popup) { + if (isChildOf(focus, popup)) + source = focus; + else + source = popup; + } + if (!source) { + const QWidget *modal = QApplication::activeModalWidget(); + if (modal) { + if (isChildOf(focus, modal)) + source = focus; + else + source = modal; + } + } + if (!source) { + source = focus; + if (!source) + source = QApplication::activeWindow(); + } } else { // Softkey merging is based on four criterias // 1. Implicit merging is used whenever focus widget does not specify any softkeys @@ -220,6 +252,20 @@ bool QSoftKeyManager::handleUpdateSoftKeys() return true; } +void QSoftKeyManager::setForceEnabledInSoftkeys(QAction *action) +{ + action->setProperty(FORCE_ENABLED_PROPERTY, QVariant(true)); +} + +bool QSoftKeyManager::isForceEnabledInSofkeys(QAction *action) +{ + bool ret = false; + QVariant property = action->property(FORCE_ENABLED_PROPERTY); + if (property.isValid() && property.toBool()) + ret = true; + return ret; +} + bool QSoftKeyManager::event(QEvent *e) { #ifndef QT_NO_ACTION diff --git a/src/gui/kernel/qsoftkeymanager_p.h b/src/gui/kernel/qsoftkeymanager_p.h index a6fe17e..a5b258b 100644 --- a/src/gui/kernel/qsoftkeymanager_p.h +++ b/src/gui/kernel/qsoftkeymanager_p.h @@ -63,7 +63,8 @@ QT_BEGIN_NAMESPACE class QSoftKeyManagerPrivate; -const char MENU_ACTION_PROPERTY[] = "_q_menuaction"; +const char MENU_ACTION_PROPERTY[] = "_q_menuAction"; +const char FORCE_ENABLED_PROPERTY[] = "_q_forceEnabledInSoftkeys"; class Q_AUTOTEST_EXPORT QSoftKeyManager : public QObject { @@ -88,6 +89,8 @@ public: static QAction *createAction(StandardSoftKey standardKey, QWidget *actionWidget); static QAction *createKeyedAction(StandardSoftKey standardKey, Qt::Key key, QWidget *actionWidget); static QString standardSoftKeyText(StandardSoftKey standardKey); + static void setForceEnabledInSoftkeys(QAction *action); + static bool isForceEnabledInSofkeys(QAction *action); protected: bool event(QEvent *e); diff --git a/src/gui/kernel/qsoftkeymanager_s60.cpp b/src/gui/kernel/qsoftkeymanager_s60.cpp index 3a0304c..9812d72 100644 --- a/src/gui/kernel/qsoftkeymanager_s60.cpp +++ b/src/gui/kernel/qsoftkeymanager_s60.cpp @@ -288,11 +288,7 @@ bool QSoftKeyManagerPrivateS60::setSoftkey(CEikButtonGroupContainer &cba, TPtrC nativeText = qt_QString2TPtrC(text); int command = S60_COMMAND_START + position; setNativeSoftkey(cba, position, command, nativeText); - // QMainWindow "Options" action is set to invisible in order it does not appear in context menu - // and all invisible actions are by default disabled. - // However we never want to dim options softkey, even it is set to invisible - QVariant property = action->property(MENU_ACTION_PROPERTY); - const bool dimmed = (property.isValid() && property.toBool()) ? false : !action->isEnabled(); + const bool dimmed = !action->isEnabled() && !QSoftKeyManager::isForceEnabledInSofkeys(action); cba.DimCommand(command, dimmed); realSoftKeyActions.insert(command, action); return true; @@ -335,6 +331,7 @@ bool QSoftKeyManagerPrivateS60::setRightSoftkey(CEikButtonGroupContainer &cba) cbaHasImage[RSK_POSITION] = false; } setNativeSoftkey(cba, RSK_POSITION, EAknSoftkeyExit, nativeText); + cba.DimCommand(EAknSoftkeyExit, false); return true; } } diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp index 42b7406..a9978f9 100644 --- a/src/gui/widgets/qmenu.cpp +++ b/src/gui/widgets/qmenu.cpp @@ -168,8 +168,8 @@ void QMenuPrivate::init() #ifdef QT_SOFTKEYS_ENABLED selectAction = QSoftKeyManager::createKeyedAction(QSoftKeyManager::SelectSoftKey, Qt::Key_Select, q); cancelAction = QSoftKeyManager::createKeyedAction(QSoftKeyManager::CancelSoftKey, Qt::Key_Back, q); - selectAction->setVisible(false); // Don't show these in the menu - cancelAction->setVisible(false); + selectAction->setPriority(QAction::HighPriority); + cancelAction->setPriority(QAction::HighPriority); q->addAction(selectAction); q->addAction(cancelAction); #endif diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp index 13aa02b..e368d3d 100644 --- a/src/gui/widgets/qmenubar.cpp +++ b/src/gui/widgets/qmenubar.cpp @@ -1404,7 +1404,6 @@ void QMenuBarPrivate::handleReparent() if (!menuBarAction) { if (newParent) { menuBarAction = QSoftKeyManager::createAction(QSoftKeyManager::MenuSoftKey, newParent); - menuBarAction->setVisible(false); newParent->addAction(menuBarAction); } } else { -- cgit v0.12 From 0409cdb406021d8609eb2a88a896f9fbc085805f Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Tue, 23 Mar 2010 11:21:38 +0200 Subject: Hotfix to const usage in 262e98f9a29385f99cd6f768632264e0b621dc01 Reviewed-By: TrustMe --- src/gui/kernel/qsoftkeymanager.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qsoftkeymanager.cpp b/src/gui/kernel/qsoftkeymanager.cpp index d324c76..923144a 100644 --- a/src/gui/kernel/qsoftkeymanager.cpp +++ b/src/gui/kernel/qsoftkeymanager.cpp @@ -197,8 +197,8 @@ QWidget *QSoftKeyManager::softkeySource(QWidget *previousSource, bool& recursive QWidget *source = NULL; if (!previousSource) { // Initial source is primarily focuswidget and secondarily activeWindow - const QWidget *focus = QApplication::focusWidget(); - const QWidget *popup = QApplication::activePopupWidget(); + QWidget *focus = QApplication::focusWidget(); + QWidget *popup = QApplication::activePopupWidget(); if (popup) { if (isChildOf(focus, popup)) source = focus; @@ -206,7 +206,7 @@ QWidget *QSoftKeyManager::softkeySource(QWidget *previousSource, bool& recursive source = popup; } if (!source) { - const QWidget *modal = QApplication::activeModalWidget(); + QWidget *modal = QApplication::activeModalWidget(); if (modal) { if (isChildOf(focus, modal)) source = focus; -- cgit v0.12 From dd9c26cba63c54358f3309143b76ae0416f89c78 Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Tue, 23 Mar 2010 11:39:56 +0200 Subject: Remove internal custom pixel metric enums Use only public custom pixel metrics. Remove the internal enum and switch usage of those to public enum values. Task-number: QTBUG-9247 Reviewed-by: Alessandro Portale --- src/gui/styles/qs60style.cpp | 30 +++++++++++++++--------------- src/gui/styles/qs60style_p.h | 8 -------- 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index ec8b468..c77d828 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -413,8 +413,8 @@ QColor QS60StylePrivate::colorFromFrameGraphics(SkinFrameElements frame) const { const bool cachedColorExists = m_colorCache.contains(frame); if (!cachedColorExists) { - const int frameCornerWidth = pixelMetric(PM_Custom_FrameCornerWidth); - const int frameCornerHeight = pixelMetric(PM_Custom_FrameCornerHeight); + const int frameCornerWidth = pixelMetric(PM_FrameCornerWidth); + const int frameCornerHeight = pixelMetric(PM_FrameCornerHeight); Q_ASSERT(2 * frameCornerWidth < 32); Q_ASSERT(2 * frameCornerHeight < 32); @@ -874,7 +874,7 @@ QSize QS60StylePrivate::partSize(QS60StyleEnums::SkinParts part, SkinElementFlag case QS60StyleEnums::SP_QgnGrafBarFrameSideL: case QS60StyleEnums::SP_QgnGrafBarFrameSideR: - result.setWidth(pixelMetric(PM_Custom_FrameCornerWidth)); + result.setWidth(pixelMetric(PM_FrameCornerWidth)); break; case QS60StyleEnums::SP_QsnCpScrollHandleTopPressed: @@ -901,15 +901,15 @@ QSize QS60StylePrivate::partSize(QS60StyleEnums::SkinParts part, SkinElementFlag case 7: /* CornerTr */ case 6: /* CornerBl */ case 5: /* CornerBr */ - result.setWidth(pixelMetric(PM_Custom_FrameCornerWidth)); + result.setWidth(pixelMetric(PM_FrameCornerWidth)); // Falltrough intended... case 4: /* SideT */ case 3: /* SideB */ - result.setHeight(pixelMetric(PM_Custom_FrameCornerHeight)); + result.setHeight(pixelMetric(PM_FrameCornerHeight)); break; case 2: /* SideL */ case 1: /* SideR */ - result.setWidth(pixelMetric(PM_Custom_FrameCornerWidth)); + result.setWidth(pixelMetric(PM_FrameCornerWidth)); break; case 0: /* center */ default: @@ -1376,7 +1376,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, } if (!comboBox->currentText.isEmpty() && !comboBox->editable) { QCommonStyle::drawItemText(painter, - editRect.adjusted(QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth), 0, -1, 0), + editRect.adjusted(QS60StylePrivate::pixelMetric(PM_FrameCornerWidth), 0, -1, 0), visualAlignment(comboBox->direction, Qt::AlignLeft | Qt::AlignVCenter), comboBox->palette, comboBox->state & State_Enabled, comboBox->currentText); } @@ -1841,8 +1841,8 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, painter->save(); QPen linePen = QPen(QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors, 1, header)); const int penWidth = (header->orientation == Qt::Horizontal) ? - linePen.width() + QS60StylePrivate::pixelMetric(PM_Custom_BoldLineWidth) - : linePen.width() + QS60StylePrivate::pixelMetric(PM_Custom_ThinLineWidth); + linePen.width() + QS60StylePrivate::pixelMetric(PM_BoldLineWidth) + : linePen.width() + QS60StylePrivate::pixelMetric(PM_ThinLineWidth); linePen.setWidth(penWidth); painter->setPen(linePen); if (header->orientation == Qt::Horizontal){ @@ -1861,7 +1861,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, //Make cornerButton slightly smaller so that it is not on top of table border graphic. QStyleOptionHeader subopt = *header; const int borderTweak = - QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth) >> 1; + QS60StylePrivate::pixelMetric(PM_FrameCornerWidth) >> 1; if (subopt.direction == Qt::LeftToRight) subopt.rect.adjust(borderTweak, borderTweak, 0, -borderTweak); else @@ -2085,7 +2085,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti // ... or normal "tick" selection at the end. } else if (option->state & State_Selected) { QRect tickRect = option->rect; - const int frameBorderWidth = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth); + const int frameBorderWidth = QS60StylePrivate::pixelMetric(PM_FrameCornerWidth); // adjust tickmark rect to exclude frame border tickRect.adjust(0, -frameBorderWidth, 0, -frameBorderWidth); QS60StyleEnums::SkinParts skinPart = QS60StyleEnums::SP_QgnIndiMarkedAdd; @@ -2166,7 +2166,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti const QS60StyleEnums::SkinParts part = (element == PE_IndicatorSpinUp) ? QS60StyleEnums::SP_QgnGrafScrollArrowUp : QS60StyleEnums::SP_QgnGrafScrollArrowDown; - const int iconMargin = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth) >> 1; + const int iconMargin = QS60StylePrivate::pixelMetric(PM_FrameCornerWidth) >> 1; optionSpinBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? iconMargin : -iconMargin ); QS60StylePrivate::drawSkinPart(part, painter, optionSpinBox.rect, flags); } else { @@ -2180,7 +2180,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti // We want to draw down arrow here for comboboxes as well. QStyleOptionFrame optionsComboBox = *cmb; const QS60StyleEnums::SkinParts part = QS60StyleEnums::SP_QgnGrafScrollArrowDown; - const int iconMargin = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth) >> 1; + const int iconMargin = QS60StylePrivate::pixelMetric(PM_FrameCornerWidth) >> 1; optionsComboBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? iconMargin : -iconMargin ); QS60StylePrivate::drawSkinPart(part, painter, optionsComboBox.rect, flags); } else { @@ -2934,9 +2934,9 @@ QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, con if (qstyleoption_cast(opt)) { // Subtract area needed for line if (opt->state & State_Horizontal) - ret.setHeight(ret.height() - QS60StylePrivate::pixelMetric(PM_Custom_BoldLineWidth)); + ret.setHeight(ret.height() - QS60StylePrivate::pixelMetric(PM_BoldLineWidth)); else - ret.setWidth(ret.width() - QS60StylePrivate::pixelMetric(PM_Custom_ThinLineWidth)); + ret.setWidth(ret.width() - QS60StylePrivate::pixelMetric(PM_ThinLineWidth)); } ret = visualRect(opt->direction, opt->rect, ret); break; diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h index df6f582..8bb2f7b 100644 --- a/src/gui/styles/qs60style_p.h +++ b/src/gui/styles/qs60style_p.h @@ -62,14 +62,6 @@ QT_BEGIN_NAMESPACE const int MAX_NON_CUSTOM_PIXELMETRICS = 92; const int CUSTOMVALUESCOUNT = 4; -//internal custom pixel metrics values, these map to entry in data[] table -enum { - PM_Custom_FrameCornerWidth = MAX_NON_CUSTOM_PIXELMETRICS, - PM_Custom_FrameCornerHeight, - PM_Custom_BoldLineWidth, - PM_Custom_ThinLineWidth - }; - const int MAX_PIXELMETRICS = MAX_NON_CUSTOM_PIXELMETRICS + CUSTOMVALUESCOUNT; typedef struct { -- cgit v0.12 From cd226eeb278108a5c1168b7cc01cadded6045f05 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 23 Mar 2010 12:27:08 +0200 Subject: Changed Symbian pkg files to deploy from under epoc32 Since the build process copies everything that is deployed using DEPLOYMENT variable under epoc32 somewhere, pkg files might as well look for the files from there. This can be useful for binary releases if the release needs to be repackaged. Task-number: QT-3147 Reviewed-by: Janne Anttila --- qmake/generators/symbian/symmake.cpp | 21 ++++++++++++++++++--- src/s60installs/s60installs.pro | 5 ++++- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/qmake/generators/symbian/symmake.cpp b/qmake/generators/symbian/symmake.cpp index 9aa122a..c6023b5 100644 --- a/qmake/generators/symbian/symmake.cpp +++ b/qmake/generators/symbian/symmake.cpp @@ -456,14 +456,29 @@ void SymbianMakefileGenerator::generatePkgFile(const QString &iconFile, Deployme // deploy any additional DEPLOYMENT files QString remoteTestPath; remoteTestPath = QString("!:\\private\\%1").arg(privateDirUid); + QString zDir = epocRoot() + QLatin1String("epoc32/data/z"); initProjectDeploySymbian(project, depList, remoteTestPath, true, "$(PLATFORM)", "$(TARGET)", generatedDirs, generatedFiles); if (depList.size()) t << "; DEPLOYMENT" << endl; for (int i = 0; i < depList.size(); ++i) { - t << QString("\"%1\" - \"%2\"") - .arg(QString(depList.at(i).from).replace('\\','/')) - .arg(depList.at(i).to) << endl; + QString from = depList.at(i).from; + QString to = depList.at(i).to; + + // Deploy anything not already deployed from under epoc32 instead from under + // \epoc32\data\z\ to enable using pkg file without rebuilding + // the project, which can be useful for some binary only distributions. + if (!from.contains(QLatin1String("epoc32"), Qt::CaseInsensitive)) { + from = to; + if (from.size() > 1 && from.at(1) == QLatin1Char(':')) + from = from.mid(2); + from.prepend(zDir); + } else { + if (from.size() > 1 && from.at(1) == QLatin1Char(':')) + from = from.mid(2); + } + + t << QString("\"%1\" - \"%2\"").arg(from.replace('\\','/')).arg(to) << endl; } t << endl; diff --git a/src/s60installs/s60installs.pro b/src/s60installs/s60installs.pro index 1f6e72b..f37cd58 100644 --- a/src/s60installs/s60installs.pro +++ b/src/s60installs/s60installs.pro @@ -13,9 +13,12 @@ symbian: { TARGET.UID3 = 0x2001E61C # sqlite3 is expected to be already found on phone if infixed configuration is built. + BLD_INF_RULES.prj_exports += \ + "sqlite3.sis $${EPOCROOT}epoc32/data/qt/sis/sqlite3.sis" \ + "sqlite3_selfsigned.sis $${EPOCROOT}epoc32/data/qt/sis/sqlite3_selfsigned.sis" sqlitedeployment = \ "; Deploy sqlite onto phone that does not have it already" \ - "@\"$$PWD/sqlite3.sis\", (0x2002af5f)" + "@\"$${EPOCROOT}epoc32/data/qt/sis/sqlite3.sis\", (0x2002af5f)" qtlibraries.pkg_postrules += sqlitedeployment } else { # Always use experimental UID for infixed configuration to avoid UID clash -- cgit v0.12 From c1b524dd8b7a7207d10c33b454519d717349ac6c Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Tue, 23 Mar 2010 09:37:27 +0100 Subject: QNAM HTTP: Do not use TCP_NODELAY Reviewed-by: thiago --- src/network/access/qhttpnetworkconnectionchannel.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index 1d8224c..82bc14f 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -865,7 +865,14 @@ void QHttpNetworkConnectionChannel::_q_disconnected() void QHttpNetworkConnectionChannel::_q_connected() { // improve performance since we get the request sent by the kernel ASAP - socket->setSocketOption(QAbstractSocket::LowDelayOption, 1); + //socket->setSocketOption(QAbstractSocket::LowDelayOption, 1); + // We have this commented out now. It did not have the effect we wanted. If we want to + // do this properly, Qt has to combine multiple HTTP requests into one buffer + // and send this to the kernel in one syscall and then the kernel immediately sends + // it as one TCP packet because of TCP_NODELAY. + // However, this code is currently not in Qt, so we rely on the kernel combining + // the requests into one TCP packet. + // not sure yet if it helps, but it makes sense socket->setSocketOption(QAbstractSocket::KeepAliveOption, 1); -- cgit v0.12 From a50519ba225459a9d21209fe50a3a8fbd8081a19 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Tue, 23 Mar 2010 14:17:29 +0100 Subject: Compile fix Commit 47902b7587d66c0941bacf08b31b8caae264f09a was missing one enum rename in qs60style_s60.cpp Reviewed-by: TrustMe --- src/gui/styles/qs60style_s60.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index 0f014c1..75ed0c7 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -978,8 +978,8 @@ void QS60StyleModeSpecifics::frameIdAndCenterId(QS60StylePrivate::SkinFrameEleme TRect QS60StyleModeSpecifics::innerRectFromElement(QS60StylePrivate::SkinFrameElements frameElement, const TRect &outerRect) { - TInt widthShrink = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth); - TInt heightShrink = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerHeight); + TInt widthShrink = QS60StylePrivate::pixelMetric(PM_FrameCornerWidth); + TInt heightShrink = QS60StylePrivate::pixelMetric(PM_FrameCornerHeight); switch(frameElement) { case QS60StylePrivate::SF_PanelBackground: // panel should have slightly slimmer border to enable thin line of background graphics between closest component -- cgit v0.12 From 66813ad3dd429c4a8d58a2b4f8b79d14b8af4356 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Tue, 23 Mar 2010 13:37:23 +0000 Subject: Added Symbian UserEnvironment capability to audioinput example Symbian applications which use QAudioInput must have this Platform Security capability. Without it, the Symbian audio subsystem will not allow the application to record audio. Reviewed-by: trustme --- examples/multimedia/audioinput/audioinput.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/multimedia/audioinput/audioinput.pro b/examples/multimedia/audioinput/audioinput.pro index a54d452..6a1c79d 100644 --- a/examples/multimedia/audioinput/audioinput.pro +++ b/examples/multimedia/audioinput/audioinput.pro @@ -12,5 +12,6 @@ INSTALLS += target sources symbian { TARGET.UID3 = 0xA000D7BF + TARGET.CAPABILITY += UserEnvironment include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) } -- cgit v0.12 From 8f01952fcc062ad042601d75a994b43ee289ac0f Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Tue, 23 Mar 2010 17:56:47 -0700 Subject: Doc update for QSpinBox::textFromValue We remove the group separator so the docs should reflect this. Reviewed-by: Donald Carr --- src/gui/widgets/qspinbox.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/gui/widgets/qspinbox.cpp b/src/gui/widgets/qspinbox.cpp index 726426d..2d871d0 100644 --- a/src/gui/widgets/qspinbox.cpp +++ b/src/gui/widgets/qspinbox.cpp @@ -448,11 +448,12 @@ void QSpinBox::setRange(int minimum, int maximum) } /*! - This virtual function is used by the spin box whenever it needs - to display the given \a value. The default implementation returns - a string containing \a value printed in the standard way using - QWidget::locale().toString(). Reimplementations may return anything. (See - the example in the detailed description.) + This virtual function is used by the spin box whenever it needs to + display the given \a value. The default implementation returns a + string containing \a value printed in the standard way using + QWidget::locale().toString(), but with the thousand separator + removed. Reimplementations may return anything. (See the example + in the detailed description.) Note: QSpinBox does not call this function for specialValueText() and that neither prefix() nor suffix() should be included in the @@ -461,7 +462,7 @@ void QSpinBox::setRange(int minimum, int maximum) If you reimplement this, you may also need to reimplement valueFromText() and validate() - \sa valueFromText(), validate() + \sa valueFromText(), validate(), QLocale::groupSeparator() */ QString QSpinBox::textFromValue(int value) const @@ -869,7 +870,7 @@ void QDoubleSpinBox::setDecimals(int decimals) If you reimplement this, you may also need to reimplement valueFromText(). - \sa valueFromText() + \sa valueFromText(), QLocale::groupSeparator() */ -- cgit v0.12 From e887e0c38b5497757dfc69190c5a86cdc8104097 Mon Sep 17 00:00:00 2001 From: Justin McPherson Date: Wed, 24 Mar 2010 12:51:58 +1000 Subject: Calculate period size correctly. Reviewed-by:Dmytro Poplavskiy --- src/multimedia/audio/qaudioinput_mac_p.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/multimedia/audio/qaudioinput_mac_p.cpp b/src/multimedia/audio/qaudioinput_mac_p.cpp index 4b37b18..cb65f6e 100644 --- a/src/multimedia/audio/qaudioinput_mac_p.cpp +++ b/src/multimedia/audio/qaudioinput_mac_p.cpp @@ -670,8 +670,8 @@ bool QAudioInputPrivate::open() } // Allocate buffer - periodSizeBytes = (numberOfFrames * streamFormat.mSampleRate / deviceFormat.mSampleRate) * - streamFormat.mBytesPerFrame; + periodSizeBytes = numberOfFrames * streamFormat.mBytesPerFrame; + if (internalBufferSize < periodSizeBytes * 2) internalBufferSize = periodSizeBytes * 2; else -- cgit v0.12 From b6b1dee9460d6fdde0b8ad005301c0a315ad30bf Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Mon, 22 Mar 2010 08:04:46 +0100 Subject: Fix a crash when reparenting an item in QGraphicsView. Before calling addItem we need to invalidate the depth otherwise if someone call anything relating to sorting when itemChange is called (because of the scene change for instance) then qt_closestItemFirst for example can crash because of an invalid state. Task-number:QTBUG-6932 Reviewed-by:janarve --- src/gui/graphicsview/qgraphicsitem.cpp | 5 ++-- tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 34 ++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index f3c90ca..9852323 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1130,6 +1130,9 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, const Q } } + // Resolve depth. + invalidateDepthRecursively(); + if ((parent = newParent)) { if (parent->d_func()->scene && parent->d_func()->scene != scene) { // Move this item to its new parent's scene @@ -1180,8 +1183,6 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, const Q } } - // Resolve depth. - invalidateDepthRecursively(); dirtySceneTransform = 1; // Restore the sub focus chain. diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 4d9f23f..75fb337 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -439,6 +439,7 @@ private slots: void QTBUG_7714_fullUpdateDiscardingOpacityUpdate2(); void QT_2653_fullUpdateDiscardingOpacityUpdate(); void QT_2649_focusScope(); + void sortItemsWhileAdding(); private: QList paintedItems; @@ -10070,5 +10071,38 @@ void tst_QGraphicsItem::QT_2649_focusScope() delete scene; } +class MyGraphicsItemWithItemChange : public QGraphicsWidget +{ +public: + MyGraphicsItemWithItemChange(QGraphicsItem *parent = 0) : QGraphicsWidget(parent) + {} + + QVariant itemChange(GraphicsItemChange change, const QVariant &value) + { + if (change == QGraphicsItem::ItemSceneHasChanged) { + foreach (QGraphicsView *view, scene()->views()) { + //We trigger a sort of unindexed items in the BSP + view->sceneRect(); + } + } + return QGraphicsWidget::itemChange(change, value); + } +}; + +void tst_QGraphicsItem::sortItemsWhileAdding() +{ + QGraphicsScene scene; + QGraphicsView view(&scene); + QGraphicsWidget grandGrandParent; + grandGrandParent.resize(200, 200); + scene.addItem(&grandGrandParent); + QGraphicsWidget grandParent; + grandParent.resize(200, 200); + QGraphicsWidget parent(&grandParent); + parent.resize(200, 200); + MyGraphicsItemWithItemChange item(&parent); + grandParent.setParentItem(&grandGrandParent); +} + QTEST_MAIN(tst_QGraphicsItem) #include "tst_qgraphicsitem.moc" -- cgit v0.12 From c8fa23a5edd790d9eed0620068a29e03e4202cac Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Wed, 24 Mar 2010 02:12:47 +0100 Subject: Invalidate the cache of QGraphicsEffect if a child becomes visible. The effect might rely on a child to draw itself. So we need to redraw if a child become visible or invisible. Task-number:QTBUG-7843 Reviewed-by:janarve --- src/gui/graphicsview/qgraphicsitem.cpp | 6 ++- tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp | 43 ++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 9852323..e10c03a 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -2177,8 +2177,12 @@ void QGraphicsItemPrivate::setVisibleHelper(bool newVisible, bool explicitly, bo QGraphicsItemCache *c = (QGraphicsItemCache *)qVariantValue(extra(ExtraCacheData)); if (c) c->purge(); - if (scene) + if (scene) { +#ifndef QT_NO_GRAPHICSEFFECT + invalidateParentGraphicsEffectsRecursively(); +#endif //QT_NO_GRAPHICSEFFECT scene->d_func()->markDirty(q_ptr, QRectF(), /*invalidateChildren=*/false, /*force=*/true); + } } // Certain properties are dropped as an item becomes invisible. diff --git a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp index 1007d61..02899ae 100644 --- a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp +++ b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include #include "../../shared/util.h" @@ -73,6 +74,7 @@ private slots: void deviceCoordinateTranslateCaching(); void inheritOpacity(); void dropShadowClipping(); + void childrenVisibilityShouldInvalidateCache(); }; void tst_QGraphicsEffect::initTestCase() @@ -613,6 +615,47 @@ void tst_QGraphicsEffect::dropShadowClipping() QCOMPARE(img.pixel(x, y), img.pixel(x, y-1)); } +class MyGraphicsItem : public QGraphicsWidget +{ +public: + MyGraphicsItem(QGraphicsItem *parent = 0) : + QGraphicsWidget(parent), nbPaint(0) + {} + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) + { + nbPaint++; + QGraphicsWidget::paint(painter, option, widget); + } + int nbPaint; +}; + +void tst_QGraphicsEffect::childrenVisibilityShouldInvalidateCache() +{ + QGraphicsScene scene; + MyGraphicsItem parent; + parent.resize(200, 200); + QGraphicsWidget child(&parent); + child.resize(200, 200); + child.setVisible(false); + scene.addItem(&parent); + QGraphicsView view(&scene); + view.show(); + QApplication::setActiveWindow(&view); + QTest::qWaitForWindowShown(&view); + QCOMPARE(parent.nbPaint, 1); + //we set an effect on the parent + parent.setGraphicsEffect(new QGraphicsDropShadowEffect(&parent)); + //flush the events + QApplication::processEvents(); + //new effect applied->repaint + QCOMPARE(parent.nbPaint, 2); + child.setVisible(true); + //flush the events + QApplication::processEvents(); + //a new child appears we need to redraw the effect. + QCOMPARE(parent.nbPaint, 3); +} + QTEST_MAIN(tst_QGraphicsEffect) #include "tst_qgraphicseffect.moc" -- cgit v0.12 From 4be83fa7337c5a4eb7b0ce085aa5854af5d33252 Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Wed, 24 Mar 2010 05:33:21 +0100 Subject: Add a children private property needed for QML to support QGraphicsObject Commit adds a private property that QML can use to add children for a given item. This is a custom list that calls a callback which actually reparent the item instead of just appending in the list (otherwise it will mess up the state of QGraphicsView). This is needed because childItems() is pretty useless you get a list but if you append something on it then it adds that into a copy. Also the children property is the default property a concept used by QML. Width and Height private properties has been added in order to support better the integration with QGraphicsWidget in QML. The actual implementation is in the private class of QGI and QGraphicsWidget reimplements it to return the geometry. (In 4.7 QDeclarativeItem reimplements it too). This change should be harmless everything is private. Task-number:QT-2757 Reviewed-by:andreas --- src/gui/graphicsview/qgraphicsitem.cpp | 103 +++++++++++++++++++++ src/gui/graphicsview/qgraphicsitem.h | 7 ++ src/gui/graphicsview/qgraphicsitem_p.h | 67 ++++++++++++++ src/gui/graphicsview/qgraphicswidget.cpp | 14 +++ src/gui/graphicsview/qgraphicswidget_p.cpp | 51 ++++++++++ src/gui/graphicsview/qgraphicswidget_p.h | 9 ++ tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp | 28 ++++++ 7 files changed, 279 insertions(+) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index e10c03a..f110a5c 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -5224,6 +5224,8 @@ void QGraphicsItemPrivate::addChild(QGraphicsItem *child) needSortChildren = 1; // ### maybe 0 child->d_ptr->siblingIndex = children.size(); children.append(child); + if (isObject) + emit static_cast(q_ptr)->childrenChanged(); } /*! @@ -5246,6 +5248,8 @@ void QGraphicsItemPrivate::removeChild(QGraphicsItem *child) // the child is not guaranteed to be at the index after the list is sorted. // (see ensureSortedChildren()). child->d_ptr->siblingIndex = -1; + if (isObject) + emit static_cast(q_ptr)->childrenChanged(); } /*! @@ -7453,6 +7457,88 @@ void QGraphicsObject::ungrabGesture(Qt::GestureType gesture) } } +void QGraphicsItemPrivate::append(QDeclarativeListProperty *list, QGraphicsObject *item) +{ + QGraphicsItemPrivate::get(item)->setParentItemHelper(static_cast(list->object), /*newParentVariant=*/0, /*thisPointerVariant=*/0); +} + +/*! + Returns a list of this item's children. + + The items are sorted by stacking order. This takes into account both the + items' insertion order and their Z-values. + +*/ +QDeclarativeListProperty QGraphicsItemPrivate::childrenList() +{ + Q_Q(QGraphicsItem); + if (isObject) { + QGraphicsObject *that = static_cast(q); + return QDeclarativeListProperty(that, &children, QGraphicsItemPrivate::append); + } else { + //QGraphicsItem is not supported for this property + return QDeclarativeListProperty(); + } +} + +/*! + \internal + Returns the width of the item + Reimplemented by QGraphicsWidget +*/ +qreal QGraphicsItemPrivate::width() const +{ + return 0; +} + +/*! + \internal + Set the width of the item + Reimplemented by QGraphicsWidget +*/ +void QGraphicsItemPrivate::setWidth(qreal w) +{ + Q_UNUSED(w); +} + +/*! + \internal + Reset the width of the item + Reimplemented by QGraphicsWidget +*/ +void QGraphicsItemPrivate::resetWidth() +{ +} + +/*! + \internal + Returns the height of the item + Reimplemented by QGraphicsWidget +*/ +qreal QGraphicsItemPrivate::height() const +{ + return 0; +} + +/*! + \internal + Set the height of the item + Reimplemented by QGraphicsWidget +*/ +void QGraphicsItemPrivate::setHeight(qreal h) +{ + Q_UNUSED(h); +} + +/*! + \internal + Reset the height of the item + Reimplemented by QGraphicsWidget +*/ +void QGraphicsItemPrivate::resetHeight() +{ +} + /*! \property QGraphicsObject::parent \brief the parent of the item @@ -7639,6 +7725,23 @@ void QGraphicsObject::ungrabGesture(Qt::GestureType gesture) \sa scale, rotation, QGraphicsItem::transformOriginPoint() */ +/*! + \fn void QGraphicsObject::widthChanged() + \internal +*/ + +/*! + \fn void QGraphicsObject::heightChanged() + \internal +*/ + +/*! + + \fn QGraphicsObject::childrenChanged() + + This signal gets emitted whenever the children list changes + \internal +*/ /*! \class QAbstractGraphicsShapeItem diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h index d72833b..5023f60 100644 --- a/src/gui/graphicsview/qgraphicsitem.h +++ b/src/gui/graphicsview/qgraphicsitem.h @@ -547,6 +547,10 @@ class Q_GUI_EXPORT QGraphicsObject : public QObject, public QGraphicsItem Q_PROPERTY(qreal rotation READ rotation WRITE setRotation NOTIFY rotationChanged) Q_PROPERTY(qreal scale READ scale WRITE setScale NOTIFY scaleChanged) Q_PROPERTY(QPointF transformOriginPoint READ transformOriginPoint WRITE setTransformOriginPoint) + Q_PRIVATE_PROPERTY(QGraphicsItem::d_func(), QDeclarativeListProperty children READ childrenList DESIGNABLE false NOTIFY childrenChanged) + Q_PRIVATE_PROPERTY(QGraphicsItem::d_func(), qreal width READ width WRITE setWidth NOTIFY widthChanged RESET resetWidth FINAL) + Q_PRIVATE_PROPERTY(QGraphicsItem::d_func(), qreal height READ height WRITE setHeight NOTIFY heightChanged RESET resetHeight FINAL) + Q_CLASSINFO("DefaultProperty", "children") Q_INTERFACES(QGraphicsItem) public: QGraphicsObject(QGraphicsItem *parent = 0); @@ -571,6 +575,9 @@ Q_SIGNALS: void zChanged(); void rotationChanged(); void scaleChanged(); + void childrenChanged(); + void widthChanged(); + void heightChanged(); protected: QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent, QGraphicsScene *scene); diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index ea04e0b..669ae1b 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -71,6 +71,62 @@ QT_BEGIN_NAMESPACE class QGraphicsItemPrivate; +#ifndef QDECLARATIVELISTPROPERTY +#define QDECLARATIVELISTPROPERTY +template +struct QDeclarativeListProperty { + typedef void (*AppendFunction)(QDeclarativeListProperty *, T*); + typedef int (*CountFunction)(QDeclarativeListProperty *); + typedef T *(*AtFunction)(QDeclarativeListProperty *, int); + typedef void (*ClearFunction)(QDeclarativeListProperty *); + + QDeclarativeListProperty() + : object(0), data(0), append(0), count(0), at(0), clear(0), dummy1(0), dummy2(0) {} + QDeclarativeListProperty(QObject *o, QList &list) + : object(o), data(&list), append(qlist_append), count(qlist_count), at(qlist_at), + clear(qlist_clear), dummy1(0), dummy2(0) {} + QDeclarativeListProperty(QObject *o, void *d, AppendFunction a, CountFunction c = 0, AtFunction t = 0, + ClearFunction r = 0) + : object(o), data(d), append(a), count(c), at(t), clear(r), dummy1(0), dummy2(0) {} + + bool operator==(const QDeclarativeListProperty &o) const { + return object == o.object && + data == o.data && + append == o.append && + count == o.count && + at == o.at && + clear == o.clear; + } + + QObject *object; + void *data; + + AppendFunction append; + + CountFunction count; + AtFunction at; + + ClearFunction clear; + + void *dummy1; + void *dummy2; + +private: + static void qlist_append(QDeclarativeListProperty *p, T *v) { + ((QList *)p->data)->append(v); + } + static int qlist_count(QDeclarativeListProperty *p) { + return ((QList *)p->data)->count(); + } + static T *qlist_at(QDeclarativeListProperty *p, int idx) { + return ((QList *)p->data)->at(idx); + } + static void qlist_clear(QDeclarativeListProperty *p) { + return ((QList *)p->data)->clear(); + } +}; +#endif + class QGraphicsItemCache { public: @@ -237,6 +293,7 @@ public: void resolveDepth(); void addChild(QGraphicsItem *child); void removeChild(QGraphicsItem *child); + QDeclarativeListProperty childrenList(); void setParentItemHelper(QGraphicsItem *parent, const QVariant *newParentVariant, const QVariant *thisPointerVariant); void childrenBoundingRectHelper(QTransform *x, QRectF *rect); @@ -423,11 +480,21 @@ public: inline QTransform transformToParent() const; inline void ensureSortedChildren(); + static void append(QDeclarativeListProperty *list, QGraphicsObject *item); static inline bool insertionOrder(QGraphicsItem *a, QGraphicsItem *b); void ensureSequentialSiblingIndex(); inline void sendScenePosChange(); virtual void siblingOrderChange(); + // Private Properties + virtual qreal width() const; + virtual void setWidth(qreal); + virtual void resetWidth(); + + virtual qreal height() const; + virtual void setHeight(qreal); + virtual void resetHeight(); + QRectF childrenBoundingRect; QRectF needsRepaint; QMap paintedViewBoundingRects; diff --git a/src/gui/graphicsview/qgraphicswidget.cpp b/src/gui/graphicsview/qgraphicswidget.cpp index f42fe4f..a091347 100644 --- a/src/gui/graphicsview/qgraphicswidget.cpp +++ b/src/gui/graphicsview/qgraphicswidget.cpp @@ -324,6 +324,14 @@ void QGraphicsWidget::resize(const QSizeF &size) */ /*! + + \fn QGraphicsWidget::geometryChanged() + + This signal gets emitted whenever the geometry of the item changes + \internal +*/ + +/*! \property QGraphicsWidget::geometry \brief the geometry of the widget @@ -391,6 +399,10 @@ void QGraphicsWidget::setGeometry(const QRectF &rect) QGraphicsSceneResizeEvent re; re.setOldSize(oldSize); re.setNewSize(newGeom.size()); + if (oldSize.width() != newGeom.size().width()) + emit widthChanged(); + if (oldSize.height() != newGeom.size().height()) + emit heightChanged(); QApplication::sendEvent(this, &re); } } @@ -2322,5 +2334,7 @@ void QGraphicsWidget::dumpFocusChain() #endif QT_END_NAMESPACE + +#include "moc_qgraphicswidget.cpp" #endif //QT_NO_GRAPHICSVIEW diff --git a/src/gui/graphicsview/qgraphicswidget_p.cpp b/src/gui/graphicsview/qgraphicswidget_p.cpp index 1835c74..6e397b6 100644 --- a/src/gui/graphicsview/qgraphicswidget_p.cpp +++ b/src/gui/graphicsview/qgraphicswidget_p.cpp @@ -44,6 +44,7 @@ #ifndef QT_NO_GRAPHICSVIEW #include +#include #include "qgraphicswidget_p.h" #include "qgraphicslayout.h" #include "qgraphicsscene_p.h" @@ -825,6 +826,56 @@ void QGraphicsWidgetPrivate::setLayout_helper(QGraphicsLayout *l) } } +qreal QGraphicsWidgetPrivate::width() const +{ + Q_Q(const QGraphicsWidget); + return q->geometry().width(); +} + +void QGraphicsWidgetPrivate::setWidth(qreal w) +{ + if (qIsNaN(w)) + return; + Q_Q(QGraphicsWidget); + if (q->geometry().width() == w) + return; + + QRectF oldGeom = q->geometry(); + + q->setGeometry(QRectF(q->x(), q->y(), w, height())); +} + +void QGraphicsWidgetPrivate::resetWidth() +{ + Q_Q(QGraphicsWidget); + q->setGeometry(QRectF(q->x(), q->y(), 0, height())); +} + +qreal QGraphicsWidgetPrivate::height() const +{ + Q_Q(const QGraphicsWidget); + return q->geometry().height(); +} + +void QGraphicsWidgetPrivate::setHeight(qreal h) +{ + if (qIsNaN(h)) + return; + Q_Q(QGraphicsWidget); + if (q->geometry().height() == h) + return; + + QRectF oldGeom = q->geometry(); + + q->setGeometry(QRectF(q->x(), q->y(), width(), h)); +} + +void QGraphicsWidgetPrivate::resetHeight() +{ + Q_Q(QGraphicsWidget); + q->setGeometry(QRectF(q->x(), q->y(), width(), 0)); +} + QT_END_NAMESPACE #endif //QT_NO_GRAPHICSVIEW diff --git a/src/gui/graphicsview/qgraphicswidget_p.h b/src/gui/graphicsview/qgraphicswidget_p.h index 2c5b3bf..f34a755 100644 --- a/src/gui/graphicsview/qgraphicswidget_p.h +++ b/src/gui/graphicsview/qgraphicswidget_p.h @@ -130,6 +130,15 @@ public: void windowFrameHoverLeaveEvent(QGraphicsSceneHoverEvent *event); bool hasDecoration() const; + // Private Properties + qreal width() const; + void setWidth(qreal); + void resetWidth(); + + qreal height() const; + void setHeight(qreal); + void resetHeight(); + // State inline int attributeToBitIndex(Qt::WidgetAttribute att) const { diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp index 0d1ad9e..5a3a54c 100644 --- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp @@ -111,6 +111,8 @@ private slots: void fontPropagationSceneChange(); void geometry_data(); void geometry(); + void width(); + void height(); void getContentsMargins_data(); void getContentsMargins(); void initStyleOption_data(); @@ -775,6 +777,32 @@ void tst_QGraphicsWidget::geometry() QCOMPARE(widget.geometry(), QRectF(pos, size)); } +void tst_QGraphicsWidget::width() +{ + QGraphicsWidget w; + QCOMPARE(w.property("width").toReal(), qreal(0)); + QSignalSpy spy(&w, SIGNAL(widthChanged())); + w.setProperty("width", qreal(50)); + QCOMPARE(w.property("width").toReal(), qreal(50)); + QCOMPARE(spy.count(), 1); + //calling old school setGeometry should work too + w.setGeometry(0, 0, 200, 200); + QCOMPARE(spy.count(), 2); +} + +void tst_QGraphicsWidget::height() +{ + QGraphicsWidget w; + QCOMPARE(w.property("height").toReal(), qreal(0)); + QSignalSpy spy(&w, SIGNAL(heightChanged())); + w.setProperty("height", qreal(50)); + QCOMPARE(w.property("height").toReal(), qreal(50)); + QCOMPARE(spy.count(), 1); + //calling old school setGeometry should work too + w.setGeometry(0, 0, 200, 200); + QCOMPARE(spy.count(), 2); +} + void tst_QGraphicsWidget::getContentsMargins_data() { QTest::addColumn("left"); -- cgit v0.12 From 6fc92ea90a078938ced596059981a120dc9ff57d Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 24 Mar 2010 09:11:30 +0000 Subject: Symbian QAudioOutput::suspend() was resetting processedUSecs() to zero Because of the logic in the Symbian implementations of suspend() and processedUSecs(), the behaviour prior to this patch was as follows: - after calling suspend(), processedUSecs() reported zero - when resume() is called, the amount of silent padding data inserted into the output stream is equal to the amount of data played prior to suspend() The patch corrects the above defect, but introduces a new one, which is described in QTBUG-9322 Reviewed-by: trustme --- src/multimedia/audio/qaudiooutput_symbian_p.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/multimedia/audio/qaudiooutput_symbian_p.cpp b/src/multimedia/audio/qaudiooutput_symbian_p.cpp index 945a08d..3f8e933 100644 --- a/src/multimedia/audio/qaudiooutput_symbian_p.cpp +++ b/src/multimedia/audio/qaudiooutput_symbian_p.cpp @@ -185,10 +185,11 @@ void QAudioOutputPrivate::suspend() const qint64 samplesWritten = SymbianAudio::Utils::bytesToSamples( m_format, m_bytesWritten); - m_bytesWritten = 0; const qint64 samplesPlayed = getSamplesPlayed(); + m_bytesWritten = 0; + // CMMFDevSound::Pause() is not guaranteed to work correctly in all // implementations, for play-mode DevSound sessions. We therefore // have to implement suspend() by calling CMMFDevSound::Stop(). -- cgit v0.12 From a2f2c87f320873d1968d931ad69a0f640c5545b1 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Wed, 24 Mar 2010 12:15:34 +0200 Subject: Made it possible to define more than one language using pkg_prerules The pkg statements were generated in invalid order if user used pkg_prerules to redefine languages supported by the pkg file. Also made it possible to override dependency statements autogenerated for Qt and QtWebkit, as these statements need to be user defined in case of multiple languages. Defining the following in .pro removes all dependencies from pkg rules: default_deployment.pkg_prerules -= \ pkg_depends_webkit \ pkg_depends_qt \ pkg_platform_dependencies Task-number: QTBUG-9279 Reviewed-by: Janne Anttila --- mkspecs/common/symbian/symbian.conf | 8 ++++++- mkspecs/features/symbian/qt.prf | 10 +++++--- qmake/generators/symbian/symmake.cpp | 44 ++++++++++++++++++++++++++---------- src/corelib/corelib.pro | 1 - src/gui/gui.pro | 1 - 5 files changed, 46 insertions(+), 18 deletions(-) diff --git a/mkspecs/common/symbian/symbian.conf b/mkspecs/common/symbian/symbian.conf index 1d00b03..c39b39d 100644 --- a/mkspecs/common/symbian/symbian.conf +++ b/mkspecs/common/symbian/symbian.conf @@ -135,8 +135,14 @@ INCLUDEPATH = \ # RVCT seems to do this automatically, but WINSCW compiler does not, so add it here. MMP_RULES += "USERINCLUDE ." +# pkg_depends_webkit, pkg_depends_core, and pkg_platform_dependencies can be removed by developer +# if multiple languages need to be supported by pkg file. In that case the developer should declare +# multiple language compatible dependency statements him/herself. + +default_deployment.pkg_prerules += pkg_depends_webkit pkg_depends_qt pkg_platform_dependencies + # Supports S60 3.0, 3.1, 3.2 and 5.0 by default -default_deployment.pkg_prerules = \ +pkg_platform_dependencies = \ "; Default HW/platform dependencies" \ "[0x101F7961],0,0,0,{\"S60ProductID\"}" \ "[0x102032BE],0,0,0,{\"S60ProductID\"}" \ diff --git a/mkspecs/features/symbian/qt.prf b/mkspecs/features/symbian/qt.prf index 275b86a..b2156a9 100644 --- a/mkspecs/features/symbian/qt.prf +++ b/mkspecs/features/symbian/qt.prf @@ -22,19 +22,23 @@ load(qt) INCLUDEPATH = $$PREPEND_INCLUDEPATH $$INCLUDEPATH # Add dependency to Qt package to all other projects besides Qt libs. -# Note: Qt libs with full capabilities has UID3 of 0x2001E61C, +# Note: Qt libs package with full capabilities has UID3 of 0x2001E61C, # while self-signed version typically has temporary UID3 of 0xE001E61C. contains(CONFIG, qt):!contains(TARGET.UID3, 0x2001E61C):!contains(TARGET.UID3, 0xE001E61C):isEmpty(QT_LIBINFIX) { - default_deployment.pkg_prerules += \ + pkg_depends_qt += \ "; Default dependency to Qt libraries" \ "(0x2001E61C), $${QT_MAJOR_VERSION}, $${QT_MINOR_VERSION}, $${QT_PATCH_VERSION}, {\"Qt\"}" # Projects linking to webkit need dependency to webkit contains(QT, webkit): { - default_deployment.pkg_prerules += \ + pkg_depends_webkit += \ "; Dependency to Qt Webkit" \ "(0x200267C2), $${QT_MAJOR_VERSION}, $${QT_MINOR_VERSION}, $${QT_PATCH_VERSION}, {\"QtWebKit\"}" + } else { + default_deployment.pkg_prerules -= pkg_depends_webkit } +} else { + default_deployment.pkg_prerules -= pkg_depends_webkit pkg_depends_qt } isEmpty(TARGET.EPOCSTACKSIZE):TARGET.EPOCSTACKSIZE = 0x14000 diff --git a/qmake/generators/symbian/symmake.cpp b/qmake/generators/symbian/symmake.cpp index c6023b5..1470a12 100644 --- a/qmake/generators/symbian/symmake.cpp +++ b/qmake/generators/symbian/symmake.cpp @@ -322,17 +322,36 @@ void SymbianMakefileGenerator::generatePkgFile(const QString &iconFile, Deployme tw << headerComment.arg(wrapperPkgFilename).arg(dateStr); // Construct QStringList from pkg_prerules since we need search it before printed to file + // Note: Though there can't be more than one language or header line, use stringlists + // in case user wants comments to go with the rules. QStringList rawPkgPreRules; + QStringList languageRules; + QStringList headerRules; foreach(QString deploymentItem, project->values("DEPLOYMENT")) { foreach(QString pkgrulesItem, project->values(deploymentItem + ".pkg_prerules")) { QStringList pkgrulesValue = project->values(pkgrulesItem); // If there is no stringlist defined for a rule, use rule name directly // This is convenience for defining single line mmp statements if (pkgrulesValue.isEmpty()) { - rawPkgPreRules << pkgrulesItem; + if (pkgrulesItem.startsWith("&")) + languageRules << pkgrulesItem; + else if (pkgrulesItem.startsWith("#")) + headerRules << pkgrulesItem; + else + rawPkgPreRules << pkgrulesItem; } else { - foreach(QString pkgrule, pkgrulesValue) { - rawPkgPreRules << pkgrule; + if (containsStartWithItem('&', pkgrulesValue)) { + foreach(QString pkgrule, pkgrulesValue) { + languageRules << pkgrule; + } + } else if (containsStartWithItem('#', pkgrulesValue)) { + foreach(QString pkgrule, pkgrulesValue) { + headerRules << pkgrule; + } + } else { + foreach(QString pkgrule, pkgrulesValue) { + rawPkgPreRules << pkgrule; + } } } } @@ -340,17 +359,17 @@ void SymbianMakefileGenerator::generatePkgFile(const QString &iconFile, Deployme // Apply some defaults if specific data does not exist in PKG pre-rules - if (!containsStartWithItem('&', rawPkgPreRules)) { + if (languageRules.isEmpty()) { // language, (*** hardcoded to english atm, should be parsed from TRANSLATIONS) - QString languageCode = "; Language\n&EN\n\n"; - t << languageCode; - tw << languageCode; - } else { + languageRules << "; Language\n&EN\n\n"; + } else if (headerRules.isEmpty()) { // In case user defines langs, he must take care also about SIS header - if (!containsStartWithItem('#', rawPkgPreRules)) - fprintf(stderr, "Warning: If language is defined with DEPLOYMENT pkg_prerules, also the SIS header must be defined\n"); + fprintf(stderr, "Warning: If language is defined with DEPLOYMENT pkg_prerules, also the SIS header must be defined\n"); } + t << languageRules.join("\n") << endl; + tw << languageRules.join("\n") << endl; + // name of application, UID and version QString applicationVersion = project->first("VERSION").isEmpty() ? "1,0,0" : project->first("VERSION").replace('.', ','); QString sisHeader = "; SIS header: name, uid, version\n#{\"%1\"},(%2),%3\n\n"; @@ -364,9 +383,10 @@ void SymbianMakefileGenerator::generatePkgFile(const QString &iconFile, Deployme tw << installerSisHeader << endl; } - if (!containsStartWithItem('#', rawPkgPreRules)) { + if (headerRules.isEmpty()) t << sisHeader.arg(visualTarget).arg(uid3).arg(applicationVersion); - } + else + t << headerRules.join("\n") << endl; // Localized vendor name QString vendorName; diff --git a/src/corelib/corelib.pro b/src/corelib/corelib.pro index efee610..717b95e 100644 --- a/src/corelib/corelib.pro +++ b/src/corelib/corelib.pro @@ -38,7 +38,6 @@ symbian: { # Partial upgrade SIS file vendorinfo = \ - "&EN" \ "; Localised Vendor name" \ "%{\"Nokia, Qt\"}" \ " " \ diff --git a/src/gui/gui.pro b/src/gui/gui.pro index d46f3b4..d2401f4 100644 --- a/src/gui/gui.pro +++ b/src/gui/gui.pro @@ -60,7 +60,6 @@ symbian: { # Partial upgrade SIS file vendorinfo = \ - "&EN" \ "; Localised Vendor name" \ "%{\"Nokia, Qt\"}" \ " " \ -- cgit v0.12 From 903d7a43a5d936bb1e853e5add7c4c3c5503737e Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 24 Mar 2010 12:17:14 +0100 Subject: Updated WebKit from /home/shausman/src/webkit/trunk to qtwebkit/qtwebkit-4.6 ( aa40cdb9595eb15a68e7be03322f973aa613a8f9 ) Changes in WebKit/qt since the last update: ++ b/WebKit/qt/ChangeLog 2010-03-21 axis Reviewed by Simon Hausmann. Fixed updating the VKB display when inputting into QGraphicsWebView. https://bugs.webkit.org/show_bug.cgi?id=36292 * Api/qgraphicswebview.cpp: (QGraphicsWebViewPrivate::_q_updateMicroFocus): (QGraphicsWebView::setPage): * Api/qgraphicswebview.h: WebCore: [Qt] Support for QT_LIBINFIX in Symbian builds Patch by Miikka Heikkinen on 2010-03-19 Reviewed by Simon Hausmann. Configuring Qt with -qtlibinfix parameter will enable installing an alternate version of Qt on devices that already have it on ROM. This patch provides support for infixed builds of Webkit. --- src/3rdparty/webkit/.gitattributes | 4 ++++ src/3rdparty/webkit/ChangeLog | 8 ++++++++ src/3rdparty/webkit/VERSION | 2 +- src/3rdparty/webkit/WebCore/ChangeLog | 12 ++++++++++++ src/3rdparty/webkit/WebCore/WebCore.pro | 9 ++++++--- src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.h | 2 +- 6 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 src/3rdparty/webkit/.gitattributes diff --git a/src/3rdparty/webkit/.gitattributes b/src/3rdparty/webkit/.gitattributes new file mode 100644 index 0000000..5b43bd0 --- /dev/null +++ b/src/3rdparty/webkit/.gitattributes @@ -0,0 +1,4 @@ +# To enable automatic merging of ChangeLog files, use the following command: +# git config merge.changelog.driver "resolve-ChangeLogs --merge-driver %O %A %B" +ChangeLog* merge=changelog + diff --git a/src/3rdparty/webkit/ChangeLog b/src/3rdparty/webkit/ChangeLog index 1e89d1e..57cb0de 100644 --- a/src/3rdparty/webkit/ChangeLog +++ b/src/3rdparty/webkit/ChangeLog @@ -1,3 +1,11 @@ +2010-02-18 Tor Arne Vestbø + + Reviewed by Eric Seidel. + + Add .gitattributes file for custom ChangeLog merge-driver + + * .gitattributes: Added. + 2009-11-30 Jan-Arve Sæther Reviewed by Simon Hausmann. diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index def66ef..9dac2f8 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 - d95c54951e7af2aa7def4346a142b2162bd89bbd + aa40cdb9595eb15a68e7be03322f973aa613a8f9 diff --git a/src/3rdparty/webkit/WebCore/ChangeLog b/src/3rdparty/webkit/WebCore/ChangeLog index 869e225..0a444bc 100644 --- a/src/3rdparty/webkit/WebCore/ChangeLog +++ b/src/3rdparty/webkit/WebCore/ChangeLog @@ -1,3 +1,15 @@ +2010-03-19 Miikka Heikkinen + + Reviewed by Simon Hausmann. + + [Qt] Support for QT_LIBINFIX in Symbian builds + + Configuring Qt with -qtlibinfix parameter will enable installing + an alternate version of Qt on devices that already have it on ROM. + This patch provides support for infixed builds of Webkit. + + * WebCore.pro: + 2010-01-31 Benjamin Poulain Reviewed by Eric Seidel. diff --git a/src/3rdparty/webkit/WebCore/WebCore.pro b/src/3rdparty/webkit/WebCore/WebCore.pro index 735c8ef..7e57394 100644 --- a/src/3rdparty/webkit/WebCore/WebCore.pro +++ b/src/3rdparty/webkit/WebCore/WebCore.pro @@ -6,9 +6,12 @@ symbian: { TARGET.EPOCALLOWDLLDATA=1 TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 // Min 128kB, Max 32MB TARGET.CAPABILITY = All -Tcb - TARGET.UID3 = 0x200267C2 - - webkitlibs.sources = QtWebKit.dll + isEmpty(QT_LIBINFIX) { + TARGET.UID3 = 0x200267C2 + } else { + TARGET.UID3 = 0xE00267C2 + } + webkitlibs.sources = QtWebKit$${QT_LIBINFIX}.dll webkitlibs.path = /sys/bin vendorinfo = \ "; Localised Vendor name" \ diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.h b/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.h index 68379a2..f983ae4 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.h +++ b/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.h @@ -134,10 +134,10 @@ protected: private: Q_PRIVATE_SLOT(d, void _q_doLoadFinished(bool success)) + Q_PRIVATE_SLOT(d, void _q_updateMicroFocus()) QGraphicsWebViewPrivate* const d; friend class QGraphicsWebViewPrivate; }; #endif // QGraphicsWebView_h - Q_PRIVATE_SLOT(d, void _q_updateMicroFocus()) -- cgit v0.12 From b87edcb5fe59b590e20367b167e50abbb23484f4 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Wed, 24 Mar 2010 13:42:38 +0200 Subject: Clarified pkg_prerules usage documentation. The default_deployment item shouldn't be used to add own rules. Task-number: QTBUG-9277 Reviewed-by: Janne Anttila --- doc/src/development/qmake-manual.qdoc | 18 +++++++++++++----- doc/src/snippets/code/doc_src_deployment.qdoc | 7 +++++-- doc/src/snippets/code/doc_src_qmake-manual.qdoc | 4 +++- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/doc/src/development/qmake-manual.qdoc b/doc/src/development/qmake-manual.qdoc index 7ab3cd2..eaf6cd0 100644 --- a/doc/src/development/qmake-manual.qdoc +++ b/doc/src/development/qmake-manual.qdoc @@ -1421,12 +1421,20 @@ is the application private directory on the drive it is installed to. attention that also other statements stay valid. For example if you override languages statement, you must override also package-header statement and all other statements which are language specific. + + On the Symbian platform, the \c default_deployment item specifies + default platform and package dependencies. Those dependencies can be + selectively disabled if alternative dependencies need to be defined + - e.g. if a specific device is required to run the application or + more languages need to be supported by the package file. The supported + \c default_deployment rules that can be disabled are: - On the Symbian platform, the \c default_deployment item specifies - default platform dependencies. It can be overwritten if a more - restrictive set is needed - e.g. if a specific - device is required to run the application. - + \list + \o pkg_depends_qt + \o pkg_depends_webkit + \o pkg_platform_dependencies + \endlist + For example: \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 141 diff --git a/doc/src/snippets/code/doc_src_deployment.qdoc b/doc/src/snippets/code/doc_src_deployment.qdoc index 3b0cda1..48e9ac6 100644 --- a/doc/src/snippets/code/doc_src_deployment.qdoc +++ b/doc/src/snippets/code/doc_src_deployment.qdoc @@ -463,7 +463,8 @@ vendorinfo = \ "%{\"Example Localized Vendor\"}" \ ":\"Example Vendor\"" -default_deployment.pkg_prerules = vendorinfo +my_deployment.pkg_prerules = vendorinfo +DEPLOYMENT += my_deployment //! [56] //! [57] @@ -471,7 +472,9 @@ supported_platforms = \ "; This demo only supports S60 5.0" \ "[0x1028315F],0,0,0,{\"S60ProductID\"}" -default_deployment.pkg_prerules += supported_platforms +default_deployment.pkg_prerules -= pkg_platform_dependencies +my_deployment.pkg_prerules += supported_platforms +DEPLOYMENT += my_deployment //! [57] //! [58] diff --git a/doc/src/snippets/code/doc_src_qmake-manual.qdoc b/doc/src/snippets/code/doc_src_qmake-manual.qdoc index 36676ae..d9e5d3c 100644 --- a/doc/src/snippets/code/doc_src_qmake-manual.qdoc +++ b/doc/src/snippets/code/doc_src_qmake-manual.qdoc @@ -933,7 +933,9 @@ DEPLOYMENT += somelib justdep //! [140] //! [141] -default_deployment.pkg_prerules = "[0x11223344],0,0,0,{\"SomeSpecificDeviceID\"}" +default_deployment.pkg_prerules -= pkg_platform_dependencies +my_deployment.pkg_prerules = "[0x11223344],0,0,0,{\"SomeSpecificDeviceID\"}" +DEPLOYMENT += my_deployment //! [141] //! [142] -- cgit v0.12 From d0645d1792e1cbdf417a923ea071975e4390fccd Mon Sep 17 00:00:00 2001 From: mread Date: Wed, 24 Mar 2010 12:25:58 +0000 Subject: QIODevice::read() and QFile::atEnd() performance improvements atEnd improvements, since atEnd is used in published example Qt read loops. The two main ideas are to push the buffer test forward, which optimises the normal buffered case, and to cache the file size till you get to the end, which otherwise has to get the file size every 16K of data. read buffer improvements: The ring buffer structure was causing significant performance overheads. In practice QIODevice has much simpler requirements on its read buffer, and a linear buffer can be used instead. This now uses a buffer optimised to QIODevice's use of it. QIODevice read function improvements. There are a number of sub-themes here, which all are aimed at getting the normal buffered path through the code done as fast as possible. This gives greatest improvements for small reads, but it is these small reads that have the biggest problems. - removing the isSequential test, by setting a pointer to the qint64 to update and using a dummy qint64 target when isSequential, then writing through the pointer. - doing the readability check on the first read only, out of the fast path - doing the maxSize<0 test after the getchar fast path - removing the buffer isEmpty test and giving a fast exit test instead - moving arithmetic out of the fast path, so "data" and "maxSize" are now dynamically updating - for RCVT builds, ARM mode is used for the read functions because the 64-bit operations are much slower with this compiler in Thumb mode There are some other changes to read() which improve clarity: - bytesToBuffer is now always set to QIODEVICE_BUFFERSIZE. This has always been the case, its just that the logic was not clear before. - moreToRead is set to false now in the case where the request was met by a direct device read. Leaving it true in this case was pointless, and setting it true in the converse case seems dangerous because the function might iterate for a very long time, although it might meet the API semantics better and would be a change in behavior because the function used to not read more when it claimed it would. Reviewed-by: Joao Reviewed-by: Aleksandar Babic --- src/corelib/io/qfile.cpp | 46 +++++++++--- src/corelib/io/qfile_p.h | 2 + src/corelib/io/qiodevice.cpp | 163 +++++++++++++++++++++++++------------------ src/corelib/io/qiodevice_p.h | 127 ++++++++++++++++++++++++++++++++- 4 files changed, 260 insertions(+), 78 deletions(-) diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp index aa1c7d9..50e9a8f 100644 --- a/src/corelib/io/qfile.cpp +++ b/src/corelib/io/qfile.cpp @@ -90,7 +90,8 @@ QFile::DecoderFn QFilePrivate::decoder = locale_decode; QFilePrivate::QFilePrivate() : fileEngine(0), lastWasWrite(false), - writeBuffer(QFILE_WRITEBUFFER_SIZE), error(QFile::NoError) + writeBuffer(QFILE_WRITEBUFFER_SIZE), error(QFile::NoError), + cachedSize(0) { } @@ -1257,8 +1258,10 @@ QFile::resize(qint64 sz) seek(sz); if(d->fileEngine->setSize(sz)) { unsetError(); + d->cachedSize = sz; return true; } + d->cachedSize = 0; d->setError(QFile::ResizeError, d->fileEngine->errorString()); return false; } @@ -1420,7 +1423,8 @@ qint64 QFile::size() const Q_D(const QFile); if (!d->ensureFlushed()) return 0; - return fileEngine()->size(); + d->cachedSize = fileEngine()->size(); + return d->cachedSize; } /*! @@ -1446,16 +1450,16 @@ bool QFile::atEnd() const { Q_D(const QFile); + // If there's buffered data left, we're not at the end. + if (!d->buffer.isEmpty()) + return false; + if (!isOpen()) return true; if (!d->ensureFlushed()) return false; - // If there's buffered data left, we're not at the end. - if (!d->buffer.isEmpty()) - return false; - // If the file engine knows best, say what it says. if (d->fileEngine->supportsExtension(QAbstractFileEngine::AtEndExtension)) { // Check if the file engine supports AtEndExtension, and if it does, @@ -1463,6 +1467,11 @@ bool QFile::atEnd() const return d->fileEngine->atEnd(); } + // if it looks like we are at the end, or if size is not cached, + // fall through to bytesAvailable() to make sure. + if (pos() < d->cachedSize) + return false; + // Fall back to checking how much is available (will stat files). return bytesAvailable() == 0; } @@ -1502,12 +1511,21 @@ qint64 QFile::readLineData(char *data, qint64 maxlen) if (!d->ensureFlushed()) return -1; - if (d->fileEngine->supportsExtension(QAbstractFileEngine::FastReadLineExtension)) - return d->fileEngine->readLine(data, maxlen); + qint64 read; + if (d->fileEngine->supportsExtension(QAbstractFileEngine::FastReadLineExtension)) { + read = d->fileEngine->readLine(data, maxlen); + } else { + // Fall back to QIODevice's readLine implementation if the engine + // cannot do it faster. + read = QIODevice::readLineData(data, maxlen); + } + + if (read < maxlen) { + // failed to read all requested, may be at the end of file, stop caching size so that it's rechecked + d->cachedSize = 0; + } - // Fall back to QIODevice's readLine implementation if the engine - // cannot do it faster. - return QIODevice::readLineData(data, maxlen); + return read; } /*! @@ -1528,6 +1546,12 @@ qint64 QFile::readData(char *data, qint64 len) err = QFile::ReadError; d->setError(err, d->fileEngine->errorString()); } + + if (read < len) { + // failed to read all requested, may be at the end of file, stop caching size so that it's rechecked + d->cachedSize = 0; + } + return read; } diff --git a/src/corelib/io/qfile_p.h b/src/corelib/io/qfile_p.h index f8f5f5c..cf76c09 100644 --- a/src/corelib/io/qfile_p.h +++ b/src/corelib/io/qfile_p.h @@ -84,6 +84,8 @@ protected: void setError(QFile::FileError err, const QString &errorString); void setError(QFile::FileError err, int errNum); + mutable qint64 cachedSize; + private: static QFile::EncoderFn encoder; static QFile::DecoderFn decoder; diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index c93f0c3..f83c142 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -84,10 +84,6 @@ void debugBinaryString(const char *data, qint64 maxlen) } #endif -#ifndef QIODEVICE_BUFFERSIZE -#define QIODEVICE_BUFFERSIZE Q_INT64_C(16384) -#endif - #define Q_VOID #define CHECK_MAXLEN(function, returnType) \ @@ -123,7 +119,9 @@ void debugBinaryString(const char *data, qint64 maxlen) QIODevicePrivate::QIODevicePrivate() : openMode(QIODevice::NotOpen), buffer(QIODEVICE_BUFFERSIZE), pos(0), devicePos(0) + , pPos(&pos), pDevicePos(&devicePos) , baseReadLineDataCalled(false) + , firstRead(true) , accessMode(Unset) #ifdef QT_NO_QOBJECT , q_ptr(0) @@ -449,11 +447,15 @@ QIODevice::OpenMode QIODevice::openMode() const */ void QIODevice::setOpenMode(OpenMode openMode) { + Q_D(QIODevice); #if defined QIODEVICE_DEBUG printf("%p QIODevice::setOpenMode(0x%x)\n", this, int(openMode)); #endif - d_func()->openMode = openMode; - d_func()->accessMode = QIODevicePrivate::Unset; + d->openMode = openMode; + d->accessMode = QIODevicePrivate::Unset; + d->firstRead = true; + if (!isReadable()) + d->buffer.clear(); } /*! @@ -537,6 +539,7 @@ bool QIODevice::open(OpenMode mode) d->pos = (mode & Append) ? size() : qint64(0); d->buffer.clear(); d->accessMode = QIODevicePrivate::Unset; + d->firstRead = true; #if defined QIODEVICE_DEBUG printf("%p QIODevice::open(0x%x)\n", this, quint32(mode)); #endif @@ -566,6 +569,7 @@ void QIODevice::close() d->errorString.clear(); d->pos = 0; d->buffer.clear(); + d->firstRead = true; } /*! @@ -729,6 +733,12 @@ qint64 QIODevice::bytesToWrite() const return qint64(0); } +#ifdef Q_CC_RVCT +// arm mode makes the 64-bit integer operations much faster in RVCT 2.2 +#pragma push +#pragma arm +#endif + /*! Reads at most \a maxSize bytes from the device into \a data, and returns the number of bytes read. If an error occurs, such as when @@ -745,21 +755,17 @@ qint64 QIODevice::bytesToWrite() const qint64 QIODevice::read(char *data, qint64 maxSize) { Q_D(QIODevice); - CHECK_READABLE(read, qint64(-1)); - CHECK_MAXLEN(read, qint64(-1)); #if defined QIODEVICE_DEBUG printf("%p QIODevice::read(%p, %d), d->pos = %d, d->buffer.size() = %d\n", this, data, int(maxSize), int(d->pos), int(d->buffer.size())); #endif - const bool sequential = d->isSequential(); // Short circuit for getChar() if (maxSize == 1) { int chint; while ((chint = d->buffer.getChar()) != -1) { - if (!sequential) - ++d->pos; + ++(*d->pPos); char c = char(uchar(chint)); if (c == '\r' && (d->openMode & Text)) @@ -773,61 +779,77 @@ qint64 QIODevice::read(char *data, qint64 maxSize) } } + CHECK_MAXLEN(read, qint64(-1)); qint64 readSoFar = 0; bool moreToRead = true; do { - int lastReadChunkSize = 0; - // Try reading from the buffer. - if (!d->buffer.isEmpty()) { - lastReadChunkSize = d->buffer.read(data + readSoFar, maxSize - readSoFar); - readSoFar += lastReadChunkSize; - if (!sequential) - d->pos += lastReadChunkSize; + int lastReadChunkSize = d->buffer.read(data, maxSize); + *d->pPos += lastReadChunkSize; + readSoFar += lastReadChunkSize; + // fast exit when satisfied by buffer + if (lastReadChunkSize == maxSize && !(d->openMode & Text)) + return readSoFar; + + if (lastReadChunkSize > 0) { + data += lastReadChunkSize; + maxSize -= lastReadChunkSize; #if defined QIODEVICE_DEBUG printf("%p \treading %d bytes from buffer into position %d\n", this, lastReadChunkSize, int(readSoFar) - lastReadChunkSize); #endif - } else if ((d->openMode & Unbuffered) == 0 && maxSize < QIODEVICE_BUFFERSIZE) { - // In buffered mode, we try to fill up the QIODevice buffer before - // we do anything else. - int bytesToBuffer = qMax(maxSize - readSoFar, QIODEVICE_BUFFERSIZE); - char *writePointer = d->buffer.reserve(bytesToBuffer); - - // Make sure the device is positioned correctly. - if (d->pos != d->devicePos && !sequential && !seek(d->pos)) - return qint64(-1); - qint64 readFromDevice = readData(writePointer, bytesToBuffer); - d->buffer.chop(bytesToBuffer - (readFromDevice < 0 ? 0 : int(readFromDevice))); + } else { + if (d->firstRead) { + // this is the first time the file has been read, check it's valid and set up pos pointers + // for fast pos updates. + CHECK_READABLE(read, qint64(-1)); + d->firstRead = false; + if (d->isSequential()) { + d->pPos = &d->seqDumpPos; + d->pDevicePos = &d->seqDumpPos; + } + } - if (readFromDevice > 0) { - if (!sequential) - d->devicePos += readFromDevice; + if ((d->openMode & Unbuffered) == 0 && maxSize < QIODEVICE_BUFFERSIZE) { + // In buffered mode, we try to fill up the QIODevice buffer before + // we do anything else. + // buffer is empty at this point, try to fill it + int bytesToBuffer = QIODEVICE_BUFFERSIZE; + char *writePointer = d->buffer.reserve(bytesToBuffer); + + // Make sure the device is positioned correctly. + if (d->pos != d->devicePos && !d->isSequential() && !seek(d->pos)) + return readSoFar ? readSoFar : qint64(-1); + qint64 readFromDevice = readData(writePointer, bytesToBuffer); + d->buffer.chop(bytesToBuffer - (readFromDevice < 0 ? 0 : int(readFromDevice))); + + if (readFromDevice > 0) { + *d->pDevicePos += readFromDevice; #if defined QIODEVICE_DEBUG - printf("%p \treading %d from device into buffer\n", this, int(readFromDevice)); + printf("%p \treading %d from device into buffer\n", this, int(readFromDevice)); #endif - if (readFromDevice < bytesToBuffer) - d->buffer.truncate(int(readFromDevice)); - if (!d->buffer.isEmpty()) { - lastReadChunkSize = d->buffer.read(data + readSoFar, maxSize - readSoFar); - readSoFar += lastReadChunkSize; - if (!sequential) - d->pos += lastReadChunkSize; + if (!d->buffer.isEmpty()) { + lastReadChunkSize = d->buffer.read(data, maxSize); + readSoFar += lastReadChunkSize; + data += lastReadChunkSize; + maxSize -= lastReadChunkSize; + *d->pPos += lastReadChunkSize; #if defined QIODEVICE_DEBUG - printf("%p \treading %d bytes from buffer at position %d\n", this, - lastReadChunkSize, int(readSoFar)); + printf("%p \treading %d bytes from buffer at position %d\n", this, + lastReadChunkSize, int(readSoFar)); #endif + } } } } // If we need more, try reading from the device. - if (readSoFar < maxSize) { + if (maxSize > 0) { // Make sure the device is positioned correctly. - if (d->pos != d->devicePos && !sequential && !seek(d->pos)) - return qint64(-1); - qint64 readFromDevice = readData(data + readSoFar, maxSize - readSoFar); + if (d->pos != d->devicePos && !d->isSequential() && !seek(d->pos)) + return readSoFar ? readSoFar : qint64(-1); + qint64 readFromDevice = readData(data, maxSize); #if defined QIODEVICE_DEBUG printf("%p \treading %d bytes from device (total %d)\n", this, int(readFromDevice), int(readSoFar)); #endif @@ -835,27 +857,21 @@ qint64 QIODevice::read(char *data, qint64 maxSize) // error and we haven't read anything: return immediately return -1; } - if (readFromDevice <= 0) { - moreToRead = false; - } else { - // see if we read as much data as we asked for - if (readFromDevice < maxSize - readSoFar) - moreToRead = false; - + if (readFromDevice > 0) { lastReadChunkSize += int(readFromDevice); readSoFar += readFromDevice; - if (!sequential) { - d->pos += readFromDevice; - d->devicePos += readFromDevice; - } + data += readFromDevice; + maxSize -= readFromDevice; + *d->pPos += readFromDevice; + *d->pDevicePos += readFromDevice; } - } else { - moreToRead = false; } + // Best attempt has been made to read data, don't try again except for text mode adjustment below + moreToRead = false; if (readSoFar && d->openMode & Text) { - char *readPtr = data + readSoFar - lastReadChunkSize; - const char *endPtr = data + readSoFar; + char *readPtr = data - lastReadChunkSize; + const char *endPtr = data; if (readPtr < endPtr) { // optimization to avoid initial self-assignment @@ -870,8 +886,11 @@ qint64 QIODevice::read(char *data, qint64 maxSize) char ch = *readPtr++; if (ch != '\r') *writePtr++ = ch; - else + else { --readSoFar; + --data; + ++maxSize; + } } // Make sure we get more data if there is room for more. This @@ -885,11 +904,15 @@ qint64 QIODevice::read(char *data, qint64 maxSize) #if defined QIODEVICE_DEBUG printf("%p \treturning %d, d->pos == %d, d->buffer.size() == %d\n", this, int(readSoFar), int(d->pos), d->buffer.size()); - debugBinaryString(data, readSoFar); + debugBinaryString(data - readSoFar, readSoFar); #endif return readSoFar; } +#ifdef Q_CC_RVCT +#pragma pop +#endif + /*! \overload @@ -997,6 +1020,12 @@ QByteArray QIODevice::readAll() return result; } +#ifdef Q_CC_RVCT +// arm mode makes the 64-bit integer operations much faster in RVCT 2.2 +#pragma push +#pragma arm +#endif + /*! This function reads a line of ASCII characters from the device, up to a maximum of \a maxSize - 1 bytes, stores the characters in \a @@ -1229,6 +1258,10 @@ qint64 QIODevice::readLineData(char *data, qint64 maxSize) return readSoFar; } +#ifdef Q_CC_RVCT +#pragma pop +#endif + /*! Returns true if a complete line of data can be read from the device; otherwise returns false. @@ -1416,9 +1449,7 @@ bool QIODevicePrivate::putCharHelper(char c) */ bool QIODevice::getChar(char *c) { - Q_D(QIODevice); - CHECK_READABLE(getChar, false); - + // readability checked in read() char ch; return (1 == read(c ? c : &ch, 1)); } diff --git a/src/corelib/io/qiodevice_p.h b/src/corelib/io/qiodevice_p.h index cc4a237..94dadca 100644 --- a/src/corelib/io/qiodevice_p.h +++ b/src/corelib/io/qiodevice_p.h @@ -64,6 +64,126 @@ QT_BEGIN_NAMESPACE +#ifndef QIODEVICE_BUFFERSIZE +#define QIODEVICE_BUFFERSIZE Q_INT64_C(16384) +#endif + +// This is QIODevice's read buffer, optimised for read(), isEmpty() and getChar() +class QIODevicePrivateLinearBuffer +{ +public: + QIODevicePrivateLinearBuffer(int) : len(0), first(0), buf(0), capacity(0) { + } + ~QIODevicePrivateLinearBuffer() { + delete [] buf; + } + void clear() { + first = buf; + len = 0; + } + int size() const { + return len; + } + bool isEmpty() const { + return len == 0; + } + void skip(int n) { + if (n >= len) { + clear(); + } else { + len -= n; + first += n; + } + } + int getChar() { + if (len == 0) + return -1; + int ch = uchar(*first); + len--; + first++; + return ch; + } + int read(char* target, int size) { + int r = qMin(size, len); + memcpy(target, first, r); + len -= r; + first += r; + return r; + } + char* reserve(int size) { + makeSpace(size + len, freeSpaceAtEnd); + char* writePtr = first + len; + len += size; + return writePtr; + } + void chop(int size) { + if (size >= len) { + clear(); + } else { + len -= size; + } + } + QByteArray readAll() { + char* f = first; + int l = len; + clear(); + return QByteArray(f, l); + } + int readLine(char* target, int size) { + int r = qMin(size, len); + char* eol = static_cast(memchr(first, '\n', r)); + if (eol) + r = 1+(eol-first); + memcpy(target, first, r); + len -= r; + first += r; + return int(r); + } + bool canReadLine() const { + return memchr(first, '\n', len); + } + void ungetChar(char c) { + if (first == buf) { + // underflow, the existing valid data needs to move to the end of the (potentially bigger) buffer + makeSpace(len+1, freeSpaceAtStart); + } + first--; + len++; + *first = c; + } + +private: + enum FreeSpacePos {freeSpaceAtStart, freeSpaceAtEnd}; + void makeSpace(size_t required, FreeSpacePos where) { + size_t newCapacity = qMax(capacity, size_t(QIODEVICE_BUFFERSIZE)); + while (newCapacity < required) + newCapacity *= 2; + int moveOffset = (where == freeSpaceAtEnd) ? 0 : newCapacity - len; + if (newCapacity > capacity) { + // allocate more space + char* newBuf = new char[newCapacity]; + memmove(newBuf + moveOffset, first, len); + delete [] buf; + buf = newBuf; + capacity = newCapacity; + } else { + // shift any existing data to make space + memmove(buf + moveOffset, first, len); + } + first = buf + moveOffset; + } + +private: + // length of the unread data + int len; + // start of the unread data + char* first; + // the allocated buffer + char* buf; + // allocated buffer size + size_t capacity; +}; + class Q_CORE_EXPORT QIODevicePrivate #ifndef QT_NO_QOBJECT : public QObjectPrivate @@ -78,10 +198,15 @@ public: QIODevice::OpenMode openMode; QString errorString; - QRingBuffer buffer; + QIODevicePrivateLinearBuffer buffer; qint64 pos; qint64 devicePos; + // these three are for fast position updates during read, avoiding isSequential test + qint64 seqDumpPos; + qint64 *pPos; + qint64 *pDevicePos; bool baseReadLineDataCalled; + bool firstRead; virtual bool putCharHelper(char c); -- cgit v0.12 From 96bd304a62f88dc097d5ac4f16d60fd8751227fd Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 24 Mar 2010 13:52:57 +0100 Subject: Stabilize QGraphicsEffect test on X11 --- tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp index 02899ae..49b840f 100644 --- a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp +++ b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp @@ -512,6 +512,7 @@ void tst_QGraphicsEffect::drawPixmapItem() QGraphicsView view(&scene); view.show(); QTest::qWaitForWindowShown(&view); + QTRY_VERIFY(effect->repaints >= 1); item->rotate(180); QTest::qWait(50); @@ -642,7 +643,7 @@ void tst_QGraphicsEffect::childrenVisibilityShouldInvalidateCache() view.show(); QApplication::setActiveWindow(&view); QTest::qWaitForWindowShown(&view); - QCOMPARE(parent.nbPaint, 1); + QTRY_COMPARE(parent.nbPaint, 1); //we set an effect on the parent parent.setGraphicsEffect(new QGraphicsDropShadowEffect(&parent)); //flush the events -- cgit v0.12 From 4fa9387f6cbba798fcd262f970d87a01e66267f5 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 24 Mar 2010 14:00:39 +0000 Subject: Fix error reporting when symbian file copy fails. When a file copy failed on symbian, the file engine error was not set. Now translates the symbian os error code to set the file engine error. Reviewed-by: Marius Storm-Olsen --- src/corelib/io/qfsfileengine_p.h | 4 ++++ src/corelib/io/qfsfileengine_unix.cpp | 40 +++++++++++++++++++++++++++++++++-- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qfsfileengine_p.h b/src/corelib/io/qfsfileengine_p.h index 0f63eb8..e50777b 100644 --- a/src/corelib/io/qfsfileengine_p.h +++ b/src/corelib/io/qfsfileengine_p.h @@ -151,6 +151,10 @@ public: static bool uncListSharesOnServer(const QString &server, QStringList *list); #endif +#ifdef Q_OS_SYMBIAN + void setSymbianError(int symbianError, QFile::FileError defaultError, QString defaultString); +#endif + protected: QFSFileEnginePrivate(); diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index 1331f54..33e00f6 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -81,6 +81,40 @@ static bool isRelativePathSymbian(const QString& fileName) && ((fileName.at(0).isLetter() && fileName.at(1) == QLatin1Char(':')) || (fileName.at(0) == QLatin1Char('/') && fileName.at(1) == QLatin1Char('/'))))); } + +/*! + \internal + convert symbian error code to the one suitable for setError. + example usage: setSymbianError(err, QFile::CopyError, QLatin1String("copy error")) +*/ +void QFSFileEnginePrivate::setSymbianError(int symbianError, QFile::FileError defaultError, QString defaultString) +{ + Q_Q(QFSFileEngine); + switch (symbianError) { + case KErrNone: + q->setError(QFile::NoError, QLatin1String("")); + break; + case KErrAccessDenied: + q->setError(QFile::PermissionsError, QLatin1String("access denied")); + break; + case KErrPermissionDenied: + q->setError(QFile::PermissionsError, QLatin1String("permission denied")); + break; + case KErrAbort: + q->setError(QFile::AbortError, QLatin1String("aborted")); + break; + case KErrCancel: + q->setError(QFile::AbortError, QLatin1String("cancelled")); + break; + case KErrTimedOut: + q->setError(QFile::TimeOutError, QLatin1String("timed out")); + break; + default: + q->setError(defaultError, defaultString); + break; + } +} + #endif /*! @@ -427,8 +461,10 @@ bool QFSFileEngine::copy(const QString &newName) } ) // End TRAP delete fm; - // ### Add error reporting on failure - return (err == KErrNone); + if (err == KErrNone) + return true; + d->setSymbianError(err, QFile::CopyError, QLatin1String("copy error")); + return false; #else Q_UNUSED(newName); // ### Add copy code for Unix here -- cgit v0.12 From 7140a55d883492564ba704a010aff547f5d7a89c Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 25 Mar 2010 14:00:35 +1000 Subject: Begin dragging PathView up to the level (quality and functionality) of other views. Task-number: QT-319 --- .../graphicsitems/qdeclarativepathview.cpp | 641 +++++++++++---------- .../graphicsitems/qdeclarativepathview_p.h | 25 +- .../graphicsitems/qdeclarativepathview_p_p.h | 25 +- .../qdeclarativepathview/data/pathview0.qml | 5 + .../qdeclarativepathview/data/pathview3.qml | 2 +- .../tst_qdeclarativepathview.cpp | 22 +- 6 files changed, 411 insertions(+), 309 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp index b9c8971..f3d6137 100644 --- a/src/declarative/graphicsitems/qdeclarativepathview.cpp +++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp @@ -138,6 +138,103 @@ void QDeclarativePathViewPrivate::clear() items.clear(); } +void QDeclarativePathViewPrivate::updateMappedRange() +{ + if (model && pathItems != -1 && pathItems < model->count()) + mappedRange = qreal(pathItems)/model->count(); + else + mappedRange = 1.0; +} + +qreal QDeclarativePathViewPrivate::positionOfIndex(int index) const +{ + qreal pos = -1.0; + + if (model && index >= 0 && index < model->count()) { + qreal globalPos = qreal(index) + offset; + globalPos = qmlMod(globalPos, qreal(model->count())) / model->count(); + if (pathItems != -1 && pathItems < model->count()) { + globalPos += snapPos * mappedRange; + globalPos = qmlMod(globalPos, 1.0); + if (globalPos < mappedRange) + pos = globalPos / mappedRange; + } else { + pos = qmlMod(globalPos + snapPos, 1.0); + } + } + + return pos; +} + +void QDeclarativePathViewPrivate::createHighlight() +{ + Q_Q(QDeclarativePathView); + bool changed = false; + if (highlightItem) { + delete highlightItem; + highlightItem = 0; + changed = true; + } + + QDeclarativeItem *item = 0; + if (highlightComponent) { + QDeclarativeContext *highlightContext = new QDeclarativeContext(qmlContext(q)); + QObject *nobj = highlightComponent->create(highlightContext); + if (nobj) { + highlightContext->setParent(nobj); + item = qobject_cast(nobj); + if (!item) + delete nobj; + } else { + delete highlightContext; + } + } else { + item = new QDeclarativeItem; + } + if (item) { + item->setParent(q); + highlightItem = item; + changed = true; + } + if (changed) + emit q->highlightItemChanged(); +} + +void QDeclarativePathViewPrivate::updateHighlight() +{ + Q_Q(QDeclarativePathView); + if (!q->isComponentComplete()) + return; + if (highlightItem) + updateItem(highlightItem, snapPos); +} + +void QDeclarativePathViewPrivate::updateItem(QDeclarativeItem *item, qreal percent) +{ + if (QDeclarativePathViewAttached *att = attached(item)) { + foreach(const QString &attr, path->attributes()) + att->setValue(attr.toUtf8(), path->attributeAt(attr, percent)); + } + QPointF pf = path->pointAt(percent); + item->setX(pf.x() - item->width()*item->scale()/2); + item->setY(pf.y() - item->height()*item->scale()/2); +} + +void QDeclarativePathViewPrivate::regenerate() +{ + Q_Q(QDeclarativePathView); + if (!q->isComponentComplete()) + return; + + clear(); + + if (!isValid()) + return; + + firstIndex = -1; + updateMappedRange(); + q->refill(); +} /*! \qmlclass PathView QDeclarativePathView @@ -232,6 +329,7 @@ void QDeclarativePathView::setModel(const QVariant &model) if (d->model) { disconnect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int))); disconnect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int))); + disconnect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int))); disconnect(d->model, SIGNAL(modelReset()), this, SLOT(modelReset())); disconnect(d->model, SIGNAL(createdItem(int, QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*))); for (int i=0; iitems.count(); i++){ @@ -261,13 +359,16 @@ void QDeclarativePathView::setModel(const QVariant &model) if (d->model) { connect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int))); connect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int))); + connect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int))); connect(d->model, SIGNAL(modelReset()), this, SLOT(modelReset())); connect(d->model, SIGNAL(createdItem(int, QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*))); } - d->firstIndex = 0; - d->pathOffset = 0; + d->offset = qmlMod(d->offset, qreal(d->model->count())); + if (d->offset < 0) + d->offset = d->model->count() + d->offset; d->regenerate(); d->fixOffset(); + emit countChanged(); emit modelChanged(); } @@ -330,7 +431,7 @@ void QDeclarativePathView::setCurrentIndex(int idx) if (d->model->count()) { int itemIndex = (d->currentIndex - d->firstIndex + d->model->count()) % d->model->count(); if (itemIndex < d->items.count()) { - if (QDeclarativeItem *item = d->items.at(d->currentIndex)) { + if (QDeclarativeItem *item = d->items.at(itemIndex)) { if (QDeclarativePathViewAttached *att = d->attached(item)) att->setIsCurrentItem(false); } @@ -354,12 +455,13 @@ void QDeclarativePathView::setCurrentIndex(int idx) /*! \qmlproperty real PathView::offset - The offset specifies how far along the path (0.0-1.0) the items are from their initial positions. + The offset specifies how far along the path the items are from their initial positions. + This is a real number that ranges from 0.0 to the count of items in the model. */ qreal QDeclarativePathView::offset() const { Q_D(const QDeclarativePathView); - return d->_offset; + return d->offset; } void QDeclarativePathView::setOffset(qreal offset) @@ -372,18 +474,25 @@ void QDeclarativePathView::setOffset(qreal offset) void QDeclarativePathViewPrivate::setOffset(qreal o) { Q_Q(QDeclarativePathView); - if (_offset != o) { - _offset = qmlMod(o, qreal(1.0)); - if (_offset < 0) - _offset = 1.0 + _offset; - q->refill(); + if (offset != o) { + if (isValid() && q->isComponentComplete()) { + offset = qmlMod(o, qreal(model->count())); + if (offset < 0) + offset = model->count() + offset; + q->refill(); + } else { + offset = o; + } + emit q->offsetChanged(); } } /*! \qmlproperty real PathView::snapPosition - This property determines the position (0.0-1.0) the nearest item will snap to. + This property determines the position on the path (0.0-1.0) the nearest item will snap to. + The item nearest this position will set currentIndex, for example when offset is 0.0 the + first item will be placed at this position and currentIndex will be 0. */ qreal QDeclarativePathView::snapPosition() const { @@ -398,10 +507,34 @@ void QDeclarativePathView::setSnapPosition(qreal pos) if (qFuzzyCompare(normalizedPos, d->snapPos)) return; d->snapPos = normalizedPos; + d->updateHighlight(); d->fixOffset(); emit snapPositionChanged(); } +QDeclarativeComponent *QDeclarativePathView::highlight() const +{ + Q_D(const QDeclarativePathView); + return d->highlightComponent; +} + +void QDeclarativePathView::setHighlight(QDeclarativeComponent *highlight) +{ + Q_D(QDeclarativePathView); + if (highlight != d->highlightComponent) { + d->highlightComponent = highlight; + d->createHighlight(); + d->updateHighlight(); + emit highlightChanged(); + } +} + +QDeclarativeItem *QDeclarativePathView::highlightItem() +{ + Q_D(const QDeclarativePathView); + return d->highlightItem; +} + /*! \qmlproperty real PathView::dragMargin This property holds the maximum distance from the path that initiate mouse dragging. @@ -426,6 +559,52 @@ void QDeclarativePathView::setDragMargin(qreal dragMargin) } /*! + \qmlproperty real PathView::flickDeceleration + This property holds the rate at which a flick will decelerate. + + The default is 100. +*/ +qreal QDeclarativePathView::flickDeceleration() const +{ + Q_D(const QDeclarativePathView); + return d->deceleration; +} + +void QDeclarativePathView::setFlickDeceleration(qreal dec) +{ + Q_D(QDeclarativePathView); + if (d->deceleration == dec) + return; + d->deceleration = dec; + emit flickDecelerationChanged(); +} + +/*! + \qmlproperty bool PathView::interactive + + A user cannot drag or flick a PathView that is not interactive. + + This property is useful for temporarily disabling flicking. This allows + special interaction with PathView's children. +*/ +bool QDeclarativePathView::isInteractive() const +{ + Q_D(const QDeclarativePathView); + return d->interactive; +} + +void QDeclarativePathView::setInteractive(bool interactive) +{ + Q_D(QDeclarativePathView); + if (interactive != d->interactive) { + d->interactive = interactive; + if (!interactive) + d->tl.clear(); + emit interactiveChanged(); + } +} + +/*! \qmlproperty component PathView::delegate The delegate provides a template defining each item instantiated by the view. @@ -467,7 +646,7 @@ void QDeclarativePathView::setDelegate(QDeclarativeComponent *delegate) /*! \qmlproperty int PathView::pathItemCount - This property holds the number of items visible on the path at any one time + This property holds the number of items visible on the path at any one time. */ int QDeclarativePathView::pathItemCount() const { @@ -480,9 +659,13 @@ void QDeclarativePathView::setPathItemCount(int i) Q_D(QDeclarativePathView); if (i == d->pathItems) return; + if (i < 1) + i = 1; d->pathItems = i; - d->regenerate(); - pathItemCountChanged(); + if (d->isValid() && isComponentComplete()) { + d->regenerate(); + } + emit pathItemCountChanged(); } QPointF QDeclarativePathViewPrivate::pointNear(const QPointF &point, qreal *nearPercent) const @@ -512,7 +695,7 @@ QPointF QDeclarativePathViewPrivate::pointNear(const QPointF &point, qreal *near void QDeclarativePathView::mousePressEvent(QGraphicsSceneMouseEvent *event) { Q_D(QDeclarativePathView); - if (!d->items.count()) + if (!d->interactive || !d->items.count()) return; QPointF scenePoint = mapToScene(event->pos()); int idx = 0; @@ -542,7 +725,7 @@ void QDeclarativePathView::mousePressEvent(QGraphicsSceneMouseEvent *event) void QDeclarativePathView::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { Q_D(QDeclarativePathView); - if (d->lastPosTime.isNull()) + if (!d->interactive || d->lastPosTime.isNull()) return; if (!d->stealMouse) { @@ -555,14 +738,14 @@ void QDeclarativePathView::mouseMoveEvent(QGraphicsSceneMouseEvent *event) d->moveReason = QDeclarativePathViewPrivate::Mouse; qreal newPc; d->pointNear(event->pos(), &newPc); - qreal diff = newPc - d->startPc; + qreal diff = (newPc - d->startPc)*d->model->count()*d->mappedRange; if (diff) { - setOffset(d->_offset + diff); + setOffset(d->offset + diff); - if (diff > 0.5) - diff -= 1.0; - else if (diff < -0.5) - diff += 1.0; + if (diff > d->model->count()/2) + diff -= d->model->count(); + else if (diff < -d->model->count()/2) + diff += d->model->count(); d->lastElapsed = QDeclarativeItemPrivate::restart(d->lastPosTime); d->lastDist = diff; @@ -574,27 +757,37 @@ void QDeclarativePathView::mouseMoveEvent(QGraphicsSceneMouseEvent *event) void QDeclarativePathView::mouseReleaseEvent(QGraphicsSceneMouseEvent *) { Q_D(QDeclarativePathView); - if (d->lastPosTime.isNull()) + d->stealMouse = false; + setKeepMouseGrab(false); + if (!d->interactive || d->lastPosTime.isNull()) return; qreal elapsed = qreal(d->lastElapsed + QDeclarativeItemPrivate::elapsed(d->lastPosTime)) / 1000.; qreal velocity = elapsed > 0. ? d->lastDist / elapsed : 0; - if (d->model && d->model->count() && qAbs(velocity) > 0.05) { - if (velocity > 1.5) - velocity = 1.5; - else if (velocity < -1.5) - velocity = -1.5; - qreal inc = qmlMod(d->_offset - d->snapPos, qreal(1.0 / d->model->count())); - qreal dist = qAbs(velocity/2 - qmlMod(velocity/2, qreal(1.0 / d->model->count()) - inc)); - d->moveOffset.setValue(d->_offset); - d->tl.accel(d->moveOffset, velocity, 0.1, dist); + if (d->model && d->model->count() && qAbs(velocity) > 1.) { + qreal count = d->pathItems == -1 ? d->model->count() : d->pathItems; + if (qAbs(velocity) > count * 2) // limit velocity + velocity = (velocity > 0 ? count : -count) * 2; + // Calculate the distance to be travelled + qreal v2 = velocity*velocity; + qreal accel = d->deceleration; + // + 0.25 to encourage moving at least one item in the flick direction + qreal dist = qMin(qreal(d->model->count()-1), d->model->count() * v2 / (accel * 2.0) + 0.25); + // round to nearest item. + if (velocity > 0.) + dist = qRound(dist + d->offset) - d->offset; + else + dist = qRound(dist - d->offset) + d->offset; + // Calculate accel required to stop on item boundary + accel = v2 / (2.0f * qAbs(dist)); + d->moveOffset.setValue(d->offset); + d->tl.accel(d->moveOffset, velocity, accel, dist); d->tl.callback(QDeclarativeTimeLineCallback(&d->moveOffset, d->fixOffsetCallback, d)); } else { d->fixOffset(); } d->lastPosTime = QTime(); - d->stealMouse = false; ungrabMouse(); } @@ -644,7 +837,8 @@ bool QDeclarativePathView::sendMouseEvent(QGraphicsSceneMouseEvent *event) bool QDeclarativePathView::sceneEventFilter(QGraphicsItem *i, QEvent *e) { - if (!isVisible()) + Q_D(QDeclarativePathView); + if (!isVisible() || !d->interactive) return QDeclarativeItem::sceneEventFilter(i, e); switch (e->type()) { @@ -669,72 +863,7 @@ void QDeclarativePathView::componentComplete() Q_D(QDeclarativePathView); QDeclarativeItem::componentComplete(); d->regenerate(); - - // move to correct offset - if (d->items.count()) { - int itemIndex = (d->currentIndex - d->firstIndex + d->model->count()) % d->model->count(); - - itemIndex += d->pathOffset; - itemIndex %= d->items.count(); - qreal targetOffset = qmlMod(1.0 + d->snapPos - qreal(itemIndex) / d->items.count(), qreal(1.0)); - - if (targetOffset < 0) - targetOffset = 1.0 + targetOffset; - if (targetOffset != d->_offset) { - d->moveOffset.setValue(targetOffset); - } - } -} - -void QDeclarativePathViewPrivate::regenerate() -{ - Q_Q(QDeclarativePathView); - if (!q->isComponentComplete()) - return; - - clear(); - - if (!isValid()) - return; - - if (firstIndex >= model->count()) - firstIndex = model->count()-1; - if (pathOffset >= model->count()) - pathOffset = model->count()-1; - - int numItems = pathItems >= 0 ? pathItems : model->count(); - for (int i=0; i < numItems && i < model->count(); ++i){ - int index = (i + firstIndex) % model->count(); - QDeclarativeItem *item = getItem(index); - if (!item) { - qWarning() << "PathView: Cannot create item, index" << (i + firstIndex) % model->count(); - return; - } - items.append(item); - item->setZValue(i); - qreal percent = qreal(i) / numItems + _offset; - percent = qAbs(qmlMod(percent, qreal(1.0))); - updateItem(item, percent); - model->completeItem(); - if (currentIndex == index) { - item->setFocus(true); - if (QDeclarativePathViewAttached *att = attached(item)) - att->setIsCurrentItem(true); - } - } - if (pathItems != -1) - q->refill(); -} - -void QDeclarativePathViewPrivate::updateItem(QDeclarativeItem *item, qreal percent) -{ - if (QDeclarativePathViewAttached *att = attached(item)) { - foreach(const QString &attr, path->attributes()) - att->setValue(attr.toUtf8(), path->attributeAt(attr, percent)); - } - QPointF pf = path->pointAt(percent); - item->setX(pf.x() - item->width()*item->scale()/2); - item->setY(pf.y() - item->height()*item->scale()/2); + d->updateHighlight(); } void QDeclarativePathView::refill() @@ -743,81 +872,85 @@ void QDeclarativePathView::refill() if (!d->isValid() || !isComponentComplete()) return; - QList positions; - for (int i=0; iitems.count(); i++){ - qreal percent = qreal(i) / d->items.count(); - percent = percent + d->_offset; - percent = qmlMod(percent, qreal(1.0)); - positions << qAbs(percent); - } - - if (d->pathItems==-1) { - for (int i=0; iupdateItem(d->items.at(i), positions[i]); - return; +// qDebug() << "offset" << d->_offset; + + // first move existing items and remove items off path + int idx = d->firstIndex; + QList::iterator it = d->items.begin(); + while (it != d->items.end()) { + qreal pos = d->positionOfIndex(idx); + QDeclarativeItem *item = *it; + if (pos >= 0.0) { + d->updateItem(item, pos); + ++it; + } else { +// qDebug() << "release"; + d->updateItem(item, 1.0); + d->releaseItem(item); + if (it == d->items.begin()) { + if (++d->firstIndex >= d->model->count()) + d->firstIndex = 0; + } + it = d->items.erase(it); + } + ++idx; + if (idx >= d->model->count()) + idx = 0; } - QList rotatedPositions; - for (int i=0; iitems.count(); i++) - rotatedPositions << positions[(i + d->pathOffset + d->items.count()) % d->items.count()]; - - int wrapIndex= -1; - for (int i=0; iitems.count()-1; i++) { - if (rotatedPositions[i] > rotatedPositions[i+1]){ - wrapIndex = i; - break; + // add items to beginning and end + int count = d->pathItems == -1 ? d->model->count() : qMin(d->pathItems, d->model->count()); + if (d->items.count() < count) { + int idx = qRound(d->model->count() - d->offset) % d->model->count(); + qreal startPos = d->snapPos; + if (d->firstIndex >= 0) { + startPos = d->positionOfIndex(d->firstIndex); + idx = (d->firstIndex + d->items.count()) % d->model->count(); } - } - if (wrapIndex != -1 ){ - //A wraparound has occured - if (wrapIndex < d->items.count()/2){ - while(wrapIndex-- >= 0){ - QDeclarativeItem* p = d->items.takeFirst(); - d->updateItem(p, 0.0); - d->releaseItem(p); - d->firstIndex++; - d->firstIndex %= d->model->count(); - int index = (d->firstIndex + d->items.count())%d->model->count(); - QDeclarativeItem *item = d->getItem(index); - item->setZValue(wrapIndex); - d->model->completeItem(); - if (d->currentIndex == index) { - item->setFocus(true); - if (QDeclarativePathViewAttached *att = d->attached(item)) - att->setIsCurrentItem(true); - } - d->items << item; - d->pathOffset++; - d->pathOffset=d->pathOffset % d->items.count(); + qreal pos = d->positionOfIndex(idx); + while ((pos > startPos || !d->items.count()) && d->items.count() < count) { +// qDebug() << "append" << idx; + QDeclarativeItem *item = d->getItem(idx); + item->setZValue(idx+1); + d->model->completeItem(); + if (d->currentIndex == idx) { + item->setFocus(true); + if (QDeclarativePathViewAttached *att = d->attached(item)) + att->setIsCurrentItem(true); } - } else { - while(wrapIndex++ < d->items.count()-1){ - QDeclarativeItem* p = d->items.takeLast(); - d->updateItem(p, 1.0); - d->releaseItem(p); - d->firstIndex--; - if (d->firstIndex < 0) - d->firstIndex = d->model->count() - 1; - QDeclarativeItem *item = d->getItem(d->firstIndex); - item->setZValue(d->firstIndex); - d->model->completeItem(); - if (d->currentIndex == d->firstIndex) { - item->setFocus(true); - if (QDeclarativePathViewAttached *att = d->attached(item)) - att->setIsCurrentItem(true); - } - d->items.prepend(item); - d->pathOffset--; - if (d->pathOffset < 0) - d->pathOffset = d->items.count() - 1; + if (d->items.count() == 0) + d->firstIndex = idx; + d->items.append(item); + d->updateItem(item, pos); + ++idx; + if (idx >= d->model->count()) + idx = 0; + pos = d->positionOfIndex(idx); + } + + idx = d->firstIndex - 1; + if (idx < 0) + idx = d->model->count() - 1; + pos = d->positionOfIndex(idx); + while (pos >= 0.0 && pos < startPos) { +// qDebug() << "prepend" << idx; + QDeclarativeItem *item = d->getItem(idx); + item->setZValue(idx+1); + d->model->completeItem(); + if (d->currentIndex == idx) { + item->setFocus(true); + if (QDeclarativePathViewAttached *att = d->attached(item)) + att->setIsCurrentItem(true); } + d->items.prepend(item); + d->updateItem(item, pos); + d->firstIndex = idx; + idx = d->firstIndex - 1; + if (idx < 0) + idx = d->model->count() - 1; + pos = d->positionOfIndex(idx); } - for (int i=0; iitems.count(); i++) - rotatedPositions[i] = positions[(i + d->pathOffset + d->items.count()) - % d->items.count()]; } - for (int i=0; iitems.count(); i++) - d->updateItem(d->items.at(i), rotatedPositions[i]); } void QDeclarativePathView::itemsInserted(int modelIndex, int count) @@ -826,29 +959,14 @@ void QDeclarativePathView::itemsInserted(int modelIndex, int count) Q_D(QDeclarativePathView); if (!d->isValid() || !isComponentComplete()) return; - if (d->pathItems == -1) { - for (int i = 0; i < count; ++i) { - QDeclarativeItem *item = d->getItem(modelIndex + i); - item->setZValue(modelIndex + i); - d->model->completeItem(); - d->items.insert(modelIndex + i, item); - } - refill(); - } else { - //XXX This is pretty heavy handed until we reference count items. - d->regenerate(); - } - // make sure the current item is still at the snap position - int itemIndex = (d->currentIndex - d->firstIndex + d->model->count())%d->model->count(); - itemIndex += d->pathOffset; - itemIndex %= d->items.count(); - qreal targetOffset = qmlMod(1.0 + d->snapPos - qreal(itemIndex) / d->items.count(), qreal(1.0)); - - if (targetOffset < 0) - targetOffset = 1.0 + targetOffset; - if (targetOffset != d->_offset) - d->moveOffset.setValue(targetOffset); + QList removedItems = d->items; + d->items.clear(); + d->regenerate(); + while (removedItems.count()) + d->releaseItem(removedItems.takeLast()); + d->updateCurrent(); + emit countChanged(); } void QDeclarativePathView::itemsRemoved(int modelIndex, int count) @@ -857,41 +975,37 @@ void QDeclarativePathView::itemsRemoved(int modelIndex, int count) Q_D(QDeclarativePathView); if (!d->isValid() || !isComponentComplete()) return; - if (d->pathItems == -1) { - for (int i = 0; i < count && d->items.count() > modelIndex; ++i) { - QDeclarativeItem* p = d->items.takeAt(modelIndex); - d->model->release(p); - } - d->snapToCurrent(); - refill(); - } else { - d->regenerate(); - } - if (d->model->count() == 0) { - d->currentIndex = -1; - d->moveOffset.setValue(0); + QList removedItems = d->items; + d->items.clear(); + if (d->offset >= d->model->count()) + d->offset = d->model->count() - 1; + d->regenerate(); + while (removedItems.count()) + d->releaseItem(removedItems.takeLast()); + d->updateCurrent(); + emit countChanged(); +} + +void QDeclarativePathView::itemsMoved(int from, int to, int count) +{ + Q_D(QDeclarativePathView); + if (!d->isValid() || !isComponentComplete()) return; - } - // make sure the current item is still at the snap position - if (d->currentIndex >= d->model->count()) - d->currentIndex = d->model->count() - 1; - int itemIndex = (d->currentIndex - d->firstIndex + d->model->count())%d->model->count(); - itemIndex += d->pathOffset; - itemIndex %= d->items.count(); - qreal targetOffset = qmlMod(1.0 + d->snapPos - qreal(itemIndex) / d->items.count(), qreal(1.0)); - - if (targetOffset < 0) - targetOffset = 1.0 + targetOffset; - if (targetOffset != d->_offset) - d->moveOffset.setValue(targetOffset); + QList removedItems = d->items; + d->items.clear(); + d->regenerate(); + while (removedItems.count()) + d->releaseItem(removedItems.takeLast()); + d->updateCurrent(); } void QDeclarativePathView::modelReset() { Q_D(QDeclarativePathView); d->regenerate(); + emit countChanged(); } void QDeclarativePathView::createdItem(int index, QDeclarativeItem *item) @@ -919,36 +1033,10 @@ int QDeclarativePathViewPrivate::calcCurrentIndex() { int current = -1; if (model && items.count()) { - _offset = qmlMod(_offset, qreal(1.0)); - if (_offset < 0) - _offset += 1.0; - - if (pathItems == -1) { - qreal delta = qmlMod(_offset - snapPos, qreal(1.0)); - if (delta < 0) - delta = 1.0 + delta; - int ii = model->count() - qRound(delta * model->count()); - if (ii < 0) - ii = 0; - current = ii; - } else { - qreal bestDiff=1e9; - int bestI=-1; - for (int i=0; icount()); + offset = qmlMod(offset, model->count()); + if (offset < 0) + offset += model->count(); + current = qRound(qAbs(qmlMod(model->count() - offset, model->count()))); } return current; @@ -1002,57 +1090,26 @@ void QDeclarativePathViewPrivate::snapToCurrent() if (!model || model->count() <= 0) return; - int itemIndex = (currentIndex - firstIndex + model->count()) % model->count(); - - //Rounds is the number of times round to make the current item visible - int rounds = itemIndex / items.count(); - int otherWayRounds = (model->count() - (itemIndex)) / items.count(); - if (otherWayRounds < rounds) - rounds = -otherWayRounds; - - itemIndex += pathOffset; - if(model->count() % items.count() && itemIndex - model->count() + items.count() > 0){ - //When model.count() is not a multiple of pathItemCount we need to manually - //fix the index so that going backwards one step works correctly. - itemIndex = itemIndex - model->count() + items.count(); - } - itemIndex %= items.count(); - qreal targetOffset = qmlMod(1.0 + snapPos - qreal(itemIndex) / items.count(), qreal(1.0)); - - if (targetOffset < 0) - targetOffset = 1.0 + targetOffset; - if (targetOffset == _offset && rounds == 0) - return; + qreal targetOffset = model->count() - currentIndex; moveReason = Other; tl.clear(); - moveOffset.setValue(_offset); - - if (rounds!=0){ - //Compensate if the targetOffset would bring the target in from off the screen - qreal distance = targetOffset - _offset; - if (distance <= -0.5) - rounds--; - if (distance > 0.5) - rounds++; - tl.move(moveOffset, targetOffset -rounds, QEasingCurve(QEasingCurve::InOutQuad), - int(items.count()*qMax((qreal)(2.0/items.count()),(qreal)qAbs(rounds)))); - tl.callback(QDeclarativeTimeLineCallback(&moveOffset, fixOffsetCallback, this)); - return; - } - - if (targetOffset - _offset > 0.5) { - qreal distance = 1 - targetOffset + _offset; - tl.move(moveOffset, 0.0, QEasingCurve(QEasingCurve::OutQuad), int(200 * _offset / distance)); - tl.set(moveOffset, 1.0); - tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::InQuad), int(200 * (1.0-targetOffset) / distance)); - } else if (targetOffset - _offset <= -0.5) { - qreal distance = 1 - _offset + targetOffset; - tl.move(moveOffset, 1.0, QEasingCurve(QEasingCurve::OutQuad), int(200 * (1.0-_offset) / distance)); + moveOffset.setValue(offset); + + const int duration = 300; + + if (targetOffset - offset > model->count()/2) { + qreal distance = model->count() - targetOffset + offset; + tl.move(moveOffset, 0.0, QEasingCurve(QEasingCurve::InQuad), int(duration * offset / distance)); + tl.set(moveOffset, model->count()); + tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::OutQuad), int(duration * (model->count()-targetOffset) / distance)); + } else if (targetOffset - offset <= -model->count()/2) { + qreal distance = model->count() - offset + targetOffset; + tl.move(moveOffset, model->count(), QEasingCurve(QEasingCurve::InQuad), int(duration * (model->count()-offset) / distance)); tl.set(moveOffset, 0.0); - tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::InQuad), int(200 * targetOffset / distance)); + tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::OutQuad), int(duration * targetOffset / distance)); } else { - tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::InOutQuad), 200); + tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::InOutQuad), duration); } } diff --git a/src/declarative/graphicsitems/qdeclarativepathview_p.h b/src/declarative/graphicsitems/qdeclarativepathview_p.h index 6dbd044..07b8f6f 100644 --- a/src/declarative/graphicsitems/qdeclarativepathview_p.h +++ b/src/declarative/graphicsitems/qdeclarativepathview_p.h @@ -62,8 +62,15 @@ class Q_DECLARATIVE_EXPORT QDeclarativePathView : public QDeclarativeItem Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged) Q_PROPERTY(qreal offset READ offset WRITE setOffset NOTIFY offsetChanged) Q_PROPERTY(qreal snapPosition READ snapPosition WRITE setSnapPosition NOTIFY snapPositionChanged) + + Q_PROPERTY(QDeclarativeComponent *highlight READ highlight WRITE setHighlight NOTIFY highlightChanged) + Q_PROPERTY(QDeclarativeItem *highlightItem READ highlightItem NOTIFY highlightItemChanged) + Q_PROPERTY(qreal dragMargin READ dragMargin WRITE setDragMargin NOTIFY dragMarginChanged) - Q_PROPERTY(int count READ count) + Q_PROPERTY(qreal flickDeceleration READ flickDeceleration WRITE setFlickDeceleration NOTIFY flickDecelerationChanged) + Q_PROPERTY(bool interactive READ isInteractive WRITE setInteractive NOTIFY interactiveChanged) + + Q_PROPERTY(int count READ count NOTIFY countChanged) Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged) Q_PROPERTY(int pathItemCount READ pathItemCount WRITE setPathItemCount NOTIFY pathItemCountChanged) @@ -86,9 +93,19 @@ public: qreal snapPosition() const; void setSnapPosition(qreal pos); + QDeclarativeComponent *highlight() const; + void setHighlight(QDeclarativeComponent *highlight); + QDeclarativeItem *highlightItem(); + qreal dragMargin() const; void setDragMargin(qreal margin); + qreal flickDeceleration() const; + void setFlickDeceleration(qreal dec); + + bool isInteractive() const; + void setInteractive(bool); + int count() const; QDeclarativeComponent *delegate() const; @@ -103,11 +120,16 @@ Q_SIGNALS: void currentIndexChanged(); void offsetChanged(); void modelChanged(); + void countChanged(); void pathChanged(); void dragMarginChanged(); void snapPositionChanged(); void delegateChanged(); void pathItemCountChanged(); + void flickDecelerationChanged(); + void interactiveChanged(); + void highlightChanged(); + void highlightItemChanged(); protected: void mousePressEvent(QGraphicsSceneMouseEvent *event); @@ -122,6 +144,7 @@ private Q_SLOTS: void ticked(); void itemsInserted(int index, int count); void itemsRemoved(int index, int count); + void itemsMoved(int,int,int); void modelReset(); void createdItem(int index, QDeclarativeItem *item); void destroyingItem(QDeclarativeItem *item); diff --git a/src/declarative/graphicsitems/qdeclarativepathview_p_p.h b/src/declarative/graphicsitems/qdeclarativepathview_p_p.h index 62f7d95..1780869 100644 --- a/src/declarative/graphicsitems/qdeclarativepathview_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativepathview_p_p.h @@ -75,17 +75,18 @@ class QDeclarativePathViewPrivate : public QDeclarativeItemPrivate public: QDeclarativePathViewPrivate() : path(0), currentIndex(0), startPc(0), lastDist(0) - , lastElapsed(0), stealMouse(false), ownModel(false), activeItem(0) - , snapPos(0), dragMargin(0), moveOffset(this, &QDeclarativePathViewPrivate::setOffset) - , firstIndex(0), pathItems(-1), pathOffset(0), requestedIndex(-1) - , moveReason(Other), attType(0) + , lastElapsed(0), mappedRange(1.0), stealMouse(false), ownModel(false), interactive(true) + , snapPos(0), dragMargin(0), deceleration(100) + , moveOffset(this, &QDeclarativePathViewPrivate::setOffset) + , firstIndex(-1), pathItems(-1), requestedIndex(-1) + , moveReason(Other), attType(0), highlightComponent(0), highlightItem(0) { } void init() { Q_Q(QDeclarativePathView); - _offset = 0; + offset = 0; q->setAcceptedMouseButtons(Qt::LeftButton); q->setFlag(QGraphicsItem::ItemIsFocusScope); q->setFiltersChildEvents(true); @@ -96,7 +97,10 @@ public: void releaseItem(QDeclarativeItem *item); QDeclarativePathViewAttached *attached(QDeclarativeItem *item); void clear(); - + void updateMappedRange(); + qreal positionOfIndex(int index) const; + void createHighlight(); + void updateHighlight(); bool isValid() const { return model && model->count() > 0 && model->isValid() && path; } @@ -117,19 +121,20 @@ public: QPointF startPoint; qreal lastDist; int lastElapsed; - qreal _offset; + qreal offset; + qreal mappedRange; bool stealMouse : 1; bool ownModel : 1; + bool interactive : 1; QTime lastPosTime; QPointF lastPos; - QDeclarativeItem *activeItem; qreal snapPos; qreal dragMargin; + qreal deceleration; QDeclarativeTimeLine tl; QDeclarativeTimeLineValueProxy moveOffset; int firstIndex; int pathItems; - int pathOffset; int requestedIndex; QList items; QDeclarativeGuard model; @@ -137,6 +142,8 @@ public: enum MovementReason { Other, Key, Mouse }; MovementReason moveReason; QDeclarativeOpenMetaObjectType *attType; + QDeclarativeComponent *highlightComponent; + QDeclarativeItem *highlightItem; }; QT_END_NAMESPACE diff --git a/tests/auto/declarative/qdeclarativepathview/data/pathview0.qml b/tests/auto/declarative/qdeclarativepathview/data/pathview0.qml index ae0c86a..8e2c251 100644 --- a/tests/auto/declarative/qdeclarativepathview/data/pathview0.qml +++ b/tests/auto/declarative/qdeclarativepathview/data/pathview0.qml @@ -49,6 +49,11 @@ Rectangle { model: testModel delegate: delegate snapPosition: 0.0001 + highlight: Rectangle { + width: 60 + height: 20 + color: "yellow" + } path: Path { startY: 120 startX: 160 diff --git a/tests/auto/declarative/qdeclarativepathview/data/pathview3.qml b/tests/auto/declarative/qdeclarativepathview/data/pathview3.qml index 70cfbcd..f1bc66e 100644 --- a/tests/auto/declarative/qdeclarativepathview/data/pathview3.qml +++ b/tests/auto/declarative/qdeclarativepathview/data/pathview3.qml @@ -2,7 +2,7 @@ import Qt 4.6 PathView { id: photoPathView - y: 100; width: 800; height: 330; pathItemCount: 4; offset: 0.1 + y: 100; width: 800; height: 330; pathItemCount: 4; offset: 1 dragMargin: 24; snapPosition: 0.50 path: Path { diff --git a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp index c16c46f..6d7cc0d 100644 --- a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp +++ b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp @@ -219,7 +219,7 @@ void tst_QDeclarativePathView::items() QDeclarativePathView *pathview = findItem(canvas->rootObject(), "view"); QVERIFY(pathview != 0); - QCOMPARE(pathview->childItems().count(), model.count()); // assumes all are visible + QCOMPARE(pathview->childItems().count(), model.count()+1); // assumes all are visible, including highlight for (int i = 0; i < model.count(); ++i) { QDeclarativeText *name = findItem(pathview, "textName", i); @@ -230,6 +230,16 @@ void tst_QDeclarativePathView::items() QCOMPARE(number->text(), model.number(i)); } + QDeclarativePath *path = qobject_cast(pathview->path()); + QVERIFY(path); + + QVERIFY(pathview->highlightItem()); + QPointF start = path->pointAt(0.0); + QPointF offset; + offset.setX(pathview->highlightItem()->width()/2); + offset.setY(pathview->highlightItem()->height()/2); + QCOMPARE(pathview->highlightItem()->pos() + offset, start); + delete canvas; } @@ -262,8 +272,8 @@ void tst_QDeclarativePathView::pathview3() QVERIFY(obj->delegate() != 0); QVERIFY(obj->model() != QVariant()); QCOMPARE(obj->currentIndex(), 0); - QCOMPARE(obj->offset(), 0.5); // ??? - QCOMPARE(obj->snapPosition(), 0.5); // ??? + QCOMPARE(obj->offset(), 1.0); + QCOMPARE(obj->snapPosition(), 0.5); QCOMPARE(obj->dragMargin(), 24.); QCOMPARE(obj->count(), 8); QCOMPARE(obj->pathItemCount(), 4); @@ -422,14 +432,14 @@ void tst_QDeclarativePathView::pathMoved() offset.setX(firstItem->width()/2); offset.setY(firstItem->height()/2); QCOMPARE(firstItem->pos() + offset, start); - pathview->setOffset(0.1); + pathview->setOffset(1.0); for(int i=0; i(pathview, "wrapper", i); - QCOMPARE(curItem->pos() + offset, path->pointAt(0.1 + i*0.25)); + QCOMPARE(curItem->pos() + offset, path->pointAt(0.25 + i*0.25)); } - pathview->setOffset(1.0); + pathview->setOffset(0.0); QCOMPARE(firstItem->pos() + offset, start); delete canvas; -- cgit v0.12 From f20433bb8b72589fff27ec66f2e283b2f48fb019 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 25 Mar 2010 14:32:05 +1000 Subject: Pen is not a creatable type. --- src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp index 1a48cbd..07d7f4d 100644 --- a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp @@ -114,7 +114,6 @@ void QDeclarativeItemModule::defineModule() qmlRegisterType("Qt",4,6,"PathPercent"); qmlRegisterType("Qt",4,6,"PathQuad"); qmlRegisterType("Qt",4,6,"PathView"); - qmlRegisterType("Qt",4,6,"Pen"); qmlRegisterType("Qt",4,6,"QIntValidator"); #if (QT_VERSION >= QT_VERSION_CHECK(4,7,0)) qmlRegisterType("Qt",4,7,"QDoubleValidator"); @@ -146,6 +145,7 @@ void QDeclarativeItemModule::defineModule() qmlRegisterType(); qmlRegisterType(); qmlRegisterType(); + qmlRegisterType(); #ifdef QT_WEBKIT_LIB qmlRegisterType(); #endif -- cgit v0.12 From d373f8b8ee0a5841bcdb264b0b01b262c15e7f89 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 25 Mar 2010 15:01:30 +1000 Subject: Update AnchorChanges to use more natural form for setting anchors. Instead of specifying left, right, etc directly, we keep the regular syntax and specify anchors.left, anchors.right, etc. Also get rid of the hacky "reset" string property and use undefined to reset (like PropertyChanges). --- src/declarative/QmlChanges.txt | 2 + .../util/qdeclarativestateoperations.cpp | 474 +++++++++++++-------- .../util/qdeclarativestateoperations_p.h | 123 +++++- src/declarative/util/qdeclarativeutilmodule.cpp | 1 + .../qdeclarativestates/data/anchorChanges1.qml | 4 +- .../qdeclarativestates/data/anchorChanges2.qml | 4 +- .../qdeclarativestates/data/anchorChanges3.qml | 8 +- .../qdeclarativestates/data/anchorChanges4.qml | 4 +- .../qdeclarativestates/data/anchorChanges5.qml | 4 +- .../qdeclarativestates/tst_qdeclarativestates.cpp | 38 +- .../visual/animation/reanchor/reanchor.qml | 15 +- 11 files changed, 447 insertions(+), 230 deletions(-) diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt index 2a35dda..9a55bde 100644 --- a/src/declarative/QmlChanges.txt +++ b/src/declarative/QmlChanges.txt @@ -13,6 +13,8 @@ AnchorAnimation must now be used to animate anchor changes (and not NumberAnimat Removed ParentAction (use ParentAnimation instead) ScriptAction: renamed stateChangeScriptName -> scriptName Animation: replace repeat with loops (loops: Animation.Infinite gives the old repeat behavior) +AnchorChanges: use natural form to specify anchors (anchors.left instead of left) +AnchorChanges: removed reset property. (reset: "left" should now be anchors.left: undefined) C++ API ------- diff --git a/src/declarative/util/qdeclarativestateoperations.cpp b/src/declarative/util/qdeclarativestateoperations.cpp index 0bc81ee..3469136 100644 --- a/src/declarative/util/qdeclarativestateoperations.cpp +++ b/src/declarative/util/qdeclarativestateoperations.cpp @@ -609,209 +609,343 @@ QString QDeclarativeStateChangeScript::typeName() const For more information on anchors see \l {anchor-layout}{Anchor Layouts}. */ - - -class QDeclarativeAnchorChangesPrivate : public QObjectPrivate +class QDeclarativeAnchorSetPrivate : public QObjectPrivate { + Q_DECLARE_PUBLIC(QDeclarativeAnchorSet) public: - QDeclarativeAnchorChangesPrivate() : target(0) {} + QDeclarativeAnchorSetPrivate() + : usedAnchors(0), fill(0), + centerIn(0)/*, leftMargin(0), rightMargin(0), topMargin(0), bottomMargin(0), + margins(0), vCenterOffset(0), hCenterOffset(0), baselineOffset(0)*/ + { + } - QDeclarativeItem *target; - QString resetString; + QDeclarativeAnchors::UsedAnchors usedAnchors; + //### change to QDeclarativeAnchors::UsedAnchors resetAnchors QStringList resetList; + QDeclarativeItem *fill; + QDeclarativeItem *centerIn; + QDeclarativeAnchorLine left; QDeclarativeAnchorLine right; - QDeclarativeAnchorLine horizontalCenter; QDeclarativeAnchorLine top; QDeclarativeAnchorLine bottom; - QDeclarativeAnchorLine verticalCenter; + QDeclarativeAnchorLine vCenter; + QDeclarativeAnchorLine hCenter; QDeclarativeAnchorLine baseline; - QDeclarativeAnchorLine origLeft; - QDeclarativeAnchorLine origRight; - QDeclarativeAnchorLine origHCenter; - QDeclarativeAnchorLine origTop; - QDeclarativeAnchorLine origBottom; - QDeclarativeAnchorLine origVCenter; - QDeclarativeAnchorLine origBaseline; - - QDeclarativeAnchorLine rewindLeft; - QDeclarativeAnchorLine rewindRight; - QDeclarativeAnchorLine rewindHCenter; - QDeclarativeAnchorLine rewindTop; - QDeclarativeAnchorLine rewindBottom; - QDeclarativeAnchorLine rewindVCenter; - QDeclarativeAnchorLine rewindBaseline; + /*qreal leftMargin; + qreal rightMargin; + qreal topMargin; + qreal bottomMargin; + qreal margins; + qreal vCenterOffset; + qreal hCenterOffset; + qreal baselineOffset;*/ +}; - qreal fromX; - qreal fromY; - qreal fromWidth; - qreal fromHeight; +QDeclarativeAnchorSet::QDeclarativeAnchorSet(QObject *parent) + : QObject(*new QDeclarativeAnchorSetPrivate, parent) +{ +} - qreal toX; - qreal toY; - qreal toWidth; - qreal toHeight; +QDeclarativeAnchorSet::~QDeclarativeAnchorSet() +{ +} - qreal rewindX; - qreal rewindY; - qreal rewindWidth; - qreal rewindHeight; +QDeclarativeAnchorLine QDeclarativeAnchorSet::top() const +{ + Q_D(const QDeclarativeAnchorSet); + return d->top; +} - bool applyOrigLeft; - bool applyOrigRight; - bool applyOrigHCenter; - bool applyOrigTop; - bool applyOrigBottom; - bool applyOrigVCenter; - bool applyOrigBaseline; -}; +void QDeclarativeAnchorSet::setTop(const QDeclarativeAnchorLine &edge) +{ + Q_D(QDeclarativeAnchorSet); + d->usedAnchors |= QDeclarativeAnchors::HasTopAnchor; + d->top = edge; +} -/*! - \qmlproperty Item AnchorChanges::target - This property holds the Item whose anchors will change -*/ +void QDeclarativeAnchorSet::resetTop() +{ + Q_D(QDeclarativeAnchorSet); + d->usedAnchors &= ~QDeclarativeAnchors::HasTopAnchor; + d->top = QDeclarativeAnchorLine(); + d->resetList << QLatin1String("top"); +} -QDeclarativeAnchorChanges::QDeclarativeAnchorChanges(QObject *parent) - : QDeclarativeStateOperation(*(new QDeclarativeAnchorChangesPrivate), parent) +QDeclarativeAnchorLine QDeclarativeAnchorSet::bottom() const { + Q_D(const QDeclarativeAnchorSet); + return d->bottom; } -QDeclarativeAnchorChanges::~QDeclarativeAnchorChanges() +void QDeclarativeAnchorSet::setBottom(const QDeclarativeAnchorLine &edge) { + Q_D(QDeclarativeAnchorSet); + d->usedAnchors |= QDeclarativeAnchors::HasBottomAnchor; + d->bottom = edge; } -QDeclarativeAnchorChanges::ActionList QDeclarativeAnchorChanges::actions() +void QDeclarativeAnchorSet::resetBottom() { - QDeclarativeAction a; - a.event = this; - return ActionList() << a; + Q_D(QDeclarativeAnchorSet); + d->usedAnchors &= ~QDeclarativeAnchors::HasBottomAnchor; + d->bottom = QDeclarativeAnchorLine(); + d->resetList << QLatin1String("bottom"); } -QDeclarativeItem *QDeclarativeAnchorChanges::object() const +QDeclarativeAnchorLine QDeclarativeAnchorSet::verticalCenter() const { - Q_D(const QDeclarativeAnchorChanges); - return d->target; + Q_D(const QDeclarativeAnchorSet); + return d->vCenter; } -void QDeclarativeAnchorChanges::setObject(QDeclarativeItem *target) +void QDeclarativeAnchorSet::setVerticalCenter(const QDeclarativeAnchorLine &edge) { - Q_D(QDeclarativeAnchorChanges); - d->target = target; + Q_D(QDeclarativeAnchorSet); + d->usedAnchors |= QDeclarativeAnchors::HasVCenterAnchor; + d->vCenter = edge; } -QString QDeclarativeAnchorChanges::reset() const +void QDeclarativeAnchorSet::resetVerticalCenter() { - Q_D(const QDeclarativeAnchorChanges); - return d->resetString; + Q_D(QDeclarativeAnchorSet); + d->usedAnchors &= ~QDeclarativeAnchors::HasVCenterAnchor; + d->vCenter = QDeclarativeAnchorLine(); + d->resetList << QLatin1String("verticalCenter"); } -void QDeclarativeAnchorChanges::setReset(const QString &reset) +QDeclarativeAnchorLine QDeclarativeAnchorSet::baseline() const { - Q_D(QDeclarativeAnchorChanges); - d->resetString = reset; - d->resetList = d->resetString.split(QLatin1Char(',')); - for (int i = 0; i < d->resetList.count(); ++i) - d->resetList[i] = d->resetList.at(i).trimmed(); + Q_D(const QDeclarativeAnchorSet); + return d->baseline; } -/*! - \qmlproperty AnchorLine AnchorChanges::left - \qmlproperty AnchorLine AnchorChanges::right - \qmlproperty AnchorLine AnchorChanges::horizontalCenter - \qmlproperty AnchorLine AnchorChanges::top - \qmlproperty AnchorLine AnchorChanges::bottom - \qmlproperty AnchorLine AnchorChanges::verticalCenter - \qmlproperty AnchorLine AnchorChanges::baseline +void QDeclarativeAnchorSet::setBaseline(const QDeclarativeAnchorLine &edge) +{ + Q_D(QDeclarativeAnchorSet); + d->usedAnchors |= QDeclarativeAnchors::HasBaselineAnchor; + d->baseline = edge; +} - These properties change the respective anchors of the item. -*/ +void QDeclarativeAnchorSet::resetBaseline() +{ + Q_D(QDeclarativeAnchorSet); + d->usedAnchors &= ~QDeclarativeAnchors::HasBaselineAnchor; + d->baseline = QDeclarativeAnchorLine(); + d->resetList << QLatin1String("baseline"); +} -QDeclarativeAnchorLine QDeclarativeAnchorChanges::left() const +QDeclarativeAnchorLine QDeclarativeAnchorSet::left() const { - Q_D(const QDeclarativeAnchorChanges); + Q_D(const QDeclarativeAnchorSet); return d->left; } -void QDeclarativeAnchorChanges::setLeft(const QDeclarativeAnchorLine &edge) +void QDeclarativeAnchorSet::setLeft(const QDeclarativeAnchorLine &edge) { - Q_D(QDeclarativeAnchorChanges); + Q_D(QDeclarativeAnchorSet); + d->usedAnchors |= QDeclarativeAnchors::HasLeftAnchor; d->left = edge; } -QDeclarativeAnchorLine QDeclarativeAnchorChanges::right() const +void QDeclarativeAnchorSet::resetLeft() { - Q_D(const QDeclarativeAnchorChanges); + Q_D(QDeclarativeAnchorSet); + d->usedAnchors &= ~QDeclarativeAnchors::HasLeftAnchor; + d->left = QDeclarativeAnchorLine(); + d->resetList << QLatin1String("left"); +} + +QDeclarativeAnchorLine QDeclarativeAnchorSet::right() const +{ + Q_D(const QDeclarativeAnchorSet); return d->right; } -void QDeclarativeAnchorChanges::setRight(const QDeclarativeAnchorLine &edge) +void QDeclarativeAnchorSet::setRight(const QDeclarativeAnchorLine &edge) { - Q_D(QDeclarativeAnchorChanges); + Q_D(QDeclarativeAnchorSet); + d->usedAnchors |= QDeclarativeAnchors::HasRightAnchor; d->right = edge; } -QDeclarativeAnchorLine QDeclarativeAnchorChanges::horizontalCenter() const +void QDeclarativeAnchorSet::resetRight() { - Q_D(const QDeclarativeAnchorChanges); - return d->horizontalCenter; + Q_D(QDeclarativeAnchorSet); + d->usedAnchors &= ~QDeclarativeAnchors::HasRightAnchor; + d->right = QDeclarativeAnchorLine(); + d->resetList << QLatin1String("right"); } -void QDeclarativeAnchorChanges::setHorizontalCenter(const QDeclarativeAnchorLine &edge) +QDeclarativeAnchorLine QDeclarativeAnchorSet::horizontalCenter() const { - Q_D(QDeclarativeAnchorChanges); - d->horizontalCenter = edge; + Q_D(const QDeclarativeAnchorSet); + return d->hCenter; } -QDeclarativeAnchorLine QDeclarativeAnchorChanges::top() const +void QDeclarativeAnchorSet::setHorizontalCenter(const QDeclarativeAnchorLine &edge) { - Q_D(const QDeclarativeAnchorChanges); - return d->top; + Q_D(QDeclarativeAnchorSet); + d->usedAnchors |= QDeclarativeAnchors::HasHCenterAnchor; + d->hCenter = edge; } -void QDeclarativeAnchorChanges::setTop(const QDeclarativeAnchorLine &edge) +void QDeclarativeAnchorSet::resetHorizontalCenter() { - Q_D(QDeclarativeAnchorChanges); - d->top = edge; + Q_D(QDeclarativeAnchorSet); + d->usedAnchors &= ~QDeclarativeAnchors::HasHCenterAnchor; + d->hCenter = QDeclarativeAnchorLine(); + d->resetList << QLatin1String("horizontalCenter"); } -QDeclarativeAnchorLine QDeclarativeAnchorChanges::bottom() const +QDeclarativeItem *QDeclarativeAnchorSet::fill() const { - Q_D(const QDeclarativeAnchorChanges); - return d->bottom; + Q_D(const QDeclarativeAnchorSet); + return d->fill; } -void QDeclarativeAnchorChanges::setBottom(const QDeclarativeAnchorLine &edge) +void QDeclarativeAnchorSet::setFill(QDeclarativeItem *f) { - Q_D(QDeclarativeAnchorChanges); - d->bottom = edge; + Q_D(QDeclarativeAnchorSet); + d->fill = f; } -QDeclarativeAnchorLine QDeclarativeAnchorChanges::verticalCenter() const +void QDeclarativeAnchorSet::resetFill() { - Q_D(const QDeclarativeAnchorChanges); - return d->verticalCenter; + setFill(0); +} + +QDeclarativeItem *QDeclarativeAnchorSet::centerIn() const +{ + Q_D(const QDeclarativeAnchorSet); + return d->centerIn; } -void QDeclarativeAnchorChanges::setVerticalCenter(const QDeclarativeAnchorLine &edge) +void QDeclarativeAnchorSet::setCenterIn(QDeclarativeItem* c) +{ + Q_D(QDeclarativeAnchorSet); + d->centerIn = c; +} + +void QDeclarativeAnchorSet::resetCenterIn() +{ + setCenterIn(0); +} + + +class QDeclarativeAnchorChangesPrivate : public QObjectPrivate +{ +public: + QDeclarativeAnchorChangesPrivate() + : target(0), anchorSet(new QDeclarativeAnchorSet) {} + ~QDeclarativeAnchorChangesPrivate() { delete anchorSet; } + + QDeclarativeItem *target; + QDeclarativeAnchorSet *anchorSet; + + QDeclarativeAnchorLine origLeft; + QDeclarativeAnchorLine origRight; + QDeclarativeAnchorLine origHCenter; + QDeclarativeAnchorLine origTop; + QDeclarativeAnchorLine origBottom; + QDeclarativeAnchorLine origVCenter; + QDeclarativeAnchorLine origBaseline; + + QDeclarativeAnchorLine rewindLeft; + QDeclarativeAnchorLine rewindRight; + QDeclarativeAnchorLine rewindHCenter; + QDeclarativeAnchorLine rewindTop; + QDeclarativeAnchorLine rewindBottom; + QDeclarativeAnchorLine rewindVCenter; + QDeclarativeAnchorLine rewindBaseline; + + qreal fromX; + qreal fromY; + qreal fromWidth; + qreal fromHeight; + + qreal toX; + qreal toY; + qreal toWidth; + qreal toHeight; + + qreal rewindX; + qreal rewindY; + qreal rewindWidth; + qreal rewindHeight; + + bool applyOrigLeft; + bool applyOrigRight; + bool applyOrigHCenter; + bool applyOrigTop; + bool applyOrigBottom; + bool applyOrigVCenter; + bool applyOrigBaseline; +}; + +/*! + \qmlproperty Item AnchorChanges::target + This property holds the Item whose anchors will change +*/ + +QDeclarativeAnchorChanges::QDeclarativeAnchorChanges(QObject *parent) + : QDeclarativeStateOperation(*(new QDeclarativeAnchorChangesPrivate), parent) +{ +} + +QDeclarativeAnchorChanges::~QDeclarativeAnchorChanges() +{ +} + +QDeclarativeAnchorChanges::ActionList QDeclarativeAnchorChanges::actions() +{ + QDeclarativeAction a; + a.event = this; + return ActionList() << a; +} + +QDeclarativeAnchorSet *QDeclarativeAnchorChanges::anchors() { Q_D(QDeclarativeAnchorChanges); - d->verticalCenter = edge; + return d->anchorSet; } -QDeclarativeAnchorLine QDeclarativeAnchorChanges::baseline() const +QDeclarativeItem *QDeclarativeAnchorChanges::object() const { Q_D(const QDeclarativeAnchorChanges); - return d->baseline; + return d->target; } -void QDeclarativeAnchorChanges::setBaseline(const QDeclarativeAnchorLine &edge) +void QDeclarativeAnchorChanges::setObject(QDeclarativeItem *target) { Q_D(QDeclarativeAnchorChanges); - d->baseline = edge; + d->target = target; } +/*! + \qmlproperty AnchorLine AnchorChanges::anchors.left + \qmlproperty AnchorLine AnchorChanges::anchors.right + \qmlproperty AnchorLine AnchorChanges::anchors.horizontalCenter + \qmlproperty AnchorLine AnchorChanges::anchors.top + \qmlproperty AnchorLine AnchorChanges::anchors.bottom + \qmlproperty AnchorLine AnchorChanges::anchors.verticalCenter + \qmlproperty AnchorLine AnchorChanges::anchors.baseline + + These properties change the respective anchors of the item. + + To reset an anchor you can assign \c undefined: + \qml + AnchorChanges { + target: myItem + left: undefined //remove myItem's left anchor + right: otherItem.right + } + \endqml +*/ + void QDeclarativeAnchorChanges::execute() { Q_D(QDeclarativeAnchorChanges); @@ -835,36 +969,36 @@ void QDeclarativeAnchorChanges::execute() d->target->anchors()->setBaseline(d->origBaseline); //reset any anchors that have been specified - if (d->resetList.contains(QLatin1String("left"))) + if (d->anchorSet->d_func()->resetList .contains(QLatin1String("left"))) d->target->anchors()->resetLeft(); - if (d->resetList.contains(QLatin1String("right"))) + if (d->anchorSet->d_func()->resetList .contains(QLatin1String("right"))) d->target->anchors()->resetRight(); - if (d->resetList.contains(QLatin1String("horizontalCenter"))) + if (d->anchorSet->d_func()->resetList .contains(QLatin1String("horizontalCenter"))) d->target->anchors()->resetHorizontalCenter(); - if (d->resetList.contains(QLatin1String("top"))) + if (d->anchorSet->d_func()->resetList .contains(QLatin1String("top"))) d->target->anchors()->resetTop(); - if (d->resetList.contains(QLatin1String("bottom"))) + if (d->anchorSet->d_func()->resetList .contains(QLatin1String("bottom"))) d->target->anchors()->resetBottom(); - if (d->resetList.contains(QLatin1String("verticalCenter"))) + if (d->anchorSet->d_func()->resetList .contains(QLatin1String("verticalCenter"))) d->target->anchors()->resetVerticalCenter(); - if (d->resetList.contains(QLatin1String("baseline"))) + if (d->anchorSet->d_func()->resetList .contains(QLatin1String("baseline"))) d->target->anchors()->resetBaseline(); //set any anchors that have been specified - if (d->left.anchorLine != QDeclarativeAnchorLine::Invalid) - d->target->anchors()->setLeft(d->left); - if (d->right.anchorLine != QDeclarativeAnchorLine::Invalid) - d->target->anchors()->setRight(d->right); - if (d->horizontalCenter.anchorLine != QDeclarativeAnchorLine::Invalid) - d->target->anchors()->setHorizontalCenter(d->horizontalCenter); - if (d->top.anchorLine != QDeclarativeAnchorLine::Invalid) - d->target->anchors()->setTop(d->top); - if (d->bottom.anchorLine != QDeclarativeAnchorLine::Invalid) - d->target->anchors()->setBottom(d->bottom); - if (d->verticalCenter.anchorLine != QDeclarativeAnchorLine::Invalid) - d->target->anchors()->setVerticalCenter(d->verticalCenter); - if (d->baseline.anchorLine != QDeclarativeAnchorLine::Invalid) - d->target->anchors()->setBaseline(d->baseline); + if (d->anchorSet->d_func()->left.anchorLine != QDeclarativeAnchorLine::Invalid) + d->target->anchors()->setLeft(d->anchorSet->d_func()->left); + if (d->anchorSet->d_func()->right.anchorLine != QDeclarativeAnchorLine::Invalid) + d->target->anchors()->setRight(d->anchorSet->d_func()->right); + if (d->anchorSet->d_func()->hCenter.anchorLine != QDeclarativeAnchorLine::Invalid) + d->target->anchors()->setHorizontalCenter(d->anchorSet->d_func()->hCenter); + if (d->anchorSet->d_func()->top.anchorLine != QDeclarativeAnchorLine::Invalid) + d->target->anchors()->setTop(d->anchorSet->d_func()->top); + if (d->anchorSet->d_func()->bottom.anchorLine != QDeclarativeAnchorLine::Invalid) + d->target->anchors()->setBottom(d->anchorSet->d_func()->bottom); + if (d->anchorSet->d_func()->vCenter.anchorLine != QDeclarativeAnchorLine::Invalid) + d->target->anchors()->setVerticalCenter(d->anchorSet->d_func()->vCenter); + if (d->anchorSet->d_func()->baseline.anchorLine != QDeclarativeAnchorLine::Invalid) + d->target->anchors()->setBaseline(d->anchorSet->d_func()->baseline); } bool QDeclarativeAnchorChanges::isReversable() @@ -879,19 +1013,19 @@ void QDeclarativeAnchorChanges::reverse() return; //reset any anchors set by the state - if (d->left.anchorLine != QDeclarativeAnchorLine::Invalid) + if (d->anchorSet->d_func()->left.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->resetLeft(); - if (d->right.anchorLine != QDeclarativeAnchorLine::Invalid) + if (d->anchorSet->d_func()->right.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->resetRight(); - if (d->horizontalCenter.anchorLine != QDeclarativeAnchorLine::Invalid) + if (d->anchorSet->d_func()->hCenter.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->resetHorizontalCenter(); - if (d->top.anchorLine != QDeclarativeAnchorLine::Invalid) + if (d->anchorSet->d_func()->top.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->resetTop(); - if (d->bottom.anchorLine != QDeclarativeAnchorLine::Invalid) + if (d->anchorSet->d_func()->bottom.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->resetBottom(); - if (d->verticalCenter.anchorLine != QDeclarativeAnchorLine::Invalid) + if (d->anchorSet->d_func()->vCenter.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->resetVerticalCenter(); - if (d->baseline.anchorLine != QDeclarativeAnchorLine::Invalid) + if (d->anchorSet->d_func()->baseline.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->resetBaseline(); //restore previous anchors @@ -977,26 +1111,26 @@ void QDeclarativeAnchorChanges::copyOriginals(QDeclarativeActionEvent *other) QDeclarativeAnchorChangesPrivate *acp = ac->d_func(); //probably also need to revert some things - d->applyOrigLeft = (acp->left.anchorLine != QDeclarativeAnchorLine::Invalid || - acp->resetList.contains(QLatin1String("left"))); + d->applyOrigLeft = (acp->anchorSet->d_func()->left.anchorLine != QDeclarativeAnchorLine::Invalid || + acp->anchorSet->d_func()->resetList.contains(QLatin1String("left"))); - d->applyOrigRight = (acp->right.anchorLine != QDeclarativeAnchorLine::Invalid || - acp->resetList.contains(QLatin1String("right"))); + d->applyOrigRight = (acp->anchorSet->d_func()->right.anchorLine != QDeclarativeAnchorLine::Invalid || + acp->anchorSet->d_func()->resetList.contains(QLatin1String("right"))); - d->applyOrigHCenter = (acp->horizontalCenter.anchorLine != QDeclarativeAnchorLine::Invalid || - acp->resetList.contains(QLatin1String("horizontalCenter"))); + d->applyOrigHCenter = (acp->anchorSet->d_func()->hCenter.anchorLine != QDeclarativeAnchorLine::Invalid || + acp->anchorSet->d_func()->resetList.contains(QLatin1String("horizontalCenter"))); - d->applyOrigTop = (acp->top.anchorLine != QDeclarativeAnchorLine::Invalid || - acp->resetList.contains(QLatin1String("top"))); + d->applyOrigTop = (acp->anchorSet->d_func()->top.anchorLine != QDeclarativeAnchorLine::Invalid || + acp->anchorSet->d_func()->resetList.contains(QLatin1String("top"))); - d->applyOrigBottom = (acp->bottom.anchorLine != QDeclarativeAnchorLine::Invalid || - acp->resetList.contains(QLatin1String("bottom"))); + d->applyOrigBottom = (acp->anchorSet->d_func()->bottom.anchorLine != QDeclarativeAnchorLine::Invalid || + acp->anchorSet->d_func()->resetList.contains(QLatin1String("bottom"))); - d->applyOrigVCenter = (acp->verticalCenter.anchorLine != QDeclarativeAnchorLine::Invalid || - acp->resetList.contains(QLatin1String("verticalCenter"))); + d->applyOrigVCenter = (acp->anchorSet->d_func()->vCenter.anchorLine != QDeclarativeAnchorLine::Invalid || + acp->anchorSet->d_func()->resetList.contains(QLatin1String("verticalCenter"))); - d->applyOrigBaseline = (acp->baseline.anchorLine != QDeclarativeAnchorLine::Invalid || - acp->resetList.contains(QLatin1String("baseline"))); + d->applyOrigBaseline = (acp->anchorSet->d_func()->baseline.anchorLine != QDeclarativeAnchorLine::Invalid || + acp->anchorSet->d_func()->resetList.contains(QLatin1String("baseline"))); d->origLeft = ac->d_func()->origLeft; d->origRight = ac->d_func()->origRight; @@ -1034,35 +1168,35 @@ void QDeclarativeAnchorChanges::clearBindings() d->target->anchors()->resetBaseline(); //reset any anchors that have been specified - if (d->resetList.contains(QLatin1String("left"))) + if (d->anchorSet->d_func()->resetList .contains(QLatin1String("left"))) d->target->anchors()->resetLeft(); - if (d->resetList.contains(QLatin1String("right"))) + if (d->anchorSet->d_func()->resetList .contains(QLatin1String("right"))) d->target->anchors()->resetRight(); - if (d->resetList.contains(QLatin1String("horizontalCenter"))) + if (d->anchorSet->d_func()->resetList .contains(QLatin1String("horizontalCenter"))) d->target->anchors()->resetHorizontalCenter(); - if (d->resetList.contains(QLatin1String("top"))) + if (d->anchorSet->d_func()->resetList .contains(QLatin1String("top"))) d->target->anchors()->resetTop(); - if (d->resetList.contains(QLatin1String("bottom"))) + if (d->anchorSet->d_func()->resetList .contains(QLatin1String("bottom"))) d->target->anchors()->resetBottom(); - if (d->resetList.contains(QLatin1String("verticalCenter"))) + if (d->anchorSet->d_func()->resetList .contains(QLatin1String("verticalCenter"))) d->target->anchors()->resetVerticalCenter(); - if (d->resetList.contains(QLatin1String("baseline"))) + if (d->anchorSet->d_func()->resetList .contains(QLatin1String("baseline"))) d->target->anchors()->resetBaseline(); //reset any anchors that we'll be setting in the state - if (d->left.anchorLine != QDeclarativeAnchorLine::Invalid) + if (d->anchorSet->d_func()->left.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->resetLeft(); - if (d->right.anchorLine != QDeclarativeAnchorLine::Invalid) + if (d->anchorSet->d_func()->right.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->resetRight(); - if (d->horizontalCenter.anchorLine != QDeclarativeAnchorLine::Invalid) + if (d->anchorSet->d_func()->hCenter.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->resetHorizontalCenter(); - if (d->top.anchorLine != QDeclarativeAnchorLine::Invalid) + if (d->anchorSet->d_func()->top.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->resetTop(); - if (d->bottom.anchorLine != QDeclarativeAnchorLine::Invalid) + if (d->anchorSet->d_func()->bottom.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->resetBottom(); - if (d->verticalCenter.anchorLine != QDeclarativeAnchorLine::Invalid) + if (d->anchorSet->d_func()->vCenter.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->resetVerticalCenter(); - if (d->baseline.anchorLine != QDeclarativeAnchorLine::Invalid) + if (d->anchorSet->d_func()->baseline.anchorLine != QDeclarativeAnchorLine::Invalid) d->target->anchors()->resetBaseline(); } diff --git a/src/declarative/util/qdeclarativestateoperations_p.h b/src/declarative/util/qdeclarativestateoperations_p.h index 66a8717..c97b2da 100644 --- a/src/declarative/util/qdeclarativestateoperations_p.h +++ b/src/declarative/util/qdeclarativestateoperations_p.h @@ -143,54 +143,132 @@ public: virtual void execute(); }; -class QDeclarativeAnchorChangesPrivate; -class Q_DECLARATIVE_EXPORT QDeclarativeAnchorChanges : public QDeclarativeStateOperation, public QDeclarativeActionEvent +class QDeclarativeAnchorChanges; +class QDeclarativeAnchorSetPrivate; +class Q_AUTOTEST_EXPORT QDeclarativeAnchorSet : public QObject { Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarativeAnchorChanges) - Q_PROPERTY(QDeclarativeItem *target READ object WRITE setObject) - Q_PROPERTY(QString reset READ reset WRITE setReset) - Q_PROPERTY(QDeclarativeAnchorLine left READ left WRITE setLeft) - Q_PROPERTY(QDeclarativeAnchorLine right READ right WRITE setRight) - Q_PROPERTY(QDeclarativeAnchorLine horizontalCenter READ horizontalCenter WRITE setHorizontalCenter) - Q_PROPERTY(QDeclarativeAnchorLine top READ top WRITE setTop) - Q_PROPERTY(QDeclarativeAnchorLine bottom READ bottom WRITE setBottom) - Q_PROPERTY(QDeclarativeAnchorLine verticalCenter READ verticalCenter WRITE setVerticalCenter) - Q_PROPERTY(QDeclarativeAnchorLine baseline READ baseline WRITE setBaseline) + Q_PROPERTY(QDeclarativeAnchorLine left READ left WRITE setLeft RESET resetLeft) + Q_PROPERTY(QDeclarativeAnchorLine right READ right WRITE setRight RESET resetRight) + Q_PROPERTY(QDeclarativeAnchorLine horizontalCenter READ horizontalCenter WRITE setHorizontalCenter RESET resetHorizontalCenter) + Q_PROPERTY(QDeclarativeAnchorLine top READ top WRITE setTop RESET resetTop) + Q_PROPERTY(QDeclarativeAnchorLine bottom READ bottom WRITE setBottom RESET resetBottom) + Q_PROPERTY(QDeclarativeAnchorLine verticalCenter READ verticalCenter WRITE setVerticalCenter RESET resetVerticalCenter) + Q_PROPERTY(QDeclarativeAnchorLine baseline READ baseline WRITE setBaseline RESET resetBaseline) + //Q_PROPERTY(QDeclarativeItem *fill READ fill WRITE setFill RESET resetFill) + //Q_PROPERTY(QDeclarativeItem *centerIn READ centerIn WRITE setCenterIn RESET resetCenterIn) + + /*Q_PROPERTY(qreal margins READ margins WRITE setMargins NOTIFY marginsChanged) + Q_PROPERTY(qreal leftMargin READ leftMargin WRITE setLeftMargin NOTIFY leftMarginChanged) + Q_PROPERTY(qreal rightMargin READ rightMargin WRITE setRightMargin NOTIFY rightMarginChanged) + Q_PROPERTY(qreal horizontalCenterOffset READ horizontalCenterOffset WRITE setHorizontalCenterOffset NOTIFY horizontalCenterOffsetChanged()) + Q_PROPERTY(qreal topMargin READ topMargin WRITE setTopMargin NOTIFY topMarginChanged) + Q_PROPERTY(qreal bottomMargin READ bottomMargin WRITE setBottomMargin NOTIFY bottomMarginChanged) + Q_PROPERTY(qreal verticalCenterOffset READ verticalCenterOffset WRITE setVerticalCenterOffset NOTIFY verticalCenterOffsetChanged()) + Q_PROPERTY(qreal baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged())*/ public: - QDeclarativeAnchorChanges(QObject *parent=0); - ~QDeclarativeAnchorChanges(); - - virtual ActionList actions(); - - QDeclarativeItem *object() const; - void setObject(QDeclarativeItem *); - - QString reset() const; - void setReset(const QString &); + QDeclarativeAnchorSet(QObject *parent=0); + virtual ~QDeclarativeAnchorSet(); QDeclarativeAnchorLine left() const; void setLeft(const QDeclarativeAnchorLine &edge); + void resetLeft(); QDeclarativeAnchorLine right() const; void setRight(const QDeclarativeAnchorLine &edge); + void resetRight(); QDeclarativeAnchorLine horizontalCenter() const; void setHorizontalCenter(const QDeclarativeAnchorLine &edge); + void resetHorizontalCenter(); QDeclarativeAnchorLine top() const; void setTop(const QDeclarativeAnchorLine &edge); + void resetTop(); QDeclarativeAnchorLine bottom() const; void setBottom(const QDeclarativeAnchorLine &edge); + void resetBottom(); QDeclarativeAnchorLine verticalCenter() const; void setVerticalCenter(const QDeclarativeAnchorLine &edge); + void resetVerticalCenter(); QDeclarativeAnchorLine baseline() const; void setBaseline(const QDeclarativeAnchorLine &edge); + void resetBaseline(); + + QDeclarativeItem *fill() const; + void setFill(QDeclarativeItem *); + void resetFill(); + + QDeclarativeItem *centerIn() const; + void setCenterIn(QDeclarativeItem *); + void resetCenterIn(); + + /*qreal leftMargin() const; + void setLeftMargin(qreal); + + qreal rightMargin() const; + void setRightMargin(qreal); + + qreal horizontalCenterOffset() const; + void setHorizontalCenterOffset(qreal); + + qreal topMargin() const; + void setTopMargin(qreal); + + qreal bottomMargin() const; + void setBottomMargin(qreal); + + qreal margins() const; + void setMargins(qreal); + + qreal verticalCenterOffset() const; + void setVerticalCenterOffset(qreal); + + qreal baselineOffset() const; + void setBaselineOffset(qreal);*/ + + QDeclarativeAnchors::UsedAnchors usedAnchors() const; + +/*Q_SIGNALS: + void leftMarginChanged(); + void rightMarginChanged(); + void topMarginChanged(); + void bottomMarginChanged(); + void marginsChanged(); + void verticalCenterOffsetChanged(); + void horizontalCenterOffsetChanged(); + void baselineOffsetChanged();*/ + +private: + friend class QDeclarativeAnchorChanges; + Q_DISABLE_COPY(QDeclarativeAnchorSet) + Q_DECLARE_PRIVATE(QDeclarativeAnchorSet) +}; + +class QDeclarativeAnchorChangesPrivate; +class Q_DECLARATIVE_EXPORT QDeclarativeAnchorChanges : public QDeclarativeStateOperation, public QDeclarativeActionEvent +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QDeclarativeAnchorChanges) + + Q_PROPERTY(QDeclarativeItem *target READ object WRITE setObject) + Q_PROPERTY(QDeclarativeAnchorSet *anchors READ anchors CONSTANT) + +public: + QDeclarativeAnchorChanges(QObject *parent=0); + ~QDeclarativeAnchorChanges(); + + virtual ActionList actions(); + + QDeclarativeAnchorSet *anchors(); + + QDeclarativeItem *object() const; + void setObject(QDeclarativeItem *); virtual void execute(); virtual bool isReversable(); @@ -212,6 +290,7 @@ QT_END_NAMESPACE QML_DECLARE_TYPE(QDeclarativeParentChange) QML_DECLARE_TYPE(QDeclarativeStateChangeScript) +QML_DECLARE_TYPE(QDeclarativeAnchorSet) QML_DECLARE_TYPE(QDeclarativeAnchorChanges) QT_END_HEADER diff --git a/src/declarative/util/qdeclarativeutilmodule.cpp b/src/declarative/util/qdeclarativeutilmodule.cpp index d79c6ba..2a02ffe 100644 --- a/src/declarative/util/qdeclarativeutilmodule.cpp +++ b/src/declarative/util/qdeclarativeutilmodule.cpp @@ -140,6 +140,7 @@ void QDeclarativeUtilModule::defineModule() qmlRegisterType(); qmlRegisterType(); + qmlRegisterType(); qmlRegisterTypeEnums("Animation"); diff --git a/tests/auto/declarative/qdeclarativestates/data/anchorChanges1.qml b/tests/auto/declarative/qdeclarativestates/data/anchorChanges1.qml index 7dce889..5443e54 100644 --- a/tests/auto/declarative/qdeclarativestates/data/anchorChanges1.qml +++ b/tests/auto/declarative/qdeclarativestates/data/anchorChanges1.qml @@ -16,8 +16,8 @@ Rectangle { AnchorChanges { id: ancCh target: myRect; - reset: "left" - right: container.right + anchors.left: undefined + anchors.right: container.right } } } diff --git a/tests/auto/declarative/qdeclarativestates/data/anchorChanges2.qml b/tests/auto/declarative/qdeclarativestates/data/anchorChanges2.qml index 545345e..56de560 100644 --- a/tests/auto/declarative/qdeclarativestates/data/anchorChanges2.qml +++ b/tests/auto/declarative/qdeclarativestates/data/anchorChanges2.qml @@ -14,8 +14,8 @@ Rectangle { name: "right" AnchorChanges { target: myRect; - reset: "left" - right: parent.right + anchors.left: undefined + anchors.right: parent.right } } } diff --git a/tests/auto/declarative/qdeclarativestates/data/anchorChanges3.qml b/tests/auto/declarative/qdeclarativestates/data/anchorChanges3.qml index 9d5b317..59c3c06 100644 --- a/tests/auto/declarative/qdeclarativestates/data/anchorChanges3.qml +++ b/tests/auto/declarative/qdeclarativestates/data/anchorChanges3.qml @@ -20,10 +20,10 @@ Rectangle { name: "reanchored" AnchorChanges { target: myRect; - left: leftGuideline.left - right: container.right - top: container.top - bottom: bottomGuideline.bottom + anchors.left: leftGuideline.left + anchors.right: container.right + anchors.top: container.top + anchors.bottom: bottomGuideline.bottom } } } diff --git a/tests/auto/declarative/qdeclarativestates/data/anchorChanges4.qml b/tests/auto/declarative/qdeclarativestates/data/anchorChanges4.qml index f128989..7e3ba1c 100644 --- a/tests/auto/declarative/qdeclarativestates/data/anchorChanges4.qml +++ b/tests/auto/declarative/qdeclarativestates/data/anchorChanges4.qml @@ -15,8 +15,8 @@ Rectangle { name: "reanchored" AnchorChanges { target: myRect; - horizontalCenter: bottomGuideline.horizontalCenter - verticalCenter: leftGuideline.verticalCenter + anchors.horizontalCenter: bottomGuideline.horizontalCenter + anchors.verticalCenter: leftGuideline.verticalCenter } } } diff --git a/tests/auto/declarative/qdeclarativestates/data/anchorChanges5.qml b/tests/auto/declarative/qdeclarativestates/data/anchorChanges5.qml index 4e6d34b..b85a922 100644 --- a/tests/auto/declarative/qdeclarativestates/data/anchorChanges5.qml +++ b/tests/auto/declarative/qdeclarativestates/data/anchorChanges5.qml @@ -15,8 +15,8 @@ Rectangle { name: "reanchored" AnchorChanges { target: myRect; - horizontalCenter: bottomGuideline.horizontalCenter - baseline: leftGuideline.baseline + anchors.horizontalCenter: bottomGuideline.horizontalCenter + anchors.baseline: leftGuideline.baseline } } } diff --git a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp index 91883c9..2ab21a4 100644 --- a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp +++ b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp @@ -564,10 +564,10 @@ void tst_qdeclarativestates::anchorChanges() rect->setState("right"); QCOMPARE(innerRect->x(), qreal(150)); - QCOMPARE(aChanges->reset(), QString("left")); + QCOMPARE(aChanges->anchors()->left().anchorLine, QDeclarativeAnchorLine::Invalid); //### was reset (how do we distinguish from not set at all) QCOMPARE(aChanges->object(), qobject_cast(innerRect)); - QCOMPARE(aChanges->right().item, rect->right().item); - QCOMPARE(aChanges->right().anchorLine, rect->right().anchorLine); + QCOMPARE(aChanges->anchors()->right().item, rect->right().item); + QCOMPARE(aChanges->anchors()->right().anchorLine, rect->right().anchorLine); rect->setState(""); QCOMPARE(innerRect->x(), qreal(5)); @@ -623,14 +623,14 @@ void tst_qdeclarativestates::anchorChanges3() rect->setState("reanchored"); QCOMPARE(aChanges->object(), qobject_cast(innerRect)); - QCOMPARE(aChanges->left().item, leftGuideline->left().item); - QCOMPARE(aChanges->left().anchorLine, leftGuideline->left().anchorLine); - QCOMPARE(aChanges->right().item, rect->right().item); - QCOMPARE(aChanges->right().anchorLine, rect->right().anchorLine); - QCOMPARE(aChanges->top().item, rect->top().item); - QCOMPARE(aChanges->top().anchorLine, rect->top().anchorLine); - QCOMPARE(aChanges->bottom().item, bottomGuideline->bottom().item); - QCOMPARE(aChanges->bottom().anchorLine, bottomGuideline->bottom().anchorLine); + QCOMPARE(aChanges->anchors()->left().item, leftGuideline->left().item); + QCOMPARE(aChanges->anchors()->left().anchorLine, leftGuideline->left().anchorLine); + QCOMPARE(aChanges->anchors()->right().item, rect->right().item); + QCOMPARE(aChanges->anchors()->right().anchorLine, rect->right().anchorLine); + QCOMPARE(aChanges->anchors()->top().item, rect->top().item); + QCOMPARE(aChanges->anchors()->top().anchorLine, rect->top().anchorLine); + QCOMPARE(aChanges->anchors()->bottom().item, bottomGuideline->bottom().item); + QCOMPARE(aChanges->anchors()->bottom().anchorLine, bottomGuideline->bottom().anchorLine); QCOMPARE(innerRect->x(), qreal(10)); QCOMPARE(innerRect->y(), qreal(0)); @@ -673,10 +673,10 @@ void tst_qdeclarativestates::anchorChanges4() rect->setState("reanchored"); QCOMPARE(aChanges->object(), qobject_cast(innerRect)); - QCOMPARE(aChanges->horizontalCenter().item, bottomGuideline->horizontalCenter().item); - QCOMPARE(aChanges->horizontalCenter().anchorLine, bottomGuideline->horizontalCenter().anchorLine); - QCOMPARE(aChanges->verticalCenter().item, leftGuideline->verticalCenter().item); - QCOMPARE(aChanges->verticalCenter().anchorLine, leftGuideline->verticalCenter().anchorLine); + QCOMPARE(aChanges->anchors()->horizontalCenter().item, bottomGuideline->horizontalCenter().item); + QCOMPARE(aChanges->anchors()->horizontalCenter().anchorLine, bottomGuideline->horizontalCenter().anchorLine); + QCOMPARE(aChanges->anchors()->verticalCenter().item, leftGuideline->verticalCenter().item); + QCOMPARE(aChanges->anchors()->verticalCenter().anchorLine, leftGuideline->verticalCenter().anchorLine); delete rect; } @@ -708,10 +708,10 @@ void tst_qdeclarativestates::anchorChanges5() rect->setState("reanchored"); QCOMPARE(aChanges->object(), qobject_cast(innerRect)); - QCOMPARE(aChanges->horizontalCenter().item, bottomGuideline->horizontalCenter().item); - QCOMPARE(aChanges->horizontalCenter().anchorLine, bottomGuideline->horizontalCenter().anchorLine); - QCOMPARE(aChanges->baseline().item, leftGuideline->baseline().item); - QCOMPARE(aChanges->baseline().anchorLine, leftGuideline->baseline().anchorLine); + QCOMPARE(aChanges->anchors()->horizontalCenter().item, bottomGuideline->horizontalCenter().item); + QCOMPARE(aChanges->anchors()->horizontalCenter().anchorLine, bottomGuideline->horizontalCenter().anchorLine); + QCOMPARE(aChanges->anchors()->baseline().item, leftGuideline->baseline().item); + QCOMPARE(aChanges->anchors()->baseline().anchorLine, leftGuideline->baseline().anchorLine); delete rect; } diff --git a/tests/auto/declarative/visual/animation/reanchor/reanchor.qml b/tests/auto/declarative/visual/animation/reanchor/reanchor.qml index e41a254..1d0495e 100644 --- a/tests/auto/declarative/visual/animation/reanchor/reanchor.qml +++ b/tests/auto/declarative/visual/animation/reanchor/reanchor.qml @@ -36,18 +36,19 @@ Rectangle { name: "reanchored" AnchorChanges { target: myRect; - left: leftGuideline.left - right: container.right - top: container.top - bottom: bottomGuideline.bottom + anchors.left: leftGuideline.left + anchors.right: container.right + anchors.top: container.top + anchors.bottom: bottomGuideline.bottom } }, State { name: "reanchored2" AnchorChanges { target: myRect; - reset: "left, right" - top: topGuideline2.top - bottom: bottomGuideline2.bottom + anchors.left: undefined + anchors.right: undefined + anchors.top: topGuideline2.top + anchors.bottom: bottomGuideline2.bottom } }] -- cgit v0.12 From 3828aea7c4a1e08d518c32e585929e379116e870 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 25 Mar 2010 15:24:52 +1000 Subject: Rename qdeclarativetime -> qmltime Consistent with "qml" runtime binary --- tests/benchmarks/declarative/declarative.pro | 2 +- .../declarative/qdeclarativetime/example.qml | 14 -- .../qdeclarativetime/qdeclarativetime.cpp | 231 --------------------- .../qdeclarativetime/qdeclarativetime.pro | 23 -- .../qdeclarativetime/tests/anchors/empty.qml | 34 --- .../qdeclarativetime/tests/anchors/fill.qml | 41 ---- .../qdeclarativetime/tests/anchors/null.qml | 27 --- .../qdeclarativetime/tests/animation/large.qml | 41 ---- .../tests/animation/largeNoProps.qml | 41 ---- .../tests/item_creation/children.qml | 34 --- .../qdeclarativetime/tests/item_creation/data.qml | 34 --- .../tests/item_creation/no_creation.qml | 12 -- .../tests/item_creation/resources.qml | 34 --- .../qdeclarativetime/tests/loader/Loaded.qml | 7 - .../tests/loader/component_loader.qml | 16 -- .../qdeclarativetime/tests/loader/empty_loader.qml | 15 -- .../qdeclarativetime/tests/loader/no_loader.qml | 14 -- .../tests/loader/source_loader.qml | 16 -- .../tests/positioner_creation/no_positioner.qml | 37 ---- .../tests/positioner_creation/null_positioner.qml | 34 --- .../tests/positioner_creation/positioner.qml | 37 ---- tests/benchmarks/declarative/qmltime/example.qml | 14 ++ tests/benchmarks/declarative/qmltime/qmltime.cpp | 231 +++++++++++++++++++++ tests/benchmarks/declarative/qmltime/qmltime.pro | 23 ++ .../declarative/qmltime/tests/anchors/empty.qml | 34 +++ .../declarative/qmltime/tests/anchors/fill.qml | 41 ++++ .../declarative/qmltime/tests/anchors/null.qml | 27 +++ .../declarative/qmltime/tests/animation/large.qml | 41 ++++ .../qmltime/tests/animation/largeNoProps.qml | 41 ++++ .../qmltime/tests/item_creation/children.qml | 34 +++ .../qmltime/tests/item_creation/data.qml | 34 +++ .../qmltime/tests/item_creation/no_creation.qml | 12 ++ .../qmltime/tests/item_creation/resources.qml | 34 +++ .../declarative/qmltime/tests/loader/Loaded.qml | 7 + .../qmltime/tests/loader/component_loader.qml | 16 ++ .../qmltime/tests/loader/empty_loader.qml | 15 ++ .../declarative/qmltime/tests/loader/no_loader.qml | 14 ++ .../qmltime/tests/loader/source_loader.qml | 16 ++ .../tests/positioner_creation/no_positioner.qml | 37 ++++ .../tests/positioner_creation/null_positioner.qml | 34 +++ .../tests/positioner_creation/positioner.qml | 37 ++++ 41 files changed, 743 insertions(+), 743 deletions(-) delete mode 100644 tests/benchmarks/declarative/qdeclarativetime/example.qml delete mode 100644 tests/benchmarks/declarative/qdeclarativetime/qdeclarativetime.cpp delete mode 100644 tests/benchmarks/declarative/qdeclarativetime/qdeclarativetime.pro delete mode 100644 tests/benchmarks/declarative/qdeclarativetime/tests/anchors/empty.qml delete mode 100644 tests/benchmarks/declarative/qdeclarativetime/tests/anchors/fill.qml delete mode 100644 tests/benchmarks/declarative/qdeclarativetime/tests/anchors/null.qml delete mode 100644 tests/benchmarks/declarative/qdeclarativetime/tests/animation/large.qml delete mode 100644 tests/benchmarks/declarative/qdeclarativetime/tests/animation/largeNoProps.qml delete mode 100644 tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/children.qml delete mode 100644 tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/data.qml delete mode 100644 tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/no_creation.qml delete mode 100644 tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/resources.qml delete mode 100644 tests/benchmarks/declarative/qdeclarativetime/tests/loader/Loaded.qml delete mode 100644 tests/benchmarks/declarative/qdeclarativetime/tests/loader/component_loader.qml delete mode 100644 tests/benchmarks/declarative/qdeclarativetime/tests/loader/empty_loader.qml delete mode 100644 tests/benchmarks/declarative/qdeclarativetime/tests/loader/no_loader.qml delete mode 100644 tests/benchmarks/declarative/qdeclarativetime/tests/loader/source_loader.qml delete mode 100644 tests/benchmarks/declarative/qdeclarativetime/tests/positioner_creation/no_positioner.qml delete mode 100644 tests/benchmarks/declarative/qdeclarativetime/tests/positioner_creation/null_positioner.qml delete mode 100644 tests/benchmarks/declarative/qdeclarativetime/tests/positioner_creation/positioner.qml create mode 100644 tests/benchmarks/declarative/qmltime/example.qml create mode 100644 tests/benchmarks/declarative/qmltime/qmltime.cpp create mode 100644 tests/benchmarks/declarative/qmltime/qmltime.pro create mode 100644 tests/benchmarks/declarative/qmltime/tests/anchors/empty.qml create mode 100644 tests/benchmarks/declarative/qmltime/tests/anchors/fill.qml create mode 100644 tests/benchmarks/declarative/qmltime/tests/anchors/null.qml create mode 100644 tests/benchmarks/declarative/qmltime/tests/animation/large.qml create mode 100644 tests/benchmarks/declarative/qmltime/tests/animation/largeNoProps.qml create mode 100644 tests/benchmarks/declarative/qmltime/tests/item_creation/children.qml create mode 100644 tests/benchmarks/declarative/qmltime/tests/item_creation/data.qml create mode 100644 tests/benchmarks/declarative/qmltime/tests/item_creation/no_creation.qml create mode 100644 tests/benchmarks/declarative/qmltime/tests/item_creation/resources.qml create mode 100644 tests/benchmarks/declarative/qmltime/tests/loader/Loaded.qml create mode 100644 tests/benchmarks/declarative/qmltime/tests/loader/component_loader.qml create mode 100644 tests/benchmarks/declarative/qmltime/tests/loader/empty_loader.qml create mode 100644 tests/benchmarks/declarative/qmltime/tests/loader/no_loader.qml create mode 100644 tests/benchmarks/declarative/qmltime/tests/loader/source_loader.qml create mode 100644 tests/benchmarks/declarative/qmltime/tests/positioner_creation/no_positioner.qml create mode 100644 tests/benchmarks/declarative/qmltime/tests/positioner_creation/null_positioner.qml create mode 100644 tests/benchmarks/declarative/qmltime/tests/positioner_creation/positioner.qml diff --git a/tests/benchmarks/declarative/declarative.pro b/tests/benchmarks/declarative/declarative.pro index 38ea6c4..a7d426c 100644 --- a/tests/benchmarks/declarative/declarative.pro +++ b/tests/benchmarks/declarative/declarative.pro @@ -8,4 +8,4 @@ SUBDIRS += \ qdeclarativeimage \ qdeclarativemetaproperty \ script \ - qdeclarativetime + qmltime diff --git a/tests/benchmarks/declarative/qdeclarativetime/example.qml b/tests/benchmarks/declarative/qdeclarativetime/example.qml deleted file mode 100644 index dd6185d..0000000 --- a/tests/benchmarks/declarative/qdeclarativetime/example.qml +++ /dev/null @@ -1,14 +0,0 @@ -import Qt 4.6 -import QDeclarativeTime 1.0 as QDeclarativeTime - -Item { - - property string name: "Bob Smith" - - QDeclarativeTime.Timer { - component: Item { - Text { text: name } - } - } -} - diff --git a/tests/benchmarks/declarative/qdeclarativetime/qdeclarativetime.cpp b/tests/benchmarks/declarative/qdeclarativetime/qdeclarativetime.cpp deleted file mode 100644 index 20f0d93d..0000000 --- a/tests/benchmarks/declarative/qdeclarativetime/qdeclarativetime.cpp +++ /dev/null @@ -1,231 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include - -class Timer : public QObject -{ - Q_OBJECT - Q_PROPERTY(QDeclarativeComponent *component READ component WRITE setComponent); - -public: - Timer(); - - QDeclarativeComponent *component() const; - void setComponent(QDeclarativeComponent *); - - static Timer *timerInstance(); - - void run(uint); - - bool willParent() const; - void setWillParent(bool p); - -private: - void runTest(QDeclarativeContext *, uint); - - QDeclarativeComponent *m_component; - static Timer *m_timer; - - bool m_willparent; - QGraphicsScene m_scene; - QGraphicsRectItem m_item; -}; -QML_DECLARE_TYPE(Timer); - -Timer *Timer::m_timer = 0; - -Timer::Timer() -: m_component(0), m_willparent(false) -{ - if (m_timer) - qWarning("Timer: Timer already registered"); - m_timer = this; - - m_scene.setItemIndexMethod(QGraphicsScene::NoIndex); - m_scene.addItem(&m_item); -} - -QDeclarativeComponent *Timer::component() const -{ - return m_component; -} - -void Timer::setComponent(QDeclarativeComponent *c) -{ - m_component = c; -} - -Timer *Timer::timerInstance() -{ - return m_timer; -} - -void Timer::run(uint iterations) -{ - QDeclarativeContext context(qmlContext(this)); - - QObject *o = m_component->create(&context); - QGraphicsObject *go = qobject_cast(o); - if (m_willparent && go) - go->setParentItem(&m_item); - delete o; - - runTest(&context, iterations); -} - -bool Timer::willParent() const -{ - return m_willparent; -} - -void Timer::setWillParent(bool p) -{ - m_willparent = p; -} - -void Timer::runTest(QDeclarativeContext *context, uint iterations) -{ - QTime t; - t.start(); - for (uint ii = 0; ii < iterations; ++ii) { - QObject *o = m_component->create(context); - QGraphicsObject *go = qobject_cast(o); - if (m_willparent && go) - go->setParentItem(&m_item); - delete o; - } - - int e = t.elapsed(); - - qWarning() << "Total:" << e << "ms, Per iteration:" << qreal(e) / qreal(iterations) << "ms"; - -} - -void usage(const char *name) -{ - qWarning("Usage: %s [-iterations ] [-parent] ", name); - exit(-1); -} - -int main(int argc, char ** argv) -{ - QApplication app(argc, argv); - - qmlRegisterType("QDeclarativeTime", 1, 0, "Timer"); - - uint iterations = 1024; - QString filename; - bool willParent = false; - - for (int ii = 1; ii < argc; ++ii) { - QByteArray arg(argv[ii]); - - if (arg == "-iterations") { - if (ii + 1 < argc) { - ++ii; - QByteArray its(argv[ii]); - bool ok = false; - iterations = its.toUInt(&ok); - if (!ok) - usage(argv[0]); - } else { - usage(argv[0]); - } - } else if (arg == "-parent") { - willParent = true; - } else { - filename = QLatin1String(argv[ii]); - } - } - - if (filename.isEmpty()) -#ifdef Q_OS_SYMBIAN - filename = QLatin1String("./tests/item_creation/data.qml"); -#else - usage(argv[0]); -#endif - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, filename); - if (component.isError()) { - qWarning() << component.errors(); - return -1; - } - - QObject *obj = component.create(); - if (!obj) { - qWarning() << component.errors(); - return -1; - } - - Timer *timer = Timer::timerInstance(); - if (!timer) { - qWarning() << "A Tester.Timer instance is required."; - return -1; - } - -#ifdef Q_OS_SYMBIAN - willParent = true; -#endif - timer->setWillParent(willParent); - - if (!timer->component()) { - qWarning() << "The timer has no component"; - return -1; - } - -#ifdef Q_OS_SYMBIAN - iterations = 1024; -#endif - - timer->run(iterations); - - return 0; -} - -#include "qdeclarativetime.moc" diff --git a/tests/benchmarks/declarative/qdeclarativetime/qdeclarativetime.pro b/tests/benchmarks/declarative/qdeclarativetime/qdeclarativetime.pro deleted file mode 100644 index 7902ee1..0000000 --- a/tests/benchmarks/declarative/qdeclarativetime/qdeclarativetime.pro +++ /dev/null @@ -1,23 +0,0 @@ -load(qttest_p4) -TEMPLATE = app -TARGET = qdeclarativetime -QT += declarative -macx:CONFIG -= app_bundle - -SOURCES += qdeclarativetime.cpp - -symbian* { - TARGET.CAPABILITY = "All -TCB" - example.sources = example.qml - esample.path = . - tests.sources = tests/* - tests.path = tests - anshors.sources = tests/anchors/* - anchors.path = tests/anchors - item_creation.sources = tests/item_creation/* - item_creation.path = tests/item_creation - positioner_creation.sources = tests/positioner_creation/* - positioner_creation.path = tests/positioner_creation - DEPLOYMENT += example tests anchors item_creation positioner_creation -} - diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/anchors/empty.qml b/tests/benchmarks/declarative/qdeclarativetime/tests/anchors/empty.qml deleted file mode 100644 index 8d93594..0000000 --- a/tests/benchmarks/declarative/qdeclarativetime/tests/anchors/empty.qml +++ /dev/null @@ -1,34 +0,0 @@ -import Qt 4.6 -import QDeclarativeTime 1.0 as QDeclarativeTime - -Item { - - QDeclarativeTime.Timer { - component: Component { - Item { - Item { - anchors.leftMargin: 0 - } - Item { - anchors.leftMargin: 0 - } - Item { - anchors.leftMargin: 0 - } - Item { - anchors.leftMargin: 0 - } - Item { - anchors.leftMargin: 0 - } - Item { - anchors.leftMargin: 0 - } - Item { - anchors.leftMargin: 0 - } - } - } - } -} - diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/anchors/fill.qml b/tests/benchmarks/declarative/qdeclarativetime/tests/anchors/fill.qml deleted file mode 100644 index 918c48a..0000000 --- a/tests/benchmarks/declarative/qdeclarativetime/tests/anchors/fill.qml +++ /dev/null @@ -1,41 +0,0 @@ -import Qt 4.6 -import QDeclarativeTime 1.0 as QDeclarativeTime - -Item { - - QDeclarativeTime.Timer { - component: Component { - Item { - Item { - anchors.fill: parent - anchors.leftMargin: 0 - } - Item { - anchors.fill: parent - anchors.leftMargin: 0 - } - Item { - anchors.fill: parent - anchors.leftMargin: 0 - } - Item { - anchors.fill: parent - anchors.leftMargin: 0 - } - Item { - anchors.fill: parent - anchors.leftMargin: 0 - } - Item { - anchors.fill: parent - anchors.leftMargin: 0 - } - Item { - anchors.fill: parent - anchors.leftMargin: 0 - } - } - } - } -} - diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/anchors/null.qml b/tests/benchmarks/declarative/qdeclarativetime/tests/anchors/null.qml deleted file mode 100644 index bb84538..0000000 --- a/tests/benchmarks/declarative/qdeclarativetime/tests/anchors/null.qml +++ /dev/null @@ -1,27 +0,0 @@ -import Qt 4.6 -import QDeclarativeTime 1.0 as QDeclarativeTime - -Item { - - QDeclarativeTime.Timer { - component: Component { - Item { - Item { - } - Item { - } - Item { - } - Item { - } - Item { - } - Item { - } - Item { - } - } - } - } -} - diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/animation/large.qml b/tests/benchmarks/declarative/qdeclarativetime/tests/animation/large.qml deleted file mode 100644 index 978e3bf..0000000 --- a/tests/benchmarks/declarative/qdeclarativetime/tests/animation/large.qml +++ /dev/null @@ -1,41 +0,0 @@ -import Qt 4.6 -import QDeclarativeTime 1.0 as QDeclarativeTime - -Item { - - QDeclarativeTime.Timer { - component: Component { - ParallelAnimation { - NumberAnimation { duration: 500 } - NumberAnimation { duration: 4000; } - NumberAnimation { duration: 2000; easing.type: "OutBack"} - ColorAnimation { duration: 3000} - SequentialAnimation { - PauseAnimation { duration: 1000 } - ScriptAction { script: doSomething(); } - PauseAnimation { duration: 800 } - ScriptAction { script: doSomethingElse(); } - PauseAnimation { duration: 800 } - ParallelAnimation { - NumberAnimation { duration: 200;} - SequentialAnimation { - PauseAnimation { duration: 200} - ParallelAnimation { - NumberAnimation { duration: 300;} - NumberAnimation { duration: 300;} - } - NumberAnimation { from: 0; to: 1; duration: 500 } - PauseAnimation { duration: 200 } - NumberAnimation { from: 1; to: 0; duration: 500 } - } - SequentialAnimation { - PauseAnimation { duration: 150} - NumberAnimation { duration: 300; easing.type: "OutBounce" } - } - } - } - } - } - } - -} diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/animation/largeNoProps.qml b/tests/benchmarks/declarative/qdeclarativetime/tests/animation/largeNoProps.qml deleted file mode 100644 index cceb3f4..0000000 --- a/tests/benchmarks/declarative/qdeclarativetime/tests/animation/largeNoProps.qml +++ /dev/null @@ -1,41 +0,0 @@ -import Qt 4.6 -import QDeclarativeTime 1.0 as QDeclarativeTime - -Item { - - QDeclarativeTime.Timer { - component: Component { - ParallelAnimation { - NumberAnimation { } - NumberAnimation { } - NumberAnimation { } - ColorAnimation { } - SequentialAnimation { - PauseAnimation { } - ScriptAction { } - PauseAnimation { } - ScriptAction { } - PauseAnimation { } - ParallelAnimation { - NumberAnimation { } - SequentialAnimation { - PauseAnimation { } - ParallelAnimation { - NumberAnimation { } - NumberAnimation { } - } - NumberAnimation { } - PauseAnimation { } - NumberAnimation { } - } - SequentialAnimation { - PauseAnimation { } - NumberAnimation { } - } - } - } - } - } - } - -} diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/children.qml b/tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/children.qml deleted file mode 100644 index 3387a32..0000000 --- a/tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/children.qml +++ /dev/null @@ -1,34 +0,0 @@ -import Qt 4.6 -import QDeclarativeTime 1.0 as QDeclarativeTime - -Item { - - QDeclarativeTime.Timer { - component: Component { - Item { - children: [ - Rectangle { }, - Rectangle { }, - Item { }, - Image { }, - Text { }, - Item { }, - Item { }, - Image { }, - Image { }, - Row { }, - Image { }, - Image { }, - Column { }, - Row { }, - Text { }, - Text { }, - Text { }, - MouseArea { } - ] - - } - } - } - -} diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/data.qml b/tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/data.qml deleted file mode 100644 index a8b653c..0000000 --- a/tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/data.qml +++ /dev/null @@ -1,34 +0,0 @@ -import Qt 4.6 -import QDeclarativeTime 1.0 as QDeclarativeTime - -Item { - - QDeclarativeTime.Timer { - component: Component { - Item { - data: [ - Rectangle { }, - Rectangle { }, - Item { }, - Image { }, - Text { }, - Item { }, - Item { }, - Image { }, - Image { }, - Row { }, - Image { }, - Image { }, - Column { }, - Row { }, - Text { }, - Text { }, - Text { }, - MouseArea { } - ] - - } - } - } - -} diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/no_creation.qml b/tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/no_creation.qml deleted file mode 100644 index 0a507d4..0000000 --- a/tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/no_creation.qml +++ /dev/null @@ -1,12 +0,0 @@ -import Qt 4.6 -import QDeclarativeTime 1.0 as QDeclarativeTime - -Item { - - QDeclarativeTime.Timer { - component: Component { - Item { - } - } - } -} diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/resources.qml b/tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/resources.qml deleted file mode 100644 index 227d8ad..0000000 --- a/tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/resources.qml +++ /dev/null @@ -1,34 +0,0 @@ -import Qt 4.6 -import QDeclarativeTime 1.0 as QDeclarativeTime - -Item { - - QDeclarativeTime.Timer { - component: Component { - Item { - resources: [ - Rectangle { }, - Rectangle { }, - Item { }, - Image { }, - Text { }, - Item { }, - Item { }, - Image { }, - Image { }, - Row { }, - Image { }, - Image { }, - Column { }, - Row { }, - Text { }, - Text { }, - Text { }, - MouseArea { } - ] - - } - } - } - -} diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/loader/Loaded.qml b/tests/benchmarks/declarative/qdeclarativetime/tests/loader/Loaded.qml deleted file mode 100644 index 6f8d849..0000000 --- a/tests/benchmarks/declarative/qdeclarativetime/tests/loader/Loaded.qml +++ /dev/null @@ -1,7 +0,0 @@ -import Qt 4.6 - -Item { - Rectangle {} - Text {} - Image {} -} diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/loader/component_loader.qml b/tests/benchmarks/declarative/qdeclarativetime/tests/loader/component_loader.qml deleted file mode 100644 index 270add4..0000000 --- a/tests/benchmarks/declarative/qdeclarativetime/tests/loader/component_loader.qml +++ /dev/null @@ -1,16 +0,0 @@ -import Qt 4.6 -import QDeclarativeTime 1.0 as QDeclarativeTime - -Item { - - QDeclarativeTime.Timer { - component: Component { - Item { - Loader { - sourceComponent: Loaded {} - } - } - } - } -} - diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/loader/empty_loader.qml b/tests/benchmarks/declarative/qdeclarativetime/tests/loader/empty_loader.qml deleted file mode 100644 index d3b84cc..0000000 --- a/tests/benchmarks/declarative/qdeclarativetime/tests/loader/empty_loader.qml +++ /dev/null @@ -1,15 +0,0 @@ -import Qt 4.6 -import QDeclarativeTime 1.0 as QDeclarativeTime - -Item { - - QDeclarativeTime.Timer { - component: Component { - Item { - Loader {} - Loaded {} - } - } - } -} - diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/loader/no_loader.qml b/tests/benchmarks/declarative/qdeclarativetime/tests/loader/no_loader.qml deleted file mode 100644 index a94a12a..0000000 --- a/tests/benchmarks/declarative/qdeclarativetime/tests/loader/no_loader.qml +++ /dev/null @@ -1,14 +0,0 @@ -import Qt 4.6 -import QDeclarativeTime 1.0 as QDeclarativeTime - -Item { - - QDeclarativeTime.Timer { - component: Component { - Item { - Loaded {} - } - } - } -} - diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/loader/source_loader.qml b/tests/benchmarks/declarative/qdeclarativetime/tests/loader/source_loader.qml deleted file mode 100644 index 39ed1a6..0000000 --- a/tests/benchmarks/declarative/qdeclarativetime/tests/loader/source_loader.qml +++ /dev/null @@ -1,16 +0,0 @@ -import Qt 4.6 -import QDeclarativeTime 1.0 as QDeclarativeTime - -Item { - - QDeclarativeTime.Timer { - component: Component { - Item { - Loader { - source: "Loaded.qml" - } - } - } - } -} - diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/positioner_creation/no_positioner.qml b/tests/benchmarks/declarative/qdeclarativetime/tests/positioner_creation/no_positioner.qml deleted file mode 100644 index c1f54a4..0000000 --- a/tests/benchmarks/declarative/qdeclarativetime/tests/positioner_creation/no_positioner.qml +++ /dev/null @@ -1,37 +0,0 @@ -import Qt 4.6 -import QDeclarativeTime 1.0 as QDeclarativeTime - -Item { - QDeclarativeTime.Timer { - component: Component { - Item { - Rectangle { } - Rectangle { } - Item { - Image { } - Text { } - } - - Item { - Item { - Image { } - Image { } - Item { - Image { } - Image { } - } - } - - Item { - Item { - Text { } - Text { } - } - Text { } - } - } - MouseArea { } - } - } - } -} diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/positioner_creation/null_positioner.qml b/tests/benchmarks/declarative/qdeclarativetime/tests/positioner_creation/null_positioner.qml deleted file mode 100644 index d49ff78..0000000 --- a/tests/benchmarks/declarative/qdeclarativetime/tests/positioner_creation/null_positioner.qml +++ /dev/null @@ -1,34 +0,0 @@ -import Qt 4.6 -import QDeclarativeTime 1.0 as QDeclarativeTime - -Item { - QDeclarativeTime.Timer { - component: Component { - Item { - Rectangle { } - Rectangle { } - Item { - Image { } - Text { } - } - - Item { - Item { - Image { } - Image { } - Row { } - Image { } - Image { } - } - - Column { } - Row { } - Text { } - Text { } - Text { } - } - MouseArea { } - } - } - } -} diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/positioner_creation/positioner.qml b/tests/benchmarks/declarative/qdeclarativetime/tests/positioner_creation/positioner.qml deleted file mode 100644 index 05ca804..0000000 --- a/tests/benchmarks/declarative/qdeclarativetime/tests/positioner_creation/positioner.qml +++ /dev/null @@ -1,37 +0,0 @@ -import Qt 4.6 -import QDeclarativeTime 1.0 as QDeclarativeTime - -Item { - QDeclarativeTime.Timer { - component: Component { - Item { - Rectangle { } - Rectangle { } - Item { - Image { } - Text { } - } - - Item { - Item { - Image { } - Image { } - Row { - Image { } - Image { } - } - } - - Column { - Row { - Text { } - Text { } - } - Text { } - } - } - MouseArea { } - } - } - } -} diff --git a/tests/benchmarks/declarative/qmltime/example.qml b/tests/benchmarks/declarative/qmltime/example.qml new file mode 100644 index 0000000..68889f0 --- /dev/null +++ b/tests/benchmarks/declarative/qmltime/example.qml @@ -0,0 +1,14 @@ +import Qt 4.6 +import QmlTime 1.0 as QmlTime + +Item { + + property string name: "Bob Smith" + + QmlTime.Timer { + component: Item { + Text { text: name } + } + } +} + diff --git a/tests/benchmarks/declarative/qmltime/qmltime.cpp b/tests/benchmarks/declarative/qmltime/qmltime.cpp new file mode 100644 index 0000000..3932e01 --- /dev/null +++ b/tests/benchmarks/declarative/qmltime/qmltime.cpp @@ -0,0 +1,231 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include + +class Timer : public QObject +{ + Q_OBJECT + Q_PROPERTY(QDeclarativeComponent *component READ component WRITE setComponent); + +public: + Timer(); + + QDeclarativeComponent *component() const; + void setComponent(QDeclarativeComponent *); + + static Timer *timerInstance(); + + void run(uint); + + bool willParent() const; + void setWillParent(bool p); + +private: + void runTest(QDeclarativeContext *, uint); + + QDeclarativeComponent *m_component; + static Timer *m_timer; + + bool m_willparent; + QGraphicsScene m_scene; + QGraphicsRectItem m_item; +}; +QML_DECLARE_TYPE(Timer); + +Timer *Timer::m_timer = 0; + +Timer::Timer() +: m_component(0), m_willparent(false) +{ + if (m_timer) + qWarning("Timer: Timer already registered"); + m_timer = this; + + m_scene.setItemIndexMethod(QGraphicsScene::NoIndex); + m_scene.addItem(&m_item); +} + +QDeclarativeComponent *Timer::component() const +{ + return m_component; +} + +void Timer::setComponent(QDeclarativeComponent *c) +{ + m_component = c; +} + +Timer *Timer::timerInstance() +{ + return m_timer; +} + +void Timer::run(uint iterations) +{ + QDeclarativeContext context(qmlContext(this)); + + QObject *o = m_component->create(&context); + QGraphicsObject *go = qobject_cast(o); + if (m_willparent && go) + go->setParentItem(&m_item); + delete o; + + runTest(&context, iterations); +} + +bool Timer::willParent() const +{ + return m_willparent; +} + +void Timer::setWillParent(bool p) +{ + m_willparent = p; +} + +void Timer::runTest(QDeclarativeContext *context, uint iterations) +{ + QTime t; + t.start(); + for (uint ii = 0; ii < iterations; ++ii) { + QObject *o = m_component->create(context); + QGraphicsObject *go = qobject_cast(o); + if (m_willparent && go) + go->setParentItem(&m_item); + delete o; + } + + int e = t.elapsed(); + + qWarning() << "Total:" << e << "ms, Per iteration:" << qreal(e) / qreal(iterations) << "ms"; + +} + +void usage(const char *name) +{ + qWarning("Usage: %s [-iterations ] [-parent] ", name); + exit(-1); +} + +int main(int argc, char ** argv) +{ + QApplication app(argc, argv); + + qmlRegisterType("QmlTime", 1, 0, "Timer"); + + uint iterations = 1024; + QString filename; + bool willParent = false; + + for (int ii = 1; ii < argc; ++ii) { + QByteArray arg(argv[ii]); + + if (arg == "-iterations") { + if (ii + 1 < argc) { + ++ii; + QByteArray its(argv[ii]); + bool ok = false; + iterations = its.toUInt(&ok); + if (!ok) + usage(argv[0]); + } else { + usage(argv[0]); + } + } else if (arg == "-parent") { + willParent = true; + } else { + filename = QLatin1String(argv[ii]); + } + } + + if (filename.isEmpty()) +#ifdef Q_OS_SYMBIAN + filename = QLatin1String("./tests/item_creation/data.qml"); +#else + usage(argv[0]); +#endif + + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, filename); + if (component.isError()) { + qWarning() << component.errors(); + return -1; + } + + QObject *obj = component.create(); + if (!obj) { + qWarning() << component.errors(); + return -1; + } + + Timer *timer = Timer::timerInstance(); + if (!timer) { + qWarning() << "A Tester.Timer instance is required."; + return -1; + } + +#ifdef Q_OS_SYMBIAN + willParent = true; +#endif + timer->setWillParent(willParent); + + if (!timer->component()) { + qWarning() << "The timer has no component"; + return -1; + } + +#ifdef Q_OS_SYMBIAN + iterations = 1024; +#endif + + timer->run(iterations); + + return 0; +} + +#include "qmltime.moc" diff --git a/tests/benchmarks/declarative/qmltime/qmltime.pro b/tests/benchmarks/declarative/qmltime/qmltime.pro new file mode 100644 index 0000000..9352f3b --- /dev/null +++ b/tests/benchmarks/declarative/qmltime/qmltime.pro @@ -0,0 +1,23 @@ +load(qttest_p4) +TEMPLATE = app +TARGET = qmltime +QT += declarative +macx:CONFIG -= app_bundle + +SOURCES += qmltime.cpp + +symbian* { + TARGET.CAPABILITY = "All -TCB" + example.sources = example.qml + esample.path = . + tests.sources = tests/* + tests.path = tests + anshors.sources = tests/anchors/* + anchors.path = tests/anchors + item_creation.sources = tests/item_creation/* + item_creation.path = tests/item_creation + positioner_creation.sources = tests/positioner_creation/* + positioner_creation.path = tests/positioner_creation + DEPLOYMENT += example tests anchors item_creation positioner_creation +} + diff --git a/tests/benchmarks/declarative/qmltime/tests/anchors/empty.qml b/tests/benchmarks/declarative/qmltime/tests/anchors/empty.qml new file mode 100644 index 0000000..31c879b --- /dev/null +++ b/tests/benchmarks/declarative/qmltime/tests/anchors/empty.qml @@ -0,0 +1,34 @@ +import Qt 4.6 +import QmlTime 1.0 as QmlTime + +Item { + + QmlTime.Timer { + component: Component { + Item { + Item { + anchors.leftMargin: 0 + } + Item { + anchors.leftMargin: 0 + } + Item { + anchors.leftMargin: 0 + } + Item { + anchors.leftMargin: 0 + } + Item { + anchors.leftMargin: 0 + } + Item { + anchors.leftMargin: 0 + } + Item { + anchors.leftMargin: 0 + } + } + } + } +} + diff --git a/tests/benchmarks/declarative/qmltime/tests/anchors/fill.qml b/tests/benchmarks/declarative/qmltime/tests/anchors/fill.qml new file mode 100644 index 0000000..23fe78e --- /dev/null +++ b/tests/benchmarks/declarative/qmltime/tests/anchors/fill.qml @@ -0,0 +1,41 @@ +import Qt 4.6 +import QmlTime 1.0 as QmlTime + +Item { + + QmlTime.Timer { + component: Component { + Item { + Item { + anchors.fill: parent + anchors.leftMargin: 0 + } + Item { + anchors.fill: parent + anchors.leftMargin: 0 + } + Item { + anchors.fill: parent + anchors.leftMargin: 0 + } + Item { + anchors.fill: parent + anchors.leftMargin: 0 + } + Item { + anchors.fill: parent + anchors.leftMargin: 0 + } + Item { + anchors.fill: parent + anchors.leftMargin: 0 + } + Item { + anchors.fill: parent + anchors.leftMargin: 0 + } + } + } + } +} + diff --git a/tests/benchmarks/declarative/qmltime/tests/anchors/null.qml b/tests/benchmarks/declarative/qmltime/tests/anchors/null.qml new file mode 100644 index 0000000..bc447ef --- /dev/null +++ b/tests/benchmarks/declarative/qmltime/tests/anchors/null.qml @@ -0,0 +1,27 @@ +import Qt 4.6 +import QmlTime 1.0 as QmlTime + +Item { + + QmlTime.Timer { + component: Component { + Item { + Item { + } + Item { + } + Item { + } + Item { + } + Item { + } + Item { + } + Item { + } + } + } + } +} + diff --git a/tests/benchmarks/declarative/qmltime/tests/animation/large.qml b/tests/benchmarks/declarative/qmltime/tests/animation/large.qml new file mode 100644 index 0000000..c1cdb68 --- /dev/null +++ b/tests/benchmarks/declarative/qmltime/tests/animation/large.qml @@ -0,0 +1,41 @@ +import Qt 4.6 +import QmlTime 1.0 as QmlTime + +Item { + + QmlTime.Timer { + component: Component { + ParallelAnimation { + NumberAnimation { duration: 500 } + NumberAnimation { duration: 4000; } + NumberAnimation { duration: 2000; easing.type: "OutBack"} + ColorAnimation { duration: 3000} + SequentialAnimation { + PauseAnimation { duration: 1000 } + ScriptAction { script: doSomething(); } + PauseAnimation { duration: 800 } + ScriptAction { script: doSomethingElse(); } + PauseAnimation { duration: 800 } + ParallelAnimation { + NumberAnimation { duration: 200;} + SequentialAnimation { + PauseAnimation { duration: 200} + ParallelAnimation { + NumberAnimation { duration: 300;} + NumberAnimation { duration: 300;} + } + NumberAnimation { from: 0; to: 1; duration: 500 } + PauseAnimation { duration: 200 } + NumberAnimation { from: 1; to: 0; duration: 500 } + } + SequentialAnimation { + PauseAnimation { duration: 150} + NumberAnimation { duration: 300; easing.type: "OutBounce" } + } + } + } + } + } + } + +} diff --git a/tests/benchmarks/declarative/qmltime/tests/animation/largeNoProps.qml b/tests/benchmarks/declarative/qmltime/tests/animation/largeNoProps.qml new file mode 100644 index 0000000..3db9f08 --- /dev/null +++ b/tests/benchmarks/declarative/qmltime/tests/animation/largeNoProps.qml @@ -0,0 +1,41 @@ +import Qt 4.6 +import QmlTime 1.0 as QmlTime + +Item { + + QmlTime.Timer { + component: Component { + ParallelAnimation { + NumberAnimation { } + NumberAnimation { } + NumberAnimation { } + ColorAnimation { } + SequentialAnimation { + PauseAnimation { } + ScriptAction { } + PauseAnimation { } + ScriptAction { } + PauseAnimation { } + ParallelAnimation { + NumberAnimation { } + SequentialAnimation { + PauseAnimation { } + ParallelAnimation { + NumberAnimation { } + NumberAnimation { } + } + NumberAnimation { } + PauseAnimation { } + NumberAnimation { } + } + SequentialAnimation { + PauseAnimation { } + NumberAnimation { } + } + } + } + } + } + } + +} diff --git a/tests/benchmarks/declarative/qmltime/tests/item_creation/children.qml b/tests/benchmarks/declarative/qmltime/tests/item_creation/children.qml new file mode 100644 index 0000000..996602c --- /dev/null +++ b/tests/benchmarks/declarative/qmltime/tests/item_creation/children.qml @@ -0,0 +1,34 @@ +import Qt 4.6 +import QmlTime 1.0 as QmlTime + +Item { + + QmlTime.Timer { + component: Component { + Item { + children: [ + Rectangle { }, + Rectangle { }, + Item { }, + Image { }, + Text { }, + Item { }, + Item { }, + Image { }, + Image { }, + Row { }, + Image { }, + Image { }, + Column { }, + Row { }, + Text { }, + Text { }, + Text { }, + MouseArea { } + ] + + } + } + } + +} diff --git a/tests/benchmarks/declarative/qmltime/tests/item_creation/data.qml b/tests/benchmarks/declarative/qmltime/tests/item_creation/data.qml new file mode 100644 index 0000000..9f79c34 --- /dev/null +++ b/tests/benchmarks/declarative/qmltime/tests/item_creation/data.qml @@ -0,0 +1,34 @@ +import Qt 4.6 +import QmlTime 1.0 as QmlTime + +Item { + + QmlTime.Timer { + component: Component { + Item { + data: [ + Rectangle { }, + Rectangle { }, + Item { }, + Image { }, + Text { }, + Item { }, + Item { }, + Image { }, + Image { }, + Row { }, + Image { }, + Image { }, + Column { }, + Row { }, + Text { }, + Text { }, + Text { }, + MouseArea { } + ] + + } + } + } + +} diff --git a/tests/benchmarks/declarative/qmltime/tests/item_creation/no_creation.qml b/tests/benchmarks/declarative/qmltime/tests/item_creation/no_creation.qml new file mode 100644 index 0000000..f228c2a --- /dev/null +++ b/tests/benchmarks/declarative/qmltime/tests/item_creation/no_creation.qml @@ -0,0 +1,12 @@ +import Qt 4.6 +import QmlTime 1.0 as QmlTime + +Item { + + QmlTime.Timer { + component: Component { + Item { + } + } + } +} diff --git a/tests/benchmarks/declarative/qmltime/tests/item_creation/resources.qml b/tests/benchmarks/declarative/qmltime/tests/item_creation/resources.qml new file mode 100644 index 0000000..335aeb8 --- /dev/null +++ b/tests/benchmarks/declarative/qmltime/tests/item_creation/resources.qml @@ -0,0 +1,34 @@ +import Qt 4.6 +import QmlTime 1.0 as QmlTime + +Item { + + QmlTime.Timer { + component: Component { + Item { + resources: [ + Rectangle { }, + Rectangle { }, + Item { }, + Image { }, + Text { }, + Item { }, + Item { }, + Image { }, + Image { }, + Row { }, + Image { }, + Image { }, + Column { }, + Row { }, + Text { }, + Text { }, + Text { }, + MouseArea { } + ] + + } + } + } + +} diff --git a/tests/benchmarks/declarative/qmltime/tests/loader/Loaded.qml b/tests/benchmarks/declarative/qmltime/tests/loader/Loaded.qml new file mode 100644 index 0000000..6f8d849 --- /dev/null +++ b/tests/benchmarks/declarative/qmltime/tests/loader/Loaded.qml @@ -0,0 +1,7 @@ +import Qt 4.6 + +Item { + Rectangle {} + Text {} + Image {} +} diff --git a/tests/benchmarks/declarative/qmltime/tests/loader/component_loader.qml b/tests/benchmarks/declarative/qmltime/tests/loader/component_loader.qml new file mode 100644 index 0000000..65d5010 --- /dev/null +++ b/tests/benchmarks/declarative/qmltime/tests/loader/component_loader.qml @@ -0,0 +1,16 @@ +import Qt 4.6 +import QmlTime 1.0 as QmlTime + +Item { + + QmlTime.Timer { + component: Component { + Item { + Loader { + sourceComponent: Loaded {} + } + } + } + } +} + diff --git a/tests/benchmarks/declarative/qmltime/tests/loader/empty_loader.qml b/tests/benchmarks/declarative/qmltime/tests/loader/empty_loader.qml new file mode 100644 index 0000000..2dfe922 --- /dev/null +++ b/tests/benchmarks/declarative/qmltime/tests/loader/empty_loader.qml @@ -0,0 +1,15 @@ +import Qt 4.6 +import QmlTime 1.0 as QmlTime + +Item { + + QmlTime.Timer { + component: Component { + Item { + Loader {} + Loaded {} + } + } + } +} + diff --git a/tests/benchmarks/declarative/qmltime/tests/loader/no_loader.qml b/tests/benchmarks/declarative/qmltime/tests/loader/no_loader.qml new file mode 100644 index 0000000..1fa0d3b --- /dev/null +++ b/tests/benchmarks/declarative/qmltime/tests/loader/no_loader.qml @@ -0,0 +1,14 @@ +import Qt 4.6 +import QmlTime 1.0 as QmlTime + +Item { + + QmlTime.Timer { + component: Component { + Item { + Loaded {} + } + } + } +} + diff --git a/tests/benchmarks/declarative/qmltime/tests/loader/source_loader.qml b/tests/benchmarks/declarative/qmltime/tests/loader/source_loader.qml new file mode 100644 index 0000000..33bb91c --- /dev/null +++ b/tests/benchmarks/declarative/qmltime/tests/loader/source_loader.qml @@ -0,0 +1,16 @@ +import Qt 4.6 +import QmlTime 1.0 as QmlTime + +Item { + + QmlTime.Timer { + component: Component { + Item { + Loader { + source: "Loaded.qml" + } + } + } + } +} + diff --git a/tests/benchmarks/declarative/qmltime/tests/positioner_creation/no_positioner.qml b/tests/benchmarks/declarative/qmltime/tests/positioner_creation/no_positioner.qml new file mode 100644 index 0000000..97bad47 --- /dev/null +++ b/tests/benchmarks/declarative/qmltime/tests/positioner_creation/no_positioner.qml @@ -0,0 +1,37 @@ +import Qt 4.6 +import QmlTime 1.0 as QmlTime + +Item { + QmlTime.Timer { + component: Component { + Item { + Rectangle { } + Rectangle { } + Item { + Image { } + Text { } + } + + Item { + Item { + Image { } + Image { } + Item { + Image { } + Image { } + } + } + + Item { + Item { + Text { } + Text { } + } + Text { } + } + } + MouseArea { } + } + } + } +} diff --git a/tests/benchmarks/declarative/qmltime/tests/positioner_creation/null_positioner.qml b/tests/benchmarks/declarative/qmltime/tests/positioner_creation/null_positioner.qml new file mode 100644 index 0000000..36dda15 --- /dev/null +++ b/tests/benchmarks/declarative/qmltime/tests/positioner_creation/null_positioner.qml @@ -0,0 +1,34 @@ +import Qt 4.6 +import QmlTime 1.0 as QmlTime + +Item { + QmlTime.Timer { + component: Component { + Item { + Rectangle { } + Rectangle { } + Item { + Image { } + Text { } + } + + Item { + Item { + Image { } + Image { } + Row { } + Image { } + Image { } + } + + Column { } + Row { } + Text { } + Text { } + Text { } + } + MouseArea { } + } + } + } +} diff --git a/tests/benchmarks/declarative/qmltime/tests/positioner_creation/positioner.qml b/tests/benchmarks/declarative/qmltime/tests/positioner_creation/positioner.qml new file mode 100644 index 0000000..396e27d --- /dev/null +++ b/tests/benchmarks/declarative/qmltime/tests/positioner_creation/positioner.qml @@ -0,0 +1,37 @@ +import Qt 4.6 +import QmlTime 1.0 as QmlTime + +Item { + QmlTime.Timer { + component: Component { + Item { + Rectangle { } + Rectangle { } + Item { + Image { } + Text { } + } + + Item { + Item { + Image { } + Image { } + Row { + Image { } + Image { } + } + } + + Column { + Row { + Text { } + Text { } + } + Text { } + } + } + MouseArea { } + } + } + } +} -- cgit v0.12 From 3ded7df045edf0639d83664605aa4236715c6d39 Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Thu, 25 Mar 2010 07:02:48 +0100 Subject: Remove the children property from QDeclarativeItem. This commit remove the children property from QDeclarativeItem because it's now in QGraphicsObject. This commit also get rid of width and height properties to use the one in QGraphicsObject. Task-number:QT-2757 Reviewed-by:akennedy --- src/declarative/graphicsitems/qdeclarativeitem.cpp | 173 +++++++++------------ src/declarative/graphicsitems/qdeclarativeitem.h | 8 +- src/declarative/graphicsitems/qdeclarativeitem_p.h | 25 +-- 3 files changed, 93 insertions(+), 113 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index 9b1bdba..f61ad8e 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -1273,16 +1273,6 @@ QDeclarativeKeysAttached *QDeclarativeKeysAttached::qmlAttachedProperties(QObjec */ /*! - \fn void QDeclarativeItem::widthChanged() - \internal -*/ - -/*! - \fn void QDeclarativeItem::heightChanged() - \internal -*/ - -/*! \fn void QDeclarativeItem::stateChanged(const QString &state) \internal */ @@ -1462,11 +1452,6 @@ QDeclarativeItem *QDeclarativeItem::parentItem() const */ /*! - \property QDeclarativeItem::children - \internal -*/ - -/*! \property QDeclarativeItem::resources \internal */ @@ -1500,11 +1485,12 @@ QDeclarativeAnchors *QDeclarativeItem::anchors() void QDeclarativeItemPrivate::data_append(QDeclarativeListProperty *prop, QObject *o) { - QDeclarativeItem *i = qobject_cast(o); - if (i) + QGraphicsObject *i = qobject_cast(o); + if (i) { i->setParentItem(static_cast(prop->object)); - else + } else { o->setParent(static_cast(prop->object)); + } } QObject *QDeclarativeItemPrivate::resources_at(QDeclarativeListProperty *prop, int index) @@ -1526,27 +1512,6 @@ int QDeclarativeItemPrivate::resources_count(QDeclarativeListProperty * return prop->object->children().count(); } -QDeclarativeItem *QDeclarativeItemPrivate::children_at(QDeclarativeListProperty *prop, int index) -{ - QList children = static_cast(prop->object)->childItems(); - - if (index < children.count()) - return qobject_cast(children.at(index)); - else - return 0; -} - -void QDeclarativeItemPrivate::children_append(QDeclarativeListProperty *prop, QDeclarativeItem *i) -{ - if (i) - i->setParentItem(static_cast(prop->object)); -} - -int QDeclarativeItemPrivate::children_count(QDeclarativeListProperty *prop) -{ - return static_cast(prop->object)->childItems().count(); -} - int QDeclarativeItemPrivate::transform_count(QDeclarativeListProperty *list) { QGraphicsObject *object = qobject_cast(list->object); @@ -1678,18 +1643,6 @@ void QDeclarativeItem::setClip(bool c) */ /*! - \property QDeclarativeItem::width - - Defines the item's width relative to its parent. - */ - -/*! - \property QDeclarativeItem::height - - Defines the item's height relative to its parent. - */ - -/*! \qmlproperty real Item::z Sets the stacking order of the item. By default the stacking order is 0. @@ -1801,11 +1754,11 @@ void QDeclarativeItem::geometryChanged(const QRectF &newGeometry, if (newGeometry.x() != oldGeometry.x()) emit xChanged(); if (newGeometry.width() != oldGeometry.width()) - emit widthChanged(newGeometry.width()); + emit widthChanged(); if (newGeometry.y() != oldGeometry.y()) emit yChanged(); if (newGeometry.height() != oldGeometry.height()) - emit heightChanged(newGeometry.height()); + emit heightChanged(); for(int ii = 0; ii < d->changeListeners.count(); ++ii) { const QDeclarativeItemPrivate::ChangeListener &change = d->changeListeners.at(ii); @@ -2281,14 +2234,6 @@ void QDeclarativeItemPrivate::focusChanged(bool flag) } /*! \internal */ -QDeclarativeListProperty QDeclarativeItem::fxChildren() -{ - return QDeclarativeListProperty(this, 0, QDeclarativeItemPrivate::children_append, - QDeclarativeItemPrivate::children_count, - QDeclarativeItemPrivate::children_at); -} - -/*! \internal */ QDeclarativeListProperty QDeclarativeItem::resources() { return QDeclarativeListProperty(this, 0, QDeclarativeItemPrivate::resources_append, @@ -2632,7 +2577,7 @@ QVariant QDeclarativeItem::itemChange(GraphicsItemChange change, QRectF QDeclarativeItem::boundingRect() const { Q_D(const QDeclarativeItem); - return QRectF(0, 0, d->width, d->height); + return QRectF(0, 0, d->mWidth, d->mHeight); } /*! @@ -2717,33 +2662,50 @@ void QDeclarativeItem::setSmooth(bool smooth) qreal QDeclarativeItem::width() const { Q_D(const QDeclarativeItem); - return d->width; + return d->width(); } void QDeclarativeItem::setWidth(qreal w) { Q_D(QDeclarativeItem); + d->setWidth(w); +} + +void QDeclarativeItem::resetWidth() +{ + Q_D(QDeclarativeItem); + d->resetWidth(); +} + +qreal QDeclarativeItemPrivate::width() const +{ + return mWidth; +} + +void QDeclarativeItemPrivate::setWidth(qreal w) +{ + Q_Q(QDeclarativeItem); if (qIsNaN(w)) return; - d->widthValid = true; - if (d->width == w) + widthValid = true; + if (mWidth == w) return; - qreal oldWidth = d->width; + qreal oldWidth = mWidth; - prepareGeometryChange(); - d->width = w; + q->prepareGeometryChange(); + mWidth = w; - geometryChanged(QRectF(x(), y(), width(), height()), - QRectF(x(), y(), oldWidth, height())); + q->geometryChanged(QRectF(q->x(), q->y(), width(), height()), + QRectF(q->x(), q->y(), oldWidth, height())); } -void QDeclarativeItem::resetWidth() +void QDeclarativeItemPrivate ::resetWidth() { - Q_D(QDeclarativeItem); - d->widthValid = false; - setImplicitWidth(implicitWidth()); + Q_Q(QDeclarativeItem); + widthValid = false; + q->setImplicitWidth(q->implicitWidth()); } /*! @@ -2763,13 +2725,13 @@ void QDeclarativeItem::setImplicitWidth(qreal w) { Q_D(QDeclarativeItem); d->implicitWidth = w; - if (d->width == w || widthValid()) + if (d->mWidth == w || widthValid()) return; - qreal oldWidth = d->width; + qreal oldWidth = d->mWidth; prepareGeometryChange(); - d->width = w; + d->mWidth = w; geometryChanged(QRectF(x(), y(), width(), height()), QRectF(x(), y(), oldWidth, height())); @@ -2787,33 +2749,50 @@ bool QDeclarativeItem::widthValid() const qreal QDeclarativeItem::height() const { Q_D(const QDeclarativeItem); - return d->height; + return d->height(); } void QDeclarativeItem::setHeight(qreal h) { Q_D(QDeclarativeItem); + d->setHeight(h); +} + +void QDeclarativeItem::resetHeight() +{ + Q_D(QDeclarativeItem); + d->resetHeight(); +} + +qreal QDeclarativeItemPrivate::height() const +{ + return mHeight; +} + +void QDeclarativeItemPrivate::setHeight(qreal h) +{ + Q_Q(QDeclarativeItem); if (qIsNaN(h)) return; - d->heightValid = true; - if (d->height == h) + heightValid = true; + if (mHeight == h) return; - qreal oldHeight = d->height; + qreal oldHeight = mHeight; - prepareGeometryChange(); - d->height = h; + q->prepareGeometryChange(); + mHeight = h; - geometryChanged(QRectF(x(), y(), width(), height()), - QRectF(x(), y(), width(), oldHeight)); + q->geometryChanged(QRectF(q->x(), q->y(), width(), height()), + QRectF(q->x(), q->y(), width(), oldHeight)); } -void QDeclarativeItem::resetHeight() +void QDeclarativeItemPrivate::resetHeight() { - Q_D(QDeclarativeItem); - d->heightValid = false; - setImplicitHeight(implicitHeight()); + Q_Q(QDeclarativeItem); + heightValid = false; + q->setImplicitHeight(q->implicitHeight()); } /*! @@ -2833,13 +2812,13 @@ void QDeclarativeItem::setImplicitHeight(qreal h) { Q_D(QDeclarativeItem); d->implicitHeight = h; - if (d->height == h || heightValid()) + if (d->mHeight == h || heightValid()) return; - qreal oldHeight = d->height; + qreal oldHeight = d->mHeight; prepareGeometryChange(); - d->height = h; + d->mHeight = h; geometryChanged(QRectF(x(), y(), width(), height()), QRectF(x(), y(), width(), oldHeight)); @@ -2861,15 +2840,15 @@ void QDeclarativeItem::setSize(const QSizeF &size) d->heightValid = true; d->widthValid = true; - if (d->height == size.height() && d->width == size.width()) + if (d->height() == size.height() && d->width() == size.width()) return; - qreal oldHeight = d->height; - qreal oldWidth = d->width; + qreal oldHeight = d->height(); + qreal oldWidth = d->width(); prepareGeometryChange(); - d->height = size.height(); - d->width = size.width(); + d->setHeight(size.height()); + d->setWidth(size.width()); geometryChanged(QRectF(x(), y(), width(), height()), QRectF(x(), y(), oldWidth, oldHeight)); diff --git a/src/declarative/graphicsitems/qdeclarativeitem.h b/src/declarative/graphicsitems/qdeclarativeitem.h index c88b1db..712e854 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.h +++ b/src/declarative/graphicsitems/qdeclarativeitem.h @@ -71,13 +71,10 @@ class Q_DECLARATIVE_EXPORT QDeclarativeItem : public QGraphicsObject, public QDe Q_PROPERTY(QDeclarativeItem * parent READ parentItem WRITE setParentItem NOTIFY parentChanged DESIGNABLE false FINAL) Q_PROPERTY(QDeclarativeListProperty data READ data DESIGNABLE false) - Q_PROPERTY(QDeclarativeListProperty children READ fxChildren DESIGNABLE false NOTIFY childrenChanged) Q_PROPERTY(QDeclarativeListProperty resources READ resources DESIGNABLE false) Q_PROPERTY(QDeclarativeListProperty states READ states DESIGNABLE false) Q_PROPERTY(QDeclarativeListProperty transitions READ transitions DESIGNABLE false) Q_PROPERTY(QString state READ state WRITE setState NOTIFY stateChanged) - Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged RESET resetWidth FINAL) - Q_PROPERTY(qreal height READ height WRITE setHeight NOTIFY heightChanged RESET resetHeight FINAL) Q_PROPERTY(QRectF childrenRect READ childrenRect NOTIFY childrenRectChanged DESIGNABLE false FINAL) Q_PROPERTY(QDeclarativeAnchors * anchors READ anchors DESIGNABLE false CONSTANT FINAL) Q_PROPERTY(QDeclarativeAnchorLine left READ left CONSTANT FINAL) @@ -113,7 +110,6 @@ public: void setParent(QDeclarativeItem *parent) { setParentItem(parent); } QDeclarativeListProperty data(); - QDeclarativeListProperty fxChildren(); QDeclarativeListProperty resources(); QDeclarativeAnchors *anchors(); @@ -173,8 +169,6 @@ public: QDeclarativeAnchorLine baseline() const; Q_SIGNALS: - void widthChanged(qreal); - void heightChanged(qreal); void childrenChanged(); void childrenRectChanged(const QRectF &); void baselineOffsetChanged(qreal); @@ -235,9 +229,11 @@ QDebug Q_DECLARATIVE_EXPORT operator<<(QDebug debug, QDeclarativeItem *item); QT_END_NAMESPACE QML_DECLARE_TYPE(QDeclarativeItem) +QML_DECLARE_TYPE(QGraphicsObject) QML_DECLARE_TYPE(QGraphicsTransform) QML_DECLARE_TYPE(QGraphicsScale) QML_DECLARE_TYPE(QGraphicsRotation) +QML_DECLARE_TYPE(QGraphicsWidget) QML_DECLARE_TYPE(QAction) QT_END_HEADER diff --git a/src/declarative/graphicsitems/qdeclarativeitem_p.h b/src/declarative/graphicsitems/qdeclarativeitem_p.h index 55df063..56b0d77 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem_p.h +++ b/src/declarative/graphicsitems/qdeclarativeitem_p.h @@ -114,7 +114,7 @@ public: widthValid(false), heightValid(false), _componentComplete(true), _keepMouse(false), smooth(false), keyHandler(0), - width(0), height(0), implicitWidth(0), implicitHeight(0) + mWidth(0), mHeight(0), implicitWidth(0), implicitHeight(0) { QGraphicsItemPrivate::acceptedMouseButtons = 0; QGraphicsItemPrivate::flags = QGraphicsItem::GraphicsItemFlags( @@ -136,6 +136,16 @@ public: QString _id; + // Private Properties + qreal width() const; + void setWidth(qreal); + void resetWidth(); + + qreal height() const; + void setHeight(qreal); + void resetHeight(); + + // data property static void data_append(QDeclarativeListProperty *, QObject *); @@ -144,11 +154,6 @@ public: static void resources_append(QDeclarativeListProperty *, QObject *); static int resources_count(QDeclarativeListProperty *); - // children property - static QDeclarativeItem *children_at(QDeclarativeListProperty *, int); - static void children_append(QDeclarativeListProperty *, QDeclarativeItem *); - static int children_count(QDeclarativeListProperty *); - // transform property static int transform_count(QDeclarativeListProperty *list); static void transform_append(QDeclarativeListProperty *list, QGraphicsTransform *); @@ -222,8 +227,8 @@ public: QDeclarativeItemKeyFilter *keyHandler; - qreal width; - qreal height; + qreal mWidth; + qreal mHeight; qreal implicitWidth; qreal implicitHeight; @@ -232,9 +237,9 @@ public: virtual void setPosHelper(const QPointF &pos) { Q_Q(QDeclarativeItem); - QRectF oldGeometry(this->pos.x(), this->pos.y(), width, height); + QRectF oldGeometry(this->pos.x(), this->pos.y(), mWidth, mHeight); QGraphicsItemPrivate::setPosHelper(pos); - q->geometryChanged(QRectF(this->pos.x(), this->pos.y(), width, height), oldGeometry); + q->geometryChanged(QRectF(this->pos.x(), this->pos.y(), mWidth, mHeight), oldGeometry); } // Reimplemented from QGraphicsItemPrivate -- cgit v0.12 From c2df63f457229ce8d3806a30f75221796c931c86 Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Thu, 25 Mar 2010 07:05:32 +0100 Subject: Fix the build due to new properties in QGraphicsObject. Reviewed-by:Martin Jones --- .../graphicsitems/qdeclarativegraphicsobjectcontainer.cpp | 10 +++++----- .../graphicsitems/qdeclarativegraphicsobjectcontainer_p.h | 1 - 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativegraphicsobjectcontainer.cpp b/src/declarative/graphicsitems/qdeclarativegraphicsobjectcontainer.cpp index eb5b6ce..ff85bbd 100644 --- a/src/declarative/graphicsitems/qdeclarativegraphicsobjectcontainer.cpp +++ b/src/declarative/graphicsitems/qdeclarativegraphicsobjectcontainer.cpp @@ -65,12 +65,12 @@ public: if (graphicsObject && graphicsObject->isWidget()) { if (!on) { graphicsObject->removeEventFilter(q); - QObject::disconnect(q, SIGNAL(widthChanged(qreal)), q, SLOT(_q_updateSize())); - QObject::disconnect(q, SIGNAL(heightChanged(qreal)), q, SLOT(_q_updateSize())); + QObject::disconnect(q, SIGNAL(widthChanged()), q, SLOT(_q_updateSize())); + QObject::disconnect(q, SIGNAL(heightChanged()), q, SLOT(_q_updateSize())); } else { graphicsObject->installEventFilter(q); - QObject::connect(q, SIGNAL(widthChanged(qreal)), q, SLOT(_q_updateSize())); - QObject::connect(q, SIGNAL(heightChanged(qreal)), q, SLOT(_q_updateSize())); + QObject::connect(q, SIGNAL(widthChanged()), q, SLOT(_q_updateSize())); + QObject::connect(q, SIGNAL(heightChanged()), q, SLOT(_q_updateSize())); } } } @@ -251,7 +251,7 @@ void QDeclarativeGraphicsObjectContainerPrivate::_q_updateSize() return; QGraphicsWidget *gw = static_cast(graphicsObject); - const QSizeF newSize(width, height); + const QSizeF newSize(width(), height()); gw->resize(newSize); //### will respecting the widgets min/max ever get us in trouble? (all other items always diff --git a/src/declarative/graphicsitems/qdeclarativegraphicsobjectcontainer_p.h b/src/declarative/graphicsitems/qdeclarativegraphicsobjectcontainer_p.h index 95d7a4b..20c5bcf 100644 --- a/src/declarative/graphicsitems/qdeclarativegraphicsobjectcontainer_p.h +++ b/src/declarative/graphicsitems/qdeclarativegraphicsobjectcontainer_p.h @@ -82,7 +82,6 @@ private: QT_END_NAMESPACE -QML_DECLARE_TYPE(QGraphicsObject) QML_DECLARE_TYPE(QDeclarativeGraphicsObjectContainer) QT_END_HEADER -- cgit v0.12 From f4c7b4f046669a4a3d6ed1e8d538e17648d27b4d Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Thu, 25 Mar 2010 07:06:38 +0100 Subject: Protect the QDeclarativeListProperty used in QGraphicsItem with ifdef Then it fixes the build Reviewed-by:TrustMe --- src/declarative/qml/qdeclarativelist.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/declarative/qml/qdeclarativelist.h b/src/declarative/qml/qdeclarativelist.h index ed402a8..bd87990 100644 --- a/src/declarative/qml/qdeclarativelist.h +++ b/src/declarative/qml/qdeclarativelist.h @@ -54,6 +54,9 @@ QT_MODULE(Declarative) class QObject; struct QMetaObject; + +#ifndef QDECLARATIVELISTPROPERTY +#define QDECLARATIVELISTPROPERTY template struct QDeclarativeListProperty { typedef void (*AppendFunction)(QDeclarativeListProperty *, T*); @@ -106,6 +109,7 @@ private: return ((QList *)p->data)->clear(); } }; +#endif class QDeclarativeEngine; class QDeclarativeListReferencePrivate; -- cgit v0.12 From 9ace4e68eb0636284ecf73ed82e4518bbf0208be Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Thu, 25 Mar 2010 07:08:15 +0100 Subject: Port Flickable and Flipable to support QGraphicsObject. Replacing QDeclarativeItem* members by QGraphicsObject*. Build fix too. Reviewed-by:akennedy --- .../graphicsitems/qdeclarativeflickable.cpp | 4 ++-- .../graphicsitems/qdeclarativeflickable_p.h | 4 ++-- .../graphicsitems/qdeclarativeflipable.cpp | 21 +++++++++++---------- .../graphicsitems/qdeclarativeflipable_p.h | 12 ++++++------ 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp index 9ccb3b6..98502fd 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp @@ -990,10 +990,10 @@ QDeclarativeListProperty QDeclarativeFlickable::flickableData() return QDeclarativeListProperty(this, (void *)d, QDeclarativeFlickablePrivate::data_append); } -QDeclarativeListProperty QDeclarativeFlickable::flickableChildren() +QDeclarativeListProperty QDeclarativeFlickable::flickableChildren() { Q_D(QDeclarativeFlickable); - return d->viewport->fxChildren(); + return QGraphicsItemPrivate::get(d->viewport)->childrenList(); } /*! diff --git a/src/declarative/graphicsitems/qdeclarativeflickable_p.h b/src/declarative/graphicsitems/qdeclarativeflickable_p.h index 7dcab98..1fa2c74 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable_p.h +++ b/src/declarative/graphicsitems/qdeclarativeflickable_p.h @@ -82,7 +82,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativeFlickable : public QDeclarativeItem Q_PROPERTY(QDeclarativeFlickableVisibleArea *visibleArea READ visibleArea CONSTANT) Q_PROPERTY(QDeclarativeListProperty flickableData READ flickableData) - Q_PROPERTY(QDeclarativeListProperty flickableChildren READ flickableChildren) + Q_PROPERTY(QDeclarativeListProperty flickableChildren READ flickableChildren) Q_CLASSINFO("DefaultProperty", "flickableData") Q_ENUMS(FlickDirection) @@ -92,7 +92,7 @@ public: ~QDeclarativeFlickable(); QDeclarativeListProperty flickableData(); - QDeclarativeListProperty flickableChildren(); + QDeclarativeListProperty flickableChildren(); bool overShoot() const; void setOverShoot(bool); diff --git a/src/declarative/graphicsitems/qdeclarativeflipable.cpp b/src/declarative/graphicsitems/qdeclarativeflipable.cpp index 0e2ae63..cb4044f 100644 --- a/src/declarative/graphicsitems/qdeclarativeflipable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflipable.cpp @@ -59,8 +59,8 @@ public: void updateSceneTransformFromParent(); QDeclarativeFlipable::Side current; - QDeclarativeGuard front; - QDeclarativeGuard back; + QDeclarativeGuard front; + QDeclarativeGuard back; }; /*! @@ -112,13 +112,13 @@ QDeclarativeFlipable::~QDeclarativeFlipable() The front and back sides of the flipable. */ -QDeclarativeItem *QDeclarativeFlipable::front() +QGraphicsObject *QDeclarativeFlipable::front() { Q_D(const QDeclarativeFlipable); return d->front; } -void QDeclarativeFlipable::setFront(QDeclarativeItem *front) +void QDeclarativeFlipable::setFront(QGraphicsObject *front) { Q_D(QDeclarativeFlipable); if (d->front) { @@ -131,13 +131,13 @@ void QDeclarativeFlipable::setFront(QDeclarativeItem *front) d->front->setOpacity(0.); } -QDeclarativeItem *QDeclarativeFlipable::back() +QGraphicsObject *QDeclarativeFlipable::back() { Q_D(const QDeclarativeFlipable); return d->back; } -void QDeclarativeFlipable::setBack(QDeclarativeItem *back) +void QDeclarativeFlipable::setBack(QGraphicsObject *back) { Q_D(QDeclarativeFlipable); if (d->back) { @@ -195,12 +195,13 @@ void QDeclarativeFlipablePrivate::updateSceneTransformFromParent() current = newSide; if (current == QDeclarativeFlipable::Back && back) { QTransform mat; - mat.translate(back->width()/2,back->height()/2); - if (back->width() && p1.x() >= p2.x()) + QGraphicsItemPrivate *dBack = QGraphicsItemPrivate::get(back); + mat.translate(dBack->width()/2,dBack->height()/2); + if (dBack->width() && p1.x() >= p2.x()) mat.rotate(180, Qt::YAxis); - if (back->height() && p2.y() >= p3.y()) + if (dBack->height() && p2.y() >= p3.y()) mat.rotate(180, Qt::XAxis); - mat.translate(-back->width()/2,-back->height()/2); + mat.translate(-dBack->width()/2,-dBack->height()/2); back->setTransform(mat); } if (front) diff --git a/src/declarative/graphicsitems/qdeclarativeflipable_p.h b/src/declarative/graphicsitems/qdeclarativeflipable_p.h index 8b9c24c..302f083 100644 --- a/src/declarative/graphicsitems/qdeclarativeflipable_p.h +++ b/src/declarative/graphicsitems/qdeclarativeflipable_p.h @@ -60,8 +60,8 @@ class Q_DECLARATIVE_EXPORT QDeclarativeFlipable : public QDeclarativeItem Q_OBJECT Q_ENUMS(Side) - Q_PROPERTY(QDeclarativeItem *front READ front WRITE setFront) - Q_PROPERTY(QDeclarativeItem *back READ back WRITE setBack) + Q_PROPERTY(QGraphicsObject *front READ front WRITE setFront) + Q_PROPERTY(QGraphicsObject *back READ back WRITE setBack) Q_PROPERTY(Side side READ side NOTIFY sideChanged) //### flipAxis //### flipRotation @@ -69,11 +69,11 @@ public: QDeclarativeFlipable(QDeclarativeItem *parent=0); ~QDeclarativeFlipable(); - QDeclarativeItem *front(); - void setFront(QDeclarativeItem *); + QGraphicsObject *front(); + void setFront(QGraphicsObject *); - QDeclarativeItem *back(); - void setBack(QDeclarativeItem *); + QGraphicsObject *back(); + void setBack(QGraphicsObject *); enum Side { Front, Back }; Side side() const; -- cgit v0.12 From 4ad6036f30db22562df4478babdc61820d94f774 Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Thu, 25 Mar 2010 07:16:42 +0100 Subject: Build Fix and port to new width and height properties Reviewed-by:Martin Jones --- src/declarative/graphicsitems/qdeclarativeborderimage.cpp | 2 +- src/declarative/graphicsitems/qdeclarativelistview.cpp | 4 ++-- src/declarative/graphicsitems/qdeclarativepainteditem.cpp | 4 ++-- src/declarative/graphicsitems/qdeclarativerectangle.cpp | 2 +- src/declarative/util/qdeclarativeview.cpp | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp index a7534b8..f92c207 100644 --- a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp @@ -444,7 +444,7 @@ void QDeclarativeBorderImage::paint(QPainter *p, const QStyleOptionGraphicsItem const QDeclarativeScaleGrid *border = d->getScaleGrid(); QMargins margins(border->left(), border->top(), border->right(), border->bottom()); QTileRules rules((Qt::TileRule)d->horizontalTileMode, (Qt::TileRule)d->verticalTileMode); - qDrawBorderPixmap(p, QRect(0, 0, (int)d->width, (int)d->height), margins, d->pix, d->pix.rect(), margins, rules); + qDrawBorderPixmap(p, QRect(0, 0, (int)d->width(), (int)d->height()), margins, d->pix, d->pix.rect(), margins, rules); if (d->smooth) { p->setRenderHint(QPainter::Antialiasing, oldAA); p->setRenderHint(QPainter::SmoothPixmapTransform, oldSmooth); diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index 320a2f0..8a70c07 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -562,7 +562,7 @@ void QDeclarativeListViewPrivate::releaseItem(FxListItem *item) return; if (trackedItem == item) { const char *notifier1 = orient == QDeclarativeListView::Vertical ? SIGNAL(yChanged()) : SIGNAL(xChanged()); - const char *notifier2 = orient == QDeclarativeListView::Vertical ? SIGNAL(heightChanged(qreal)) : SIGNAL(widthChanged(qreal)); + const char *notifier2 = orient == QDeclarativeListView::Vertical ? SIGNAL(heightChanged()) : SIGNAL(widthChanged()); QObject::disconnect(trackedItem->item, notifier1, q, SLOT(trackedPositionChanged())); QObject::disconnect(trackedItem->item, notifier2, q, SLOT(trackedPositionChanged())); trackedItem = 0; @@ -763,7 +763,7 @@ void QDeclarativeListViewPrivate::updateTrackedItem() FxListItem *oldTracked = trackedItem; const char *notifier1 = orient == QDeclarativeListView::Vertical ? SIGNAL(yChanged()) : SIGNAL(xChanged()); - const char *notifier2 = orient == QDeclarativeListView::Vertical ? SIGNAL(heightChanged(qreal)) : SIGNAL(widthChanged(qreal)); + const char *notifier2 = orient == QDeclarativeListView::Vertical ? SIGNAL(heightChanged()) : SIGNAL(widthChanged()); if (trackedItem && item != trackedItem) { QObject::disconnect(trackedItem->item, notifier1, q, SLOT(trackedPositionChanged())); diff --git a/src/declarative/graphicsitems/qdeclarativepainteditem.cpp b/src/declarative/graphicsitems/qdeclarativepainteditem.cpp index 28a93d2..ab6007a 100644 --- a/src/declarative/graphicsitems/qdeclarativepainteditem.cpp +++ b/src/declarative/graphicsitems/qdeclarativepainteditem.cpp @@ -211,8 +211,8 @@ QDeclarativePaintedItem::~QDeclarativePaintedItem() */ void QDeclarativePaintedItem::init() { - connect(this,SIGNAL(widthChanged(qreal)),this,SLOT(clearCache())); - connect(this,SIGNAL(heightChanged(qreal)),this,SLOT(clearCache())); + connect(this,SIGNAL(widthChanged()),this,SLOT(clearCache())); + connect(this,SIGNAL(heightChanged()),this,SLOT(clearCache())); connect(this,SIGNAL(visibleChanged()),this,SLOT(clearCache())); } diff --git a/src/declarative/graphicsitems/qdeclarativerectangle.cpp b/src/declarative/graphicsitems/qdeclarativerectangle.cpp index 207d05e..b82fb53 100644 --- a/src/declarative/graphicsitems/qdeclarativerectangle.cpp +++ b/src/declarative/graphicsitems/qdeclarativerectangle.cpp @@ -470,7 +470,7 @@ void QDeclarativeRectangle::drawRect(QPainter &p) QRectF QDeclarativeRectangle::boundingRect() const { Q_D(const QDeclarativeRectangle); - return QRectF(-d->paintmargin, -d->paintmargin, d->width+d->paintmargin*2, d->height+d->paintmargin*2); + return QRectF(-d->paintmargin, -d->paintmargin, d->width()+d->paintmargin*2, d->height()+d->paintmargin*2); } QT_END_NAMESPACE diff --git a/src/declarative/util/qdeclarativeview.cpp b/src/declarative/util/qdeclarativeview.cpp index d97fb5f..8e65151 100644 --- a/src/declarative/util/qdeclarativeview.cpp +++ b/src/declarative/util/qdeclarativeview.cpp @@ -448,8 +448,8 @@ void QDeclarativeView::setRootObject(QObject *obj) d->root = item; d->qmlRoot = item; - connect(item, SIGNAL(widthChanged(qreal)), this, SLOT(sizeChanged())); - connect(item, SIGNAL(heightChanged(qreal)), this, SLOT(sizeChanged())); + connect(item, SIGNAL(widthChanged()), this, SLOT(sizeChanged())); + connect(item, SIGNAL(heightChanged()), this, SLOT(sizeChanged())); if (d->initialSize.height() <= 0 && d->qmlRoot->width() > 0) d->initialSize.setWidth(d->qmlRoot->width()); if (d->initialSize.height() <= 0 && d->qmlRoot->height() > 0) -- cgit v0.12 From 18137c664abd3bb3825ec44864a938d1acaf7b79 Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Thu, 25 Mar 2010 07:38:55 +0100 Subject: Auto-test fix. Also fix a connect in QDeclarativeItem. Reviewed-by:TrustMe --- src/declarative/graphicsitems/qdeclarativeitem.cpp | 4 ++-- .../auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp | 10 ++-------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index f61ad8e..e6ade00 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -312,9 +312,9 @@ void QDeclarativeContents::setItem(QDeclarativeItem *item) QDeclarativeItem *child = qobject_cast(children.at(i)); if(!child)//### Should this be ignoring non-QDeclarativeItem graphicsobjects? continue; - connect(child, SIGNAL(heightChanged(qreal)), this, SLOT(calcHeight())); + connect(child, SIGNAL(heightChanged()), this, SLOT(calcHeight())); connect(child, SIGNAL(yChanged()), this, SLOT(calcHeight())); - connect(child, SIGNAL(widthChanged(qreal)), this, SLOT(calcWidth())); + connect(child, SIGNAL(widthChanged()), this, SLOT(calcWidth())); connect(child, SIGNAL(xChanged()), this, SLOT(calcWidth())); connect(this, SIGNAL(rectChanged(QRectF)), m_item, SIGNAL(childrenRectChanged(QRectF))); } diff --git a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp index ba69cd8..7665e18 100644 --- a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp +++ b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp @@ -421,8 +421,8 @@ void tst_QDeclarativeItem::propertyChanges() QVERIFY(parentItem); QSignalSpy parentSpy(item, SIGNAL(parentChanged(QDeclarativeItem *))); - QSignalSpy widthSpy(item, SIGNAL(widthChanged(qreal))); - QSignalSpy heightSpy(item, SIGNAL(heightChanged(qreal))); + QSignalSpy widthSpy(item, SIGNAL(widthChanged())); + QSignalSpy heightSpy(item, SIGNAL(heightChanged())); QSignalSpy baselineOffsetSpy(item, SIGNAL(baselineOffsetChanged(qreal))); QSignalSpy childrenRectSpy(parentItem, SIGNAL(childrenRectChanged(QRectF))); QSignalSpy focusSpy(item, SIGNAL(focusChanged(bool))); @@ -442,15 +442,9 @@ void tst_QDeclarativeItem::propertyChanges() QCOMPARE(item->width(), 100.0); QCOMPARE(widthSpy.count(),1); - QList widthArguments = widthSpy.first(); - QVERIFY(widthArguments.count() == 1); - QCOMPARE(item->width(), widthArguments.at(0).toReal()); QCOMPARE(item->height(), 200.0); QCOMPARE(heightSpy.count(),1); - QList heightArguments = heightSpy.first(); - QVERIFY(heightArguments.count() == 1); - QCOMPARE(item->height(), heightArguments.at(0).toReal()); QCOMPARE(item->baselineOffset(), 10.0); QCOMPARE(baselineOffsetSpy.count(),1); -- cgit v0.12 From 0ae469c1bbe2f5fa033b88116546b293a8bdf565 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 25 Mar 2010 15:24:52 +1000 Subject: Rename qdeclarativetime -> qmltime Consistent with "qml" runtime binary --- tests/benchmarks/declarative/declarative.pro | 2 +- .../declarative/qdeclarativetime/example.qml | 14 -- .../qdeclarativetime/qdeclarativetime.cpp | 231 --------------------- .../qdeclarativetime/qdeclarativetime.pro | 23 -- .../qdeclarativetime/tests/anchors/empty.qml | 34 --- .../qdeclarativetime/tests/anchors/fill.qml | 41 ---- .../qdeclarativetime/tests/anchors/null.qml | 27 --- .../qdeclarativetime/tests/animation/large.qml | 41 ---- .../tests/animation/largeNoProps.qml | 41 ---- .../tests/item_creation/children.qml | 34 --- .../qdeclarativetime/tests/item_creation/data.qml | 34 --- .../tests/item_creation/no_creation.qml | 12 -- .../tests/item_creation/resources.qml | 34 --- .../qdeclarativetime/tests/loader/Loaded.qml | 7 - .../tests/loader/component_loader.qml | 16 -- .../qdeclarativetime/tests/loader/empty_loader.qml | 15 -- .../qdeclarativetime/tests/loader/no_loader.qml | 14 -- .../tests/loader/source_loader.qml | 16 -- .../tests/positioner_creation/no_positioner.qml | 37 ---- .../tests/positioner_creation/null_positioner.qml | 34 --- .../tests/positioner_creation/positioner.qml | 37 ---- tests/benchmarks/declarative/qmltime/example.qml | 14 ++ tests/benchmarks/declarative/qmltime/qmltime.cpp | 231 +++++++++++++++++++++ tests/benchmarks/declarative/qmltime/qmltime.pro | 23 ++ .../declarative/qmltime/tests/anchors/empty.qml | 34 +++ .../declarative/qmltime/tests/anchors/fill.qml | 41 ++++ .../declarative/qmltime/tests/anchors/null.qml | 27 +++ .../declarative/qmltime/tests/animation/large.qml | 41 ++++ .../qmltime/tests/animation/largeNoProps.qml | 41 ++++ .../qmltime/tests/item_creation/children.qml | 34 +++ .../qmltime/tests/item_creation/data.qml | 34 +++ .../qmltime/tests/item_creation/no_creation.qml | 12 ++ .../qmltime/tests/item_creation/resources.qml | 34 +++ .../declarative/qmltime/tests/loader/Loaded.qml | 7 + .../qmltime/tests/loader/component_loader.qml | 16 ++ .../qmltime/tests/loader/empty_loader.qml | 15 ++ .../declarative/qmltime/tests/loader/no_loader.qml | 14 ++ .../qmltime/tests/loader/source_loader.qml | 16 ++ .../tests/positioner_creation/no_positioner.qml | 37 ++++ .../tests/positioner_creation/null_positioner.qml | 34 +++ .../tests/positioner_creation/positioner.qml | 37 ++++ 41 files changed, 743 insertions(+), 743 deletions(-) delete mode 100644 tests/benchmarks/declarative/qdeclarativetime/example.qml delete mode 100644 tests/benchmarks/declarative/qdeclarativetime/qdeclarativetime.cpp delete mode 100644 tests/benchmarks/declarative/qdeclarativetime/qdeclarativetime.pro delete mode 100644 tests/benchmarks/declarative/qdeclarativetime/tests/anchors/empty.qml delete mode 100644 tests/benchmarks/declarative/qdeclarativetime/tests/anchors/fill.qml delete mode 100644 tests/benchmarks/declarative/qdeclarativetime/tests/anchors/null.qml delete mode 100644 tests/benchmarks/declarative/qdeclarativetime/tests/animation/large.qml delete mode 100644 tests/benchmarks/declarative/qdeclarativetime/tests/animation/largeNoProps.qml delete mode 100644 tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/children.qml delete mode 100644 tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/data.qml delete mode 100644 tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/no_creation.qml delete mode 100644 tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/resources.qml delete mode 100644 tests/benchmarks/declarative/qdeclarativetime/tests/loader/Loaded.qml delete mode 100644 tests/benchmarks/declarative/qdeclarativetime/tests/loader/component_loader.qml delete mode 100644 tests/benchmarks/declarative/qdeclarativetime/tests/loader/empty_loader.qml delete mode 100644 tests/benchmarks/declarative/qdeclarativetime/tests/loader/no_loader.qml delete mode 100644 tests/benchmarks/declarative/qdeclarativetime/tests/loader/source_loader.qml delete mode 100644 tests/benchmarks/declarative/qdeclarativetime/tests/positioner_creation/no_positioner.qml delete mode 100644 tests/benchmarks/declarative/qdeclarativetime/tests/positioner_creation/null_positioner.qml delete mode 100644 tests/benchmarks/declarative/qdeclarativetime/tests/positioner_creation/positioner.qml create mode 100644 tests/benchmarks/declarative/qmltime/example.qml create mode 100644 tests/benchmarks/declarative/qmltime/qmltime.cpp create mode 100644 tests/benchmarks/declarative/qmltime/qmltime.pro create mode 100644 tests/benchmarks/declarative/qmltime/tests/anchors/empty.qml create mode 100644 tests/benchmarks/declarative/qmltime/tests/anchors/fill.qml create mode 100644 tests/benchmarks/declarative/qmltime/tests/anchors/null.qml create mode 100644 tests/benchmarks/declarative/qmltime/tests/animation/large.qml create mode 100644 tests/benchmarks/declarative/qmltime/tests/animation/largeNoProps.qml create mode 100644 tests/benchmarks/declarative/qmltime/tests/item_creation/children.qml create mode 100644 tests/benchmarks/declarative/qmltime/tests/item_creation/data.qml create mode 100644 tests/benchmarks/declarative/qmltime/tests/item_creation/no_creation.qml create mode 100644 tests/benchmarks/declarative/qmltime/tests/item_creation/resources.qml create mode 100644 tests/benchmarks/declarative/qmltime/tests/loader/Loaded.qml create mode 100644 tests/benchmarks/declarative/qmltime/tests/loader/component_loader.qml create mode 100644 tests/benchmarks/declarative/qmltime/tests/loader/empty_loader.qml create mode 100644 tests/benchmarks/declarative/qmltime/tests/loader/no_loader.qml create mode 100644 tests/benchmarks/declarative/qmltime/tests/loader/source_loader.qml create mode 100644 tests/benchmarks/declarative/qmltime/tests/positioner_creation/no_positioner.qml create mode 100644 tests/benchmarks/declarative/qmltime/tests/positioner_creation/null_positioner.qml create mode 100644 tests/benchmarks/declarative/qmltime/tests/positioner_creation/positioner.qml diff --git a/tests/benchmarks/declarative/declarative.pro b/tests/benchmarks/declarative/declarative.pro index 38ea6c4..a7d426c 100644 --- a/tests/benchmarks/declarative/declarative.pro +++ b/tests/benchmarks/declarative/declarative.pro @@ -8,4 +8,4 @@ SUBDIRS += \ qdeclarativeimage \ qdeclarativemetaproperty \ script \ - qdeclarativetime + qmltime diff --git a/tests/benchmarks/declarative/qdeclarativetime/example.qml b/tests/benchmarks/declarative/qdeclarativetime/example.qml deleted file mode 100644 index dd6185d..0000000 --- a/tests/benchmarks/declarative/qdeclarativetime/example.qml +++ /dev/null @@ -1,14 +0,0 @@ -import Qt 4.6 -import QDeclarativeTime 1.0 as QDeclarativeTime - -Item { - - property string name: "Bob Smith" - - QDeclarativeTime.Timer { - component: Item { - Text { text: name } - } - } -} - diff --git a/tests/benchmarks/declarative/qdeclarativetime/qdeclarativetime.cpp b/tests/benchmarks/declarative/qdeclarativetime/qdeclarativetime.cpp deleted file mode 100644 index 20f0d93d..0000000 --- a/tests/benchmarks/declarative/qdeclarativetime/qdeclarativetime.cpp +++ /dev/null @@ -1,231 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include - -class Timer : public QObject -{ - Q_OBJECT - Q_PROPERTY(QDeclarativeComponent *component READ component WRITE setComponent); - -public: - Timer(); - - QDeclarativeComponent *component() const; - void setComponent(QDeclarativeComponent *); - - static Timer *timerInstance(); - - void run(uint); - - bool willParent() const; - void setWillParent(bool p); - -private: - void runTest(QDeclarativeContext *, uint); - - QDeclarativeComponent *m_component; - static Timer *m_timer; - - bool m_willparent; - QGraphicsScene m_scene; - QGraphicsRectItem m_item; -}; -QML_DECLARE_TYPE(Timer); - -Timer *Timer::m_timer = 0; - -Timer::Timer() -: m_component(0), m_willparent(false) -{ - if (m_timer) - qWarning("Timer: Timer already registered"); - m_timer = this; - - m_scene.setItemIndexMethod(QGraphicsScene::NoIndex); - m_scene.addItem(&m_item); -} - -QDeclarativeComponent *Timer::component() const -{ - return m_component; -} - -void Timer::setComponent(QDeclarativeComponent *c) -{ - m_component = c; -} - -Timer *Timer::timerInstance() -{ - return m_timer; -} - -void Timer::run(uint iterations) -{ - QDeclarativeContext context(qmlContext(this)); - - QObject *o = m_component->create(&context); - QGraphicsObject *go = qobject_cast(o); - if (m_willparent && go) - go->setParentItem(&m_item); - delete o; - - runTest(&context, iterations); -} - -bool Timer::willParent() const -{ - return m_willparent; -} - -void Timer::setWillParent(bool p) -{ - m_willparent = p; -} - -void Timer::runTest(QDeclarativeContext *context, uint iterations) -{ - QTime t; - t.start(); - for (uint ii = 0; ii < iterations; ++ii) { - QObject *o = m_component->create(context); - QGraphicsObject *go = qobject_cast(o); - if (m_willparent && go) - go->setParentItem(&m_item); - delete o; - } - - int e = t.elapsed(); - - qWarning() << "Total:" << e << "ms, Per iteration:" << qreal(e) / qreal(iterations) << "ms"; - -} - -void usage(const char *name) -{ - qWarning("Usage: %s [-iterations ] [-parent] ", name); - exit(-1); -} - -int main(int argc, char ** argv) -{ - QApplication app(argc, argv); - - qmlRegisterType("QDeclarativeTime", 1, 0, "Timer"); - - uint iterations = 1024; - QString filename; - bool willParent = false; - - for (int ii = 1; ii < argc; ++ii) { - QByteArray arg(argv[ii]); - - if (arg == "-iterations") { - if (ii + 1 < argc) { - ++ii; - QByteArray its(argv[ii]); - bool ok = false; - iterations = its.toUInt(&ok); - if (!ok) - usage(argv[0]); - } else { - usage(argv[0]); - } - } else if (arg == "-parent") { - willParent = true; - } else { - filename = QLatin1String(argv[ii]); - } - } - - if (filename.isEmpty()) -#ifdef Q_OS_SYMBIAN - filename = QLatin1String("./tests/item_creation/data.qml"); -#else - usage(argv[0]); -#endif - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, filename); - if (component.isError()) { - qWarning() << component.errors(); - return -1; - } - - QObject *obj = component.create(); - if (!obj) { - qWarning() << component.errors(); - return -1; - } - - Timer *timer = Timer::timerInstance(); - if (!timer) { - qWarning() << "A Tester.Timer instance is required."; - return -1; - } - -#ifdef Q_OS_SYMBIAN - willParent = true; -#endif - timer->setWillParent(willParent); - - if (!timer->component()) { - qWarning() << "The timer has no component"; - return -1; - } - -#ifdef Q_OS_SYMBIAN - iterations = 1024; -#endif - - timer->run(iterations); - - return 0; -} - -#include "qdeclarativetime.moc" diff --git a/tests/benchmarks/declarative/qdeclarativetime/qdeclarativetime.pro b/tests/benchmarks/declarative/qdeclarativetime/qdeclarativetime.pro deleted file mode 100644 index 7902ee1..0000000 --- a/tests/benchmarks/declarative/qdeclarativetime/qdeclarativetime.pro +++ /dev/null @@ -1,23 +0,0 @@ -load(qttest_p4) -TEMPLATE = app -TARGET = qdeclarativetime -QT += declarative -macx:CONFIG -= app_bundle - -SOURCES += qdeclarativetime.cpp - -symbian* { - TARGET.CAPABILITY = "All -TCB" - example.sources = example.qml - esample.path = . - tests.sources = tests/* - tests.path = tests - anshors.sources = tests/anchors/* - anchors.path = tests/anchors - item_creation.sources = tests/item_creation/* - item_creation.path = tests/item_creation - positioner_creation.sources = tests/positioner_creation/* - positioner_creation.path = tests/positioner_creation - DEPLOYMENT += example tests anchors item_creation positioner_creation -} - diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/anchors/empty.qml b/tests/benchmarks/declarative/qdeclarativetime/tests/anchors/empty.qml deleted file mode 100644 index 8d93594..0000000 --- a/tests/benchmarks/declarative/qdeclarativetime/tests/anchors/empty.qml +++ /dev/null @@ -1,34 +0,0 @@ -import Qt 4.6 -import QDeclarativeTime 1.0 as QDeclarativeTime - -Item { - - QDeclarativeTime.Timer { - component: Component { - Item { - Item { - anchors.leftMargin: 0 - } - Item { - anchors.leftMargin: 0 - } - Item { - anchors.leftMargin: 0 - } - Item { - anchors.leftMargin: 0 - } - Item { - anchors.leftMargin: 0 - } - Item { - anchors.leftMargin: 0 - } - Item { - anchors.leftMargin: 0 - } - } - } - } -} - diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/anchors/fill.qml b/tests/benchmarks/declarative/qdeclarativetime/tests/anchors/fill.qml deleted file mode 100644 index 918c48a..0000000 --- a/tests/benchmarks/declarative/qdeclarativetime/tests/anchors/fill.qml +++ /dev/null @@ -1,41 +0,0 @@ -import Qt 4.6 -import QDeclarativeTime 1.0 as QDeclarativeTime - -Item { - - QDeclarativeTime.Timer { - component: Component { - Item { - Item { - anchors.fill: parent - anchors.leftMargin: 0 - } - Item { - anchors.fill: parent - anchors.leftMargin: 0 - } - Item { - anchors.fill: parent - anchors.leftMargin: 0 - } - Item { - anchors.fill: parent - anchors.leftMargin: 0 - } - Item { - anchors.fill: parent - anchors.leftMargin: 0 - } - Item { - anchors.fill: parent - anchors.leftMargin: 0 - } - Item { - anchors.fill: parent - anchors.leftMargin: 0 - } - } - } - } -} - diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/anchors/null.qml b/tests/benchmarks/declarative/qdeclarativetime/tests/anchors/null.qml deleted file mode 100644 index bb84538..0000000 --- a/tests/benchmarks/declarative/qdeclarativetime/tests/anchors/null.qml +++ /dev/null @@ -1,27 +0,0 @@ -import Qt 4.6 -import QDeclarativeTime 1.0 as QDeclarativeTime - -Item { - - QDeclarativeTime.Timer { - component: Component { - Item { - Item { - } - Item { - } - Item { - } - Item { - } - Item { - } - Item { - } - Item { - } - } - } - } -} - diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/animation/large.qml b/tests/benchmarks/declarative/qdeclarativetime/tests/animation/large.qml deleted file mode 100644 index 978e3bf..0000000 --- a/tests/benchmarks/declarative/qdeclarativetime/tests/animation/large.qml +++ /dev/null @@ -1,41 +0,0 @@ -import Qt 4.6 -import QDeclarativeTime 1.0 as QDeclarativeTime - -Item { - - QDeclarativeTime.Timer { - component: Component { - ParallelAnimation { - NumberAnimation { duration: 500 } - NumberAnimation { duration: 4000; } - NumberAnimation { duration: 2000; easing.type: "OutBack"} - ColorAnimation { duration: 3000} - SequentialAnimation { - PauseAnimation { duration: 1000 } - ScriptAction { script: doSomething(); } - PauseAnimation { duration: 800 } - ScriptAction { script: doSomethingElse(); } - PauseAnimation { duration: 800 } - ParallelAnimation { - NumberAnimation { duration: 200;} - SequentialAnimation { - PauseAnimation { duration: 200} - ParallelAnimation { - NumberAnimation { duration: 300;} - NumberAnimation { duration: 300;} - } - NumberAnimation { from: 0; to: 1; duration: 500 } - PauseAnimation { duration: 200 } - NumberAnimation { from: 1; to: 0; duration: 500 } - } - SequentialAnimation { - PauseAnimation { duration: 150} - NumberAnimation { duration: 300; easing.type: "OutBounce" } - } - } - } - } - } - } - -} diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/animation/largeNoProps.qml b/tests/benchmarks/declarative/qdeclarativetime/tests/animation/largeNoProps.qml deleted file mode 100644 index cceb3f4..0000000 --- a/tests/benchmarks/declarative/qdeclarativetime/tests/animation/largeNoProps.qml +++ /dev/null @@ -1,41 +0,0 @@ -import Qt 4.6 -import QDeclarativeTime 1.0 as QDeclarativeTime - -Item { - - QDeclarativeTime.Timer { - component: Component { - ParallelAnimation { - NumberAnimation { } - NumberAnimation { } - NumberAnimation { } - ColorAnimation { } - SequentialAnimation { - PauseAnimation { } - ScriptAction { } - PauseAnimation { } - ScriptAction { } - PauseAnimation { } - ParallelAnimation { - NumberAnimation { } - SequentialAnimation { - PauseAnimation { } - ParallelAnimation { - NumberAnimation { } - NumberAnimation { } - } - NumberAnimation { } - PauseAnimation { } - NumberAnimation { } - } - SequentialAnimation { - PauseAnimation { } - NumberAnimation { } - } - } - } - } - } - } - -} diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/children.qml b/tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/children.qml deleted file mode 100644 index 3387a32..0000000 --- a/tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/children.qml +++ /dev/null @@ -1,34 +0,0 @@ -import Qt 4.6 -import QDeclarativeTime 1.0 as QDeclarativeTime - -Item { - - QDeclarativeTime.Timer { - component: Component { - Item { - children: [ - Rectangle { }, - Rectangle { }, - Item { }, - Image { }, - Text { }, - Item { }, - Item { }, - Image { }, - Image { }, - Row { }, - Image { }, - Image { }, - Column { }, - Row { }, - Text { }, - Text { }, - Text { }, - MouseArea { } - ] - - } - } - } - -} diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/data.qml b/tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/data.qml deleted file mode 100644 index a8b653c..0000000 --- a/tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/data.qml +++ /dev/null @@ -1,34 +0,0 @@ -import Qt 4.6 -import QDeclarativeTime 1.0 as QDeclarativeTime - -Item { - - QDeclarativeTime.Timer { - component: Component { - Item { - data: [ - Rectangle { }, - Rectangle { }, - Item { }, - Image { }, - Text { }, - Item { }, - Item { }, - Image { }, - Image { }, - Row { }, - Image { }, - Image { }, - Column { }, - Row { }, - Text { }, - Text { }, - Text { }, - MouseArea { } - ] - - } - } - } - -} diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/no_creation.qml b/tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/no_creation.qml deleted file mode 100644 index 0a507d4..0000000 --- a/tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/no_creation.qml +++ /dev/null @@ -1,12 +0,0 @@ -import Qt 4.6 -import QDeclarativeTime 1.0 as QDeclarativeTime - -Item { - - QDeclarativeTime.Timer { - component: Component { - Item { - } - } - } -} diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/resources.qml b/tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/resources.qml deleted file mode 100644 index 227d8ad..0000000 --- a/tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/resources.qml +++ /dev/null @@ -1,34 +0,0 @@ -import Qt 4.6 -import QDeclarativeTime 1.0 as QDeclarativeTime - -Item { - - QDeclarativeTime.Timer { - component: Component { - Item { - resources: [ - Rectangle { }, - Rectangle { }, - Item { }, - Image { }, - Text { }, - Item { }, - Item { }, - Image { }, - Image { }, - Row { }, - Image { }, - Image { }, - Column { }, - Row { }, - Text { }, - Text { }, - Text { }, - MouseArea { } - ] - - } - } - } - -} diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/loader/Loaded.qml b/tests/benchmarks/declarative/qdeclarativetime/tests/loader/Loaded.qml deleted file mode 100644 index 6f8d849..0000000 --- a/tests/benchmarks/declarative/qdeclarativetime/tests/loader/Loaded.qml +++ /dev/null @@ -1,7 +0,0 @@ -import Qt 4.6 - -Item { - Rectangle {} - Text {} - Image {} -} diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/loader/component_loader.qml b/tests/benchmarks/declarative/qdeclarativetime/tests/loader/component_loader.qml deleted file mode 100644 index 270add4..0000000 --- a/tests/benchmarks/declarative/qdeclarativetime/tests/loader/component_loader.qml +++ /dev/null @@ -1,16 +0,0 @@ -import Qt 4.6 -import QDeclarativeTime 1.0 as QDeclarativeTime - -Item { - - QDeclarativeTime.Timer { - component: Component { - Item { - Loader { - sourceComponent: Loaded {} - } - } - } - } -} - diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/loader/empty_loader.qml b/tests/benchmarks/declarative/qdeclarativetime/tests/loader/empty_loader.qml deleted file mode 100644 index d3b84cc..0000000 --- a/tests/benchmarks/declarative/qdeclarativetime/tests/loader/empty_loader.qml +++ /dev/null @@ -1,15 +0,0 @@ -import Qt 4.6 -import QDeclarativeTime 1.0 as QDeclarativeTime - -Item { - - QDeclarativeTime.Timer { - component: Component { - Item { - Loader {} - Loaded {} - } - } - } -} - diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/loader/no_loader.qml b/tests/benchmarks/declarative/qdeclarativetime/tests/loader/no_loader.qml deleted file mode 100644 index a94a12a..0000000 --- a/tests/benchmarks/declarative/qdeclarativetime/tests/loader/no_loader.qml +++ /dev/null @@ -1,14 +0,0 @@ -import Qt 4.6 -import QDeclarativeTime 1.0 as QDeclarativeTime - -Item { - - QDeclarativeTime.Timer { - component: Component { - Item { - Loaded {} - } - } - } -} - diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/loader/source_loader.qml b/tests/benchmarks/declarative/qdeclarativetime/tests/loader/source_loader.qml deleted file mode 100644 index 39ed1a6..0000000 --- a/tests/benchmarks/declarative/qdeclarativetime/tests/loader/source_loader.qml +++ /dev/null @@ -1,16 +0,0 @@ -import Qt 4.6 -import QDeclarativeTime 1.0 as QDeclarativeTime - -Item { - - QDeclarativeTime.Timer { - component: Component { - Item { - Loader { - source: "Loaded.qml" - } - } - } - } -} - diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/positioner_creation/no_positioner.qml b/tests/benchmarks/declarative/qdeclarativetime/tests/positioner_creation/no_positioner.qml deleted file mode 100644 index c1f54a4..0000000 --- a/tests/benchmarks/declarative/qdeclarativetime/tests/positioner_creation/no_positioner.qml +++ /dev/null @@ -1,37 +0,0 @@ -import Qt 4.6 -import QDeclarativeTime 1.0 as QDeclarativeTime - -Item { - QDeclarativeTime.Timer { - component: Component { - Item { - Rectangle { } - Rectangle { } - Item { - Image { } - Text { } - } - - Item { - Item { - Image { } - Image { } - Item { - Image { } - Image { } - } - } - - Item { - Item { - Text { } - Text { } - } - Text { } - } - } - MouseArea { } - } - } - } -} diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/positioner_creation/null_positioner.qml b/tests/benchmarks/declarative/qdeclarativetime/tests/positioner_creation/null_positioner.qml deleted file mode 100644 index d49ff78..0000000 --- a/tests/benchmarks/declarative/qdeclarativetime/tests/positioner_creation/null_positioner.qml +++ /dev/null @@ -1,34 +0,0 @@ -import Qt 4.6 -import QDeclarativeTime 1.0 as QDeclarativeTime - -Item { - QDeclarativeTime.Timer { - component: Component { - Item { - Rectangle { } - Rectangle { } - Item { - Image { } - Text { } - } - - Item { - Item { - Image { } - Image { } - Row { } - Image { } - Image { } - } - - Column { } - Row { } - Text { } - Text { } - Text { } - } - MouseArea { } - } - } - } -} diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/positioner_creation/positioner.qml b/tests/benchmarks/declarative/qdeclarativetime/tests/positioner_creation/positioner.qml deleted file mode 100644 index 05ca804..0000000 --- a/tests/benchmarks/declarative/qdeclarativetime/tests/positioner_creation/positioner.qml +++ /dev/null @@ -1,37 +0,0 @@ -import Qt 4.6 -import QDeclarativeTime 1.0 as QDeclarativeTime - -Item { - QDeclarativeTime.Timer { - component: Component { - Item { - Rectangle { } - Rectangle { } - Item { - Image { } - Text { } - } - - Item { - Item { - Image { } - Image { } - Row { - Image { } - Image { } - } - } - - Column { - Row { - Text { } - Text { } - } - Text { } - } - } - MouseArea { } - } - } - } -} diff --git a/tests/benchmarks/declarative/qmltime/example.qml b/tests/benchmarks/declarative/qmltime/example.qml new file mode 100644 index 0000000..68889f0 --- /dev/null +++ b/tests/benchmarks/declarative/qmltime/example.qml @@ -0,0 +1,14 @@ +import Qt 4.6 +import QmlTime 1.0 as QmlTime + +Item { + + property string name: "Bob Smith" + + QmlTime.Timer { + component: Item { + Text { text: name } + } + } +} + diff --git a/tests/benchmarks/declarative/qmltime/qmltime.cpp b/tests/benchmarks/declarative/qmltime/qmltime.cpp new file mode 100644 index 0000000..3932e01 --- /dev/null +++ b/tests/benchmarks/declarative/qmltime/qmltime.cpp @@ -0,0 +1,231 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include + +class Timer : public QObject +{ + Q_OBJECT + Q_PROPERTY(QDeclarativeComponent *component READ component WRITE setComponent); + +public: + Timer(); + + QDeclarativeComponent *component() const; + void setComponent(QDeclarativeComponent *); + + static Timer *timerInstance(); + + void run(uint); + + bool willParent() const; + void setWillParent(bool p); + +private: + void runTest(QDeclarativeContext *, uint); + + QDeclarativeComponent *m_component; + static Timer *m_timer; + + bool m_willparent; + QGraphicsScene m_scene; + QGraphicsRectItem m_item; +}; +QML_DECLARE_TYPE(Timer); + +Timer *Timer::m_timer = 0; + +Timer::Timer() +: m_component(0), m_willparent(false) +{ + if (m_timer) + qWarning("Timer: Timer already registered"); + m_timer = this; + + m_scene.setItemIndexMethod(QGraphicsScene::NoIndex); + m_scene.addItem(&m_item); +} + +QDeclarativeComponent *Timer::component() const +{ + return m_component; +} + +void Timer::setComponent(QDeclarativeComponent *c) +{ + m_component = c; +} + +Timer *Timer::timerInstance() +{ + return m_timer; +} + +void Timer::run(uint iterations) +{ + QDeclarativeContext context(qmlContext(this)); + + QObject *o = m_component->create(&context); + QGraphicsObject *go = qobject_cast(o); + if (m_willparent && go) + go->setParentItem(&m_item); + delete o; + + runTest(&context, iterations); +} + +bool Timer::willParent() const +{ + return m_willparent; +} + +void Timer::setWillParent(bool p) +{ + m_willparent = p; +} + +void Timer::runTest(QDeclarativeContext *context, uint iterations) +{ + QTime t; + t.start(); + for (uint ii = 0; ii < iterations; ++ii) { + QObject *o = m_component->create(context); + QGraphicsObject *go = qobject_cast(o); + if (m_willparent && go) + go->setParentItem(&m_item); + delete o; + } + + int e = t.elapsed(); + + qWarning() << "Total:" << e << "ms, Per iteration:" << qreal(e) / qreal(iterations) << "ms"; + +} + +void usage(const char *name) +{ + qWarning("Usage: %s [-iterations ] [-parent] ", name); + exit(-1); +} + +int main(int argc, char ** argv) +{ + QApplication app(argc, argv); + + qmlRegisterType("QmlTime", 1, 0, "Timer"); + + uint iterations = 1024; + QString filename; + bool willParent = false; + + for (int ii = 1; ii < argc; ++ii) { + QByteArray arg(argv[ii]); + + if (arg == "-iterations") { + if (ii + 1 < argc) { + ++ii; + QByteArray its(argv[ii]); + bool ok = false; + iterations = its.toUInt(&ok); + if (!ok) + usage(argv[0]); + } else { + usage(argv[0]); + } + } else if (arg == "-parent") { + willParent = true; + } else { + filename = QLatin1String(argv[ii]); + } + } + + if (filename.isEmpty()) +#ifdef Q_OS_SYMBIAN + filename = QLatin1String("./tests/item_creation/data.qml"); +#else + usage(argv[0]); +#endif + + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, filename); + if (component.isError()) { + qWarning() << component.errors(); + return -1; + } + + QObject *obj = component.create(); + if (!obj) { + qWarning() << component.errors(); + return -1; + } + + Timer *timer = Timer::timerInstance(); + if (!timer) { + qWarning() << "A Tester.Timer instance is required."; + return -1; + } + +#ifdef Q_OS_SYMBIAN + willParent = true; +#endif + timer->setWillParent(willParent); + + if (!timer->component()) { + qWarning() << "The timer has no component"; + return -1; + } + +#ifdef Q_OS_SYMBIAN + iterations = 1024; +#endif + + timer->run(iterations); + + return 0; +} + +#include "qmltime.moc" diff --git a/tests/benchmarks/declarative/qmltime/qmltime.pro b/tests/benchmarks/declarative/qmltime/qmltime.pro new file mode 100644 index 0000000..9352f3b --- /dev/null +++ b/tests/benchmarks/declarative/qmltime/qmltime.pro @@ -0,0 +1,23 @@ +load(qttest_p4) +TEMPLATE = app +TARGET = qmltime +QT += declarative +macx:CONFIG -= app_bundle + +SOURCES += qmltime.cpp + +symbian* { + TARGET.CAPABILITY = "All -TCB" + example.sources = example.qml + esample.path = . + tests.sources = tests/* + tests.path = tests + anshors.sources = tests/anchors/* + anchors.path = tests/anchors + item_creation.sources = tests/item_creation/* + item_creation.path = tests/item_creation + positioner_creation.sources = tests/positioner_creation/* + positioner_creation.path = tests/positioner_creation + DEPLOYMENT += example tests anchors item_creation positioner_creation +} + diff --git a/tests/benchmarks/declarative/qmltime/tests/anchors/empty.qml b/tests/benchmarks/declarative/qmltime/tests/anchors/empty.qml new file mode 100644 index 0000000..31c879b --- /dev/null +++ b/tests/benchmarks/declarative/qmltime/tests/anchors/empty.qml @@ -0,0 +1,34 @@ +import Qt 4.6 +import QmlTime 1.0 as QmlTime + +Item { + + QmlTime.Timer { + component: Component { + Item { + Item { + anchors.leftMargin: 0 + } + Item { + anchors.leftMargin: 0 + } + Item { + anchors.leftMargin: 0 + } + Item { + anchors.leftMargin: 0 + } + Item { + anchors.leftMargin: 0 + } + Item { + anchors.leftMargin: 0 + } + Item { + anchors.leftMargin: 0 + } + } + } + } +} + diff --git a/tests/benchmarks/declarative/qmltime/tests/anchors/fill.qml b/tests/benchmarks/declarative/qmltime/tests/anchors/fill.qml new file mode 100644 index 0000000..23fe78e --- /dev/null +++ b/tests/benchmarks/declarative/qmltime/tests/anchors/fill.qml @@ -0,0 +1,41 @@ +import Qt 4.6 +import QmlTime 1.0 as QmlTime + +Item { + + QmlTime.Timer { + component: Component { + Item { + Item { + anchors.fill: parent + anchors.leftMargin: 0 + } + Item { + anchors.fill: parent + anchors.leftMargin: 0 + } + Item { + anchors.fill: parent + anchors.leftMargin: 0 + } + Item { + anchors.fill: parent + anchors.leftMargin: 0 + } + Item { + anchors.fill: parent + anchors.leftMargin: 0 + } + Item { + anchors.fill: parent + anchors.leftMargin: 0 + } + Item { + anchors.fill: parent + anchors.leftMargin: 0 + } + } + } + } +} + diff --git a/tests/benchmarks/declarative/qmltime/tests/anchors/null.qml b/tests/benchmarks/declarative/qmltime/tests/anchors/null.qml new file mode 100644 index 0000000..bc447ef --- /dev/null +++ b/tests/benchmarks/declarative/qmltime/tests/anchors/null.qml @@ -0,0 +1,27 @@ +import Qt 4.6 +import QmlTime 1.0 as QmlTime + +Item { + + QmlTime.Timer { + component: Component { + Item { + Item { + } + Item { + } + Item { + } + Item { + } + Item { + } + Item { + } + Item { + } + } + } + } +} + diff --git a/tests/benchmarks/declarative/qmltime/tests/animation/large.qml b/tests/benchmarks/declarative/qmltime/tests/animation/large.qml new file mode 100644 index 0000000..c1cdb68 --- /dev/null +++ b/tests/benchmarks/declarative/qmltime/tests/animation/large.qml @@ -0,0 +1,41 @@ +import Qt 4.6 +import QmlTime 1.0 as QmlTime + +Item { + + QmlTime.Timer { + component: Component { + ParallelAnimation { + NumberAnimation { duration: 500 } + NumberAnimation { duration: 4000; } + NumberAnimation { duration: 2000; easing.type: "OutBack"} + ColorAnimation { duration: 3000} + SequentialAnimation { + PauseAnimation { duration: 1000 } + ScriptAction { script: doSomething(); } + PauseAnimation { duration: 800 } + ScriptAction { script: doSomethingElse(); } + PauseAnimation { duration: 800 } + ParallelAnimation { + NumberAnimation { duration: 200;} + SequentialAnimation { + PauseAnimation { duration: 200} + ParallelAnimation { + NumberAnimation { duration: 300;} + NumberAnimation { duration: 300;} + } + NumberAnimation { from: 0; to: 1; duration: 500 } + PauseAnimation { duration: 200 } + NumberAnimation { from: 1; to: 0; duration: 500 } + } + SequentialAnimation { + PauseAnimation { duration: 150} + NumberAnimation { duration: 300; easing.type: "OutBounce" } + } + } + } + } + } + } + +} diff --git a/tests/benchmarks/declarative/qmltime/tests/animation/largeNoProps.qml b/tests/benchmarks/declarative/qmltime/tests/animation/largeNoProps.qml new file mode 100644 index 0000000..3db9f08 --- /dev/null +++ b/tests/benchmarks/declarative/qmltime/tests/animation/largeNoProps.qml @@ -0,0 +1,41 @@ +import Qt 4.6 +import QmlTime 1.0 as QmlTime + +Item { + + QmlTime.Timer { + component: Component { + ParallelAnimation { + NumberAnimation { } + NumberAnimation { } + NumberAnimation { } + ColorAnimation { } + SequentialAnimation { + PauseAnimation { } + ScriptAction { } + PauseAnimation { } + ScriptAction { } + PauseAnimation { } + ParallelAnimation { + NumberAnimation { } + SequentialAnimation { + PauseAnimation { } + ParallelAnimation { + NumberAnimation { } + NumberAnimation { } + } + NumberAnimation { } + PauseAnimation { } + NumberAnimation { } + } + SequentialAnimation { + PauseAnimation { } + NumberAnimation { } + } + } + } + } + } + } + +} diff --git a/tests/benchmarks/declarative/qmltime/tests/item_creation/children.qml b/tests/benchmarks/declarative/qmltime/tests/item_creation/children.qml new file mode 100644 index 0000000..996602c --- /dev/null +++ b/tests/benchmarks/declarative/qmltime/tests/item_creation/children.qml @@ -0,0 +1,34 @@ +import Qt 4.6 +import QmlTime 1.0 as QmlTime + +Item { + + QmlTime.Timer { + component: Component { + Item { + children: [ + Rectangle { }, + Rectangle { }, + Item { }, + Image { }, + Text { }, + Item { }, + Item { }, + Image { }, + Image { }, + Row { }, + Image { }, + Image { }, + Column { }, + Row { }, + Text { }, + Text { }, + Text { }, + MouseArea { } + ] + + } + } + } + +} diff --git a/tests/benchmarks/declarative/qmltime/tests/item_creation/data.qml b/tests/benchmarks/declarative/qmltime/tests/item_creation/data.qml new file mode 100644 index 0000000..9f79c34 --- /dev/null +++ b/tests/benchmarks/declarative/qmltime/tests/item_creation/data.qml @@ -0,0 +1,34 @@ +import Qt 4.6 +import QmlTime 1.0 as QmlTime + +Item { + + QmlTime.Timer { + component: Component { + Item { + data: [ + Rectangle { }, + Rectangle { }, + Item { }, + Image { }, + Text { }, + Item { }, + Item { }, + Image { }, + Image { }, + Row { }, + Image { }, + Image { }, + Column { }, + Row { }, + Text { }, + Text { }, + Text { }, + MouseArea { } + ] + + } + } + } + +} diff --git a/tests/benchmarks/declarative/qmltime/tests/item_creation/no_creation.qml b/tests/benchmarks/declarative/qmltime/tests/item_creation/no_creation.qml new file mode 100644 index 0000000..f228c2a --- /dev/null +++ b/tests/benchmarks/declarative/qmltime/tests/item_creation/no_creation.qml @@ -0,0 +1,12 @@ +import Qt 4.6 +import QmlTime 1.0 as QmlTime + +Item { + + QmlTime.Timer { + component: Component { + Item { + } + } + } +} diff --git a/tests/benchmarks/declarative/qmltime/tests/item_creation/resources.qml b/tests/benchmarks/declarative/qmltime/tests/item_creation/resources.qml new file mode 100644 index 0000000..335aeb8 --- /dev/null +++ b/tests/benchmarks/declarative/qmltime/tests/item_creation/resources.qml @@ -0,0 +1,34 @@ +import Qt 4.6 +import QmlTime 1.0 as QmlTime + +Item { + + QmlTime.Timer { + component: Component { + Item { + resources: [ + Rectangle { }, + Rectangle { }, + Item { }, + Image { }, + Text { }, + Item { }, + Item { }, + Image { }, + Image { }, + Row { }, + Image { }, + Image { }, + Column { }, + Row { }, + Text { }, + Text { }, + Text { }, + MouseArea { } + ] + + } + } + } + +} diff --git a/tests/benchmarks/declarative/qmltime/tests/loader/Loaded.qml b/tests/benchmarks/declarative/qmltime/tests/loader/Loaded.qml new file mode 100644 index 0000000..6f8d849 --- /dev/null +++ b/tests/benchmarks/declarative/qmltime/tests/loader/Loaded.qml @@ -0,0 +1,7 @@ +import Qt 4.6 + +Item { + Rectangle {} + Text {} + Image {} +} diff --git a/tests/benchmarks/declarative/qmltime/tests/loader/component_loader.qml b/tests/benchmarks/declarative/qmltime/tests/loader/component_loader.qml new file mode 100644 index 0000000..65d5010 --- /dev/null +++ b/tests/benchmarks/declarative/qmltime/tests/loader/component_loader.qml @@ -0,0 +1,16 @@ +import Qt 4.6 +import QmlTime 1.0 as QmlTime + +Item { + + QmlTime.Timer { + component: Component { + Item { + Loader { + sourceComponent: Loaded {} + } + } + } + } +} + diff --git a/tests/benchmarks/declarative/qmltime/tests/loader/empty_loader.qml b/tests/benchmarks/declarative/qmltime/tests/loader/empty_loader.qml new file mode 100644 index 0000000..2dfe922 --- /dev/null +++ b/tests/benchmarks/declarative/qmltime/tests/loader/empty_loader.qml @@ -0,0 +1,15 @@ +import Qt 4.6 +import QmlTime 1.0 as QmlTime + +Item { + + QmlTime.Timer { + component: Component { + Item { + Loader {} + Loaded {} + } + } + } +} + diff --git a/tests/benchmarks/declarative/qmltime/tests/loader/no_loader.qml b/tests/benchmarks/declarative/qmltime/tests/loader/no_loader.qml new file mode 100644 index 0000000..1fa0d3b --- /dev/null +++ b/tests/benchmarks/declarative/qmltime/tests/loader/no_loader.qml @@ -0,0 +1,14 @@ +import Qt 4.6 +import QmlTime 1.0 as QmlTime + +Item { + + QmlTime.Timer { + component: Component { + Item { + Loaded {} + } + } + } +} + diff --git a/tests/benchmarks/declarative/qmltime/tests/loader/source_loader.qml b/tests/benchmarks/declarative/qmltime/tests/loader/source_loader.qml new file mode 100644 index 0000000..33bb91c --- /dev/null +++ b/tests/benchmarks/declarative/qmltime/tests/loader/source_loader.qml @@ -0,0 +1,16 @@ +import Qt 4.6 +import QmlTime 1.0 as QmlTime + +Item { + + QmlTime.Timer { + component: Component { + Item { + Loader { + source: "Loaded.qml" + } + } + } + } +} + diff --git a/tests/benchmarks/declarative/qmltime/tests/positioner_creation/no_positioner.qml b/tests/benchmarks/declarative/qmltime/tests/positioner_creation/no_positioner.qml new file mode 100644 index 0000000..97bad47 --- /dev/null +++ b/tests/benchmarks/declarative/qmltime/tests/positioner_creation/no_positioner.qml @@ -0,0 +1,37 @@ +import Qt 4.6 +import QmlTime 1.0 as QmlTime + +Item { + QmlTime.Timer { + component: Component { + Item { + Rectangle { } + Rectangle { } + Item { + Image { } + Text { } + } + + Item { + Item { + Image { } + Image { } + Item { + Image { } + Image { } + } + } + + Item { + Item { + Text { } + Text { } + } + Text { } + } + } + MouseArea { } + } + } + } +} diff --git a/tests/benchmarks/declarative/qmltime/tests/positioner_creation/null_positioner.qml b/tests/benchmarks/declarative/qmltime/tests/positioner_creation/null_positioner.qml new file mode 100644 index 0000000..36dda15 --- /dev/null +++ b/tests/benchmarks/declarative/qmltime/tests/positioner_creation/null_positioner.qml @@ -0,0 +1,34 @@ +import Qt 4.6 +import QmlTime 1.0 as QmlTime + +Item { + QmlTime.Timer { + component: Component { + Item { + Rectangle { } + Rectangle { } + Item { + Image { } + Text { } + } + + Item { + Item { + Image { } + Image { } + Row { } + Image { } + Image { } + } + + Column { } + Row { } + Text { } + Text { } + Text { } + } + MouseArea { } + } + } + } +} diff --git a/tests/benchmarks/declarative/qmltime/tests/positioner_creation/positioner.qml b/tests/benchmarks/declarative/qmltime/tests/positioner_creation/positioner.qml new file mode 100644 index 0000000..396e27d --- /dev/null +++ b/tests/benchmarks/declarative/qmltime/tests/positioner_creation/positioner.qml @@ -0,0 +1,37 @@ +import Qt 4.6 +import QmlTime 1.0 as QmlTime + +Item { + QmlTime.Timer { + component: Component { + Item { + Rectangle { } + Rectangle { } + Item { + Image { } + Text { } + } + + Item { + Item { + Image { } + Image { } + Row { + Image { } + Image { } + } + } + + Column { + Row { + Text { } + Text { } + } + Text { } + } + } + MouseArea { } + } + } + } +} -- cgit v0.12 From ef9fd657a71375b58be01efb18a16fb04a1b90f5 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 25 Mar 2010 14:00:35 +1000 Subject: Begin dragging PathView up to the level (quality and functionality) of other views. Task-number: QT-319 --- .../graphicsitems/qdeclarativepathview.cpp | 641 +++++++++++---------- .../graphicsitems/qdeclarativepathview_p.h | 25 +- .../graphicsitems/qdeclarativepathview_p_p.h | 25 +- .../qdeclarativepathview/data/pathview0.qml | 5 + .../qdeclarativepathview/data/pathview3.qml | 2 +- .../tst_qdeclarativepathview.cpp | 22 +- 6 files changed, 411 insertions(+), 309 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp index b9c8971..f3d6137 100644 --- a/src/declarative/graphicsitems/qdeclarativepathview.cpp +++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp @@ -138,6 +138,103 @@ void QDeclarativePathViewPrivate::clear() items.clear(); } +void QDeclarativePathViewPrivate::updateMappedRange() +{ + if (model && pathItems != -1 && pathItems < model->count()) + mappedRange = qreal(pathItems)/model->count(); + else + mappedRange = 1.0; +} + +qreal QDeclarativePathViewPrivate::positionOfIndex(int index) const +{ + qreal pos = -1.0; + + if (model && index >= 0 && index < model->count()) { + qreal globalPos = qreal(index) + offset; + globalPos = qmlMod(globalPos, qreal(model->count())) / model->count(); + if (pathItems != -1 && pathItems < model->count()) { + globalPos += snapPos * mappedRange; + globalPos = qmlMod(globalPos, 1.0); + if (globalPos < mappedRange) + pos = globalPos / mappedRange; + } else { + pos = qmlMod(globalPos + snapPos, 1.0); + } + } + + return pos; +} + +void QDeclarativePathViewPrivate::createHighlight() +{ + Q_Q(QDeclarativePathView); + bool changed = false; + if (highlightItem) { + delete highlightItem; + highlightItem = 0; + changed = true; + } + + QDeclarativeItem *item = 0; + if (highlightComponent) { + QDeclarativeContext *highlightContext = new QDeclarativeContext(qmlContext(q)); + QObject *nobj = highlightComponent->create(highlightContext); + if (nobj) { + highlightContext->setParent(nobj); + item = qobject_cast(nobj); + if (!item) + delete nobj; + } else { + delete highlightContext; + } + } else { + item = new QDeclarativeItem; + } + if (item) { + item->setParent(q); + highlightItem = item; + changed = true; + } + if (changed) + emit q->highlightItemChanged(); +} + +void QDeclarativePathViewPrivate::updateHighlight() +{ + Q_Q(QDeclarativePathView); + if (!q->isComponentComplete()) + return; + if (highlightItem) + updateItem(highlightItem, snapPos); +} + +void QDeclarativePathViewPrivate::updateItem(QDeclarativeItem *item, qreal percent) +{ + if (QDeclarativePathViewAttached *att = attached(item)) { + foreach(const QString &attr, path->attributes()) + att->setValue(attr.toUtf8(), path->attributeAt(attr, percent)); + } + QPointF pf = path->pointAt(percent); + item->setX(pf.x() - item->width()*item->scale()/2); + item->setY(pf.y() - item->height()*item->scale()/2); +} + +void QDeclarativePathViewPrivate::regenerate() +{ + Q_Q(QDeclarativePathView); + if (!q->isComponentComplete()) + return; + + clear(); + + if (!isValid()) + return; + + firstIndex = -1; + updateMappedRange(); + q->refill(); +} /*! \qmlclass PathView QDeclarativePathView @@ -232,6 +329,7 @@ void QDeclarativePathView::setModel(const QVariant &model) if (d->model) { disconnect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int))); disconnect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int))); + disconnect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int))); disconnect(d->model, SIGNAL(modelReset()), this, SLOT(modelReset())); disconnect(d->model, SIGNAL(createdItem(int, QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*))); for (int i=0; iitems.count(); i++){ @@ -261,13 +359,16 @@ void QDeclarativePathView::setModel(const QVariant &model) if (d->model) { connect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int))); connect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int))); + connect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int))); connect(d->model, SIGNAL(modelReset()), this, SLOT(modelReset())); connect(d->model, SIGNAL(createdItem(int, QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*))); } - d->firstIndex = 0; - d->pathOffset = 0; + d->offset = qmlMod(d->offset, qreal(d->model->count())); + if (d->offset < 0) + d->offset = d->model->count() + d->offset; d->regenerate(); d->fixOffset(); + emit countChanged(); emit modelChanged(); } @@ -330,7 +431,7 @@ void QDeclarativePathView::setCurrentIndex(int idx) if (d->model->count()) { int itemIndex = (d->currentIndex - d->firstIndex + d->model->count()) % d->model->count(); if (itemIndex < d->items.count()) { - if (QDeclarativeItem *item = d->items.at(d->currentIndex)) { + if (QDeclarativeItem *item = d->items.at(itemIndex)) { if (QDeclarativePathViewAttached *att = d->attached(item)) att->setIsCurrentItem(false); } @@ -354,12 +455,13 @@ void QDeclarativePathView::setCurrentIndex(int idx) /*! \qmlproperty real PathView::offset - The offset specifies how far along the path (0.0-1.0) the items are from their initial positions. + The offset specifies how far along the path the items are from their initial positions. + This is a real number that ranges from 0.0 to the count of items in the model. */ qreal QDeclarativePathView::offset() const { Q_D(const QDeclarativePathView); - return d->_offset; + return d->offset; } void QDeclarativePathView::setOffset(qreal offset) @@ -372,18 +474,25 @@ void QDeclarativePathView::setOffset(qreal offset) void QDeclarativePathViewPrivate::setOffset(qreal o) { Q_Q(QDeclarativePathView); - if (_offset != o) { - _offset = qmlMod(o, qreal(1.0)); - if (_offset < 0) - _offset = 1.0 + _offset; - q->refill(); + if (offset != o) { + if (isValid() && q->isComponentComplete()) { + offset = qmlMod(o, qreal(model->count())); + if (offset < 0) + offset = model->count() + offset; + q->refill(); + } else { + offset = o; + } + emit q->offsetChanged(); } } /*! \qmlproperty real PathView::snapPosition - This property determines the position (0.0-1.0) the nearest item will snap to. + This property determines the position on the path (0.0-1.0) the nearest item will snap to. + The item nearest this position will set currentIndex, for example when offset is 0.0 the + first item will be placed at this position and currentIndex will be 0. */ qreal QDeclarativePathView::snapPosition() const { @@ -398,10 +507,34 @@ void QDeclarativePathView::setSnapPosition(qreal pos) if (qFuzzyCompare(normalizedPos, d->snapPos)) return; d->snapPos = normalizedPos; + d->updateHighlight(); d->fixOffset(); emit snapPositionChanged(); } +QDeclarativeComponent *QDeclarativePathView::highlight() const +{ + Q_D(const QDeclarativePathView); + return d->highlightComponent; +} + +void QDeclarativePathView::setHighlight(QDeclarativeComponent *highlight) +{ + Q_D(QDeclarativePathView); + if (highlight != d->highlightComponent) { + d->highlightComponent = highlight; + d->createHighlight(); + d->updateHighlight(); + emit highlightChanged(); + } +} + +QDeclarativeItem *QDeclarativePathView::highlightItem() +{ + Q_D(const QDeclarativePathView); + return d->highlightItem; +} + /*! \qmlproperty real PathView::dragMargin This property holds the maximum distance from the path that initiate mouse dragging. @@ -426,6 +559,52 @@ void QDeclarativePathView::setDragMargin(qreal dragMargin) } /*! + \qmlproperty real PathView::flickDeceleration + This property holds the rate at which a flick will decelerate. + + The default is 100. +*/ +qreal QDeclarativePathView::flickDeceleration() const +{ + Q_D(const QDeclarativePathView); + return d->deceleration; +} + +void QDeclarativePathView::setFlickDeceleration(qreal dec) +{ + Q_D(QDeclarativePathView); + if (d->deceleration == dec) + return; + d->deceleration = dec; + emit flickDecelerationChanged(); +} + +/*! + \qmlproperty bool PathView::interactive + + A user cannot drag or flick a PathView that is not interactive. + + This property is useful for temporarily disabling flicking. This allows + special interaction with PathView's children. +*/ +bool QDeclarativePathView::isInteractive() const +{ + Q_D(const QDeclarativePathView); + return d->interactive; +} + +void QDeclarativePathView::setInteractive(bool interactive) +{ + Q_D(QDeclarativePathView); + if (interactive != d->interactive) { + d->interactive = interactive; + if (!interactive) + d->tl.clear(); + emit interactiveChanged(); + } +} + +/*! \qmlproperty component PathView::delegate The delegate provides a template defining each item instantiated by the view. @@ -467,7 +646,7 @@ void QDeclarativePathView::setDelegate(QDeclarativeComponent *delegate) /*! \qmlproperty int PathView::pathItemCount - This property holds the number of items visible on the path at any one time + This property holds the number of items visible on the path at any one time. */ int QDeclarativePathView::pathItemCount() const { @@ -480,9 +659,13 @@ void QDeclarativePathView::setPathItemCount(int i) Q_D(QDeclarativePathView); if (i == d->pathItems) return; + if (i < 1) + i = 1; d->pathItems = i; - d->regenerate(); - pathItemCountChanged(); + if (d->isValid() && isComponentComplete()) { + d->regenerate(); + } + emit pathItemCountChanged(); } QPointF QDeclarativePathViewPrivate::pointNear(const QPointF &point, qreal *nearPercent) const @@ -512,7 +695,7 @@ QPointF QDeclarativePathViewPrivate::pointNear(const QPointF &point, qreal *near void QDeclarativePathView::mousePressEvent(QGraphicsSceneMouseEvent *event) { Q_D(QDeclarativePathView); - if (!d->items.count()) + if (!d->interactive || !d->items.count()) return; QPointF scenePoint = mapToScene(event->pos()); int idx = 0; @@ -542,7 +725,7 @@ void QDeclarativePathView::mousePressEvent(QGraphicsSceneMouseEvent *event) void QDeclarativePathView::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { Q_D(QDeclarativePathView); - if (d->lastPosTime.isNull()) + if (!d->interactive || d->lastPosTime.isNull()) return; if (!d->stealMouse) { @@ -555,14 +738,14 @@ void QDeclarativePathView::mouseMoveEvent(QGraphicsSceneMouseEvent *event) d->moveReason = QDeclarativePathViewPrivate::Mouse; qreal newPc; d->pointNear(event->pos(), &newPc); - qreal diff = newPc - d->startPc; + qreal diff = (newPc - d->startPc)*d->model->count()*d->mappedRange; if (diff) { - setOffset(d->_offset + diff); + setOffset(d->offset + diff); - if (diff > 0.5) - diff -= 1.0; - else if (diff < -0.5) - diff += 1.0; + if (diff > d->model->count()/2) + diff -= d->model->count(); + else if (diff < -d->model->count()/2) + diff += d->model->count(); d->lastElapsed = QDeclarativeItemPrivate::restart(d->lastPosTime); d->lastDist = diff; @@ -574,27 +757,37 @@ void QDeclarativePathView::mouseMoveEvent(QGraphicsSceneMouseEvent *event) void QDeclarativePathView::mouseReleaseEvent(QGraphicsSceneMouseEvent *) { Q_D(QDeclarativePathView); - if (d->lastPosTime.isNull()) + d->stealMouse = false; + setKeepMouseGrab(false); + if (!d->interactive || d->lastPosTime.isNull()) return; qreal elapsed = qreal(d->lastElapsed + QDeclarativeItemPrivate::elapsed(d->lastPosTime)) / 1000.; qreal velocity = elapsed > 0. ? d->lastDist / elapsed : 0; - if (d->model && d->model->count() && qAbs(velocity) > 0.05) { - if (velocity > 1.5) - velocity = 1.5; - else if (velocity < -1.5) - velocity = -1.5; - qreal inc = qmlMod(d->_offset - d->snapPos, qreal(1.0 / d->model->count())); - qreal dist = qAbs(velocity/2 - qmlMod(velocity/2, qreal(1.0 / d->model->count()) - inc)); - d->moveOffset.setValue(d->_offset); - d->tl.accel(d->moveOffset, velocity, 0.1, dist); + if (d->model && d->model->count() && qAbs(velocity) > 1.) { + qreal count = d->pathItems == -1 ? d->model->count() : d->pathItems; + if (qAbs(velocity) > count * 2) // limit velocity + velocity = (velocity > 0 ? count : -count) * 2; + // Calculate the distance to be travelled + qreal v2 = velocity*velocity; + qreal accel = d->deceleration; + // + 0.25 to encourage moving at least one item in the flick direction + qreal dist = qMin(qreal(d->model->count()-1), d->model->count() * v2 / (accel * 2.0) + 0.25); + // round to nearest item. + if (velocity > 0.) + dist = qRound(dist + d->offset) - d->offset; + else + dist = qRound(dist - d->offset) + d->offset; + // Calculate accel required to stop on item boundary + accel = v2 / (2.0f * qAbs(dist)); + d->moveOffset.setValue(d->offset); + d->tl.accel(d->moveOffset, velocity, accel, dist); d->tl.callback(QDeclarativeTimeLineCallback(&d->moveOffset, d->fixOffsetCallback, d)); } else { d->fixOffset(); } d->lastPosTime = QTime(); - d->stealMouse = false; ungrabMouse(); } @@ -644,7 +837,8 @@ bool QDeclarativePathView::sendMouseEvent(QGraphicsSceneMouseEvent *event) bool QDeclarativePathView::sceneEventFilter(QGraphicsItem *i, QEvent *e) { - if (!isVisible()) + Q_D(QDeclarativePathView); + if (!isVisible() || !d->interactive) return QDeclarativeItem::sceneEventFilter(i, e); switch (e->type()) { @@ -669,72 +863,7 @@ void QDeclarativePathView::componentComplete() Q_D(QDeclarativePathView); QDeclarativeItem::componentComplete(); d->regenerate(); - - // move to correct offset - if (d->items.count()) { - int itemIndex = (d->currentIndex - d->firstIndex + d->model->count()) % d->model->count(); - - itemIndex += d->pathOffset; - itemIndex %= d->items.count(); - qreal targetOffset = qmlMod(1.0 + d->snapPos - qreal(itemIndex) / d->items.count(), qreal(1.0)); - - if (targetOffset < 0) - targetOffset = 1.0 + targetOffset; - if (targetOffset != d->_offset) { - d->moveOffset.setValue(targetOffset); - } - } -} - -void QDeclarativePathViewPrivate::regenerate() -{ - Q_Q(QDeclarativePathView); - if (!q->isComponentComplete()) - return; - - clear(); - - if (!isValid()) - return; - - if (firstIndex >= model->count()) - firstIndex = model->count()-1; - if (pathOffset >= model->count()) - pathOffset = model->count()-1; - - int numItems = pathItems >= 0 ? pathItems : model->count(); - for (int i=0; i < numItems && i < model->count(); ++i){ - int index = (i + firstIndex) % model->count(); - QDeclarativeItem *item = getItem(index); - if (!item) { - qWarning() << "PathView: Cannot create item, index" << (i + firstIndex) % model->count(); - return; - } - items.append(item); - item->setZValue(i); - qreal percent = qreal(i) / numItems + _offset; - percent = qAbs(qmlMod(percent, qreal(1.0))); - updateItem(item, percent); - model->completeItem(); - if (currentIndex == index) { - item->setFocus(true); - if (QDeclarativePathViewAttached *att = attached(item)) - att->setIsCurrentItem(true); - } - } - if (pathItems != -1) - q->refill(); -} - -void QDeclarativePathViewPrivate::updateItem(QDeclarativeItem *item, qreal percent) -{ - if (QDeclarativePathViewAttached *att = attached(item)) { - foreach(const QString &attr, path->attributes()) - att->setValue(attr.toUtf8(), path->attributeAt(attr, percent)); - } - QPointF pf = path->pointAt(percent); - item->setX(pf.x() - item->width()*item->scale()/2); - item->setY(pf.y() - item->height()*item->scale()/2); + d->updateHighlight(); } void QDeclarativePathView::refill() @@ -743,81 +872,85 @@ void QDeclarativePathView::refill() if (!d->isValid() || !isComponentComplete()) return; - QList positions; - for (int i=0; iitems.count(); i++){ - qreal percent = qreal(i) / d->items.count(); - percent = percent + d->_offset; - percent = qmlMod(percent, qreal(1.0)); - positions << qAbs(percent); - } - - if (d->pathItems==-1) { - for (int i=0; iupdateItem(d->items.at(i), positions[i]); - return; +// qDebug() << "offset" << d->_offset; + + // first move existing items and remove items off path + int idx = d->firstIndex; + QList::iterator it = d->items.begin(); + while (it != d->items.end()) { + qreal pos = d->positionOfIndex(idx); + QDeclarativeItem *item = *it; + if (pos >= 0.0) { + d->updateItem(item, pos); + ++it; + } else { +// qDebug() << "release"; + d->updateItem(item, 1.0); + d->releaseItem(item); + if (it == d->items.begin()) { + if (++d->firstIndex >= d->model->count()) + d->firstIndex = 0; + } + it = d->items.erase(it); + } + ++idx; + if (idx >= d->model->count()) + idx = 0; } - QList rotatedPositions; - for (int i=0; iitems.count(); i++) - rotatedPositions << positions[(i + d->pathOffset + d->items.count()) % d->items.count()]; - - int wrapIndex= -1; - for (int i=0; iitems.count()-1; i++) { - if (rotatedPositions[i] > rotatedPositions[i+1]){ - wrapIndex = i; - break; + // add items to beginning and end + int count = d->pathItems == -1 ? d->model->count() : qMin(d->pathItems, d->model->count()); + if (d->items.count() < count) { + int idx = qRound(d->model->count() - d->offset) % d->model->count(); + qreal startPos = d->snapPos; + if (d->firstIndex >= 0) { + startPos = d->positionOfIndex(d->firstIndex); + idx = (d->firstIndex + d->items.count()) % d->model->count(); } - } - if (wrapIndex != -1 ){ - //A wraparound has occured - if (wrapIndex < d->items.count()/2){ - while(wrapIndex-- >= 0){ - QDeclarativeItem* p = d->items.takeFirst(); - d->updateItem(p, 0.0); - d->releaseItem(p); - d->firstIndex++; - d->firstIndex %= d->model->count(); - int index = (d->firstIndex + d->items.count())%d->model->count(); - QDeclarativeItem *item = d->getItem(index); - item->setZValue(wrapIndex); - d->model->completeItem(); - if (d->currentIndex == index) { - item->setFocus(true); - if (QDeclarativePathViewAttached *att = d->attached(item)) - att->setIsCurrentItem(true); - } - d->items << item; - d->pathOffset++; - d->pathOffset=d->pathOffset % d->items.count(); + qreal pos = d->positionOfIndex(idx); + while ((pos > startPos || !d->items.count()) && d->items.count() < count) { +// qDebug() << "append" << idx; + QDeclarativeItem *item = d->getItem(idx); + item->setZValue(idx+1); + d->model->completeItem(); + if (d->currentIndex == idx) { + item->setFocus(true); + if (QDeclarativePathViewAttached *att = d->attached(item)) + att->setIsCurrentItem(true); } - } else { - while(wrapIndex++ < d->items.count()-1){ - QDeclarativeItem* p = d->items.takeLast(); - d->updateItem(p, 1.0); - d->releaseItem(p); - d->firstIndex--; - if (d->firstIndex < 0) - d->firstIndex = d->model->count() - 1; - QDeclarativeItem *item = d->getItem(d->firstIndex); - item->setZValue(d->firstIndex); - d->model->completeItem(); - if (d->currentIndex == d->firstIndex) { - item->setFocus(true); - if (QDeclarativePathViewAttached *att = d->attached(item)) - att->setIsCurrentItem(true); - } - d->items.prepend(item); - d->pathOffset--; - if (d->pathOffset < 0) - d->pathOffset = d->items.count() - 1; + if (d->items.count() == 0) + d->firstIndex = idx; + d->items.append(item); + d->updateItem(item, pos); + ++idx; + if (idx >= d->model->count()) + idx = 0; + pos = d->positionOfIndex(idx); + } + + idx = d->firstIndex - 1; + if (idx < 0) + idx = d->model->count() - 1; + pos = d->positionOfIndex(idx); + while (pos >= 0.0 && pos < startPos) { +// qDebug() << "prepend" << idx; + QDeclarativeItem *item = d->getItem(idx); + item->setZValue(idx+1); + d->model->completeItem(); + if (d->currentIndex == idx) { + item->setFocus(true); + if (QDeclarativePathViewAttached *att = d->attached(item)) + att->setIsCurrentItem(true); } + d->items.prepend(item); + d->updateItem(item, pos); + d->firstIndex = idx; + idx = d->firstIndex - 1; + if (idx < 0) + idx = d->model->count() - 1; + pos = d->positionOfIndex(idx); } - for (int i=0; iitems.count(); i++) - rotatedPositions[i] = positions[(i + d->pathOffset + d->items.count()) - % d->items.count()]; } - for (int i=0; iitems.count(); i++) - d->updateItem(d->items.at(i), rotatedPositions[i]); } void QDeclarativePathView::itemsInserted(int modelIndex, int count) @@ -826,29 +959,14 @@ void QDeclarativePathView::itemsInserted(int modelIndex, int count) Q_D(QDeclarativePathView); if (!d->isValid() || !isComponentComplete()) return; - if (d->pathItems == -1) { - for (int i = 0; i < count; ++i) { - QDeclarativeItem *item = d->getItem(modelIndex + i); - item->setZValue(modelIndex + i); - d->model->completeItem(); - d->items.insert(modelIndex + i, item); - } - refill(); - } else { - //XXX This is pretty heavy handed until we reference count items. - d->regenerate(); - } - // make sure the current item is still at the snap position - int itemIndex = (d->currentIndex - d->firstIndex + d->model->count())%d->model->count(); - itemIndex += d->pathOffset; - itemIndex %= d->items.count(); - qreal targetOffset = qmlMod(1.0 + d->snapPos - qreal(itemIndex) / d->items.count(), qreal(1.0)); - - if (targetOffset < 0) - targetOffset = 1.0 + targetOffset; - if (targetOffset != d->_offset) - d->moveOffset.setValue(targetOffset); + QList removedItems = d->items; + d->items.clear(); + d->regenerate(); + while (removedItems.count()) + d->releaseItem(removedItems.takeLast()); + d->updateCurrent(); + emit countChanged(); } void QDeclarativePathView::itemsRemoved(int modelIndex, int count) @@ -857,41 +975,37 @@ void QDeclarativePathView::itemsRemoved(int modelIndex, int count) Q_D(QDeclarativePathView); if (!d->isValid() || !isComponentComplete()) return; - if (d->pathItems == -1) { - for (int i = 0; i < count && d->items.count() > modelIndex; ++i) { - QDeclarativeItem* p = d->items.takeAt(modelIndex); - d->model->release(p); - } - d->snapToCurrent(); - refill(); - } else { - d->regenerate(); - } - if (d->model->count() == 0) { - d->currentIndex = -1; - d->moveOffset.setValue(0); + QList removedItems = d->items; + d->items.clear(); + if (d->offset >= d->model->count()) + d->offset = d->model->count() - 1; + d->regenerate(); + while (removedItems.count()) + d->releaseItem(removedItems.takeLast()); + d->updateCurrent(); + emit countChanged(); +} + +void QDeclarativePathView::itemsMoved(int from, int to, int count) +{ + Q_D(QDeclarativePathView); + if (!d->isValid() || !isComponentComplete()) return; - } - // make sure the current item is still at the snap position - if (d->currentIndex >= d->model->count()) - d->currentIndex = d->model->count() - 1; - int itemIndex = (d->currentIndex - d->firstIndex + d->model->count())%d->model->count(); - itemIndex += d->pathOffset; - itemIndex %= d->items.count(); - qreal targetOffset = qmlMod(1.0 + d->snapPos - qreal(itemIndex) / d->items.count(), qreal(1.0)); - - if (targetOffset < 0) - targetOffset = 1.0 + targetOffset; - if (targetOffset != d->_offset) - d->moveOffset.setValue(targetOffset); + QList removedItems = d->items; + d->items.clear(); + d->regenerate(); + while (removedItems.count()) + d->releaseItem(removedItems.takeLast()); + d->updateCurrent(); } void QDeclarativePathView::modelReset() { Q_D(QDeclarativePathView); d->regenerate(); + emit countChanged(); } void QDeclarativePathView::createdItem(int index, QDeclarativeItem *item) @@ -919,36 +1033,10 @@ int QDeclarativePathViewPrivate::calcCurrentIndex() { int current = -1; if (model && items.count()) { - _offset = qmlMod(_offset, qreal(1.0)); - if (_offset < 0) - _offset += 1.0; - - if (pathItems == -1) { - qreal delta = qmlMod(_offset - snapPos, qreal(1.0)); - if (delta < 0) - delta = 1.0 + delta; - int ii = model->count() - qRound(delta * model->count()); - if (ii < 0) - ii = 0; - current = ii; - } else { - qreal bestDiff=1e9; - int bestI=-1; - for (int i=0; icount()); + offset = qmlMod(offset, model->count()); + if (offset < 0) + offset += model->count(); + current = qRound(qAbs(qmlMod(model->count() - offset, model->count()))); } return current; @@ -1002,57 +1090,26 @@ void QDeclarativePathViewPrivate::snapToCurrent() if (!model || model->count() <= 0) return; - int itemIndex = (currentIndex - firstIndex + model->count()) % model->count(); - - //Rounds is the number of times round to make the current item visible - int rounds = itemIndex / items.count(); - int otherWayRounds = (model->count() - (itemIndex)) / items.count(); - if (otherWayRounds < rounds) - rounds = -otherWayRounds; - - itemIndex += pathOffset; - if(model->count() % items.count() && itemIndex - model->count() + items.count() > 0){ - //When model.count() is not a multiple of pathItemCount we need to manually - //fix the index so that going backwards one step works correctly. - itemIndex = itemIndex - model->count() + items.count(); - } - itemIndex %= items.count(); - qreal targetOffset = qmlMod(1.0 + snapPos - qreal(itemIndex) / items.count(), qreal(1.0)); - - if (targetOffset < 0) - targetOffset = 1.0 + targetOffset; - if (targetOffset == _offset && rounds == 0) - return; + qreal targetOffset = model->count() - currentIndex; moveReason = Other; tl.clear(); - moveOffset.setValue(_offset); - - if (rounds!=0){ - //Compensate if the targetOffset would bring the target in from off the screen - qreal distance = targetOffset - _offset; - if (distance <= -0.5) - rounds--; - if (distance > 0.5) - rounds++; - tl.move(moveOffset, targetOffset -rounds, QEasingCurve(QEasingCurve::InOutQuad), - int(items.count()*qMax((qreal)(2.0/items.count()),(qreal)qAbs(rounds)))); - tl.callback(QDeclarativeTimeLineCallback(&moveOffset, fixOffsetCallback, this)); - return; - } - - if (targetOffset - _offset > 0.5) { - qreal distance = 1 - targetOffset + _offset; - tl.move(moveOffset, 0.0, QEasingCurve(QEasingCurve::OutQuad), int(200 * _offset / distance)); - tl.set(moveOffset, 1.0); - tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::InQuad), int(200 * (1.0-targetOffset) / distance)); - } else if (targetOffset - _offset <= -0.5) { - qreal distance = 1 - _offset + targetOffset; - tl.move(moveOffset, 1.0, QEasingCurve(QEasingCurve::OutQuad), int(200 * (1.0-_offset) / distance)); + moveOffset.setValue(offset); + + const int duration = 300; + + if (targetOffset - offset > model->count()/2) { + qreal distance = model->count() - targetOffset + offset; + tl.move(moveOffset, 0.0, QEasingCurve(QEasingCurve::InQuad), int(duration * offset / distance)); + tl.set(moveOffset, model->count()); + tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::OutQuad), int(duration * (model->count()-targetOffset) / distance)); + } else if (targetOffset - offset <= -model->count()/2) { + qreal distance = model->count() - offset + targetOffset; + tl.move(moveOffset, model->count(), QEasingCurve(QEasingCurve::InQuad), int(duration * (model->count()-offset) / distance)); tl.set(moveOffset, 0.0); - tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::InQuad), int(200 * targetOffset / distance)); + tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::OutQuad), int(duration * targetOffset / distance)); } else { - tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::InOutQuad), 200); + tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::InOutQuad), duration); } } diff --git a/src/declarative/graphicsitems/qdeclarativepathview_p.h b/src/declarative/graphicsitems/qdeclarativepathview_p.h index 6dbd044..07b8f6f 100644 --- a/src/declarative/graphicsitems/qdeclarativepathview_p.h +++ b/src/declarative/graphicsitems/qdeclarativepathview_p.h @@ -62,8 +62,15 @@ class Q_DECLARATIVE_EXPORT QDeclarativePathView : public QDeclarativeItem Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged) Q_PROPERTY(qreal offset READ offset WRITE setOffset NOTIFY offsetChanged) Q_PROPERTY(qreal snapPosition READ snapPosition WRITE setSnapPosition NOTIFY snapPositionChanged) + + Q_PROPERTY(QDeclarativeComponent *highlight READ highlight WRITE setHighlight NOTIFY highlightChanged) + Q_PROPERTY(QDeclarativeItem *highlightItem READ highlightItem NOTIFY highlightItemChanged) + Q_PROPERTY(qreal dragMargin READ dragMargin WRITE setDragMargin NOTIFY dragMarginChanged) - Q_PROPERTY(int count READ count) + Q_PROPERTY(qreal flickDeceleration READ flickDeceleration WRITE setFlickDeceleration NOTIFY flickDecelerationChanged) + Q_PROPERTY(bool interactive READ isInteractive WRITE setInteractive NOTIFY interactiveChanged) + + Q_PROPERTY(int count READ count NOTIFY countChanged) Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged) Q_PROPERTY(int pathItemCount READ pathItemCount WRITE setPathItemCount NOTIFY pathItemCountChanged) @@ -86,9 +93,19 @@ public: qreal snapPosition() const; void setSnapPosition(qreal pos); + QDeclarativeComponent *highlight() const; + void setHighlight(QDeclarativeComponent *highlight); + QDeclarativeItem *highlightItem(); + qreal dragMargin() const; void setDragMargin(qreal margin); + qreal flickDeceleration() const; + void setFlickDeceleration(qreal dec); + + bool isInteractive() const; + void setInteractive(bool); + int count() const; QDeclarativeComponent *delegate() const; @@ -103,11 +120,16 @@ Q_SIGNALS: void currentIndexChanged(); void offsetChanged(); void modelChanged(); + void countChanged(); void pathChanged(); void dragMarginChanged(); void snapPositionChanged(); void delegateChanged(); void pathItemCountChanged(); + void flickDecelerationChanged(); + void interactiveChanged(); + void highlightChanged(); + void highlightItemChanged(); protected: void mousePressEvent(QGraphicsSceneMouseEvent *event); @@ -122,6 +144,7 @@ private Q_SLOTS: void ticked(); void itemsInserted(int index, int count); void itemsRemoved(int index, int count); + void itemsMoved(int,int,int); void modelReset(); void createdItem(int index, QDeclarativeItem *item); void destroyingItem(QDeclarativeItem *item); diff --git a/src/declarative/graphicsitems/qdeclarativepathview_p_p.h b/src/declarative/graphicsitems/qdeclarativepathview_p_p.h index 62f7d95..1780869 100644 --- a/src/declarative/graphicsitems/qdeclarativepathview_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativepathview_p_p.h @@ -75,17 +75,18 @@ class QDeclarativePathViewPrivate : public QDeclarativeItemPrivate public: QDeclarativePathViewPrivate() : path(0), currentIndex(0), startPc(0), lastDist(0) - , lastElapsed(0), stealMouse(false), ownModel(false), activeItem(0) - , snapPos(0), dragMargin(0), moveOffset(this, &QDeclarativePathViewPrivate::setOffset) - , firstIndex(0), pathItems(-1), pathOffset(0), requestedIndex(-1) - , moveReason(Other), attType(0) + , lastElapsed(0), mappedRange(1.0), stealMouse(false), ownModel(false), interactive(true) + , snapPos(0), dragMargin(0), deceleration(100) + , moveOffset(this, &QDeclarativePathViewPrivate::setOffset) + , firstIndex(-1), pathItems(-1), requestedIndex(-1) + , moveReason(Other), attType(0), highlightComponent(0), highlightItem(0) { } void init() { Q_Q(QDeclarativePathView); - _offset = 0; + offset = 0; q->setAcceptedMouseButtons(Qt::LeftButton); q->setFlag(QGraphicsItem::ItemIsFocusScope); q->setFiltersChildEvents(true); @@ -96,7 +97,10 @@ public: void releaseItem(QDeclarativeItem *item); QDeclarativePathViewAttached *attached(QDeclarativeItem *item); void clear(); - + void updateMappedRange(); + qreal positionOfIndex(int index) const; + void createHighlight(); + void updateHighlight(); bool isValid() const { return model && model->count() > 0 && model->isValid() && path; } @@ -117,19 +121,20 @@ public: QPointF startPoint; qreal lastDist; int lastElapsed; - qreal _offset; + qreal offset; + qreal mappedRange; bool stealMouse : 1; bool ownModel : 1; + bool interactive : 1; QTime lastPosTime; QPointF lastPos; - QDeclarativeItem *activeItem; qreal snapPos; qreal dragMargin; + qreal deceleration; QDeclarativeTimeLine tl; QDeclarativeTimeLineValueProxy moveOffset; int firstIndex; int pathItems; - int pathOffset; int requestedIndex; QList items; QDeclarativeGuard model; @@ -137,6 +142,8 @@ public: enum MovementReason { Other, Key, Mouse }; MovementReason moveReason; QDeclarativeOpenMetaObjectType *attType; + QDeclarativeComponent *highlightComponent; + QDeclarativeItem *highlightItem; }; QT_END_NAMESPACE diff --git a/tests/auto/declarative/qdeclarativepathview/data/pathview0.qml b/tests/auto/declarative/qdeclarativepathview/data/pathview0.qml index ae0c86a..8e2c251 100644 --- a/tests/auto/declarative/qdeclarativepathview/data/pathview0.qml +++ b/tests/auto/declarative/qdeclarativepathview/data/pathview0.qml @@ -49,6 +49,11 @@ Rectangle { model: testModel delegate: delegate snapPosition: 0.0001 + highlight: Rectangle { + width: 60 + height: 20 + color: "yellow" + } path: Path { startY: 120 startX: 160 diff --git a/tests/auto/declarative/qdeclarativepathview/data/pathview3.qml b/tests/auto/declarative/qdeclarativepathview/data/pathview3.qml index 70cfbcd..f1bc66e 100644 --- a/tests/auto/declarative/qdeclarativepathview/data/pathview3.qml +++ b/tests/auto/declarative/qdeclarativepathview/data/pathview3.qml @@ -2,7 +2,7 @@ import Qt 4.6 PathView { id: photoPathView - y: 100; width: 800; height: 330; pathItemCount: 4; offset: 0.1 + y: 100; width: 800; height: 330; pathItemCount: 4; offset: 1 dragMargin: 24; snapPosition: 0.50 path: Path { diff --git a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp index c16c46f..6d7cc0d 100644 --- a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp +++ b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp @@ -219,7 +219,7 @@ void tst_QDeclarativePathView::items() QDeclarativePathView *pathview = findItem(canvas->rootObject(), "view"); QVERIFY(pathview != 0); - QCOMPARE(pathview->childItems().count(), model.count()); // assumes all are visible + QCOMPARE(pathview->childItems().count(), model.count()+1); // assumes all are visible, including highlight for (int i = 0; i < model.count(); ++i) { QDeclarativeText *name = findItem(pathview, "textName", i); @@ -230,6 +230,16 @@ void tst_QDeclarativePathView::items() QCOMPARE(number->text(), model.number(i)); } + QDeclarativePath *path = qobject_cast(pathview->path()); + QVERIFY(path); + + QVERIFY(pathview->highlightItem()); + QPointF start = path->pointAt(0.0); + QPointF offset; + offset.setX(pathview->highlightItem()->width()/2); + offset.setY(pathview->highlightItem()->height()/2); + QCOMPARE(pathview->highlightItem()->pos() + offset, start); + delete canvas; } @@ -262,8 +272,8 @@ void tst_QDeclarativePathView::pathview3() QVERIFY(obj->delegate() != 0); QVERIFY(obj->model() != QVariant()); QCOMPARE(obj->currentIndex(), 0); - QCOMPARE(obj->offset(), 0.5); // ??? - QCOMPARE(obj->snapPosition(), 0.5); // ??? + QCOMPARE(obj->offset(), 1.0); + QCOMPARE(obj->snapPosition(), 0.5); QCOMPARE(obj->dragMargin(), 24.); QCOMPARE(obj->count(), 8); QCOMPARE(obj->pathItemCount(), 4); @@ -422,14 +432,14 @@ void tst_QDeclarativePathView::pathMoved() offset.setX(firstItem->width()/2); offset.setY(firstItem->height()/2); QCOMPARE(firstItem->pos() + offset, start); - pathview->setOffset(0.1); + pathview->setOffset(1.0); for(int i=0; i(pathview, "wrapper", i); - QCOMPARE(curItem->pos() + offset, path->pointAt(0.1 + i*0.25)); + QCOMPARE(curItem->pos() + offset, path->pointAt(0.25 + i*0.25)); } - pathview->setOffset(1.0); + pathview->setOffset(0.0); QCOMPARE(firstItem->pos() + offset, start); delete canvas; -- cgit v0.12 From 72599ca45c416f2f0a9654412c14a148ca3d728c Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 25 Mar 2010 17:49:33 +1000 Subject: Optimize QML "parent" property access For properties that are as important as "parent", QML cannot afford the overhead of a signal/slot connection. --- src/declarative/graphicsitems/qdeclarativeitem.cpp | 11 ++- src/declarative/graphicsitems/qdeclarativeitem_p.h | 6 ++ .../qml/qdeclarativecompiledbindings.cpp | 88 ++++++++++++++++++---- src/declarative/qml/qml.pri | 2 + 4 files changed, 91 insertions(+), 16 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index e6ade00..ee0682a 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -1554,6 +1554,14 @@ void QDeclarativeItemPrivate::transform_clear(QDeclarativeListProperty(o); + if (e) + e->connect(&item->d_func()->parentNotifier); + *((QDeclarativeItem **)rv) = item->parentItem(); +} + /*! \qmlproperty list Item::data \default @@ -2539,10 +2547,11 @@ bool QDeclarativeItem::sceneEvent(QEvent *event) QVariant QDeclarativeItem::itemChange(GraphicsItemChange change, const QVariant &value) { - Q_D(const QDeclarativeItem); + Q_D(QDeclarativeItem); switch (change) { case ItemParentHasChanged: emit parentChanged(parentItem()); + d->parentNotifier.notify(); break; case ItemChildAddedChange: case ItemChildRemovedChange: diff --git a/src/declarative/graphicsitems/qdeclarativeitem_p.h b/src/declarative/graphicsitems/qdeclarativeitem_p.h index 56b0d77..4828f4e 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem_p.h +++ b/src/declarative/graphicsitems/qdeclarativeitem_p.h @@ -62,6 +62,8 @@ #include #include +#include + #include #include @@ -160,6 +162,10 @@ public: static QGraphicsTransform *transform_at(QDeclarativeListProperty *list, int); static void transform_clear(QDeclarativeListProperty *list); + // Accelerated property accessors + QDeclarativeNotifier parentNotifier; + static void parentProperty(QObject *o, void *rv, QDeclarativeNotifierEndpoint *e); + QDeclarativeAnchors *anchors() { if (!_anchors) { Q_Q(QDeclarativeItem); diff --git a/src/declarative/qml/qdeclarativecompiledbindings.cpp b/src/declarative/qml/qdeclarativecompiledbindings.cpp index 1acca2f..67750a4 100644 --- a/src/declarative/qml/qdeclarativecompiledbindings.cpp +++ b/src/declarative/qml/qdeclarativecompiledbindings.cpp @@ -53,11 +53,15 @@ #include #include #include +#include QT_BEGIN_NAMESPACE DEFINE_BOOL_CONFIG_OPTION(qmlExperimental, QML_EXPERIMENTAL); DEFINE_BOOL_CONFIG_OPTION(qmlDisableOptimizer, QML_DISABLE_OPTIMIZER); +DEFINE_BOOL_CONFIG_OPTION(qmlDisableFastProperties, QML_DISABLE_FAST_PROPERTIES); + +Q_GLOBAL_STATIC(QDeclarativeFastProperties, fastProperties); using namespace QDeclarativeJS; @@ -334,6 +338,8 @@ struct Instr { Subscribe, // subscribe SubscribeId, // subscribe + FetchAndSubscribe, // fetchAndSubscribe + LoadId, // load LoadScope, // load LoadRoot, // load @@ -433,6 +439,14 @@ struct Instr { qint8 output; qint8 objectReg; quint8 exceptionId; + quint16 subscription; + quint16 function; + } fetchAndSubscribe; + struct { + quint8 type; + qint8 output; + qint8 objectReg; + quint8 exceptionId; quint32 index; } fetch; struct { @@ -937,6 +951,9 @@ static void dumpInstruction(const Instr *instr) case Instr::SubscribeId: qWarning().nospace() << "SubscribeId" << "\t\t" << instr->subscribe.offset << "\t" << instr->subscribe.reg << "\t" << instr->subscribe.index; break; + case Instr::FetchAndSubscribe: + qWarning().nospace() << "FetchAndSubscribe" << "\t" << instr->fetchAndSubscribe.output << "\t" << instr->fetchAndSubscribe.objectReg << "\t" << instr->fetchAndSubscribe.subscription; + break; case Instr::LoadId: qWarning().nospace() << "LoadId" << "\t\t\t" << instr->load.index << "\t" << instr->load.reg; break; @@ -1070,6 +1087,8 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex, QDeclarativeContextData *context, QDeclarativeDelayedError *error, QObject *scope, QObject *output) { + Q_Q(QDeclarativeCompiledBindings); + error->removeError(); Register registers[32]; @@ -1081,6 +1100,7 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex, instr += instrIndex; const char *data = program->data(); + // return; #ifdef COMPILEDBINDINGS_DEBUG qWarning().nospace() << "Begin binding run"; #endif @@ -1107,6 +1127,32 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex, } break; + case Instr::FetchAndSubscribe: + { + const Register &input = registers[instr->fetchAndSubscribe.objectReg]; + Register &output = registers[instr->fetchAndSubscribe.output]; + + if (input.isUndefined()) { + throwException(instr->fetchAndSubscribe.exceptionId, error, program, context); + return; + } + + QObject *object = input.getQObject(); + if (!object) { + output.setUndefined(); + } else { + int subIdx = instr->fetchAndSubscribe.subscription; + QDeclarativeCompiledBindingsPrivate::Subscription *sub = 0; + if (subIdx != -1) { + sub = (subscriptions + subIdx); + sub->target = q; + sub->targetMethod = methodCount + subIdx; + } + fastProperties()->accessor(instr->fetchAndSubscribe.function)(object, output.typeDataPtr(), sub); + } + } + break; + case Instr::LoadId: registers[instr->load.reg].setQObject(context->idValues[instr->load.index].data()); break; @@ -2376,29 +2422,41 @@ bool QDeclarativeBindingCompilerPrivate::buildName(QStringList &name, return true; } - bool QDeclarativeBindingCompilerPrivate::fetch(Result &rv, const QMetaObject *mo, int reg, - int idx, const QStringList &subName, QDeclarativeJS::AST::ExpressionNode *node) + int idx, const QStringList &subName, + QDeclarativeJS::AST::ExpressionNode *node) { QMetaProperty prop = mo->property(idx); rv.metaObject = 0; rv.type = 0; - if (subscription(subName, &rv) && prop.hasNotifySignal() && prop.notifySignalIndex() != -1) { - Instr sub; - sub.common.type = Instr::Subscribe; - sub.subscribe.offset = subscriptionIndex(subName); - sub.subscribe.reg = reg; - sub.subscribe.index = prop.notifySignalIndex(); - bytecode << sub; - } + int fastFetchIndex = fastProperties()->accessorIndexForProperty(mo, idx); Instr fetch; - fetch.common.type = Instr::Fetch; - fetch.fetch.objectReg = reg; - fetch.fetch.index = idx; - fetch.fetch.output = reg; - fetch.fetch.exceptionId = exceptionId(node); + + if (!qmlDisableFastProperties() && fastFetchIndex != -1) { + fetch.common.type = Instr::FetchAndSubscribe; + fetch.fetchAndSubscribe.objectReg = reg; + fetch.fetchAndSubscribe.output = reg; + fetch.fetchAndSubscribe.function = fastFetchIndex; + fetch.fetchAndSubscribe.subscription = subscriptionIndex(subName); + fetch.fetchAndSubscribe.exceptionId = exceptionId(node); + } else { + if (subscription(subName, &rv) && prop.hasNotifySignal() && prop.notifySignalIndex() != -1) { + Instr sub; + sub.common.type = Instr::Subscribe; + sub.subscribe.offset = subscriptionIndex(subName); + sub.subscribe.reg = reg; + sub.subscribe.index = prop.notifySignalIndex(); + bytecode << sub; + } + + fetch.common.type = Instr::Fetch; + fetch.fetch.objectReg = reg; + fetch.fetch.index = idx; + fetch.fetch.output = reg; + fetch.fetch.exceptionId = exceptionId(node); + } rv.type = prop.userType(); rv.metaObject = engine->metaObjectForType(rv.type); diff --git a/src/declarative/qml/qml.pri b/src/declarative/qml/qml.pri index 49888c3..fc8ba50 100644 --- a/src/declarative/qml/qml.pri +++ b/src/declarative/qml/qml.pri @@ -31,6 +31,7 @@ SOURCES += \ $$PWD/qdeclarativerewrite.cpp \ $$PWD/qdeclarativevaluetype.cpp \ $$PWD/qdeclarativecompiledbindings.cpp \ + $$PWD/qdeclarativefastproperties.cpp \ $$PWD/qdeclarativexmlhttprequest.cpp \ $$PWD/qdeclarativesqldatabase.cpp \ $$PWD/qmetaobjectbuilder.cpp \ @@ -103,6 +104,7 @@ HEADERS += \ $$PWD/qbitfield_p.h \ $$PWD/qdeclarativevaluetype_p.h \ $$PWD/qdeclarativecompiledbindings_p.h \ + $$PWD/qdeclarativefastproperties_p.h \ $$PWD/qdeclarativexmlhttprequest_p.h \ $$PWD/qdeclarativesqldatabase_p.h \ $$PWD/qmetaobjectbuilder_p.h \ -- cgit v0.12