/tests/auto/qplaintextedit/

.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 490cd29001670b37204dcf5e24398073f610fabd Mon Sep 17 00:00:00 2001 From: Justin McPherson Date: Thu, 25 Mar 2010 13:50:08 +1000 Subject: Update Phonon core to 4.4.0 --- src/3rdparty/phonon/phonon/CMakeLists.txt | 35 ++ src/3rdparty/phonon/phonon/audiooutput.cpp | 106 +++++- src/3rdparty/phonon/phonon/audiooutput.h | 1 + src/3rdparty/phonon/phonon/audiooutput_p.h | 8 +- src/3rdparty/phonon/phonon/audiooutputinterface.h | 2 +- src/3rdparty/phonon/phonon/backendcapabilities.cpp | 2 +- src/3rdparty/phonon/phonon/factory.cpp | 25 +- src/3rdparty/phonon/phonon/factory_p.h | 7 + src/3rdparty/phonon/phonon/globalconfig.cpp | 358 ++++++++++++++++----- src/3rdparty/phonon/phonon/globalconfig_p.h | 31 +- src/3rdparty/phonon/phonon/mediaobject.cpp | 12 +- src/3rdparty/phonon/phonon/objectdescription.cpp | 44 ++- .../phonon/phonon/objectdescriptionmodel.cpp | 2 + .../phonon/phonon/objectdescriptionmodel.h | 36 +-- src/3rdparty/phonon/phonon/path.cpp | 8 +- src/3rdparty/phonon/phonon/phonondefs.h | 5 + src/3rdparty/phonon/phonon/seekslider.cpp | 4 +- src/3rdparty/phonon/phonon/seekslider_p.h | 4 +- src/3rdparty/phonon/phonon/videowidget.cpp | 16 +- src/3rdparty/phonon/phonon/videowidget.h | 1 + src/3rdparty/phonon/phonon/videowidgetinterface.h | 13 + src/3rdparty/phonon/phonon/volumeslider_p.h | 4 +- src/phonon/phonon.pro | 64 ++-- 23 files changed, 571 insertions(+), 217 deletions(-) diff --git a/src/3rdparty/phonon/phonon/CMakeLists.txt b/src/3rdparty/phonon/phonon/CMakeLists.txt index 11d7913..ace934a 100644 --- a/src/3rdparty/phonon/phonon/CMakeLists.txt +++ b/src/3rdparty/phonon/phonon/CMakeLists.txt @@ -8,6 +8,30 @@ endif (PHONON_BUILD_EXAMPLES) add_subdirectory(experimental) +set(PULSEAUDIO_MINIMUM_VERSION "0.9.15") +macro_optional_find_package(PulseAudio) +if (PULSEAUDIO_FOUND) + # PULSEAUDIO_DEVICE_MANAGER feature check could be moved to FindPulseAudio.cmake, hint hint. -- Rex + macro_ensure_version("0.9.21" "${PULSEAUDIO_VERSION}" PULSEAUDIO_DEVICE_MANAGER) +endif (PULSEAUDIO_FOUND) +macro_log_feature(PULSEAUDIO_FOUND "PulseAudio" "A cross-platform, networked sound server." "http://www.pulseaudio.org" FALSE "" "Allows audio playback via the PulseAudio soundserver when it is running") +macro_optional_find_package(GLIB2) +macro_log_feature(GLIB2_FOUND "GLib2" "GLib 2 is required to compile the pulseaudio for Phonon" "http://www.gtk.org/download/" FALSE) + + +if (GLIB2_FOUND AND PULSEAUDIO_FOUND) + add_definitions(-DHAVE_PULSEAUDIO) + include_directories(${GLIB2_INCLUDE_DIR} ${PULSEAUDIO_INCLUDE_DIR}) + if (PULSEAUDIO_DEVICE_MANAGER) + add_definitions(-DHAVE_PULSEAUDIO_DEVICE_MANAGER) + endif(PULSEAUDIO_DEVICE_MANAGER) +else(GLIB2_FOUND AND PULSEAUDIO_FOUND) + set(PULSEAUDIO_INCLUDE_DIR "") + set(PULSEAUDIO_LIBRARY "") + set(PULSEAUDIO_MAINLOOP_LIBRARY "") +endif(GLIB2_FOUND AND PULSEAUDIO_FOUND) + + set(phonon_LIB_SRCS objectdescription.cpp objectdescriptionmodel.cpp @@ -35,9 +59,12 @@ set(phonon_LIB_SRCS videowidget.cpp videoplayer.cpp seekslider.cpp + swiftslider.cpp volumeslider.cpp effectwidget.cpp iodevicestream.cpp + audiodataoutput.cpp + pulsesupport.cpp ) if (QT_QTDBUS_FOUND) @@ -50,6 +77,10 @@ endif (QT_QTDBUS_FOUND) add_definitions(-DPHONON_LIBRARY_PATH="${PLUGIN_INSTALL_DIR}/plugins") automoc4_add_library(phonon SHARED ${phonon_LIB_SRCS}) target_link_libraries(phonon ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY}) +if (GLIB2_FOUND AND PULSEAUDIO_FOUND) +target_link_libraries(phonon ${GLIB2_LIBRARIES} ${GOBJECT_LIBRARIES} ${PULSEAUDIO_LIBRARY} ${PULSEAUDIO_MAINLOOP_LIBRARY}) +endif (GLIB2_FOUND AND PULSEAUDIO_FOUND) + if (QT_QTDBUS_FOUND) target_link_libraries(phonon ${QT_QTDBUS_LIBRARY}) endif (QT_QTDBUS_FOUND) @@ -99,6 +130,10 @@ install(FILES volumeslider.h effectwidget.h platformplugin.h + audiodataoutput.h + audiodataoutputinterface.h + globalconfig.h + pulsesupport.h DESTINATION ${INCLUDE_INSTALL_DIR}/phonon COMPONENT Devel) install(FILES org.kde.Phonon.AudioOutput.xml DESTINATION ${DBUS_INTERFACES_INSTALL_DIR}) diff --git a/src/3rdparty/phonon/phonon/audiooutput.cpp b/src/3rdparty/phonon/phonon/audiooutput.cpp index 0f6a49b..932a875 100644 --- a/src/3rdparty/phonon/phonon/audiooutput.cpp +++ b/src/3rdparty/phonon/phonon/audiooutput.cpp @@ -24,10 +24,11 @@ #include "factory_p.h" #include "objectdescription.h" #include "audiooutputadaptor_p.h" -#include "globalconfig_p.h" +#include "globalconfig.h" #include "audiooutputinterface.h" #include "phononnamespace_p.h" #include "platform_p.h" +#include "pulsesupport.h" #include @@ -42,8 +43,12 @@ QT_BEGIN_NAMESPACE namespace Phonon { -static inline bool callSetOutputDevice(MediaNodePrivate *const d, int index) +static inline bool callSetOutputDevice(AudioOutputPrivate *const d, int index) { + PulseSupport *pulse = PulseSupport::getInstance(); + if (pulse->isActive()) + return pulse->setOutputDevice(d->getStreamUuid(), index); + Iface iface(d); if (iface) { return iface->setOutputDevice(AudioOutputDevice::fromIndex(index)); @@ -51,8 +56,12 @@ static inline bool callSetOutputDevice(MediaNodePrivate *const d, int index) return Iface::cast(d)->setOutputDevice(index); } -static inline bool callSetOutputDevice(MediaNodePrivate *const d, const AudioOutputDevice &dev) +static inline bool callSetOutputDevice(AudioOutputPrivate *const d, const AudioOutputDevice &dev) { + PulseSupport *pulse = PulseSupport::getInstance(); + if (pulse->isActive()) + return pulse->setOutputDevice(d->getStreamUuid(), dev.index()); + Iface iface(d); if (iface) { return iface->setOutputDevice(dev); @@ -89,16 +98,20 @@ void AudioOutputPrivate::init(Phonon::Category c) #endif category = c; - - // select hardware device according to the category - device = AudioOutputDevice::fromIndex(GlobalConfig().audioOutputDeviceFor(category, GlobalConfig::AdvancedDevicesFromSettings | GlobalConfig::HideUnavailableDevices)); + streamUuid = QUuid::createUuid().toString(); + PulseSupport *pulse = PulseSupport::getInstance(); + pulse->setStreamPropList(category, streamUuid); + q->connect(pulse, SIGNAL(usingDevice(QString,int)), SLOT(_k_deviceChanged(QString,int))); createBackendObject(); q->connect(Factory::sender(), SIGNAL(availableAudioOutputDevicesChanged()), SLOT(_k_deviceListChanged())); } - +QString AudioOutputPrivate::getStreamUuid() +{ + return streamUuid; +} void AudioOutputPrivate::createBackendObject() { @@ -106,6 +119,7 @@ void AudioOutputPrivate::createBackendObject() return; Q_Q(AudioOutput); m_backendObject = Factory::createAudioOutput(q); + device = AudioOutputDevice::fromIndex(GlobalConfig().audioOutputDeviceFor(category, GlobalConfig::AdvancedDevicesFromSettings | GlobalConfig::HideUnavailableDevices)); if (m_backendObject) { setupBackendObject(); } @@ -220,21 +234,21 @@ bool AudioOutput::setOutputDevice(const AudioOutputDevice &newAudioOutputDevice) { K_D(AudioOutput); if (!newAudioOutputDevice.isValid()) { - d->outputDeviceOverridden = false; + d->outputDeviceOverridden = d->forceMove = false; const int newIndex = GlobalConfig().audioOutputDeviceFor(d->category); if (newIndex == d->device.index()) { return true; } d->device = AudioOutputDevice::fromIndex(newIndex); } else { - d->outputDeviceOverridden = true; + d->outputDeviceOverridden = d->forceMove = true; if (d->device == newAudioOutputDevice) { return true; } d->device = newAudioOutputDevice; } if (k_ptr->backendObject()) { - return callSetOutputDevice(k_ptr, d->device.index()); + return callSetOutputDevice(d, d->device.index()); } return true; } @@ -261,7 +275,10 @@ void AudioOutputPrivate::setupBackendObject() #ifndef QT_NO_PHONON_SETTINGSGROUP // if the output device is not available and the device was not explicitly set - if (!callSetOutputDevice(this, device) && !outputDeviceOverridden) { + // There is no need to set the output device initially if PA is used as + // we know it will not work (stream doesn't exist yet) and that this will be + // handled by _k_deviceChanged() + if (!PulseSupport::getInstance()->isActive() && !callSetOutputDevice(this, device) && !outputDeviceOverridden) { // fall back in the preference list of output devices QList deviceList = GlobalConfig().audioOutputDeviceListFor(category, GlobalConfig::AdvancedDevicesFromSettings | GlobalConfig::HideUnavailableDevices); if (deviceList.isEmpty()) { @@ -306,10 +323,14 @@ void AudioOutputPrivate::_k_revertFallback() void AudioOutputPrivate::_k_audioDeviceFailed() { + if (PulseSupport::getInstance()->isActive()) + return; + +#ifndef QT_NO_PHONON_SETTINGSGROUP + pDebug() << Q_FUNC_INFO; // outputDeviceIndex identifies a failing device // fall back in the preference list of output devices -#ifndef QT_NO_PHONON_SETTINGSGROUP const QList deviceList = GlobalConfig().audioOutputDeviceListFor(category, GlobalConfig::AdvancedDevicesFromSettings | GlobalConfig::HideUnavailableDevices); for (int i = 0; i < deviceList.count(); ++i) { const int devIndex = deviceList.at(i); @@ -331,8 +352,15 @@ void AudioOutputPrivate::_k_audioDeviceFailed() void AudioOutputPrivate::_k_deviceListChanged() { - pDebug() << Q_FUNC_INFO; + if (PulseSupport::getInstance()->isActive()) + return; + #ifndef QT_NO_PHONON_SETTINGSGROUP + pDebug() << Q_FUNC_INFO; + // Check to see if we have an override and do not change to a higher priority device if the overridden device is still present. + if (outputDeviceOverridden && device.property("available").toBool()) { + return; + } // let's see if there's a usable device higher in the preference list const QList deviceList = GlobalConfig().audioOutputDeviceListFor(category, GlobalConfig::AdvancedDevicesFromSettings); DeviceChangeType changeType = HigherPreferenceChange; @@ -361,6 +389,36 @@ void AudioOutputPrivate::_k_deviceListChanged() #endif //QT_NO_PHONON_SETTINGSGROUP } +void AudioOutputPrivate::_k_deviceChanged(QString inStreamUuid, int deviceIndex) +{ + // Note that this method is only used by PulseAudio at present. + if (inStreamUuid == streamUuid) { + // 1. Check to see if we are overridden. If we are, and devices do not match, + // then try and apply our own device as the output device. + // We only do this the first time + if (outputDeviceOverridden && forceMove) { + forceMove = false; + const AudioOutputDevice ¤tDevice = AudioOutputDevice::fromIndex(deviceIndex); + if (currentDevice != device) { + if (!callSetOutputDevice(this, device)) { + // What to do if we are overridden and cannot change to our preferred device? + } + } + } + // 2. If we are not overridden, then we need to update our perception of what + // device we are using. If the devices do not match, something lower in the + // stack is overriding our preferences (e.g. a per-application stream preference, + // specific application move, priority list changed etc. etc.) + else if (!outputDeviceOverridden) { + const AudioOutputDevice ¤tDevice = AudioOutputDevice::fromIndex(deviceIndex); + if (currentDevice != device) { + // The device is not what we think it is, so lets say what is happening. + handleAutomaticDeviceChange(currentDevice, SoundSystemChange); + } + } + } +} + static struct { int first; @@ -405,11 +463,33 @@ void AudioOutputPrivate::handleAutomaticDeviceChange(const AudioOutputDevice &de g_lastFallback.second = 0; } break; + case SoundSystemChange: + { +#ifndef QT_NO_PHONON_PLATFORMPLUGIN + if (device1.property("available").toBool()) { + const QString text = AudioOutput::tr("Switching to the audio playback device %1
" + "which has higher preference or is specifically configured for this stream.").arg(device2.name()); + Platform::notification("AudioDeviceFallback", text, + QStringList(AudioOutput::tr("Revert back to device '%1'").arg(device1.name())), + q, SLOT(_k_revertFallback())); + } else { + const QString &text = + AudioOutput::tr("The audio playback device %1 does not work.
" + "Falling back to %2.").arg(device1.name()).arg(device2.name()); + Platform::notification("AudioDeviceFallback", text); + } +#endif //QT_NO_PHONON_PLATFORMPLUGIN + //outputDeviceOverridden = true; + g_lastFallback.first = 0; + g_lastFallback.second = 0; + } + break; } } AudioOutputPrivate::~AudioOutputPrivate() { + PulseSupport::getInstance()->clearStreamCache(streamUuid); #ifndef QT_NO_DBUS if (adaptor) { emit adaptor->outputDestroyed(); diff --git a/src/3rdparty/phonon/phonon/audiooutput.h b/src/3rdparty/phonon/phonon/audiooutput.h index 4edf135..513a863 100644 --- a/src/3rdparty/phonon/phonon/audiooutput.h +++ b/src/3rdparty/phonon/phonon/audiooutput.h @@ -169,6 +169,7 @@ namespace Phonon Q_PRIVATE_SLOT(k_func(), void _k_revertFallback()) Q_PRIVATE_SLOT(k_func(), void _k_audioDeviceFailed()) Q_PRIVATE_SLOT(k_func(), void _k_deviceListChanged()) + Q_PRIVATE_SLOT(k_func(), void _k_deviceChanged(QString streamUuid, int device)) }; } //namespace Phonon diff --git a/src/3rdparty/phonon/phonon/audiooutput_p.h b/src/3rdparty/phonon/phonon/audiooutput_p.h index fdee299..01dc48f 100644 --- a/src/3rdparty/phonon/phonon/audiooutput_p.h +++ b/src/3rdparty/phonon/phonon/audiooutput_p.h @@ -46,6 +46,7 @@ class AudioOutputPrivate : public AbstractAudioOutputPrivate return 0; } void init(Phonon::Category c); + QString getStreamUuid(); protected: @@ -58,6 +59,7 @@ class AudioOutputPrivate : public AbstractAudioOutputPrivate #endif deviceBeforeFallback(-1), outputDeviceOverridden(false), + forceMove(false), muted(false) { } @@ -66,7 +68,8 @@ class AudioOutputPrivate : public AbstractAudioOutputPrivate enum DeviceChangeType { FallbackChange, - HigherPreferenceChange + HigherPreferenceChange, + SoundSystemChange }; void handleAutomaticDeviceChange(const AudioOutputDevice &newDev, DeviceChangeType type); @@ -74,17 +77,20 @@ class AudioOutputPrivate : public AbstractAudioOutputPrivate void _k_revertFallback(); void _k_audioDeviceFailed(); void _k_deviceListChanged(); + void _k_deviceChanged(QString streamUuid, int deviceIndex); private: QString name; Phonon::AudioOutputDevice device; qreal volume; + QString streamUuid; #ifndef QT_NO_DBUS Phonon::AudioOutputAdaptor *adaptor; #endif Category category; int deviceBeforeFallback; bool outputDeviceOverridden; + bool forceMove; bool muted; }; } //namespace Phonon diff --git a/src/3rdparty/phonon/phonon/audiooutputinterface.h b/src/3rdparty/phonon/phonon/audiooutputinterface.h index 80ba11c..cce12b2 100644 --- a/src/3rdparty/phonon/phonon/audiooutputinterface.h +++ b/src/3rdparty/phonon/phonon/audiooutputinterface.h @@ -64,7 +64,7 @@ class AudioOutputInterface40 * A value of 0.0 means muted, 1.0 means unchanged, 2.0 means double voltage (i.e. all * samples are multiplied by 2). * - * Everytime the volume in the backend changes it should emit volumeChanged(qreal), also + * Every time the volume in the backend changes it should emit volumeChanged(qreal), also * inside this function. */ virtual void setVolume(qreal) = 0; diff --git a/src/3rdparty/phonon/phonon/backendcapabilities.cpp b/src/3rdparty/phonon/phonon/backendcapabilities.cpp index fbeb020..8dad589 100644 --- a/src/3rdparty/phonon/phonon/backendcapabilities.cpp +++ b/src/3rdparty/phonon/phonon/backendcapabilities.cpp @@ -26,7 +26,7 @@ #include "phonondefs_p.h" #include "backendinterface.h" #include "factory_p.h" -#include "globalconfig_p.h" +#include "globalconfig.h" #include "globalstatic_p.h" #include "objectdescription.h" diff --git a/src/3rdparty/phonon/phonon/factory.cpp b/src/3rdparty/phonon/phonon/factory.cpp index 9967c971..24be0f3 100644 --- a/src/3rdparty/phonon/phonon/factory.cpp +++ b/src/3rdparty/phonon/phonon/factory.cpp @@ -134,30 +134,24 @@ bool FactoryPrivate::createBackend() continue; } - QStringList plugins(dir.entryList(QDir::Files)); + QStringList plugins(dir.entryList(QDir::Files)); #ifdef Q_OS_SYMBIAN /* On Symbian OS we might have two plugins, one which uses Symbian - * MMF framework("phonon_mmf"), and one which uses Real Networks's + * MMF framework("mmf"), and one which uses Real Networks's * Helix("hxphonon"). We prefer the latter because it's more * sophisticated, so we make sure the Helix backend is attempted * to be loaded first, and the MMF backend is used for backup. */ { - - const int hxphonon = plugins.indexOf(QLatin1String("hxphonon")); - if (hxphonon != -1) - plugins.move(hxphonon, 0); - - // Code for debugging the MMF backend. - if(hxphonon != -1) { - qDebug() << "Found hxphonon backend and removed it from the lookup list."; - plugins.removeAll(QLatin1String("hxphonon")); - } + const int helix = plugins.indexof(QLatin1String("hxphonon")); + if (helix != -1) + plugins.move(helix, 0); } #endif - for (int i = 0; i < plugins.count(); ++i) { - QPluginLoader pluginLoader(libPath + plugins.at(i)); + const QStringList files = dir.entryList(QDir::Files); + for (int i = 0; i < files.count(); ++i) { + QPluginLoader pluginLoader(libPath + files.at(i)); if (!pluginLoader.load()) { pDebug() << Q_FUNC_INFO << " load failed:" << pluginLoader.errorString(); @@ -350,6 +344,7 @@ FACTORY_IMPL(AudioOutput) #ifndef QT_NO_PHONON_VIDEO FACTORY_IMPL(VideoWidget) #endif //QT_NO_PHONON_VIDEO +FACTORY_IMPL(AudioDataOutput) #undef FACTORY_IMPL @@ -469,7 +464,7 @@ GET_STRING_PROPERTY(backendWebsite) QObject *Factory::registerQObject(QObject *o) { if (o) { - QObject::connect(o, SIGNAL(destroyed(QObject*)), globalFactory, SLOT(objectDestroyed(QObject*)), Qt::DirectConnection); + QObject::connect(o, SIGNAL(destroyed(QObject *)), globalFactory, SLOT(objectDestroyed(QObject *)), Qt::DirectConnection); globalFactory->objects.append(o); } return o; diff --git a/src/3rdparty/phonon/phonon/factory_p.h b/src/3rdparty/phonon/phonon/factory_p.h index dee2b56..41b8c5b 100644 --- a/src/3rdparty/phonon/phonon/factory_p.h +++ b/src/3rdparty/phonon/phonon/factory_p.h @@ -122,6 +122,13 @@ namespace Factory #endif //QT_NO_PHONON_VIDEO /** + * Create a new backend object for a AudioDataOutput. + * + * \return a pointer to the AudioDataOutput the backend provides. + */ + PHONON_EXPORT QObject *createAudioDataOutput(QObject *parent = 0); + + /** * \return a pointer to the backend interface. */ PHONON_EXPORT QObject *backend(bool createWhenNull = true); diff --git a/src/3rdparty/phonon/phonon/globalconfig.cpp b/src/3rdparty/phonon/phonon/globalconfig.cpp index 3b77a18..be751ce 100644 --- a/src/3rdparty/phonon/phonon/globalconfig.cpp +++ b/src/3rdparty/phonon/phonon/globalconfig.cpp @@ -20,6 +20,7 @@ */ +#include "globalconfig.h" #include "globalconfig_p.h" #include "factory_p.h" @@ -29,6 +30,7 @@ #include "backendinterface.h" #include "qsettingsgroup_p.h" #include "phononnamespace_p.h" +#include "pulsesupport.h" #include #include @@ -38,15 +40,18 @@ QT_BEGIN_NAMESPACE namespace Phonon { +GlobalConfigPrivate::GlobalConfigPrivate() : config(QLatin1String("kde.org"), QLatin1String("libphonon")) +{ +} + GlobalConfig::GlobalConfig() -#ifndef QT_NO_SETTINGS - : m_config(QLatin1String("kde.org"), QLatin1String("libphonon")) -#endif //QT_NO_SETTINGS + : k_ptr(new GlobalConfigPrivate) { } GlobalConfig::~GlobalConfig() { + delete k_ptr; } enum WhatToFilter { @@ -59,7 +64,11 @@ static void filter(ObjectDescriptionType type, BackendInterface *backendIface, Q { QMutableListIterator it(*list); while (it.hasNext()) { - const QHash properties = backendIface->objectDescriptionProperties(type, it.next()); + QHash properties; + if (backendIface) + properties = backendIface->objectDescriptionProperties(type, it.next()); + else + properties = PulseSupport::getInstance()->objectDescriptionProperties(type, it.next()); QVariant var; if (whatToFilter & FilterAdvancedDevices) { var = properties.value("isAdvanced"); @@ -73,6 +82,7 @@ static void filter(ObjectDescriptionType type, BackendInterface *backendIface, Q if (var.isValid() && var.toBool()) { it.remove(); continue; +#ifndef QT_NO_PHONON_SETTINGSGROUP } } if (whatToFilter & FilterUnavailableDevices) { @@ -85,9 +95,12 @@ static void filter(ObjectDescriptionType type, BackendInterface *backendIface, Q } } -#ifndef QT_NO_PHONON_SETTINGSGROUP -static QList listSortedByConfig(const QSettingsGroup &backendConfig, Phonon::Category category, QList &defaultList) +static QList sortDevicesByCategoryPriority(const GlobalConfig *config, const QSettingsGroup *backendConfig, ObjectDescriptionType type, Phonon::Category category, QList &defaultList) { + Q_ASSERT(config); + Q_ASSERT(backendConfig); + Q_ASSERT(type == AudioOutputDeviceType || type == AudioCaptureDeviceType); + if (defaultList.size() <= 1) { // nothing to sort return defaultList; @@ -104,20 +117,26 @@ static QList listSortedByConfig(const QSettingsGroup &backendConfig, Phonon } } - QString categoryKey = QLatin1String("Category_") + QString::number(static_cast(category)); - if (!backendConfig.hasKey(categoryKey)) { - // no list in config for the given category - categoryKey = QLatin1String("Category_") + QString::number(static_cast(Phonon::NoCategory)); - if (!backendConfig.hasKey(categoryKey)) { - // no list in config for NoCategory - return defaultList; + QList deviceList; + PulseSupport *pulse = PulseSupport::getInstance(); + if (pulse->isActive()) { + deviceList = pulse->objectIndexesByCategory(type, category); + } else { + QString categoryKey = QLatin1String("Category_") + QString::number(static_cast(category)); + if (!backendConfig->hasKey(categoryKey)) { + // no list in config for the given category + categoryKey = QLatin1String("Category_") + QString::number(static_cast(Phonon::NoCategory)); + if (!backendConfig->hasKey(categoryKey)) { + // no list in config for NoCategory + return defaultList; + } } - } - //Now the list from m_config - QList deviceList = backendConfig.value(categoryKey, QList()); + //Now the list from d->config + deviceList = backendConfig->value(categoryKey, QList()); + } - //if there are devices in m_config that the backend doesn't report, remove them from the list + //if there are devices in d->config that the backend doesn't report, remove them from the list QMutableListIterator i(deviceList); while (i.hasNext()) { if (0 == defaultList.removeAll(i.next())) { @@ -125,58 +144,198 @@ static QList listSortedByConfig(const QSettingsGroup &backendConfig, Phonon } } - //if the backend reports more devices that are not in m_config append them to the list + //if the backend reports more devices that are not in d->config append them to the list deviceList += defaultList; return deviceList; } + +bool GlobalConfig::hideAdvancedDevices() const +{ + K_D(const GlobalConfig); + //The devices need to be stored independently for every backend + const QSettingsGroup generalGroup(&d->config, QLatin1String("General")); + return generalGroup.value(QLatin1String("HideAdvancedDevices"), true); +} + +void GlobalConfig::setHideAdvancedDevices(bool hide) +{ + K_D(GlobalConfig); + QSettingsGroup generalGroup(&d->config, QLatin1String("General")); + generalGroup.setValue(QLatin1String("HideAdvancedDevices"), hide); +} + +static bool isHiddenAudioOutputDevice(const GlobalConfig *config, int i) +{ + Q_ASSERT(config); + + if (!config->hideAdvancedDevices()) + return false; + + AudioOutputDevice ad = AudioOutputDevice::fromIndex(i); + const QVariant var = ad.property("isAdvanced"); + return (var.isValid() && var.toBool()); +} + +#ifndef QT_NO_PHONON_AUDIOCAPTURE +static bool isHiddenAudioCaptureDevice(const GlobalConfig *config, int i) +{ + Q_ASSERT(config); + + if (!config->hideAdvancedDevices()) + return false; + + AudioCaptureDevice ad = AudioCaptureDevice::fromIndex(i); + const QVariant var = ad.property("isAdvanced"); + return (var.isValid() && var.toBool()); +} +#endif + +static QList reindexList(const GlobalConfig *config, Phonon::Category category, QListnewOrder, bool output) +{ + Q_ASSERT(config); +#ifdef QT_NO_PHONON_AUDIOCAPTURE + Q_ASSERT(output); +#endif + + /*QString sb; + sb = QString("(Size %1)").arg(currentList.size()); + foreach (int i, currentList) + sb += QString("%1, ").arg(i); + fprintf(stderr, "=== Reindex Current: %s\n", sb.toUtf8().constData()); + sb = QString("(Size %1)").arg(newOrder.size()); + foreach (int i, newOrder) + sb += QString("%1, ").arg(i); + fprintf(stderr, "=== Reindex Before : %s\n", sb.toUtf8().constData());*/ + + QList currentList; + if (output) + currentList = config->audioOutputDeviceListFor(category, GlobalConfig::ShowUnavailableDevices|GlobalConfig::ShowAdvancedDevices); +#ifndef QT_NO_PHONON_AUDIOCAPTURE + else + currentList = config->audioCaptureDeviceListFor(category, GlobalConfig::ShowUnavailableDevices|GlobalConfig::ShowAdvancedDevices); +#endif + + QList newList; + + foreach (int i, newOrder) { + int found = currentList.indexOf(i); + if (found < 0) { + // It's not in the list, so something is odd (e.g. client error). Ignore it. + continue; + } + + // Iterate through the list from this point onward. If there are hidden devices + // immediately following, take them too. + newList.append(currentList.takeAt(found)); + while (found < currentList.size()) { + bool hidden = true; + if (output) + hidden = isHiddenAudioOutputDevice(config, currentList.at(found)); +#ifndef QT_NO_PHONON_AUDIOCAPTURE + else + hidden = isHiddenAudioCaptureDevice(config, currentList.at(found)); +#endif + + if (!hidden) + break; + newList.append(currentList.takeAt(found)); + } + } + + // If there are any devices left in.. just tack them on the end. + if (currentList.size() > 0) + newList += currentList; + + /*sb = QString("(Size %1)").arg(newList.size()); + foreach (int i, newList) + sb += QString("%1, ").arg(i); + fprintf(stderr, "=== Reindex After : %s\n", sb.toUtf8().constData());*/ + return newList; +} + + +void GlobalConfig::setAudioOutputDeviceListFor(Phonon::Category category, QList order) +{ + PulseSupport *pulse = PulseSupport::getInstance(); + if (pulse->isActive()) { + pulse->setOutputDevicePriorityForCategory(category, order); + return; + } + + K_D(GlobalConfig); + QSettingsGroup backendConfig(&d->config, QLatin1String("AudioOutputDevice")); // + Factory::identifier()); + + order = reindexList(this, category, order, true); + + const QList noCategoryOrder = audioOutputDeviceListFor(Phonon::NoCategory, ShowUnavailableDevices|ShowAdvancedDevices); + if (category != Phonon::NoCategory && order == noCategoryOrder) { + backendConfig.removeEntry(QLatin1String("Category_") + QString::number(category)); + } else { + backendConfig.setValue(QLatin1String("Category_") + QString::number(category), order); + } +} #endif //QT_NO_PHONON_SETTINGSGROUP #ifndef QT_NO_PHONON_SETTINGSGROUP QList GlobalConfig::audioOutputDeviceListFor(Phonon::Category category, int override) const { - //The devices need to be stored independently for every backend - const QSettingsGroup backendConfig(&m_config, QLatin1String("AudioOutputDevice")); // + Factory::identifier()); - const QSettingsGroup generalGroup(&m_config, QLatin1String("General")); - const bool hideAdvancedDevices = ((override & AdvancedDevicesFromSettings) - ? generalGroup.value(QLatin1String("HideAdvancedDevices"), true) + K_D(const GlobalConfig); + + const bool hide = ((override & AdvancedDevicesFromSettings) + ? hideAdvancedDevices() : static_cast(override & HideAdvancedDevices)); QList defaultList; + + PulseSupport *pulse = PulseSupport::getInstance(); + if (pulse->isActive()) { + defaultList = pulse->objectDescriptionIndexes(Phonon::AudioOutputDeviceType); + if (hide || (override & HideUnavailableDevices)) { + filter(AudioOutputDeviceType, NULL, &defaultList, + (hide ? FilterAdvancedDevices : 0) + | ((override & HideUnavailableDevices) ? FilterUnavailableDevices : 0) + ); + } + } else { + BackendInterface *backendIface = qobject_cast(Factory::backend()); + #ifndef QT_NO_PHONON_PLATFORMPLUGIN - if (PlatformPlugin *platformPlugin = Factory::platformPlugin()) { - // the platform plugin lists the audio devices for the platform - // this list already is in default order (as defined by the platform plugin) - defaultList = platformPlugin->objectDescriptionIndexes(Phonon::AudioOutputDeviceType); - if (hideAdvancedDevices) { - QMutableListIterator it(defaultList); - while (it.hasNext()) { - AudioOutputDevice objDesc = AudioOutputDevice::fromIndex(it.next()); - const QVariant var = objDesc.property("isAdvanced"); - if (var.isValid() && var.toBool()) { - it.remove(); + if (PlatformPlugin *platformPlugin = Factory::platformPlugin()) { + // the platform plugin lists the audio devices for the platform + // this list already is in default order (as defined by the platform plugin) + defaultList = platformPlugin->objectDescriptionIndexes(Phonon::AudioOutputDeviceType); + if (hide) { + QMutableListIterator it(defaultList); + while (it.hasNext()) { + AudioOutputDevice objDesc = AudioOutputDevice::fromIndex(it.next()); + const QVariant var = objDesc.property("isAdvanced"); + if (var.isValid() && var.toBool()) { + it.remove(); + } } } } - } #endif //QT_NO_PHONON_PLATFORMPLUGIN - // lookup the available devices directly from the backend (mostly for virtual devices) - if (BackendInterface *backendIface = qobject_cast(Factory::backend())) { - // this list already is in default order (as defined by the backend) - QList list = backendIface->objectDescriptionIndexes(Phonon::AudioOutputDeviceType); - if (hideAdvancedDevices || !defaultList.isEmpty() || (override & HideUnavailableDevices)) { - filter(AudioOutputDeviceType, backendIface, &list, - (hideAdvancedDevices ? FilterAdvancedDevices : 0) - // the platform plugin already provided the hardware devices - | (defaultList.isEmpty() ? 0 : FilterHardwareDevices) - | ((override & HideUnavailableDevices) ? FilterUnavailableDevices : 0) - ); + // lookup the available devices directly from the backend + if (backendIface) { + // this list already is in default order (as defined by the backend) + QList list = backendIface->objectDescriptionIndexes(Phonon::AudioOutputDeviceType); + if (hide || !defaultList.isEmpty() || (override & HideUnavailableDevices)) { + filter(AudioOutputDeviceType, backendIface, &list, + (hide ? FilterAdvancedDevices : 0) + // the platform plugin maybe already provided the hardware devices? + | (defaultList.isEmpty() ? 0 : FilterHardwareDevices) + | ((override & HideUnavailableDevices) ? FilterUnavailableDevices : 0) + ); + } + defaultList += list; } - defaultList += list; } - return listSortedByConfig(backendConfig, category, defaultList); + const QSettingsGroup backendConfig(&d->config, QLatin1String("AudioOutputDevice")); // + Factory::identifier()); + return sortDevicesByCategoryPriority(this, &backendConfig, AudioOutputDeviceType, category, defaultList); } #endif //QT_NO_PHONON_SETTINGSGROUP int GlobalConfig::audioOutputDeviceFor(Phonon::Category category, int override) const @@ -190,54 +349,89 @@ int GlobalConfig::audioOutputDeviceFor(Phonon::Category category, int override) } #ifndef QT_NO_PHONON_AUDIOCAPTURE -QList GlobalConfig::audioCaptureDeviceListFor(Phonon::Category category, int override) const +void GlobalConfig::setAudioCaptureDeviceListFor(Phonon::Category category, QList order) { #ifndef QT_NO_PHONON_SETTINGSGROUP - //The devices need to be stored independently for every backend - const QSettingsGroup backendConfig(&m_config, QLatin1String("AudioCaptureDevice")); // + Factory::identifier()); - const QSettingsGroup generalGroup(&m_config, QLatin1String("General")); - const bool hideAdvancedDevices = ((override & AdvancedDevicesFromSettings) - ? generalGroup.value(QLatin1String("HideAdvancedDevices"), true) + PulseSupport *pulse = PulseSupport::getInstance(); + if (pulse->isActive()) { + pulse->setCaptureDevicePriorityForCategory(category, order); + return; + } + + K_D(GlobalConfig); + QSettingsGroup backendConfig(&d->config, QLatin1String("AudioCaptureDevice")); // + Factory::identifier()); + + order = reindexList(this, category, order, false); + + const QList noCategoryOrder = audioCaptureDeviceListFor(Phonon::NoCategory, ShowUnavailableDevices|ShowAdvancedDevices); + if (category != Phonon::NoCategory && order == noCategoryOrder) { + backendConfig.removeEntry(QLatin1String("Category_") + QString::number(category)); + } else { + backendConfig.setValue(QLatin1String("Category_") + QString::number(category), order); + } +} + +QList GlobalConfig::audioCaptureDeviceListFor(Phonon::Category category, int override) const +{ + K_D(const GlobalConfig); + + const bool hide = ((override & AdvancedDevicesFromSettings) + ? hideAdvancedDevices() : static_cast(override & HideAdvancedDevices)); QList defaultList; + + PulseSupport *pulse = PulseSupport::getInstance(); + if (pulse->isActive()) { + defaultList = pulse->objectDescriptionIndexes(Phonon::AudioCaptureDeviceType); + if (hide || (override & HideUnavailableDevices)) { + filter(AudioCaptureDeviceType, NULL, &defaultList, + (hide ? FilterAdvancedDevices : 0) + | ((override & HideUnavailableDevices) ? FilterUnavailableDevices : 0) + ); + } + } else { + BackendInterface *backendIface = qobject_cast(Factory::backend()); + #ifndef QT_NO_PHONON_PLATFORMPLUGIN - if (PlatformPlugin *platformPlugin = Factory::platformPlugin()) { - // the platform plugin lists the audio devices for the platform - // this list already is in default order (as defined by the platform plugin) - defaultList = platformPlugin->objectDescriptionIndexes(Phonon::AudioCaptureDeviceType); - if (hideAdvancedDevices) { - QMutableListIterator it(defaultList); - while (it.hasNext()) { - AudioCaptureDevice objDesc = AudioCaptureDevice::fromIndex(it.next()); - const QVariant var = objDesc.property("isAdvanced"); - if (var.isValid() && var.toBool()) { - it.remove(); +#else //QT_NO_SETTINGSGROUP + return QList(); +#endif //QT_NO_SETTINGSGROUP + if (PlatformPlugin *platformPlugin = Factory::platformPlugin()) { + // the platform plugin lists the audio devices for the platform + // this list already is in default order (as defined by the platform plugin) + defaultList = platformPlugin->objectDescriptionIndexes(Phonon::AudioCaptureDeviceType); + if (hide) { + QMutableListIterator it(defaultList); + while (it.hasNext()) { + AudioCaptureDevice objDesc = AudioCaptureDevice::fromIndex(it.next()); + const QVariant var = objDesc.property("isAdvanced"); + if (var.isValid() && var.toBool()) { + it.remove(); + } } } } - } #endif //QT_NO_PHONON_PLATFORMPLUGIN - // lookup the available devices directly from the backend (mostly for virtual devices) - if (BackendInterface *backendIface = qobject_cast(Factory::backend())) { - // this list already is in default order (as defined by the backend) - QList list = backendIface->objectDescriptionIndexes(Phonon::AudioCaptureDeviceType); - if (hideAdvancedDevices || !defaultList.isEmpty() || (override & HideUnavailableDevices)) { - filter(AudioCaptureDeviceType, backendIface, &list, - (hideAdvancedDevices ? FilterAdvancedDevices : 0) - // the platform plugin already provided the hardware devices - | (defaultList.isEmpty() ? 0 : FilterHardwareDevices) - | ((override & HideUnavailableDevices) ? FilterUnavailableDevices : 0) - ); + // lookup the available devices directly from the backend + if (backendIface) { + // this list already is in default order (as defined by the backend) + QList list = backendIface->objectDescriptionIndexes(Phonon::AudioCaptureDeviceType); + if (hide || !defaultList.isEmpty() || (override & HideUnavailableDevices)) { + filter(AudioCaptureDeviceType, backendIface, &list, + (hide ? FilterAdvancedDevices : 0) + // the platform plugin maybe already provided the hardware devices? + | (defaultList.isEmpty() ? 0 : FilterHardwareDevices) + | ((override & HideUnavailableDevices) ? FilterUnavailableDevices : 0) + ); + } + defaultList += list; } - defaultList += list; } - return listSortedByConfig(backendConfig, category, defaultList); -#else //QT_NO_SETTINGSGROUP - return QList(); -#endif //QT_NO_SETTINGSGROUP + const QSettingsGroup backendConfig(&d->config, QLatin1String("AudioCaptureDevice")); // + Factory::identifier()); + return sortDevicesByCategoryPriority(this, &backendConfig, AudioCaptureDeviceType, category, defaultList); } int GlobalConfig::audioCaptureDeviceFor(Phonon::Category category, int override) const diff --git a/src/3rdparty/phonon/phonon/globalconfig_p.h b/src/3rdparty/phonon/phonon/globalconfig_p.h index ec70b6f..090ca6b 100644 --- a/src/3rdparty/phonon/phonon/globalconfig_p.h +++ b/src/3rdparty/phonon/phonon/globalconfig_p.h @@ -26,40 +26,19 @@ Copyright (C) 2006-2008 Matthias Kretz #include #include "phonon_export.h" -#include "phononnamespace.h" QT_BEGIN_HEADER QT_BEGIN_NAMESPACE namespace Phonon { - class PHONON_EXPORT GlobalConfig + class GlobalConfigPrivate { - public: - GlobalConfig(); - virtual ~GlobalConfig(); + public: + GlobalConfigPrivate(); + virtual ~GlobalConfigPrivate() {} - enum DevicesToHideFlag { - ShowUnavailableDevices = 0, - ShowAdvancedDevices = 0, - HideAdvancedDevices = 1, - AdvancedDevicesFromSettings = 2, - HideUnavailableDevices = 4 - }; -#ifndef QT_NO_PHONON_SETTINGSGROUP - QList audioOutputDeviceListFor(Phonon::Category category, int override = AdvancedDevicesFromSettings) const; -#endif //QT_NO_PHONON_SETTINGSGROUP - int audioOutputDeviceFor(Phonon::Category category, int override = AdvancedDevicesFromSettings) const; - -#ifndef QT_NO_PHONON_AUDIOCAPTURE - QList audioCaptureDeviceListFor(Phonon::Category category, int override = AdvancedDevicesFromSettings) const; - int audioCaptureDeviceFor(Phonon::Category category, int override = AdvancedDevicesFromSettings) const; -#endif //QT_NO_PHONON_AUDIOCAPTURE - - protected: -#ifndef QT_NO_SETTINGS - QSettings m_config; -#endif //QT_NO_SETTINGS + QSettings config; }; } // namespace Phonon diff --git a/src/3rdparty/phonon/phonon/mediaobject.cpp b/src/3rdparty/phonon/phonon/mediaobject.cpp index 41e8dc2..13d303c 100644 --- a/src/3rdparty/phonon/phonon/mediaobject.cpp +++ b/src/3rdparty/phonon/phonon/mediaobject.cpp @@ -453,9 +453,9 @@ void MediaObjectPrivate::setupBackendObject() //pDebug() << Q_FUNC_INFO; #ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM - QObject::connect(m_backendObject, SIGNAL(stateChanged(Phonon::State,Phonon::State)), q, SLOT(_k_stateChanged(Phonon::State,Phonon::State))); + QObject::connect(m_backendObject, SIGNAL(stateChanged(Phonon::State, Phonon::State)), q, SLOT(_k_stateChanged(Phonon::State, Phonon::State))); #else - QObject::connect(m_backendObject, SIGNAL(stateChanged(Phonon::State,Phonon::State)), q, SIGNAL(stateChanged(Phonon::State,Phonon::State))); + QObject::connect(m_backendObject, SIGNAL(stateChanged(Phonon::State, Phonon::State)), q, SIGNAL(stateChanged(Phonon::State, Phonon::State))); #endif // QT_NO_PHONON_ABSTRACTMEDIASTREAM QObject::connect(m_backendObject, SIGNAL(tick(qint64)), q, SIGNAL(tick(qint64))); QObject::connect(m_backendObject, SIGNAL(seekableChanged(bool)), q, SIGNAL(seekableChanged(bool))); @@ -467,10 +467,10 @@ void MediaObjectPrivate::setupBackendObject() QObject::connect(m_backendObject, SIGNAL(aboutToFinish()), q, SLOT(_k_aboutToFinish())); QObject::connect(m_backendObject, SIGNAL(prefinishMarkReached(qint32)), q, SIGNAL(prefinishMarkReached(qint32))); QObject::connect(m_backendObject, SIGNAL(totalTimeChanged(qint64)), q, SIGNAL(totalTimeChanged(qint64))); - QObject::connect(m_backendObject, SIGNAL(metaDataChanged(QMultiMap)), - q, SLOT(_k_metaDataChanged(QMultiMap))); - QObject::connect(m_backendObject, SIGNAL(currentSourceChanged(MediaSource)), - q, SLOT(_k_currentSourceChanged(MediaSource))); + QObject::connect(m_backendObject, SIGNAL(metaDataChanged(const QMultiMap &)), + q, SLOT(_k_metaDataChanged(const QMultiMap &))); + QObject::connect(m_backendObject, SIGNAL(currentSourceChanged(const MediaSource&)), + q, SLOT(_k_currentSourceChanged(const MediaSource&))); // set up attributes pINTERFACE_CALL(setTickInterval(tickInterval)); diff --git a/src/3rdparty/phonon/phonon/objectdescription.cpp b/src/3rdparty/phonon/phonon/objectdescription.cpp index e058b89..55e74b5 100644 --- a/src/3rdparty/phonon/phonon/objectdescription.cpp +++ b/src/3rdparty/phonon/phonon/objectdescription.cpp @@ -29,6 +29,7 @@ #include #include "backendinterface.h" #include "platformplugin.h" +#include "pulsesupport.h" QT_BEGIN_NAMESPACE @@ -108,27 +109,38 @@ bool ObjectDescriptionData::isValid() const ObjectDescriptionData *ObjectDescriptionData::fromIndex(ObjectDescriptionType type, int index) { - // prefer to get the ObjectDescriptionData from the platform plugin for audio devices + bool is_audio_device = (AudioOutputDeviceType == type || AudioCaptureDeviceType == type); + + PulseSupport *pulse = PulseSupport::getInstance(); + if (is_audio_device && pulse->isActive()) { + QList indexes = pulse->objectDescriptionIndexes(type); + if (indexes.contains(index)) { + QHash properties = pulse->objectDescriptionProperties(type, index); + return new ObjectDescriptionData(index, properties); + } + } else { + BackendInterface *iface = qobject_cast(Factory::backend()); + + // prefer to get the ObjectDescriptionData from the platform plugin for audio devices #ifndef QT_NO_PHONON_PLATFORMPLUGIN - if (type == AudioOutputDeviceType || type == AudioCaptureDeviceType) { - PlatformPlugin *platformPlugin = Factory::platformPlugin(); - if (platformPlugin) { - QList indexes = platformPlugin->objectDescriptionIndexes(type); - if (indexes.contains(index)) { - QHash properties = platformPlugin->objectDescriptionProperties(type, index); - return new ObjectDescriptionData(index, properties); + if (is_audio_device) { + PlatformPlugin *platformPlugin = Factory::platformPlugin(); + if (platformPlugin) { + QList indexes = platformPlugin->objectDescriptionIndexes(type); + if (indexes.contains(index)) { + QHash properties = platformPlugin->objectDescriptionProperties(type, index); + return new ObjectDescriptionData(index, properties); + } } } - } #endif //QT_NO_PHONON_PLATFORMPLUGIN - QObject *b = Factory::backend(); - BackendInterface *iface = qobject_cast(b); - if (iface) { - QList indexes = iface->objectDescriptionIndexes(type); - if (indexes.contains(index)) { - QHash properties = iface->objectDescriptionProperties(type, index); - return new ObjectDescriptionData(index, properties); + if (iface) { + QList indexes = iface->objectDescriptionIndexes(type); + if (indexes.contains(index)) { + QHash properties = iface->objectDescriptionProperties(type, index); + return new ObjectDescriptionData(index, properties); + } } } return new ObjectDescriptionData(0); // invalid diff --git a/src/3rdparty/phonon/phonon/objectdescriptionmodel.cpp b/src/3rdparty/phonon/phonon/objectdescriptionmodel.cpp index bf5be6d..741a74c 100644 --- a/src/3rdparty/phonon/phonon/objectdescriptionmodel.cpp +++ b/src/3rdparty/phonon/phonon/objectdescriptionmodel.cpp @@ -362,6 +362,7 @@ QStringList ObjectDescriptionModelData::mimeTypes(ObjectDescriptionType type) co return QStringList(QLatin1String("application/x-phonon-objectdescription") + QString::number(static_cast(type))); } +#if !defined(Q_CC_MSVC) || _MSC_VER > 1300 || defined(Q_CC_INTEL) || defined(Q_CC_MINGW) #define INSTANTIATE_META_FUNCTIONS(type) \ template const QMetaObject *ObjectDescriptionModel::metaObject() const; \ template void *ObjectDescriptionModel::qt_metacast(const char *) @@ -371,6 +372,7 @@ INSTANTIATE_META_FUNCTIONS(AudioCaptureDeviceType); INSTANTIATE_META_FUNCTIONS(EffectType); INSTANTIATE_META_FUNCTIONS(AudioChannelType); INSTANTIATE_META_FUNCTIONS(SubtitleType); +#endif /*INSTANTIATE_META_FUNCTIONS(VideoOutputDeviceType); INSTANTIATE_META_FUNCTIONS(VideoCaptureDeviceType); INSTANTIATE_META_FUNCTIONS(AudioCodecType); diff --git a/src/3rdparty/phonon/phonon/objectdescriptionmodel.h b/src/3rdparty/phonon/phonon/objectdescriptionmodel.h index 8fd622f..a1540e8 100644 --- a/src/3rdparty/phonon/phonon/objectdescriptionmodel.h +++ b/src/3rdparty/phonon/phonon/objectdescriptionmodel.h @@ -35,6 +35,18 @@ QT_BEGIN_NAMESPACE #ifndef QT_NO_PHONON_OBJECTDESCRIPTIONMODEL +/* MinGW 3.4.x gives an ICE when trying to instantiate one of the + ObjectDescriptionModel classes because it can't handle + half exported classes correct. gcc 4.3.x has a fix for this but + we currently there's no official gcc 4.3 on windows available. + Because of this we need this little hack + */ +#if defined(Q_CC_MINGW) +#define PHONON_EXPORT_ODM +#else +#define PHONON_EXPORT_ODM PHONON_EXPORT +#endif + namespace Phonon { class ObjectDescriptionModelDataPrivate; @@ -139,21 +151,6 @@ namespace Phonon ObjectDescriptionModelDataPrivate *const d; }; -/* Required to ensure template class vtables are exported on both symbian -and existing builds. */ -#if defined(Q_OS_SYMBIAN) && defined(Q_CC_RVCT) -// RVCT compiler (2.2.686) requires the export declaration to be on the class to export vtables -// MWC compiler works both ways -// GCCE compiler is unknown (it can't compile QtCore yet) -#define PHONON_TEMPLATE_CLASS_EXPORT PHONON_EXPORT -#define PHONON_TEMPLATE_CLASS_MEMBER_EXPORT -#else -// Windows builds (at least) do not support export declaration on templated class -// But if you export a member function, the vtable is implicitly exported -#define PHONON_TEMPLATE_CLASS_EXPORT -#define PHONON_TEMPLATE_CLASS_MEMBER_EXPORT PHONON_EXPORT -#endif - /** \class ObjectDescriptionModel objectdescriptionmodel.h Phonon/ObjectDescriptionModel * \short The ObjectDescriptionModel class provides a model from * a list of ObjectDescription objects. @@ -190,17 +187,16 @@ and existing builds. */ * \author Matthias Kretz */ template - class PHONON_TEMPLATE_CLASS_EXPORT ObjectDescriptionModel : public QAbstractListModel + class ObjectDescriptionModel : public QAbstractListModel { public: Q_OBJECT_CHECK - /** \internal */ - static PHONON_TEMPLATE_CLASS_MEMBER_EXPORT const QMetaObject staticMetaObject; + static PHONON_EXPORT const QMetaObject staticMetaObject; /** \internal */ - PHONON_TEMPLATE_CLASS_MEMBER_EXPORT const QMetaObject *metaObject() const; + PHONON_EXPORT_ODM const QMetaObject *metaObject() const; /** \internal */ - PHONON_TEMPLATE_CLASS_MEMBER_EXPORT void *qt_metacast(const char *_clname); + PHONON_EXPORT_ODM void *qt_metacast(const char *_clname); //int qt_metacall(QMetaObject::Call _c, int _id, void **_a); /** diff --git a/src/3rdparty/phonon/phonon/path.cpp b/src/3rdparty/phonon/phonon/path.cpp index 51c33b2..1c25b89 100644 --- a/src/3rdparty/phonon/phonon/path.cpp +++ b/src/3rdparty/phonon/phonon/path.cpp @@ -310,8 +310,8 @@ bool PathPrivate::executeTransaction( const QList &disconnections, if (!transaction) return false; - QList::const_iterator it = disconnections.constBegin(); - for(;it != disconnections.constEnd();++it) { + QList::const_iterator it = disconnections.begin(); + for(;it != disconnections.end();++it) { const QObjectPair &pair = *it; if (!backend->disconnectNodes(pair.first, pair.second)) { @@ -327,8 +327,8 @@ bool PathPrivate::executeTransaction( const QList &disconnections, } } - for(it = connections.constBegin(); it != connections.constEnd(); ++it) { - const QObjectPair pair = *it; + for(it = connections.begin(); it != connections.end();++it) { + const QObjectPair &pair = *it; if (!backend->connectNodes(pair.first, pair.second)) { //Error: a connection failed QList::const_iterator it2 = connections.begin(); diff --git a/src/3rdparty/phonon/phonon/phonondefs.h b/src/3rdparty/phonon/phonon/phonondefs.h index 15a1815..765eb1c 100644 --- a/src/3rdparty/phonon/phonon/phonondefs.h +++ b/src/3rdparty/phonon/phonon/phonondefs.h @@ -29,6 +29,11 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE +#ifdef PHONON_BACKEND_VERSION_4_4 +# ifndef PHONON_BACKEND_VERSION_4_3 +# define PHONON_BACKEND_VERSION_4_3 +# endif +#endif #ifdef PHONON_BACKEND_VERSION_4_3 # ifndef PHONON_BACKEND_VERSION_4_2 # define PHONON_BACKEND_VERSION_4_2 diff --git a/src/3rdparty/phonon/phonon/seekslider.cpp b/src/3rdparty/phonon/phonon/seekslider.cpp index 41baf2d..b5b25f0 100644 --- a/src/3rdparty/phonon/phonon/seekslider.cpp +++ b/src/3rdparty/phonon/phonon/seekslider.cpp @@ -72,12 +72,12 @@ void SeekSlider::setMediaObject(MediaObject *media) d->media = media; if (media) { - connect(media, SIGNAL(stateChanged(Phonon::State,Phonon::State)), + connect(media, SIGNAL(stateChanged(Phonon::State, Phonon::State)), SLOT(_k_stateChanged(Phonon::State))); connect(media, SIGNAL(totalTimeChanged(qint64)), SLOT(_k_length(qint64))); connect(media, SIGNAL(tick(qint64)), SLOT(_k_tick(qint64))); connect(media, SIGNAL(seekableChanged(bool)), SLOT(_k_seekableChanged(bool))); - connect(media, SIGNAL(currentSourceChanged(Phonon::MediaSource)), SLOT(_k_currentSourceChanged())); + connect(media, SIGNAL(currentSourceChanged(const Phonon::MediaSource&)), SLOT(_k_currentSourceChanged())); d->_k_stateChanged(media->state()); d->_k_seekableChanged(media->isSeekable()); d->_k_length(media->totalTime()); diff --git a/src/3rdparty/phonon/phonon/seekslider_p.h b/src/3rdparty/phonon/phonon/seekslider_p.h index c87a4b0..911ab25 100644 --- a/src/3rdparty/phonon/phonon/seekslider_p.h +++ b/src/3rdparty/phonon/phonon/seekslider_p.h @@ -24,8 +24,8 @@ #define SEEKSLIDER_P_H #include "seekslider.h" +#include "swiftslider_p.h" #include -#include #include #include #include @@ -84,7 +84,7 @@ class SeekSliderPrivate void _k_currentSourceChanged(); QBoxLayout layout; - QSlider slider; + SwiftSlider slider; QLabel iconLabel; QPointer media; bool ticking; diff --git a/src/3rdparty/phonon/phonon/videowidget.cpp b/src/3rdparty/phonon/phonon/videowidget.cpp index a9e83a6..4575dfd 100644 --- a/src/3rdparty/phonon/phonon/videowidget.cpp +++ b/src/3rdparty/phonon/phonon/videowidget.cpp @@ -28,8 +28,9 @@ #include "phononnamespace_p.h" #include - -#define PHONON_INTERFACENAME VideoWidgetInterface +#define IFACES4 VideoWidgetInterface44 +#define IFACES0 VideoWidgetInterface, IFACES4 +#define PHONON_INTERFACENAME IFACES0 QT_BEGIN_NAMESPACE @@ -48,6 +49,8 @@ VideoWidget::VideoWidget(QWidget *parent) setMouseTracking(true); } + + VideoWidget::VideoWidget(VideoWidgetPrivate &dd, QWidget *parent) : QWidget(parent), Phonon::AbstractVideoOutput(dd) @@ -98,6 +101,15 @@ PHONON_INTERFACE_SETTER(setHue, hue, qreal) PHONON_INTERFACE_GETTER(qreal, saturation, d->saturation) PHONON_INTERFACE_SETTER(setSaturation, saturation, qreal) + +QImage VideoWidget::snapshot() const { + K_D(const VideoWidget); + ConstIface iface(d); + if(iface) return iface->snapshot(); + return QImage(); // TODO not implemented in VideoInterface +} + + void VideoWidget::setFullScreen(bool newFullScreen) { pDebug() << Q_FUNC_INFO << newFullScreen; diff --git a/src/3rdparty/phonon/phonon/videowidget.h b/src/3rdparty/phonon/phonon/videowidget.h index 1d95490..804e61a 100644 --- a/src/3rdparty/phonon/phonon/videowidget.h +++ b/src/3rdparty/phonon/phonon/videowidget.h @@ -172,6 +172,7 @@ class AbstractVideoOutput; qreal contrast() const; qreal hue() const; qreal saturation() const; + QImage snapshot() const; //TODO: bar colors property public Q_SLOTS: diff --git a/src/3rdparty/phonon/phonon/videowidgetinterface.h b/src/3rdparty/phonon/phonon/videowidgetinterface.h index 3e6fd22..0c33956 100644 --- a/src/3rdparty/phonon/phonon/videowidgetinterface.h +++ b/src/3rdparty/phonon/phonon/videowidgetinterface.h @@ -53,8 +53,21 @@ class VideoWidgetInterface //X virtual int overlayCapabilities() const = 0; //X virtual bool createOverlay(QWidget *widget, int type) = 0; }; + +class VideoWidgetInterface44 : public VideoWidgetInterface +{ + public: + virtual QImage snapshot() const = 0; +}; } +#ifdef PHONON_BACKEND_VERSION_4_4 +namespace Phonon { typedef VideoWidgetInterface44 VideoWidgetInterfaceLatest; } +#else +namespace Phonon { typedef VideoWidgetInterface VideoWidgetInterfaceLatest; } +#endif + +Q_DECLARE_INTERFACE(Phonon::VideoWidgetInterface44, "VideoWidgetInterface44.phonon.kde.org") Q_DECLARE_INTERFACE(Phonon::VideoWidgetInterface, "VideoWidgetInterface3.phonon.kde.org") #endif //QT_NO_PHONON_VIDEO diff --git a/src/3rdparty/phonon/phonon/volumeslider_p.h b/src/3rdparty/phonon/phonon/volumeslider_p.h index 3827659..623275f 100644 --- a/src/3rdparty/phonon/phonon/volumeslider_p.h +++ b/src/3rdparty/phonon/phonon/volumeslider_p.h @@ -24,8 +24,8 @@ #define VOLUMESLIDER_P_H #include "volumeslider.h" +#include "swiftslider_p.h" #include -#include #include #include #include @@ -83,7 +83,7 @@ class VolumeSliderPrivate private: QBoxLayout layout; - QSlider slider; + SwiftSlider slider; QToolButton muteButton; QIcon volumeIcon; QIcon mutedIcon; diff --git a/src/phonon/phonon.pro b/src/phonon/phonon.pro index 0469839..7f79d0b 100644 --- a/src/phonon/phonon.pro +++ b/src/phonon/phonon.pro @@ -2,8 +2,8 @@ TARGET = phonon include(../qbase.pri) PHONON_MAJOR_VERSION = $${QT_MAJOR_VERSION} -PHONON_MINOR_VERSION = 3 -PHONON_PATCH_VERSION = 1 +PHONON_MINOR_VERSION = 4 +PHONON_PATCH_VERSION = 0 VERSION = $${PHONON_MAJOR_VERSION}.$${PHONON_MINOR_VERSION}.$${PHONON_PATCH_VERSION} DEPENDPATH += . @@ -21,6 +21,9 @@ HEADERS += $$PHONON_DIR/abstractaudiooutput.h \ $$PHONON_DIR/abstractvideooutput.h \ $$PHONON_DIR/abstractvideooutput_p.h \ $$PHONON_DIR/addoninterface.h \ + $$PHONON_DIR/audiodataoutput_p.h \ + $$PHONON_DIR/audiodataoutput.h \ + $$PHONON_DIR/audiodataoutputinterface.h \ $$PHONON_DIR/audiooutput.h \ $$PHONON_DIR/audiooutput_p.h \ $$PHONON_DIR/audiooutputinterface.h \ @@ -36,6 +39,7 @@ HEADERS += $$PHONON_DIR/abstractaudiooutput.h \ $$PHONON_DIR/effectwidget_p.h \ $$PHONON_DIR/factory_p.h \ $$PHONON_DIR/frontendinterface_p.h \ + $$PHONON_DIR/globalconfig.h \ $$PHONON_DIR/globalconfig_p.h \ $$PHONON_DIR/iodevicestream_p.h \ $$PHONON_DIR/mediacontroller.h \ @@ -53,6 +57,7 @@ HEADERS += $$PHONON_DIR/abstractaudiooutput.h \ $$PHONON_DIR/objectdescriptionmodel_p.h \ $$PHONON_DIR/path.h \ $$PHONON_DIR/path_p.h \ + $$PHONON_DIR/pulsesupport.h \ $$PHONON_DIR/phonondefs.h \ $$PHONON_DIR/phonondefs_p.h \ $$PHONON_DIR/phononnamespace.h \ @@ -64,6 +69,7 @@ HEADERS += $$PHONON_DIR/abstractaudiooutput.h \ $$PHONON_DIR/seekslider_p.h \ $$PHONON_DIR/streaminterface.h \ $$PHONON_DIR/streaminterface_p.h \ + $$PHONON_DIR/swiftslider_p.h \ $$PHONON_DIR/videoplayer.h \ $$PHONON_DIR/videowidget.h \ $$PHONON_DIR/videowidget_p.h \ @@ -73,35 +79,39 @@ HEADERS += $$PHONON_DIR/abstractaudiooutput.h \ $$PHONON_DIR/volumefaderinterface.h \ $$PHONON_DIR/volumeslider.h \ $$PHONON_DIR/volumeslider_p.h -SOURCES += $$PHONON_DIR/objectdescription.cpp \ - $$PHONON_DIR/objectdescriptionmodel.cpp \ - $$PHONON_DIR/phononnamespace.cpp \ - $$PHONON_DIR/mediasource.cpp \ - $$PHONON_DIR/abstractmediastream.cpp \ - $$PHONON_DIR/streaminterface.cpp \ - $$PHONON_DIR/mediaobject.cpp \ - $$PHONON_DIR/medianode.cpp \ - $$PHONON_DIR/path.cpp \ - $$PHONON_DIR/effectparameter.cpp \ - $$PHONON_DIR/effect.cpp \ - $$PHONON_DIR/volumefadereffect.cpp \ - $$PHONON_DIR/abstractaudiooutput.cpp \ + +SOURCES += $$PHONON_DIR/abstractaudiooutput.cpp \ $$PHONON_DIR/abstractaudiooutput_p.cpp \ - $$PHONON_DIR/audiooutput.cpp \ - $$PHONON_DIR/audiooutputinterface.cpp \ + $$PHONON_DIR/abstractmediastream.cpp \ $$PHONON_DIR/abstractvideooutput.cpp \ $$PHONON_DIR/abstractvideooutput_p.cpp \ + $$PHONON_DIR/audiodataoutput.cpp \ + $$PHONON_DIR/audiooutput.cpp \ + $$PHONON_DIR/audiooutputinterface.cpp \ $$PHONON_DIR/backendcapabilities.cpp \ - $$PHONON_DIR/globalconfig.cpp \ + $$PHONON_DIR/effect.cpp \ + $$PHONON_DIR/effectparameter.cpp \ + $$PHONON_DIR/effectwidget.cpp \ $$PHONON_DIR/factory.cpp \ - $$PHONON_DIR/platform.cpp \ + $$PHONON_DIR/globalconfig.cpp \ + $$PHONON_DIR/iodevicestream.cpp \ $$PHONON_DIR/mediacontroller.cpp \ - $$PHONON_DIR/videowidget.cpp \ - $$PHONON_DIR/videoplayer.cpp \ + $$PHONON_DIR/medianode.cpp \ + $$PHONON_DIR/mediaobject.cpp \ + $$PHONON_DIR/mediasource.cpp \ + $$PHONON_DIR/objectdescription.cpp \ + $$PHONON_DIR/objectdescriptionmodel.cpp \ + $$PHONON_DIR/path.cpp \ + $$PHONON_DIR/phononnamespace.cpp \ + $$PHONON_DIR/platform.cpp \ + $$PHONON_DIR/pulsesupport.cpp \ $$PHONON_DIR/seekslider.cpp \ - $$PHONON_DIR/volumeslider.cpp \ - $$PHONON_DIR/effectwidget.cpp \ - $$PHONON_DIR/iodevicestream.cpp + $$PHONON_DIR/streaminterface.cpp \ + $$PHONON_DIR/swiftslider.cpp \ + $$PHONON_DIR/videoplayer.cpp \ + $$PHONON_DIR/videowidget.cpp \ + $$PHONON_DIR/volumefadereffect.cpp \ + $$PHONON_DIR/volumeslider.cpp contains(QT_CONFIG, dbus) { QT += dbus @@ -114,6 +124,12 @@ contains(QT_CONFIG, dbus) { contains(QT_CONFIG, reduce_exports): CONFIG += hide_symbols +unix:!isEmpty(QT_CFLAGS_PULSEAUDIO) { + DEFINES += HAVE_PULSEAUDIO + QMAKE_CXXFLAGS += $$QT_CFLAGS_PULSEAUDIO + LIBS += $$QT_LIBS_PULSEAUDIO +} + symbian: { # Phonon depends on numeric_limits. Enabling STL support in Qt # would bring in link dependencies, and we don't need that for -- cgit v0.12 From edb67f204302fff4f1e46676112931ea054deb88 Mon Sep 17 00:00:00 2001 From: Justin McPherson Date: Thu, 25 Mar 2010 13:57:36 +1000 Subject: Update Phonon GStreamer backend to 4.4.0. --- src/3rdparty/phonon/gstreamer/CMakeLists.txt | 18 +- .../phonon/gstreamer/ConfigureChecks.cmake | 7 +- src/3rdparty/phonon/gstreamer/audiodataoutput.cpp | 143 ++++++++++ src/3rdparty/phonon/gstreamer/audiodataoutput.h | 84 ++++++ src/3rdparty/phonon/gstreamer/audiooutput.cpp | 16 +- src/3rdparty/phonon/gstreamer/backend.cpp | 46 ++-- src/3rdparty/phonon/gstreamer/backend.h | 1 - src/3rdparty/phonon/gstreamer/devicemanager.cpp | 70 +++-- src/3rdparty/phonon/gstreamer/devicemanager.h | 6 +- src/3rdparty/phonon/gstreamer/effectmanager.cpp | 2 +- src/3rdparty/phonon/gstreamer/glrenderer.cpp | 2 +- src/3rdparty/phonon/gstreamer/gsthelper.cpp | 2 +- src/3rdparty/phonon/gstreamer/gstreamer.desktop | 57 ++++ src/3rdparty/phonon/gstreamer/medianode.cpp | 4 +- src/3rdparty/phonon/gstreamer/mediaobject.cpp | 296 ++++++++++++++++----- src/3rdparty/phonon/gstreamer/mediaobject.h | 12 +- src/3rdparty/phonon/gstreamer/qwidgetvideosink.h | 1 + src/3rdparty/phonon/gstreamer/videowidget.h | 1 + src/3rdparty/phonon/gstreamer/x11renderer.cpp | 3 +- src/plugins/phonon/gstreamer/gstreamer.pro | 22 +- 20 files changed, 651 insertions(+), 142 deletions(-) create mode 100644 src/3rdparty/phonon/gstreamer/audiodataoutput.cpp create mode 100644 src/3rdparty/phonon/gstreamer/audiodataoutput.h diff --git a/src/3rdparty/phonon/gstreamer/CMakeLists.txt b/src/3rdparty/phonon/gstreamer/CMakeLists.txt index 08f892a..2249ac3 100644 --- a/src/3rdparty/phonon/gstreamer/CMakeLists.txt +++ b/src/3rdparty/phonon/gstreamer/CMakeLists.txt @@ -19,7 +19,7 @@ include(ConfigureChecks.cmake) if (BUILD_PHONON_GSTREAMER) include_directories( ${CMAKE_CURRENT_BINARY_DIR} - ${GSTREAMER_INCLUDE_DIR} + ${GSTREAMER_INCLUDE_DIR} ${GLIB2_INCLUDE_DIR} ${LIBXML2_INCLUDE_DIR} ${X11_X11_INCLUDE_PATH}) @@ -34,7 +34,6 @@ if (BUILD_PHONON_GSTREAMER) set(phonon_gstreamer_SRCS audiooutput.cpp - artssink.cpp backend.cpp devicemanager.cpp effectmanager.cpp @@ -50,14 +49,20 @@ if (BUILD_PHONON_GSTREAMER) message.cpp audioeffect.cpp abstractrenderer.cpp - x11renderer.cpp widgetrenderer.cpp glrenderer.cpp volumefadereffect.cpp + audiodataoutput.cpp ) - find_package(Alsa) - macro_ensure_version("0.10.22" ${GSTREAMER_VERSION} GSTREAMER_HAS_NONBLOCKING_ALSASINK) + if(NOT WIN32) + set(phonon_gstreamer_SRCS + ${phonon_gstreamer_SRCS} + artssink.cpp + x11renderer.cpp) + macro_optional_find_package(Alsa) + macro_ensure_version("0.10.22" ${GSTREAMER_VERSION} GSTREAMER_HAS_NONBLOCKING_ALSASINK) + endif(NOT WIN32) if(ALSA_FOUND AND NOT GSTREAMER_HAS_NONBLOCKING_ALSASINK) add_definitions(-DUSE_ALSASINK2) include_directories(${ALSA_INCLUDES}) @@ -78,6 +83,9 @@ if (BUILD_PHONON_GSTREAMER) if(ALSA_FOUND) target_link_libraries(phonon_gstreamer ${ASOUND_LIBRARY}) endif(ALSA_FOUND) + if(USE_INSTALL_PLUGIN) + target_link_libraries(phonon_gstreamer ${GSTREAMER_PLUGIN_PBUTILS_LIBRARIES}) + endif(USE_INSTALL_PLUGIN) install(TARGETS phonon_gstreamer DESTINATION ${PLUGIN_INSTALL_DIR}/plugins/phonon_backend) install(FILES gstreamer.desktop DESTINATION ${SERVICES_INSTALL_DIR}/phononbackends) diff --git a/src/3rdparty/phonon/gstreamer/ConfigureChecks.cmake b/src/3rdparty/phonon/gstreamer/ConfigureChecks.cmake index f2922e1..eaf5b99 100644 --- a/src/3rdparty/phonon/gstreamer/ConfigureChecks.cmake +++ b/src/3rdparty/phonon/gstreamer/ConfigureChecks.cmake @@ -17,6 +17,7 @@ macro_log_feature(GSTREAMER_FOUND "GStreamer" "gstreamer 0.10 is required for th macro_optional_find_package(GStreamerPlugins) macro_log_feature(GSTREAMER_PLUGIN_VIDEO_LIBRARIES "GStreamer video plugin" "The gstreamer video plugin (part of gstreamer-plugins-base 0.10) is required for the multimedia gstreamer backend" "http://gstreamer.freedesktop.org/modules/" FALSE "0.10") +macro_log_feature(GSTREAMER_PLUGIN_AUDIO_LIBRARIES "GStreamer audio plugin" "The gstreamer audio plugin (part of gstreamer-plugins-base 0.10) is required for the multimedia gstreamer backend" "http://gstreamer.freedesktop.org/modules/" FALSE "0.10") macro_optional_find_package(GLIB2) macro_log_feature(GLIB2_FOUND "GLib2" "GLib 2 is required to compile the gstreamer backend for Phonon" "http://www.gtk.org/download/" FALSE) @@ -30,8 +31,8 @@ macro_log_feature(LIBXML2_FOUND "LibXml2" "LibXml2 is required to compile the gs macro_optional_find_package(OpenGL) macro_log_feature(OPENGL_FOUND "OpenGL" "OpenGL support is required to compile the gstreamer backend for Phonon" "" FALSE) -if (GSTREAMER_FOUND AND GSTREAMER_PLUGIN_VIDEO_LIBRARIES AND GLIB2_FOUND AND GOBJECT_FOUND AND LIBXML2_FOUND AND OPENGL_FOUND) +if (GSTREAMER_FOUND AND GSTREAMER_PLUGIN_VIDEO_LIBRARIES AND GSTREAMER_PLUGIN_AUDIO_LIBRARIES AND GLIB2_FOUND AND GOBJECT_FOUND AND LIBXML2_FOUND AND OPENGL_FOUND) set(BUILD_PHONON_GSTREAMER TRUE) -else (GSTREAMER_FOUND AND GSTREAMER_PLUGIN_VIDEO_LIBRARIES AND GLIB2_FOUND AND GOBJECT_FOUND AND LIBXML2_FOUND AND OPENGL_FOUND) +else (GSTREAMER_FOUND AND GSTREAMER_PLUGIN_VIDEO_LIBRARIES AND GSTREAMER_PLUGIN_AUDIO_LIBRARIES AND GLIB2_FOUND AND GOBJECT_FOUND AND LIBXML2_FOUND AND OPENGL_FOUND) set(BUILD_PHONON_GSTREAMER FALSE) -endif (GSTREAMER_FOUND AND GSTREAMER_PLUGIN_VIDEO_LIBRARIES AND GLIB2_FOUND AND GOBJECT_FOUND AND LIBXML2_FOUND AND OPENGL_FOUND) +endif (GSTREAMER_FOUND AND GSTREAMER_PLUGIN_VIDEO_LIBRARIES AND GSTREAMER_PLUGIN_AUDIO_LIBRARIES AND GLIB2_FOUND AND GOBJECT_FOUND AND LIBXML2_FOUND AND OPENGL_FOUND) diff --git a/src/3rdparty/phonon/gstreamer/audiodataoutput.cpp b/src/3rdparty/phonon/gstreamer/audiodataoutput.cpp new file mode 100644 index 0000000..30dabdf --- /dev/null +++ b/src/3rdparty/phonon/gstreamer/audiodataoutput.cpp @@ -0,0 +1,143 @@ +/* This file is part of the KDE project + Copyright (C) 2006 Matthias Kretz + Copyright (C) 2009 Martin Sandsmark + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) version 3, or any + later version accepted by the membership of KDE e.V. (or its + successor approved by the membership of KDE e.V.), Nokia Corporation + (or its successors, if any) and the KDE Free Qt Foundation, which shall + act as a proxy defined in Section 6 of version 3 of the license. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library. If not, see . + +*/ + +#include "audiodataoutput.h" +#include "gsthelper.h" +#include "medianode.h" +#include "mediaobject.h" +#include +#include +#include + +namespace Phonon +{ +namespace Gstreamer +{ +AudioDataOutput::AudioDataOutput(Backend *backend, QObject *parent) + : QObject(parent), + MediaNode(backend, AudioSink | AudioSource) +{ + static int count = 0; + m_name = "AudioDataOutput" + QString::number(count++); + + m_queue = gst_element_factory_make ("identity", NULL); + gst_object_ref(m_queue); + m_isValid = true; +} + +AudioDataOutput::~AudioDataOutput() +{ + gst_element_set_state(m_queue, GST_STATE_NULL); + gst_object_unref(m_queue); +} + +int AudioDataOutput::dataSize() const +{ + return m_dataSize; +} + +int AudioDataOutput::sampleRate() const +{ + return 44100; +} + +void AudioDataOutput::setDataSize(int size) +{ + m_dataSize = size; +} + +typedef QMap > FloatMap; +typedef QMap > IntMap; + +inline void AudioDataOutput::convertAndEmit(const QVector &leftBuffer, const QVector &rightBuffer) +{ + //TODO: Floats + IntMap map; + map.insert(Phonon::AudioDataOutput::LeftChannel, leftBuffer); + map.insert(Phonon::AudioDataOutput::RightChannel, rightBuffer); + emit dataReady(map); +} + +void AudioDataOutput::processBuffer(GstPad*, GstBuffer* buffer, gpointer gThat) +{ + // TODO emit endOfMedia + AudioDataOutput *that = reinterpret_cast(gThat); + + // determine the number of channels + GstStructure* structure = gst_caps_get_structure (GST_BUFFER_CAPS(buffer), 0); + gst_structure_get_int (structure, "channels", &that->m_channels); + + if (that->m_channels > 2 || that->m_channels < 0) { + qWarning() << Q_FUNC_INFO << ": Number of channels not supported: " << that->m_channels; + return; + } + + gint16 *data = reinterpret_cast(GST_BUFFER_DATA(buffer)); + guint size = GST_BUFFER_SIZE(buffer) / sizeof(gint16); + + that->m_pendingData.reserve(that->m_pendingData.size() + size); + + for (uint i=0; im_pendingData.append(data[i]); + } + + while (that->m_pendingData.size() > that->m_dataSize * that->m_channels) { + if (that->m_channels == 1) { + QVector intBuffer(that->m_dataSize); + memcpy(intBuffer.data(), that->m_pendingData.constData(), that->m_dataSize * sizeof(qint16)); + + that->convertAndEmit(intBuffer, intBuffer); + int newSize = that->m_pendingData.size() - that->m_dataSize; + memmove(that->m_pendingData.data(), that->m_pendingData.constData() + that->m_dataSize, newSize * sizeof(qint16)); + that->m_pendingData.resize(newSize); + } else { + QVector left(that->m_dataSize), right(that->m_dataSize); + for (int i=0; im_dataSize; i++) { + left[i] = that->m_pendingData[i*2]; + right[i] = that->m_pendingData[i*2+1]; + } + that->m_pendingData.resize(that->m_pendingData.size() - that->m_dataSize*2); + that->convertAndEmit(left, right); + } + } +} + +void AudioDataOutput::mediaNodeEvent(const MediaNodeEvent *event) +{ + if (event->type() == MediaNodeEvent::MediaObjectConnected && root()) { + g_object_set(G_OBJECT(audioElement()), "sync", true, (const char*)NULL); + GstPad *audiopad = gst_element_get_pad (audioElement(), "src"); + gst_pad_add_buffer_probe (audiopad, G_CALLBACK(processBuffer), this); + gst_object_unref (audiopad); + return; + } + + MediaNode::mediaNodeEvent(event); +} + +}} //namespace Phonon::Gstreamer + +#include "moc_audiodataoutput.cpp" +// vim: sw=4 ts=4 + diff --git a/src/3rdparty/phonon/gstreamer/audiodataoutput.h b/src/3rdparty/phonon/gstreamer/audiodataoutput.h new file mode 100644 index 0000000..5e30a1d --- /dev/null +++ b/src/3rdparty/phonon/gstreamer/audiodataoutput.h @@ -0,0 +1,84 @@ +/* This file is part of the KDE project + Copyright (C) 2006 Matthias Kretz + Copyright (C) 2009 Martin Sandsmark + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) version 3, or any + later version accepted by the membership of KDE e.V. (or its + successor approved by the membership of KDE e.V.), Nokia Corporation + (or its successors, if any) and the KDE Free Qt Foundation, which shall + act as a proxy defined in Section 6 of version 3 of the license. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library. If not, see . +*/ + +#ifndef Phonon_GSTREAMER_AUDIODATAOUTPUT_H +#define Phonon_GSTREAMER_AUDIODATAOUTPUT_H + +#include "abstractaudiooutput.h" +#include "backend.h" +#include "medianode.h" +#include +#include + +namespace Phonon +{ +namespace Gstreamer +{ + /** + * \author Martin Sandsmark + */ + class AudioDataOutput : public QObject, + public AudioDataOutputInterface, + public MediaNode + { + Q_OBJECT + Q_INTERFACES(Phonon::AudioDataOutputInterface Phonon::Gstreamer::MediaNode) + + public: + AudioDataOutput(Backend *, QObject *); + ~AudioDataOutput(); + + public Q_SLOTS: + int dataSize() const; + int sampleRate() const; + void setDataSize(int size); + + public: + /// callback function for handling new audio data + static void processBuffer(GstPad*, GstBuffer*, gpointer); + + Phonon::AudioDataOutput* frontendObject() const { return m_frontend; } + void setFrontendObject(Phonon::AudioDataOutput *frontend) { m_frontend = frontend; } + + GstElement *audioElement() { return m_queue; } + + void mediaNodeEvent(const MediaNodeEvent *event); + + + signals: + void dataReady(const QMap > &data); + void dataReady(const QMap > &data); + void endOfMedia(int remainingSamples); + + private: + void convertAndEmit(const QVector&, const QVector&); + + GstElement *m_queue; + int m_dataSize; + QVector m_pendingData; + Phonon::AudioDataOutput *m_frontend; + int m_channels; + }; +}} //namespace Phonon::Gstreamer + +// vim: sw=4 ts=4 tw=80 +#endif // Phonon_FAKE_AUDIODATAOUTPUT_H diff --git a/src/3rdparty/phonon/gstreamer/audiooutput.cpp b/src/3rdparty/phonon/gstreamer/audiooutput.cpp index 641ff6b..f3137b2 100644 --- a/src/3rdparty/phonon/gstreamer/audiooutput.cpp +++ b/src/3rdparty/phonon/gstreamer/audiooutput.cpp @@ -125,6 +125,7 @@ void AudioOutput::setVolume(qreal newVolume) bool AudioOutput::setOutputDevice(int newDevice) { m_backend->logMessage(Q_FUNC_INFO + QString::number(newDevice), Backend::Info, this); + if (newDevice == m_device) return true; @@ -135,20 +136,11 @@ bool AudioOutput::setOutputDevice(int newDevice) } bool success = false; - const QList deviceList = m_backend->deviceManager()->audioOutputDevices(); - int deviceIdx = -1; - for (int i=0; i= 0) { + if (m_audioSink && newDevice >= 0) { // Save previous state GstState oldState = GST_STATE(m_audioSink); const QByteArray oldDeviceValue = GstHelper::property(m_audioSink, "device"); - const QByteArray deviceId = deviceList.at(deviceIdx).gstId; + const QByteArray deviceId = m_backend->deviceManager()->gstId(newDevice); m_device = newDevice; // We test if the device can be opened by checking if it can go from NULL to READY state @@ -170,7 +162,7 @@ bool AudioOutput::setOutputDevice(int newDevice) deviceId, Backend::Info, this); } - // Note the stopped state should not really be neccessary, but seems to be required to + // Note the stopped state should not really be necessary, but seems to be required to // properly reset after changing the audio state if (root()) { QMetaObject::invokeMethod(root(), "setState", Qt::QueuedConnection, Q_ARG(State, StoppedState)); diff --git a/src/3rdparty/phonon/gstreamer/backend.cpp b/src/3rdparty/phonon/gstreamer/backend.cpp index dab6f35..8c2b42f 100644 --- a/src/3rdparty/phonon/gstreamer/backend.cpp +++ b/src/3rdparty/phonon/gstreamer/backend.cpp @@ -18,6 +18,7 @@ #include "common.h" #include "backend.h" #include "audiooutput.h" +#include "audiodataoutput.h" #include "audioeffect.h" #include "mediaobject.h" #include "videowidget.h" @@ -26,6 +27,7 @@ #include "message.h" #include "volumefadereffect.h" #include +#include #include #include @@ -49,13 +51,17 @@ Backend::Backend(QObject *parent, const QVariantList &) , m_debugLevel(Warning) , m_isValid(false) { + // Initialise PulseAudio support + PulseSupport *pulse = PulseSupport::getInstance(); + pulse->enable(); + connect(pulse, SIGNAL(objectDescriptionChanged(ObjectDescriptionType)), SIGNAL(objectDescriptionChanged(ObjectDescriptionType))); + // In order to support reloading, we only set the app name once... static bool first = true; if (first) { first = false; g_set_application_name(qApp->applicationName().toUtf8()); } - GError *err = 0; bool wasInit = gst_init_check(0, 0, &err); //init gstreamer: must be called before any gst-related functions if (err) @@ -92,6 +98,9 @@ Backend::Backend(QObject *parent, const QVariantList &) Backend::~Backend() { + delete m_effectManager; + delete m_deviceManager; + PulseSupport::shutdown(); } gboolean Backend::busCall(GstBus *bus, GstMessage *msg, gpointer data) @@ -119,18 +128,15 @@ QObject *Backend::createObject(BackendInterface::Class c, QObject *parent, const case MediaObjectClass: return new MediaObject(this, parent); - case AudioOutputClass: { - AudioOutput *ao = new AudioOutput(this, parent); - m_audioOutputs.append(ao); - return ao; - } + case AudioOutputClass: + return new AudioOutput(this, parent); + #ifndef QT_NO_PHONON_EFFECT case EffectClass: return new AudioEffect(this, args[0].toInt(), parent); #endif //QT_NO_PHONON_EFFECT case AudioDataOutputClass: - logMessage("createObject() : AudioDataOutput not implemented"); - break; + return new AudioDataOutput(this, parent); #ifndef QT_NO_PHONON_VIDEO case VideoDataOutputClass: @@ -244,6 +250,15 @@ QStringList Backend::availableMimeTypes() const } } g_list_free(factoryList); + if (availableMimeTypes.contains("audio/x-vorbis") + && availableMimeTypes.contains("application/x-ogm-audio")) { + if (!availableMimeTypes.contains("audio/x-vorbis+ogg")) + availableMimeTypes.append("audio/x-vorbis+ogg"); + if (!availableMimeTypes.contains("application/ogg")) /* *.ogg */ + availableMimeTypes.append("application/ogg"); + if (!availableMimeTypes.contains("audio/ogg")) /* *.oga */ + availableMimeTypes.append("audio/ogg"); + } availableMimeTypes.sort(); return availableMimeTypes; } @@ -293,14 +308,11 @@ QHash Backend::objectDescriptionProperties(ObjectDescripti switch (type) { case Phonon::AudioOutputDeviceType: { - QList audioDevices = deviceManager()->audioOutputDevices(); - foreach(const AudioDevice &device, audioDevices) { - if (device.id == index) { - ret.insert("name", device.gstId); - ret.insert("description", device.description); - ret.insert("icon", QLatin1String("audio-card")); - break; - } + AudioDevice* ad; + if ((ad = deviceManager()->audioDevice(index))) { + ret.insert("name", ad->gstId); + ret.insert("description", ad->description); + ret.insert("icon", ad->icon); } } break; @@ -429,7 +441,7 @@ EffectManager* Backend::effectManager() const /** * Returns a debuglevel that is determined by the - * PHONON_GSTREAMER_DEBUG environment variable. + * PHONON_GST_DEBUG environment variable. * * Warning - important warnings * Info - general info diff --git a/src/3rdparty/phonon/gstreamer/backend.h b/src/3rdparty/phonon/gstreamer/backend.h index 2aab6fa..d157f11 100644 --- a/src/3rdparty/phonon/gstreamer/backend.h +++ b/src/3rdparty/phonon/gstreamer/backend.h @@ -86,7 +86,6 @@ private Q_SLOTS: private: static gboolean busCall(GstBus *bus, GstMessage *msg, gpointer data); - QList > m_audioOutputs; DeviceManager *m_deviceManager; EffectManager *m_effectManager; diff --git a/src/3rdparty/phonon/gstreamer/devicemanager.cpp b/src/3rdparty/phonon/gstreamer/devicemanager.cpp index 60e860f..c3826eb 100644 --- a/src/3rdparty/phonon/gstreamer/devicemanager.cpp +++ b/src/3rdparty/phonon/gstreamer/devicemanager.cpp @@ -24,6 +24,7 @@ #include "widgetrenderer.h" #include "x11renderer.h" #include "artssink.h" +#include "pulsesupport.h" #ifdef USE_ALSASINK2 #include "alsasink2.h" @@ -44,9 +45,12 @@ namespace Gstreamer AudioDevice::AudioDevice(DeviceManager *manager, const QByteArray &gstId) : gstId(gstId) { - //get an id - static int counter = 0; - id = counter++; + // This should never be called when PulseAudio is active. + Q_ASSERT(!PulseSupport::getInstance()->isActive()); + + id = manager->allocateDeviceId(); + icon = "audio-card"; + //get name from device if (gstId == "default") { description = "Default audio device"; @@ -71,22 +75,25 @@ AudioDevice::AudioDevice(DeviceManager *manager, const QByteArray &gstId) DeviceManager::DeviceManager(Backend *backend) : QObject(backend) , m_backend(backend) + , m_audioDeviceCounter(0) { - m_audioSink = qgetenv("PHONON_GST_AUDIOSINK"); - m_videoSinkWidget = qgetenv("PHONON_GST_VIDEOMODE"); - -#ifndef QT_NO_SETTINGS QSettings settings(QLatin1String("Trolltech")); settings.beginGroup(QLatin1String("Qt")); + PulseSupport *pulse = PulseSupport::getInstance(); + m_audioSink = qgetenv("PHONON_GST_AUDIOSINK"); if (m_audioSink.isEmpty()) { m_audioSink = settings.value(QLatin1String("audiosink"), "Auto").toByteArray().toLower(); + if (m_audioSink == "auto" && pulse->isActive()) + m_audioSink = "pulsesink"; } + if ("pulsesink" != m_audioSink) + pulse->enable(false); + m_videoSinkWidget = qgetenv("PHONON_GST_VIDEOMODE"); if (m_videoSinkWidget.isEmpty()) { m_videoSinkWidget = settings.value(QLatin1String("videomode"), "Auto").toByteArray().toLower(); } -#endif //QT_NO_SETTINGS if (m_backend->isValid()) updateDeviceList(); @@ -271,9 +278,17 @@ AbstractRenderer *DeviceManager::createVideoRenderer(VideoWidget *parent) } #endif //QT_NO_PHONON_VIDEO -/* - * Returns a positive device id or -1 if device - * does not exist +/** + * Allocate a device id for a new audio device + */ +int DeviceManager::allocateDeviceId() +{ + return m_audioDeviceCounter++; +} + + +/** + * Returns a positive device id or -1 if device does not exist * * The gstId is typically in the format hw:1,0 */ @@ -288,16 +303,30 @@ int DeviceManager::deviceId(const QByteArray &gstId) const } /** - * Get a human-readable description from a device id + * Returns a gstId or "default" if device does not exist + * + * The gstId is typically in the format hw:1,0 */ -QByteArray DeviceManager::deviceDescription(int id) const +const QByteArray DeviceManager::gstId(int deviceId) +{ + if (!PulseSupport::getInstance()->isActive()) { + AudioDevice *ad = audioDevice(deviceId); + if (ad) + return QByteArray(ad->gstId); + } + return QByteArray("default"); +} + +/** +* Get the AudioDevice for a given device id +*/ +AudioDevice* DeviceManager::audioDevice(int id) { for (int i = 0 ; i < m_audioDeviceList.size() ; ++i) { - if (m_audioDeviceList[i].id == id) { - return m_audioDeviceList[i].description; - } + if (m_audioDeviceList[i].id == id) + return &m_audioDeviceList[i]; } - return QByteArray(); + return NULL; } /** @@ -311,8 +340,11 @@ void DeviceManager::updateDeviceList() QList list; if (audioSink) { - list = GstHelper::extractProperties(audioSink, "device"); - list.prepend("default"); + if (!PulseSupport::getInstance()->isActive()) { + // If we're using pulse, the PulseSupport class takes care of things for us. + list = GstHelper::extractProperties(audioSink, "device"); + list.prepend("default"); + } for (int i = 0 ; i < list.size() ; ++i) { QByteArray gstId = list.at(i); diff --git a/src/3rdparty/phonon/gstreamer/devicemanager.h b/src/3rdparty/phonon/gstreamer/devicemanager.h index a5e8289..9c6aa8d 100644 --- a/src/3rdparty/phonon/gstreamer/devicemanager.h +++ b/src/3rdparty/phonon/gstreamer/devicemanager.h @@ -42,6 +42,7 @@ public : int id; QByteArray gstId; QByteArray description; + QString icon; }; class DeviceManager : public QObject { @@ -51,8 +52,10 @@ public: virtual ~DeviceManager(); const QList audioOutputDevices() const; GstPad *requestPad(int device) const; + int allocateDeviceId(); int deviceId(const QByteArray &gstId) const; - QByteArray deviceDescription(int id) const; + const QByteArray gstId(int id); + AudioDevice* audioDevice(int id); GstElement *createGNOMEAudioSink(Category category); GstElement *createAudioSink(Category category = NoCategory); AbstractRenderer *createVideoRenderer(VideoWidget *parent); @@ -68,6 +71,7 @@ private: bool canOpenDevice(GstElement *element) const; Backend *m_backend; QList m_audioDeviceList; + int m_audioDeviceCounter; QTimer m_devicePollTimer; QByteArray m_audioSink; QByteArray m_videoSinkWidget; diff --git a/src/3rdparty/phonon/gstreamer/effectmanager.cpp b/src/3rdparty/phonon/gstreamer/effectmanager.cpp index 563e6fc..6c88148 100644 --- a/src/3rdparty/phonon/gstreamer/effectmanager.cpp +++ b/src/3rdparty/phonon/gstreamer/effectmanager.cpp @@ -54,7 +54,7 @@ EffectManager::EffectManager(Backend *backend) // "volume" not needed // "equalizer-nbands" not really useful at the moment - // These plugins simply dont work or have major stability issues: + // These plugins simply don't work or have major stability issues: // "iir" Does not seem to do much at the moment // "audioinvert" Only works for some streams, should be invesigated // "lpwsinc" Crashes for large values of filter kernel diff --git a/src/3rdparty/phonon/gstreamer/glrenderer.cpp b/src/3rdparty/phonon/gstreamer/glrenderer.cpp index 6cf3459..c72780a 100644 --- a/src/3rdparty/phonon/gstreamer/glrenderer.cpp +++ b/src/3rdparty/phonon/gstreamer/glrenderer.cpp @@ -266,7 +266,7 @@ GLRenderWidgetImplementation::GLRenderWidgetImplementation(VideoWidget*videoWidg palette.setColor(QPalette::Background, Qt::black); setPalette(palette); setAutoFillBackground(true); - // Videowidget allways have this property to allow hiding the mouse cursor + // Videowidget always have this property to allow hiding the mouse cursor setMouseTracking(true); } diff --git a/src/3rdparty/phonon/gstreamer/gsthelper.cpp b/src/3rdparty/phonon/gstreamer/gsthelper.cpp index 34d99fa..69bb75c 100644 --- a/src/3rdparty/phonon/gstreamer/gsthelper.cpp +++ b/src/3rdparty/phonon/gstreamer/gsthelper.cpp @@ -121,7 +121,7 @@ GstElement* GstHelper::createPluggablePlaybin() { GstElement *playbin = 0; //init playbin and add to our pipeline - playbin = gst_element_factory_make("playbin", NULL); + playbin = gst_element_factory_make("playbin2", NULL); //Create an identity element to redirect sound GstElement *audioSinkBin = gst_bin_new (NULL); diff --git a/src/3rdparty/phonon/gstreamer/gstreamer.desktop b/src/3rdparty/phonon/gstreamer/gstreamer.desktop index b62472b..0861762 100644 --- a/src/3rdparty/phonon/gstreamer/gstreamer.desktop +++ b/src/3rdparty/phonon/gstreamer/gstreamer.desktop @@ -10,28 +10,81 @@ Icon=phonon-gstreamer InitialPreference=10 Name=GStreamer +Name[bg]=GStreamer +Name[ca]=GStreamer +Name[ca@valencia]=GStreamer +Name[cs]=GStreamer +Name[da]=GStreamer +Name[de]=GStreamer +Name[el]=GStreamer +Name[en_GB]=GStreamer +Name[es]=GStreamer +Name[et]=GStreamer +Name[eu]=GStreamer +Name[fi]=GStreamer +Name[fr]=GStreamer +Name[ga]=GStreamer +Name[gl]=GStreamer +Name[hsb]=GStreamer +Name[hu]=GStreamer +Name[id]=GStreamer +Name[is]=GStreamer +Name[it]=GStreamer +Name[ja]=GStreamer +Name[ko]=GStreamer +Name[ku]=GStreamer +Name[lt]=GStreamer +Name[lv]=GStreamer +Name[nb]=GStreamer +Name[nds]=GStreamer +Name[nl]=GStreamer +Name[nn]=GStreamer Name[pa]=ਜੀਸਟੀਰਮਰ +Name[pl]=GStreamer +Name[pt]=GStreamer +Name[pt_BR]=GStreamer +Name[ru]=GStreamer +Name[se]=GStreamer +Name[sk]=GStreamer +Name[sl]=GStreamer Name[sr]=Гстример +Name[sr@ijekavian]=Гстример +Name[sr@ijekavianlatin]=GStreamer +Name[sr@latin]=GStreamer Name[sv]=Gstreamer +Name[tr]=GStreamer +Name[uk]=GStreamer Name[x-test]=xxGStreamerxx +Name[zh_CN]=GStreamer +Name[zh_TW]=GStreamer Comment=Phonon GStreamer backend Comment[bg]=Phonon GStreamer Comment[ca]=Dorsal GStreamer del Phonon +Comment[ca@valencia]=Dorsal GStreamer del Phonon +Comment[cs]=Phonon GStreamer backend Comment[da]=GStreamer-backend til Phonon Comment[de]=Phonon-Treiber für GStreamer Comment[el]=Σύστημα υποστήριξης GStreamer του Phonon +Comment[en_GB]=Phonon GStreamer backend Comment[es]=Motor GStreamer para Phonon Comment[et]=Phononi GStreameri taustaprogramm +Comment[eu]=Phonon GStreamer backend +Comment[fi]=Phonon GStreamer-taustaohjelma Comment[fr]=Système de gestion GStreamer pour Phonon Comment[ga]=Inneall GStreamer le haghaidh Phonon Comment[gl]=Infraestrutura de GStreamer para Phonon +Comment[hsb]=Phonon GStreamer backend +Comment[hu]=Phonon GStreamer modul +Comment[id]=Phonon GStreamer backend Comment[is]=Phonon GStreamer bakendi Comment[it]=Motore Gstreamer di Phonon Comment[ja]=Phonon GStreamer バックエンド Comment[ko]=Phonon GStreamer 백엔드 Comment[ku]=Binesaza Phonon GStreamer +Comment[lt]=Phonon GStreamer galinė sąsaja Comment[lv]=Phonon GStreamer aizmugure +Comment[nb]=Phonon-motor for GStreamer Comment[nds]=Phonon-Hülpprogramm GStreamer Comment[nl]=GStreamer-backend (Phonon) Comment[nn]=Phonon-motor for GStreamer @@ -39,9 +92,13 @@ Comment[pa]=ਫੋਨੋਨ ਜਸਟੀਰਮਰ ਬੈਕਐਂਡ Comment[pl]=Obsługa GStreamera przez Phonon Comment[pt]=Infra-estrutura do GStreamer para o Phonon Comment[pt_BR]=Infraestrutura Phonon GStreamer +Comment[ru]=Механизм GStreamer для Phonon +Comment[se]=Phonon GStreamer duogášmohtor Comment[sk]=GStreamer podsystém Comment[sl]=Phononova hrbtenica GStreamer Comment[sr]=Гстример као позадина Фонона +Comment[sr@ijekavian]=Гстример као позадина Фонона +Comment[sr@ijekavianlatin]=GStreamer kao pozadina Phonona Comment[sr@latin]=GStreamer kao pozadina Phonona Comment[sv]=Phonon Gstreamer-gränssnitt Comment[tr]=Phonon GStreamer arka ucu diff --git a/src/3rdparty/phonon/gstreamer/medianode.cpp b/src/3rdparty/phonon/gstreamer/medianode.cpp index 7257972..1a84592 100644 --- a/src/3rdparty/phonon/gstreamer/medianode.cpp +++ b/src/3rdparty/phonon/gstreamer/medianode.cpp @@ -198,9 +198,9 @@ bool MediaNode::disconnectNode(QObject *obj) // Disconnecting elements while playing or paused seems to cause // potential deadlock. Hence we force the pipeline into ready state // before any nodes are disconnected. - gst_element_set_state(root()->pipeline(), GST_STATE_READY); + gst_element_set_state(root()->pipeline(), GST_STATE_READY); - Q_ASSERT(sink->root()); //sink has to have a root since it is onnected + Q_ASSERT(sink->root()); //sink has to have a root since it is connected if (sink->description() & (AudioSink)) { GstPad *sinkPad = gst_element_get_pad(sink->audioElement(), "sink"); diff --git a/src/3rdparty/phonon/gstreamer/mediaobject.cpp b/src/3rdparty/phonon/gstreamer/mediaobject.cpp index b6d23ec..3e0addc 100644 --- a/src/3rdparty/phonon/gstreamer/mediaobject.cpp +++ b/src/3rdparty/phonon/gstreamer/mediaobject.cpp @@ -16,6 +16,7 @@ */ #include #include +#include #include "common.h" #include "mediaobject.h" #include "videowidget.h" @@ -53,6 +54,7 @@ MediaObject::MediaObject(Backend *backend, QObject *parent) , m_tickTimer(new QTimer(this)) , m_prefinishMark(0) , m_transitionTime(0) + , m_isStream(false) , m_posAtSeek(-1) , m_prefinishMarkReachedNotEmitted(true) , m_aboutToFinishEmitted(false) @@ -79,6 +81,7 @@ MediaObject::MediaObject(Backend *backend, QObject *parent) , m_autoplayTitles(true) , m_availableTitles(0) , m_currentTitle(1) + , m_pendingTitle(1) { qRegisterMetaType("GstCaps*"); qRegisterMetaType("State"); @@ -95,8 +98,8 @@ MediaObject::MediaObject(Backend *backend, QObject *parent) m_backend->addBusWatcher(this); connect(m_tickTimer, SIGNAL(timeout()), SLOT(emitTick())); } - connect(this, SIGNAL(stateChanged(Phonon::State,Phonon::State)), - this, SLOT(notifyStateChange(Phonon::State,Phonon::State))); + connect(this, SIGNAL(stateChanged(Phonon::State, Phonon::State)), + this, SLOT(notifyStateChange(Phonon::State, Phonon::State))); } @@ -136,6 +139,14 @@ QString stateString(const Phonon::State &state) return QString(); } +void +pluginInstallationDone( GstInstallPluginsReturn res, gpointer userData ) +{ + // Nothing inside yet + Q_UNUSED(res); + Q_UNUSED(userData); +} + void MediaObject::saveState() { //Only first resumeState is respected @@ -195,13 +206,35 @@ void MediaObject::noMorePadsAvailable () if (m_missingCodecs.size() > 0) { bool canPlay = (m_hasAudio || m_videoStreamFound); Phonon::ErrorType error = canPlay ? Phonon::NormalError : Phonon::FatalError; +#ifdef PLUGIN_INSTALL_API + GstInstallPluginsContext *ctx = gst_install_plugins_context_new (); + gchar *details[2]; + details[0] = m_missingCodecs[0].toLocal8Bit().data(); + details[1] = NULL; + GstInstallPluginsReturn status; + + status = gst_install_plugins_async( details, ctx, pluginInstallationDone, NULL ); + gst_install_plugins_context_free ( ctx ); + + if ( status != GST_INSTALL_PLUGINS_STARTED_OK ) + { + if( status == GST_INSTALL_PLUGINS_HELPER_MISSING ) + setError(QString(tr("Missing codec helper script assistant.")), Phonon::FatalError ); + else + setError(QString(tr("Plugin codec installation failed for codec: %0")) + .arg(m_missingCodecs[0].split("|")[3]), error); + } + m_missingCodecs.clear(); +#else + QString codecs = m_missingCodecs.join(", "); + if (error == Phonon::NormalError && m_hasVideo && !m_videoStreamFound) { m_hasVideo = false; emit hasVideoChanged(false); } - QString codecs = m_missingCodecs.join(", "); setError(QString(tr("A required codec is missing. You need to install the following codec(s) to play this content: %0")).arg(codecs), error); m_missingCodecs.clear(); +#endif } } @@ -248,7 +281,16 @@ void MediaObject::cb_unknown_type (GstElement *decodebin, GstPad *pad, GstCaps * value = QString::fromUtf8(gst_structure_get_name (str)); } - media->addMissingCodecName(value); + +#ifdef PLUGIN_INSTALL_API + QString plugins = QString("gstreamer|0.10|%0|%1|decoder-%2") + .arg( qApp->applicationName() ) + .arg( value ) + .arg( QString::fromUtf8(gst_caps_to_string (caps) ) ); + media->addMissingCodecName( plugins ); +#else + media->addMissingCodecName( value ); +#endif } static void notifyVideoCaps(GObject *obj, GParamSpec *, gpointer data) @@ -309,7 +351,7 @@ void MediaObject::connectVideo(GstPad *pad) m_backend->logMessage("Video track connected", Backend::Info, this); // Note that the notify::caps _must_ be installed after linking to work with Dapper m_capsHandler = g_signal_connect(pad, "notify::caps", G_CALLBACK(notifyVideoCaps), this); - + if (!m_loading && !m_hasVideo) { m_hasVideo = m_videoStreamFound; emit hasVideoChanged(m_hasVideo); @@ -368,7 +410,10 @@ bool MediaObject::createPipefromURL(const QUrl &url) } // Create a new datasource based on the input URL - QByteArray encoded_cstr_url = url.toEncoded(); + // add the 'file' scheme if it's missing; the double '/' is needed! + QByteArray encoded_cstr_url = (url.scheme() == QLatin1String("") ? + "file://" + url.toEncoded() : + url.toEncoded()); m_datasource = gst_element_make_from_uri(GST_URI_SRC, encoded_cstr_url.constData(), (const char*)NULL); if (!m_datasource) return false; @@ -388,6 +433,14 @@ bool MediaObject::createPipefromURL(const QUrl &url) g_object_set (G_OBJECT (m_datasource), "read-speed", 2, (const char*)NULL); m_backend->logMessage(QString("new device speed : 2X"), Backend::Info, this); } + } + + /* make HTTP sources send extra headers so we get icecast + * metadata in case the stream is an icecast stream */ + if (encoded_cstr_url.startsWith("http://") + && g_object_class_find_property (G_OBJECT_GET_CLASS (m_datasource), "iradio-mode")) { + g_object_set (m_datasource, "iradio-mode", TRUE, NULL); + m_isStream = true; } // Link data source into pipeline @@ -442,7 +495,7 @@ void MediaObject::createPipeline() gst_object_ref (GST_OBJECT (m_pipeline)); gst_object_sink (GST_OBJECT (m_pipeline)); - m_decodebin = gst_element_factory_make ("decodebin", NULL); + m_decodebin = gst_element_factory_make ("decodebin2", NULL); g_signal_connect (m_decodebin, "new-decoded-pad", G_CALLBACK (&cb_newpad), this); g_signal_connect (m_decodebin, "unknown-type", G_CALLBACK (&cb_unknown_type), this); g_signal_connect (m_decodebin, "no-more-pads", G_CALLBACK (&cb_no_more_pads), this); @@ -646,7 +699,7 @@ void MediaObject::setState(State newstate) m_backend->logMessage("EOS already reached", Backend::Info, this); } else if (currentState == GST_STATE_PLAYING) { changeState(Phonon::PlayingState); - } else if (!m_atEndOfStream && gst_element_set_state(m_pipeline, GST_STATE_PLAYING) != GST_STATE_CHANGE_FAILURE) { + } else if (gst_element_set_state(m_pipeline, GST_STATE_PLAYING) != GST_STATE_CHANGE_FAILURE) { m_pendingState = Phonon::PlayingState; } else { m_backend->logMessage("phonon state request failed", Backend::Info, this); @@ -676,7 +729,7 @@ void MediaObject::changeState(State newstate) return; Phonon::State oldState = m_state; - m_state = newstate; // m_state must be set before emitting, since + m_state = newstate; // m_state must be set before emitting, since // Error state requires that state() will return the new value m_pendingState = newstate; emit stateChanged(newstate, oldState); @@ -696,6 +749,8 @@ void MediaObject::changeState(State newstate) case Phonon::StoppedState: m_backend->logMessage("phonon state changed: Stopped", Backend::Info, this); + // We must reset the pipeline when playing again + m_resetNeeded = true; m_tickTimer->stop(); break; @@ -861,7 +916,7 @@ void MediaObject::setSource(const MediaSource &source) // such as failing duration queries etc GstState state; gst_element_set_state(m_pipeline, GST_STATE_NULL); - gst_element_get_state (m_pipeline, &state, NULL, 2000); + gst_element_get_state(m_pipeline, &state, NULL, 2000); m_source = source; emit currentSourceChanged(m_source); @@ -871,7 +926,9 @@ void MediaObject::setSource(const MediaSource &source) // Go into to loading state changeState(Phonon::LoadingState); m_loading = true; - m_resetNeeded = false; + // IMPORTANT: Honor the m_resetNeeded flag as it currently stands. + // See https://qa.mandriva.com/show_bug.cgi?id=56807 + //m_resetNeeded = false; m_resumeState = false; m_pendingState = Phonon::StoppedState; @@ -884,8 +941,8 @@ void MediaObject::setSource(const MediaSource &source) // Clear any existing errors m_aboutToFinishEmitted = false; m_error = NoError; - m_errorString = QString(); - + m_errorString.clear(); + m_bufferPercent = 0; m_prefinishMarkReachedNotEmitted = true; m_aboutToFinishEmitted = false; @@ -894,22 +951,23 @@ void MediaObject::setSource(const MediaSource &source) setTotalTime(-1); m_atEndOfStream = false; - // Clear exising meta tags + m_availableTitles = 0; + m_pendingTitle = 1; + m_currentTitle = 1; + + // Clear existing meta tags m_metaData.clear(); + m_isStream = false; switch (source.type()) { - case MediaSource::Url: { - if (createPipefromURL(source.url())) - m_loading = true; - else + case MediaSource::Url: { + if (!createPipefromURL(source.url())) setError(tr("Could not open media source.")); } break; case MediaSource::LocalFile: { - if (createPipefromURL(QUrl::fromLocalFile(source.fileName()))) - m_loading = true; - else + if (!createPipefromURL(QUrl::fromLocalFile(source.fileName()))) setError(tr("Could not open media source.")); } break; @@ -922,17 +980,15 @@ void MediaObject::setSource(const MediaSource &source) break; case MediaSource::Stream: - if (createPipefromStream(source)) - m_loading = true; - else + if (!createPipefromStream(source)) setError(tr("Could not open media source.")); break; case MediaSource::Disc: { - QString mediaUrl; - switch (source.discType()) { - case Phonon::NoDisc: + QString mediaUrl; + switch (source.discType()) { + case Phonon::NoDisc: qWarning() << "I should never get to see a MediaSource that is a disc but doesn't specify which one"; return; case Phonon::Cd: // CD tracks can be specified by setting the url in the following way uri=cdda:4 @@ -948,9 +1004,7 @@ void MediaObject::setSource(const MediaSource &source) qWarning() << "media " << source.discType() << " not implemented"; return; } - if (!mediaUrl.isEmpty() && createPipefromURL(QUrl(mediaUrl))) - m_loading = true; - else + if (mediaUrl.isEmpty() || !createPipefromURL(QUrl(mediaUrl))) setError(tr("Could not open media source.")); } break; @@ -966,8 +1020,7 @@ void MediaObject::setSource(const MediaSource &source) // We need to link this node to ensure that fake sinks are connected // before loading, otherwise the stream will be blocked - if (m_loading) - link(); + link(); beginLoad(); } @@ -1004,22 +1057,22 @@ void MediaObject::getStreamInfo() emit hasVideoChanged(m_hasVideo); } - m_availableTitles = 1; - gint64 titleCount; - GstFormat format = gst_format_get_by_nick("track"); - if (gst_element_query_duration (m_pipeline, &format, &titleCount)) { + if (m_source.discType() == Phonon::Cd) { + gint64 titleCount; + GstFormat format = gst_format_get_by_nick("track"); + if (gst_element_query_duration (m_pipeline, &format, &titleCount)) { //check if returned format is still "track", //gstreamer sometimes returns the total time, if tracks information is not available. - if (qstrcmp(gst_format_get_name(format), "track") == 0) { - int oldAvailableTitles = m_availableTitles; - m_availableTitles = (int)titleCount; - if (m_availableTitles != oldAvailableTitles) { - emit availableTitlesChanged(m_availableTitles); - m_backend->logMessage(QString("Available titles changed: %0").arg(m_availableTitles), Backend::Info, this); + if (qstrcmp(gst_format_get_name(format), "track") == 0) { + int oldAvailableTitles = m_availableTitles; + m_availableTitles = (int)titleCount; + if (m_availableTitles != oldAvailableTitles) { + emit availableTitlesChanged(m_availableTitles); + m_backend->logMessage(QString("Available titles changed: %0").arg(m_availableTitles), Backend::Info, this); + } } } } - } void MediaObject::setPrefinishMark(qint32 newPrefinishMark) @@ -1077,7 +1130,7 @@ void MediaObject::seek(qint64 time) } quint64 current = currentTime(); - quint64 total = totalTime(); + quint64 total = totalTime(); if (current < total - m_prefinishMark) m_prefinishMarkReachedNotEmitted = true; @@ -1098,7 +1151,7 @@ void MediaObject::emitTick() if (m_tickInterval > 0 && currentTime != m_previousTickTime) { emit tick(currentTime); - m_previousTickTime = currentTime; + m_previousTickTime = currentTime; } if (m_state == Phonon::PlayingState) { if (currentTime >= totalTime - m_prefinishMark) { @@ -1109,7 +1162,12 @@ void MediaObject::emitTick() } // Prepare load of next source if (currentTime >= totalTime - ABOUT_TO_FINNISH_TIME) { - if (!m_aboutToFinishEmitted) { + if (m_source.type() == MediaSource::Disc && + m_autoplayTitles && + m_availableTitles > 1 && + m_currentTitle < m_availableTitles) { + m_aboutToFinishEmitted = false; + } else if (!m_aboutToFinishEmitted) { m_aboutToFinishEmitted = true; // track is about to finish emit aboutToFinish(); } @@ -1213,8 +1271,8 @@ void MediaObject::handleBusMessage(const Message &message) switch (GST_MESSAGE_TYPE (gstMessage)) { - case GST_MESSAGE_EOS: - m_backend->logMessage("EOS recieved", Backend::Info, this); + case GST_MESSAGE_EOS: + m_backend->logMessage("EOS received", Backend::Info, this); handleEndOfStream(); break; @@ -1222,14 +1280,98 @@ void MediaObject::handleBusMessage(const Message &message) GstTagList* tag_list = 0; gst_message_parse_tag(gstMessage, &tag_list); if (tag_list) { + TagMap newTags; + gst_tag_list_foreach (tag_list, &foreach_tag_function, &newTags); + gst_tag_list_free(tag_list); + + // Determine if we should no fake the album/artist tags. + // This is a little confusing as we want to fake it on initial + // connection where title, album and artist are all missing. + // There are however times when we get just other information, + // e.g. codec, and so we want to only do clever stuff if we + // have a commonly available tag (ORGANIZATION) or we have a + // change in title + bool fake_it = + (m_isStream + && ((!newTags.contains("TITLE") + && newTags.contains("ORGANIZATION")) + || (newTags.contains("TITLE") + && m_metaData.value("TITLE") != newTags.value("TITLE"))) + && !newTags.contains("ALBUM") + && !newTags.contains("ARTIST")); + TagMap oldMap = m_metaData; // Keep a copy of the old one for reference - // Append any new meta tags to the existing tag list - gst_tag_list_foreach (tag_list, &foreach_tag_function, &m_metaData); + + // Now we've checked the new data, append any new meta tags to the existing tag list + // We cannot use TagMap::iterator as this is a multimap and when streaming data + // could in theory be lost. + QList keys = newTags.keys(); + for (QList::iterator i = keys.begin(); i != keys.end(); ++i) { + QString key = *i; + if (m_isStream) { + // If we're streaming, we need to remove data in m_metaData + // in order to stop it filling up indefinitely (as it's a multimap) + m_metaData.remove(key); + } + QList values = newTags.values(key); + for (QList::iterator j = values.begin(); j != values.end(); ++j) { + QString value = *j; + QString currVal = m_metaData.value(key); + if (!m_metaData.contains(key) || currVal != value) { + m_metaData.insert(key, value); + } + } + } + m_backend->logMessage("Meta tags found", Backend::Info, this); - if (oldMap != m_metaData && !m_loading) - emit metaDataChanged(m_metaData); - gst_tag_list_free(tag_list); - } + if (oldMap != m_metaData) { + // This is a bit of a hack to ensure that stream metadata is + // returned. We get as much as we can from the Shoutcast server's + // StreamTitle= header. If further info is decoded from the stream + // itself later, then it will overwrite this info. + if (m_isStream && fake_it) { + m_metaData.remove("ALBUM"); + m_metaData.remove("ARTIST"); + + // Detect whether we want to "fill in the blanks" + QString str; + if (m_metaData.contains("TITLE")) + { + str = m_metaData.value("TITLE"); + int splitpoint; + // Check to see if our title matches "%s - %s" + // Where neither %s are empty... + if ((splitpoint = str.indexOf(" - ")) > 0 + && str.size() > (splitpoint+3)) { + m_metaData.insert("ARTIST", str.left(splitpoint)); + m_metaData.replace("TITLE", str.mid(splitpoint+3)); + } + } else { + str = m_metaData.value("GENRE"); + if (!str.isEmpty()) + m_metaData.insert("TITLE", str); + else + m_metaData.insert("TITLE", "Streaming Data"); + } + if (!m_metaData.contains("ARTIST")) { + str = m_metaData.value("LOCATION"); + if (!str.isEmpty()) + m_metaData.insert("ARTIST", str); + else + m_metaData.insert("ARTIST", "Streaming Data"); + } + str = m_metaData.value("ORGANIZATION"); + if (!str.isEmpty()) + m_metaData.insert("ALBUM", str); + else + m_metaData.insert("ALBUM", "Streaming Data"); + } + // As we manipulate the title, we need to recompare + // oldMap and m_metaData here... + if (oldMap != m_metaData && !m_loading) + emit metaDataChanged(m_metaData); + } + } } break; @@ -1255,6 +1397,9 @@ void MediaObject::handleBusMessage(const Message &message) m_backend->logMessage("gstreamer: pipeline state set to playing", Backend::Info, this); m_tickTimer->start(); changeState(Phonon::PlayingState); + if ((m_source.type() == MediaSource::Disc) && (m_currentTitle != m_pendingTitle)) { + setTrack(m_pendingTitle); + } if (m_resumeState && m_oldState == Phonon::PlayingState) { seek(m_oldPos); m_resumeState = false; @@ -1290,6 +1435,9 @@ void MediaObject::handleBusMessage(const Message &message) changeState(Phonon::StoppedState); m_backend->logMessage("gstreamer: pipeline state set to ready", Backend::Debug, this); m_tickTimer->stop(); + if ((m_source.type() == MediaSource::Disc) && (m_currentTitle != m_pendingTitle)) { + setTrack(m_pendingTitle); + } break; case GST_STATE_VOID_PENDING : @@ -1328,7 +1476,7 @@ void MediaObject::handleBusMessage(const Message &message) setError(err->message, Phonon::FatalError); gst_caps_unref (caps); gst_object_unref (sinkPad); - } + } } else { setError(QString(err->message), Phonon::FatalError); } @@ -1400,8 +1548,8 @@ void MediaObject::handleBusMessage(const Message &message) //case GST_MESSAGE_STEP_DONE: //case GST_MESSAGE_LATENCY: only from 0.10.12 //case GST_MESSAGE_ASYNC_DONE: only from 0.10.13 - default: - break; + default: + break; } } @@ -1417,7 +1565,8 @@ void MediaObject::handleEndOfStream() if (!m_seekable) m_atEndOfStream = true; - if (m_autoplayTitles && + if (m_source.type() == MediaSource::Disc && + m_autoplayTitles && m_availableTitles > 1 && m_currentTitle < m_availableTitles) { _iface_setCurrentTitle(m_currentTitle + 1); @@ -1444,6 +1593,14 @@ void MediaObject::handleEndOfStream() } } +void MediaObject::invalidateGraph() +{ + m_resetNeeded = true; + if (m_state == Phonon::PlayingState || m_state == Phonon::PausedState) { + changeState(Phonon::StoppedState); + } +} + // Notifes the pipeline about state changes in the media object void MediaObject::notifyStateChange(Phonon::State newstate, Phonon::State oldstate) { @@ -1502,15 +1659,30 @@ int MediaObject::_iface_currentTitle() const void MediaObject::_iface_setCurrentTitle(int title) { - GstFormat trackFormat = gst_format_get_by_nick("track"); m_backend->logMessage(QString("setCurrentTitle %0").arg(title), Backend::Info, this); - if ((title == m_currentTitle) || (title < 1) || (title > m_availableTitles)) + if ((title == m_currentTitle) || (title == m_pendingTitle)) + return; + + m_pendingTitle = title; + + if (m_state == Phonon::PlayingState || m_state == Phonon::StoppedState) { + setTrack(m_pendingTitle); + } else { + setState(Phonon::StoppedState); + } +} + +void MediaObject::setTrack(int title) +{ + if (((m_state != Phonon::PlayingState) && (m_state != Phonon::StoppedState)) || (title < 1) || (title > m_availableTitles)) return; - m_currentTitle = title; //let's seek to the beginning of the song - if (gst_element_seek_simple(m_pipeline, trackFormat, GST_SEEK_FLAG_FLUSH, m_currentTitle - 1)) { + GstFormat trackFormat = gst_format_get_by_nick("track"); + m_backend->logMessage(QString("setTrack %0").arg(title), Backend::Info, this); + if (gst_element_seek_simple(m_pipeline, trackFormat, GST_SEEK_FLAG_FLUSH, title - 1)) { + m_currentTitle = title; updateTotalTime(); m_atEndOfStream = false; emit titleChanged(title); diff --git a/src/3rdparty/phonon/gstreamer/mediaobject.h b/src/3rdparty/phonon/gstreamer/mediaobject.h index 64b3510..d588ffc 100644 --- a/src/3rdparty/phonon/gstreamer/mediaobject.h +++ b/src/3rdparty/phonon/gstreamer/mediaobject.h @@ -55,6 +55,7 @@ class MediaObject : public QObject, public MediaObjectInterface , public MediaNode { friend class Stream; + friend class AudioDataOutput; Q_OBJECT Q_INTERFACES(Phonon::MediaObjectInterface #ifndef QT_NO_PHONON_MEDIACONTROLLER @@ -144,12 +145,8 @@ public: void handleBusMessage(const Message &msg); void handleEndOfStream(); void addMissingCodecName(const QString &codec) { m_missingCodecs.append(codec); } - void invalidateGraph() { - m_resetNeeded = true; - if (m_state == Phonon::PlayingState || m_state == Phonon::PausedState) { - changeState(Phonon::StoppedState); - } - } + void invalidateGraph(); + static void cb_newpad (GstElement *decodebin, GstPad *pad, gboolean last, gpointer data); static void cb_pad_added (GstElement *decodebin, GstPad *pad, gpointer data); static void cb_unknown_type (GstElement *decodebin, GstPad *pad, GstCaps *caps, gpointer data); @@ -236,6 +233,7 @@ private: int _iface_availableTitles() const; int _iface_currentTitle() const; void _iface_setCurrentTitle(int title); + void setTrack(int title); bool m_resumeState; State m_oldState; @@ -250,6 +248,7 @@ private: MediaSource m_nextSource; qint32 m_prefinishMark; qint32 m_transitionTime; + bool m_isStream; qint64 m_posAtSeek; @@ -285,6 +284,7 @@ private: bool m_autoplayTitles; int m_availableTitles; int m_currentTitle; + int m_pendingTitle; }; } } //namespace Phonon::Gstreamer diff --git a/src/3rdparty/phonon/gstreamer/qwidgetvideosink.h b/src/3rdparty/phonon/gstreamer/qwidgetvideosink.h index 73a494a..f83dba5 100644 --- a/src/3rdparty/phonon/gstreamer/qwidgetvideosink.h +++ b/src/3rdparty/phonon/gstreamer/qwidgetvideosink.h @@ -19,6 +19,7 @@ #define Phonon_GSTREAMER_VIDEOSINK_H #include "common.h" +#include "qwidgetvideosink.h" #include #include diff --git a/src/3rdparty/phonon/gstreamer/videowidget.h b/src/3rdparty/phonon/gstreamer/videowidget.h index dc0754d..8603f6a 100644 --- a/src/3rdparty/phonon/gstreamer/videowidget.h +++ b/src/3rdparty/phonon/gstreamer/videowidget.h @@ -25,6 +25,7 @@ #include "common.h" #include "medianode.h" #include "abstractrenderer.h" +#include "videowidget.h" #include diff --git a/src/3rdparty/phonon/gstreamer/x11renderer.cpp b/src/3rdparty/phonon/gstreamer/x11renderer.cpp index 73877a8..968f3a8 100644 --- a/src/3rdparty/phonon/gstreamer/x11renderer.cpp +++ b/src/3rdparty/phonon/gstreamer/x11renderer.cpp @@ -90,7 +90,7 @@ GstElement* X11Renderer::createVideoSink() gst_object_unref(GST_OBJECT(videoSink)); videoSink = 0; } else { - // Note that this should not really be neccessary as these are + // Note that this should not really be necessary as these are // default values, though under certain conditions values are retained // even between application instances. (reproducible on 0.10.16/Gutsy) g_object_set(G_OBJECT(videoSink), "brightness", 0, (const char*)NULL); @@ -138,6 +138,7 @@ void X11Renderer::scaleModeChanged(Phonon::VideoWidget::ScaleMode) void X11Renderer::movieSizeChanged(const QSize &movieSize) { Q_UNUSED(movieSize); + if (m_renderWidget) { m_renderWidget->setGeometry(m_videoWidget->calculateDrawFrameRect()); } diff --git a/src/plugins/phonon/gstreamer/gstreamer.pro b/src/plugins/phonon/gstreamer/gstreamer.pro index ae597fa..1013205 100644 --- a/src/plugins/phonon/gstreamer/gstreamer.pro +++ b/src/plugins/phonon/gstreamer/gstreamer.pro @@ -15,6 +15,7 @@ PHONON_GSTREAMER_DIR = $$QT_SOURCE_TREE/src/3rdparty/phonon/gstreamer HEADERS += $$PHONON_GSTREAMER_DIR/common.h \ $$PHONON_GSTREAMER_DIR/audiooutput.h \ + $$PHONON_GSTREAMER_DIR/audiodataoutput.h \ $$PHONON_GSTREAMER_DIR/artssink.h \ $$PHONON_GSTREAMER_DIR/abstractrenderer.h \ $$PHONON_GSTREAMER_DIR/backend.h \ @@ -35,26 +36,27 @@ HEADERS += $$PHONON_GSTREAMER_DIR/common.h \ $$PHONON_GSTREAMER_DIR/audioeffect.h \ $$PHONON_GSTREAMER_DIR/volumefadereffect.h -SOURCES += $$PHONON_GSTREAMER_DIR/audiooutput.cpp \ - $$PHONON_GSTREAMER_DIR/abstractrenderer.cpp \ +SOURCES += $$PHONON_GSTREAMER_DIR/abstractrenderer.cpp \ $$PHONON_GSTREAMER_DIR/artssink.cpp \ + $$PHONON_GSTREAMER_DIR/audioeffect.cpp \ + $$PHONON_GSTREAMER_DIR/audiooutput.cpp \ + $$PHONON_GSTREAMER_DIR/audiodataoutput.cpp \ $$PHONON_GSTREAMER_DIR/backend.cpp \ $$PHONON_GSTREAMER_DIR/devicemanager.cpp \ $$PHONON_GSTREAMER_DIR/effect.cpp \ $$PHONON_GSTREAMER_DIR/effectmanager.cpp \ + $$PHONON_GSTREAMER_DIR/glrenderer.cpp \ $$PHONON_GSTREAMER_DIR/gsthelper.cpp \ - $$PHONON_GSTREAMER_DIR/mediaobject.cpp \ $$PHONON_GSTREAMER_DIR/medianode.cpp \ $$PHONON_GSTREAMER_DIR/medianodeevent.cpp \ - $$PHONON_GSTREAMER_DIR/widgetrenderer.cpp \ - $$PHONON_GSTREAMER_DIR/videowidget.cpp \ - $$PHONON_GSTREAMER_DIR/glrenderer.cpp \ - $$PHONON_GSTREAMER_DIR/qwidgetvideosink.cpp \ + $$PHONON_GSTREAMER_DIR/mediaobject.cpp \ + $$PHONON_GSTREAMER_DIR/message.cpp \ $$PHONON_GSTREAMER_DIR/phononsrc.cpp \ + $$PHONON_GSTREAMER_DIR/qwidgetvideosink.cpp \ $$PHONON_GSTREAMER_DIR/streamreader.cpp \ - $$PHONON_GSTREAMER_DIR/message.cpp \ - $$PHONON_GSTREAMER_DIR/audioeffect.cpp \ - $$PHONON_GSTREAMER_DIR/volumefadereffect.cpp + $$PHONON_GSTREAMER_DIR/videowidget.cpp \ + $$PHONON_GSTREAMER_DIR/volumefadereffect.cpp \ + $$PHONON_GSTREAMER_DIR/widgetrenderer.cpp !embedded { HEADERS += $$PHONON_GSTREAMER_DIR/x11renderer.h -- cgit v0.12 From 19a3fc3bd817628070e5637caf158b0be79eee82 Mon Sep 17 00:00:00 2001 From: Justin McPherson Date: Thu, 25 Mar 2010 14:00:31 +1000 Subject: Update Phonon ds9 backend to 4.4.0. --- src/3rdparty/phonon/ds9/abstractvideorenderer.cpp | 4 +- src/3rdparty/phonon/ds9/backend.cpp | 14 +- src/3rdparty/phonon/ds9/backend.h | 4 - src/3rdparty/phonon/ds9/backendnode.cpp | 19 -- src/3rdparty/phonon/ds9/ds9.desktop | 17 +- src/3rdparty/phonon/ds9/effect.cpp | 4 +- src/3rdparty/phonon/ds9/fakesource.cpp | 34 +++- src/3rdparty/phonon/ds9/iodevicereader.cpp | 92 ++++++--- src/3rdparty/phonon/ds9/iodevicereader.h | 1 + src/3rdparty/phonon/ds9/mediagraph.cpp | 38 ++-- src/3rdparty/phonon/ds9/mediaobject.cpp | 201 +++++++++++--------- src/3rdparty/phonon/ds9/mediaobject.h | 8 +- src/3rdparty/phonon/ds9/qasyncreader.cpp | 72 +++++--- src/3rdparty/phonon/ds9/qasyncreader.h | 6 +- src/3rdparty/phonon/ds9/qaudiocdreader.cpp | 54 ++++-- src/3rdparty/phonon/ds9/qaudiocdreader.h | 2 +- src/3rdparty/phonon/ds9/qbasefilter.cpp | 33 ++-- src/3rdparty/phonon/ds9/qbasefilter.h | 4 +- src/3rdparty/phonon/ds9/qevr9.h | 143 -------------- src/3rdparty/phonon/ds9/qmeminputpin.cpp | 113 ++++++++---- src/3rdparty/phonon/ds9/qmeminputpin.h | 9 +- src/3rdparty/phonon/ds9/qpin.cpp | 73 +++++--- src/3rdparty/phonon/ds9/qpin.h | 7 +- src/3rdparty/phonon/ds9/videorenderer_default.cpp | 153 --------------- src/3rdparty/phonon/ds9/videorenderer_default.h | 55 ------ src/3rdparty/phonon/ds9/videorenderer_evr.cpp | 215 ---------------------- src/3rdparty/phonon/ds9/videorenderer_evr.h | 56 ------ src/3rdparty/phonon/ds9/videorenderer_soft.cpp | 15 +- src/3rdparty/phonon/ds9/videorenderer_vmr9.cpp | 113 +++++++++++- src/3rdparty/phonon/ds9/videorenderer_vmr9.h | 1 + src/3rdparty/phonon/ds9/videowidget.cpp | 50 +---- src/3rdparty/phonon/ds9/volumeeffect.cpp | 5 +- src/3rdparty/phonon/ds9/volumeeffect.h | 2 +- 33 files changed, 621 insertions(+), 996 deletions(-) delete mode 100644 src/3rdparty/phonon/ds9/qevr9.h delete mode 100644 src/3rdparty/phonon/ds9/videorenderer_default.cpp delete mode 100644 src/3rdparty/phonon/ds9/videorenderer_default.h delete mode 100644 src/3rdparty/phonon/ds9/videorenderer_evr.cpp delete mode 100644 src/3rdparty/phonon/ds9/videorenderer_evr.h diff --git a/src/3rdparty/phonon/ds9/abstractvideorenderer.cpp b/src/3rdparty/phonon/ds9/abstractvideorenderer.cpp index a9d0694..e932e70 100644 --- a/src/3rdparty/phonon/ds9/abstractvideorenderer.cpp +++ b/src/3rdparty/phonon/ds9/abstractvideorenderer.cpp @@ -99,8 +99,8 @@ namespace Phonon m_dstX = m_dstY = 0; if (ratio > 0) { - if ((realWidth / realHeight > ratio && scaleMode == Phonon::VideoWidget::FitInView) - || (realWidth / realHeight < ratio && scaleMode == Phonon::VideoWidget::ScaleAndCrop)) { + if (realWidth / realHeight > ratio && scaleMode == Phonon::VideoWidget::FitInView + || realWidth / realHeight < ratio && scaleMode == Phonon::VideoWidget::ScaleAndCrop) { //the height is correct, let's change the width m_dstWidth = qRound(realHeight * ratio); m_dstX = qRound((realWidth - realHeight * ratio) / 2.); diff --git a/src/3rdparty/phonon/ds9/backend.cpp b/src/3rdparty/phonon/ds9/backend.cpp index fbc4bdc..2c56af7 100644 --- a/src/3rdparty/phonon/ds9/backend.cpp +++ b/src/3rdparty/phonon/ds9/backend.cpp @@ -41,8 +41,6 @@ namespace Phonon { namespace DS9 { - QMutex *Backend::directShowMutex = 0; - bool Backend::AudioMoniker::operator==(const AudioMoniker &other) { return other->IsEqual(*this) == S_OK; @@ -52,8 +50,6 @@ namespace Phonon Backend::Backend(QObject *parent, const QVariantList &) : QObject(parent) { - directShowMutex = &m_directShowMutex; - ::CoInitialize(0); //registering meta types @@ -66,8 +62,6 @@ namespace Phonon m_audioOutputs.clear(); m_audioEffects.clear(); ::CoUninitialize(); - - directShowMutex = 0; } QObject *Backend::createObject(BackendInterface::Class c, QObject *parent, const QList &args) @@ -137,7 +131,6 @@ namespace Phonon QList Backend::objectDescriptionIndexes(Phonon::ObjectDescriptionType type) const { - QMutexLocker locker(&m_directShowMutex); QList ret; switch(type) @@ -164,7 +157,7 @@ namespace Phonon while (S_OK == enumMon->Next(1, mon.pparam(), 0)) { LPOLESTR str = 0; mon->GetDisplayName(0,0,&str); - const QString name = QString::fromWCharArray(str); + const QString name = QString::fromUtf16((unsigned short*)str); ComPointer alloc; ::CoGetMalloc(1, alloc.pparam()); alloc->Free(str); @@ -211,7 +204,6 @@ namespace Phonon QHash Backend::objectDescriptionProperties(Phonon::ObjectDescriptionType type, int index) const { - QMutexLocker locker(&m_directShowMutex); QHash ret; switch (type) { @@ -224,7 +216,7 @@ namespace Phonon LPOLESTR str = 0; HRESULT hr = mon->GetDisplayName(0,0, &str); if (SUCCEEDED(hr)) { - QString name = QString::fromWCharArray(str); + QString name = QString::fromUtf16((unsigned short*)str); ComPointer alloc; ::CoGetMalloc(1, alloc.pparam()); alloc->Free(str); @@ -239,7 +231,7 @@ namespace Phonon WCHAR name[80]; // 80 is clearly stated in the MSDN doc HRESULT hr = ::DMOGetName(m_audioEffects[index], name); if (SUCCEEDED(hr)) { - ret["name"] = QString::fromWCharArray(name); + ret["name"] = QString::fromUtf16((unsigned short*)name); } } break; diff --git a/src/3rdparty/phonon/ds9/backend.h b/src/3rdparty/phonon/ds9/backend.h index 7c3c109..ad638f2 100644 --- a/src/3rdparty/phonon/ds9/backend.h +++ b/src/3rdparty/phonon/ds9/backend.h @@ -23,7 +23,6 @@ along with this library. If not, see . #include #include -#include #include "compointer.h" #include "backendnode.h" @@ -64,8 +63,6 @@ namespace Phonon Filter getAudioOutputFilter(int index) const; - static QMutex *directShowMutex; - Q_SIGNALS: void objectDescriptionChanged(ObjectDescriptionType); @@ -77,7 +74,6 @@ namespace Phonon }; mutable QVector m_audioOutputs; mutable QVector m_audioEffects; - mutable QMutex m_directShowMutex; }; } } diff --git a/src/3rdparty/phonon/ds9/backendnode.cpp b/src/3rdparty/phonon/ds9/backendnode.cpp index 737ab7b..7e0b3cd 100644 --- a/src/3rdparty/phonon/ds9/backendnode.cpp +++ b/src/3rdparty/phonon/ds9/backendnode.cpp @@ -57,25 +57,6 @@ namespace Phonon BackendNode::~BackendNode() { - //this will remove the filter from the graph - FILTER_INFO info; - for(int i = 0; i < FILTER_COUNT; ++i) { - const Filter &filter = m_filters[i]; - if (!filter) - continue; - filter->QueryFilterInfo(&info); - if (info.pGraph) { - HRESULT hr = info.pGraph->RemoveFilter(filter); - - if (FAILED(hr) && m_mediaObject) { - m_mediaObject->ensureStopped(); - - hr = info.pGraph->RemoveFilter(filter); - } - Q_ASSERT(SUCCEEDED(hr)); - info.pGraph->Release(); - } - } } void BackendNode::setMediaObject(MediaObject *mo) diff --git a/src/3rdparty/phonon/ds9/ds9.desktop b/src/3rdparty/phonon/ds9/ds9.desktop index 764390e..1bc3451 100644 --- a/src/3rdparty/phonon/ds9/ds9.desktop +++ b/src/3rdparty/phonon/ds9/ds9.desktop @@ -5,12 +5,13 @@ MimeType=application/x-annodex;video/quicktime;video/x-quicktime;audio/x-m4a;app X-KDE-Library=phonon_ds9 X-KDE-PhononBackendInfo-InterfaceVersion=1 X-KDE-PhononBackendInfo-Version=0.1 -X-KDE-PhononBackendInfo-Website=http://qt.nokia.com/ +X-KDE-PhononBackendInfo-Website=http://www.trolltech.com/ InitialPreference=15 Name=DirectShow9 Name[bg]=DirectShow9 Name[ca]=DirectShow9 +Name[ca@valencia]=DirectShow9 Name[cs]=DirectShow9 Name[da]=DirectShow9 Name[de]=DirectShow9 @@ -19,11 +20,14 @@ Name[en_GB]=DirectShow9 Name[es]=DirectShow9 Name[et]=DirectShow9 Name[eu]=DirectShow9 +Name[fi]=DirectShow9 Name[fr]=DirectShow9 Name[ga]=DirectShow9 Name[gl]=DirectShow9 +Name[hr]=DirectShow9 Name[hsb]=DirectShow9 Name[hu]=DirectShow9 +Name[id]=DirectShow9 Name[is]=DirectShow9 Name[it]=DirectShow9 Name[ja]=DirectShow9 @@ -31,6 +35,7 @@ Name[ko]=DirectShow9 Name[ku]=DirectShow9 Name[lt]=DirectShow9 Name[lv]=DirectShow9 +Name[nb]=DirectShow9 Name[nds]=DirectShow9 Name[nl]=DirectShow9 Name[nn]=DirectShow9 @@ -38,10 +43,13 @@ Name[pa]=ਡਾਇਰੈਕਸ਼ੋ9 Name[pl]=DirectShow9 Name[pt]=DirectShow9 Name[pt_BR]=DirectShow9 +Name[ru]=DirectShow9 Name[se]=DirectShow9 Name[sk]=DirectShow 9 Name[sl]=DirectShow 9 Name[sr]=Директшоу‑9 +Name[sr@ijekavian]=Директшоу‑9 +Name[sr@ijekavianlatin]=DirectShow‑9 Name[sr@latin]=DirectShow‑9 Name[sv]=Directshow 9 Name[tr]=DirectShow9 @@ -53,6 +61,7 @@ Name[zh_TW]=DirectShow9 Comment=Phonon DirectShow9 backend Comment[bg]=Phonon DirectShow9 Comment[ca]=Dorsal DirectShow9 del Phonon +Comment[ca@valencia]=Dorsal DirectShow9 del Phonon Comment[cs]=Phonon DirectShow9 backend Comment[da]=DirectShow9-backend til Phonon Comment[de]=Phonon-Treiber für DirectShow9 @@ -61,11 +70,13 @@ Comment[en_GB]=Phonon DirectShow9 backend Comment[es]=Motor DirectShow9 para Phonon Comment[et]=Phononi DirectShow9 taustaprogramm Comment[eu]=Phonon DirectShow9 backend +Comment[fi]=Phonon DirectShow9-taustaohjelma Comment[fr]=Système de gestion DirectShow9 pour Phonon Comment[ga]=Inneall DirectShow9 le haghaidh Phonon Comment[gl]=Infraestrutura de DirectShow9 para Phonon Comment[hsb]=Phonon DirectShow9 backend Comment[hu]=Phonon DirectShow9 modul +Comment[id]=Phonon DirectShow9 backend Comment[is]=Phonon DirectShow9 bakendi Comment[it]=Motore DirectShow9 di Phonon Comment[ja]=Phonon DirectShow9 バックエンド @@ -73,6 +84,7 @@ Comment[ko]=Phonon DirectShow9 백엔드 Comment[ku]=Binesaza Phonon DirectShow9 Comment[lt]=Phonon DirectShow9 galinė sąsaja Comment[lv]=Phonon DirectShow9 aizmugure +Comment[nb]=Phonon-motor for DirectShow9 Comment[nds]=Phonon-Hülpprogrmm DirectShow9 Comment[nl]=DirectShow9-backend (Phonon) Comment[nn]=Phonon-motor for DirectShow9 @@ -80,10 +92,13 @@ Comment[pa]=ਫੋਨੋਨ ਡਾਇਰੈਕਟਸ਼ੋ9 ਬੈਕਐਂਡ Comment[pl]=Obsługa DirectShow9 przez Phonon Comment[pt]=Infra-estrutura do DirectShow9 para o Phonon Comment[pt_BR]=Infraestrutura Phonon DirectShow9 +Comment[ru]=Механизм DirectShow9 для Phonon Comment[se]=Phonon DirectShow9 duogášmohtor Comment[sk]=Phonon DirectShow 9 podsystém Comment[sl]=Phononova Hrbtenica DirectShow 9 Comment[sr]=Директшоу‑9 као позадина Фонона +Comment[sr@ijekavian]=Директшоу‑9 као позадина Фонона +Comment[sr@ijekavianlatin]=DirectShow‑9 kao pozadina Phonona Comment[sr@latin]=DirectShow‑9 kao pozadina Phonona Comment[sv]=Phonon Directshow 9-gränssnitt Comment[tr]=Phonon DirectShow9 arka ucu diff --git a/src/3rdparty/phonon/ds9/effect.cpp b/src/3rdparty/phonon/ds9/effect.cpp index ebe976b..104a3c1 100644 --- a/src/3rdparty/phonon/ds9/effect.cpp +++ b/src/3rdparty/phonon/ds9/effect.cpp @@ -82,7 +82,7 @@ namespace Phonon current += wcslen(current) + 1; //skip the name current += wcslen(current) + 1; //skip the unit for(; *current; current += wcslen(current) + 1) { - values.append( QString::fromWCharArray(current) ); + values.append( QString::fromUtf16((unsigned short*)current) ); } } //FALLTHROUGH @@ -107,7 +107,7 @@ namespace Phonon Phonon::EffectParameter::Hints hint = info.mopCaps == MP_CAPS_CURVE_INVSQUARE ? Phonon::EffectParameter::LogarithmicHint : Phonon::EffectParameter::Hints(0); - const QString n = QString::fromWCharArray(name); + const QString n = QString::fromUtf16((unsigned short*)name); ret.append(Phonon::EffectParameter(i, n, hint, def, min, max, values)); ::CoTaskMemFree(name); //let's free the memory } diff --git a/src/3rdparty/phonon/ds9/fakesource.cpp b/src/3rdparty/phonon/ds9/fakesource.cpp index 4dce138..9a61a2e 100644 --- a/src/3rdparty/phonon/ds9/fakesource.cpp +++ b/src/3rdparty/phonon/ds9/fakesource.cpp @@ -29,10 +29,8 @@ namespace Phonon namespace DS9 { static WAVEFORMATEX g_defaultWaveFormat = {WAVE_FORMAT_PCM, 2, 44100, 176400, 4, 16, 0}; - static VIDEOINFOHEADER2 g_defaultVideoInfo = { { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, 0, 0, 0, 0, 0, 0, 0, {0}, 0, {sizeof(BITMAPINFOHEADER), 1, 1, 1, 0, 0, 0, 0, 0, 0, 0} }; - - static const AM_MEDIA_TYPE g_fakeAudioType = {MEDIATYPE_Audio, MEDIASUBTYPE_PCM, 0, 0, 2, FORMAT_WaveFormatEx, 0, sizeof(WAVEFORMATEX), reinterpret_cast(&g_defaultWaveFormat)}; - static const AM_MEDIA_TYPE g_fakeVideoType = {MEDIATYPE_Video, MEDIASUBTYPE_RGB32, TRUE, FALSE, 0, FORMAT_VideoInfo2, 0, sizeof(VIDEOINFOHEADER2), reinterpret_cast(&g_defaultVideoInfo)}; + static BITMAPINFOHEADER g_defautBitmapHeader = { sizeof(BITMAPINFOHEADER), 1, 1, 1, 0, 0, 0, 0, 0, 0, 0}; + static VIDEOINFOHEADER2 g_defaultVideoInfo = { { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; class FakePin : public QPin { @@ -130,12 +128,36 @@ namespace Phonon void FakeSource::createFakeAudioPin() { - new FakePin(this, g_fakeAudioType); + AM_MEDIA_TYPE mt; + qMemSet(&mt, 0, sizeof(AM_MEDIA_TYPE)); + mt.majortype = MEDIATYPE_Audio; + mt.subtype = MEDIASUBTYPE_PCM; + mt.formattype = FORMAT_WaveFormatEx; + mt.lSampleSize = 2; + + //fake the format (stereo 44.1 khz stereo 16 bits) + mt.cbFormat = sizeof(WAVEFORMATEX); + mt.pbFormat = reinterpret_cast(&g_defaultWaveFormat); + + new FakePin(this, mt); } void FakeSource::createFakeVideoPin() { - new FakePin(this, g_fakeVideoType); + AM_MEDIA_TYPE mt; + qMemSet(&mt, 0, sizeof(AM_MEDIA_TYPE)); + mt.majortype = MEDIATYPE_Video; + mt.subtype = MEDIASUBTYPE_RGB32; + mt.formattype = FORMAT_VideoInfo2; + mt.bFixedSizeSamples = 1; + + g_defaultVideoInfo.bmiHeader = g_defautBitmapHeader; + + //fake the format + mt.cbFormat = sizeof(VIDEOINFOHEADER2); + mt.pbFormat = reinterpret_cast(&g_defaultVideoInfo); + + new FakePin(this, mt); } } diff --git a/src/3rdparty/phonon/ds9/iodevicereader.cpp b/src/3rdparty/phonon/ds9/iodevicereader.cpp index 695af59..2dff1fe 100644 --- a/src/3rdparty/phonon/ds9/iodevicereader.cpp +++ b/src/3rdparty/phonon/ds9/iodevicereader.cpp @@ -36,20 +36,18 @@ namespace Phonon //these mediatypes define a stream, its type will be autodetected by DirectShow static QVector getMediaTypes() { - //the order here is important because otherwise, - //directshow might not be able to detect the stream type correctly - - AM_MEDIA_TYPE mt = { MEDIATYPE_Stream, MEDIASUBTYPE_Avi, TRUE, FALSE, 1, GUID_NULL, 0, 0, 0}; + AM_MEDIA_TYPE mt = { MEDIATYPE_Stream, MEDIASUBTYPE_NULL, TRUE, FALSE, 1, GUID_NULL, 0, 0, 0}; QVector ret; + //normal auto-detect stream + mt.subtype = MEDIASUBTYPE_NULL; + ret << mt; //AVI stream + mt.subtype = MEDIASUBTYPE_Avi; ret << mt; //WAVE stream mt.subtype = MEDIASUBTYPE_WAVE; ret << mt; - //normal auto-detect stream (must be at the end!) - mt.subtype = MEDIASUBTYPE_NULL; - ret << mt; return ret; } @@ -66,6 +64,7 @@ namespace Phonon //for Phonon::StreamInterface void writeData(const QByteArray &data) { + QWriteLocker locker(&m_lock); m_pos += data.size(); m_buffer += data; } @@ -76,22 +75,54 @@ namespace Phonon void setStreamSize(qint64 newSize) { - QMutexLocker locker(&m_mutex); + QWriteLocker locker(&m_lock); m_size = newSize; } + qint64 streamSize() const + { + QReadLocker locker(&m_lock); + return m_size; + } + void setStreamSeekable(bool s) { - QMutexLocker locker(&m_mutex); + QWriteLocker locker(&m_lock); m_seekable = s; } + bool streamSeekable() const + { + QReadLocker locker(&m_lock); + return m_seekable; + } + + void setCurrentPos(qint64 pos) + { + QWriteLocker locker(&m_lock); + m_pos = pos; + seekStream(pos); + m_buffer.clear(); + } + + qint64 currentPos() const + { + QReadLocker locker(&m_lock); + return m_pos; + } + + int currentBufferSize() const + { + QReadLocker locker(&m_lock); + return m_buffer.size(); + } + //virtual pure members //implementation from IAsyncReader STDMETHODIMP Length(LONGLONG *total, LONGLONG *available) { - QMutexLocker locker(&m_mutex); + QReadLocker locker(&m_lock); if (total) { *total = m_size; } @@ -106,42 +137,44 @@ namespace Phonon HRESULT read(LONGLONG pos, LONG length, BYTE *buffer, LONG *actual) { - Q_ASSERT(!m_mutex.tryLock()); + QMutexLocker locker(&m_mutexRead); + if (m_mediaGraph->isStopping()) { return VFW_E_WRONG_STATE; } - if(m_size != 1 && pos + length > m_size) { + if(streamSize() != 1 && pos + length > streamSize()) { //it tries to read outside of the boundaries return E_FAIL; } - if (m_pos - m_buffer.size() != pos) { - if (!m_seekable) { + if (currentPos() - currentBufferSize() != pos) { + if (!streamSeekable()) { return S_FALSE; } - m_pos = pos; - seekStream(pos); - m_buffer.clear(); + setCurrentPos(pos); } - int oldSize = m_buffer.size(); - while (m_buffer.size() < int(length)) { + int oldSize = currentBufferSize(); + while (currentBufferSize() < int(length)) { needData(); if (m_mediaGraph->isStopping()) { return VFW_E_WRONG_STATE; } - if (oldSize == m_buffer.size()) { + if (oldSize == currentBufferSize()) { break; //we didn't get any data } - oldSize = m_buffer.size(); + oldSize = currentBufferSize(); } - int bytesRead = qMin(m_buffer.size(), int(length)); - qMemCopy(buffer, m_buffer.data(), bytesRead); - //truncate the buffer - m_buffer = m_buffer.mid(bytesRead); + DWORD bytesRead = qMin(currentBufferSize(), int(length)); + { + QWriteLocker locker(&m_lock); + qMemCopy(buffer, m_buffer.data(), bytesRead); + //truncate the buffer + m_buffer = m_buffer.mid(bytesRead); + } if (actual) { *actual = bytesRead; //initialization @@ -157,6 +190,7 @@ namespace Phonon qint64 m_pos; qint64 m_size; + QMutex m_mutexRead; const MediaGraph *m_mediaGraph; }; @@ -170,6 +204,14 @@ namespace Phonon IODeviceReader::~IODeviceReader() { } + + STDMETHODIMP IODeviceReader::Stop() + { + HRESULT hr = QBaseFilter::Stop(); + m_streamReader->enoughData(); //this asks to cancel any blocked call to needData + return hr; + } + } } diff --git a/src/3rdparty/phonon/ds9/iodevicereader.h b/src/3rdparty/phonon/ds9/iodevicereader.h index c8b91c3..af4b271 100644 --- a/src/3rdparty/phonon/ds9/iodevicereader.h +++ b/src/3rdparty/phonon/ds9/iodevicereader.h @@ -41,6 +41,7 @@ namespace Phonon public: IODeviceReader(const MediaSource &source, const MediaGraph *); ~IODeviceReader(); + STDMETHODIMP Stop(); private: StreamReader *m_streamReader; diff --git a/src/3rdparty/phonon/ds9/mediagraph.cpp b/src/3rdparty/phonon/ds9/mediagraph.cpp index 3e7a68b..db0ec84 100644 --- a/src/3rdparty/phonon/ds9/mediagraph.cpp +++ b/src/3rdparty/phonon/ds9/mediagraph.cpp @@ -68,8 +68,6 @@ namespace Phonon return ret; } - -/* static HRESULT saveToFile(Graph graph, const QString &filepath) { const WCHAR wszStreamName[] = L"ActiveMovieGraph"; @@ -105,7 +103,7 @@ namespace Phonon return hr; } -*/ + MediaGraph::MediaGraph(MediaObject *mo, short index) : m_graph(CLSID_FilterGraph, IID_IGraphBuilder), @@ -379,12 +377,11 @@ namespace Phonon FILTER_INFO info; filter->QueryFilterInfo(&info); #ifdef GRAPH_DEBUG - qDebug() << "removeFilter" << QString((const QChar *)info.achName); + qDebug() << "removeFilter" << QString::fromUtf16(info.achName); #endif if (info.pGraph) { info.pGraph->Release(); - if (info.pGraph == m_graph) - return m_graph->RemoveFilter(filter); + return m_graph->RemoveFilter(filter); } //already removed @@ -540,11 +537,11 @@ namespace Phonon const QList outputs = BackendNode::pins(filter, PINDIR_OUTPUT); for(int i = 0; i < outputs.count(); ++i) { const OutputPin &pin = outputs.at(i); - if (HRESULT(VFW_E_NOT_CONNECTED) == pin->ConnectedTo(inPin.pparam())) { + if (VFW_E_NOT_CONNECTED == pin->ConnectedTo(inPin.pparam())) { return SUCCEEDED(pin->Connect(newIn, 0)); } } - //we shoud never go here + //we should never go here return false; } else { QAMMediaType type; @@ -682,6 +679,7 @@ namespace Phonon #ifndef QT_NO_PHONON_MEDIACONTROLLER } else if (source.discType() == Phonon::Cd) { m_realSource = Filter(new QAudioCDPlayer); + m_result = m_graph->AddFilter(m_realSource, 0); #endif //QT_NO_PHONON_MEDIACONTROLLER } else { @@ -811,7 +809,7 @@ namespace Phonon for (int i = 0; i < outputs.count(); ++i) { const OutputPin &out = outputs.at(i); InputPin pin; - if (out->ConnectedTo(pin.pparam()) == HRESULT(VFW_E_NOT_CONNECTED)) { + if (out->ConnectedTo(pin.pparam()) == VFW_E_NOT_CONNECTED) { m_decoderPins += out; //unconnected outputs can be decoded outputs } } @@ -822,7 +820,7 @@ namespace Phonon //let's reestablish the connections for (int i = 0; i < connections.count(); ++i) { const GraphConnection &connection = connections.at(i); - //check if we shoud transfer the sink node + //check if we should transfer the sink node grabFilter(connection.input); grabFilter(connection.output); @@ -875,7 +873,7 @@ namespace Phonon { FILTER_INFO info; filter->QueryFilterInfo(&info); - qDebug() << Q_FUNC_INFO << QString((const QChar *)info.achName); + qDebug() << Q_FUNC_INFO << QString::fromUtf16(info.achName); if (info.pGraph) { info.pGraph->Release(); } @@ -921,7 +919,7 @@ namespace Phonon { FILTER_INFO info; filter->QueryFilterInfo(&info); - qDebug() << "found a decoder filter" << QString((const QChar *)info.achName); + qDebug() << "found a decoder filter" << QString::fromUtf16(info.achName); if (info.pGraph) { info.pGraph->Release(); } @@ -937,7 +935,7 @@ namespace Phonon { FILTER_INFO info; filter->QueryFilterInfo(&info); - qDebug() << Q_FUNC_INFO << QString((const QChar *)info.achName); + qDebug() << Q_FUNC_INFO << QString::fromUtf16(info.achName); if (info.pGraph) { info.pGraph->Release(); } @@ -956,7 +954,7 @@ namespace Phonon { FILTER_INFO info; filter->QueryFilterInfo(&info); - qDebug() << Q_FUNC_INFO << QString((const QChar *)info.achName); + qDebug() << Q_FUNC_INFO << QString::fromUtf16(info.achName); if (info.pGraph) { info.pGraph->Release(); } @@ -990,7 +988,7 @@ namespace Phonon { FILTER_INFO info; filter->QueryFilterInfo(&info); - qDebug() << "found a demuxer filter" << QString((const QChar *)info.achName); + qDebug() << "found a demuxer filter" << QString::fromUtf16(info.achName); if (info.pGraph) { info.pGraph->Release(); } @@ -1008,27 +1006,27 @@ namespace Phonon BSTR str; HRESULT hr = mediaContent->get_AuthorName(&str); if (SUCCEEDED(hr)) { - ret.insert(QLatin1String("ARTIST"), QString::fromWCharArray(str)); + ret.insert(QLatin1String("ARTIST"), QString::fromUtf16((const unsigned short*)str)); SysFreeString(str); } hr = mediaContent->get_Title(&str); if (SUCCEEDED(hr)) { - ret.insert(QLatin1String("TITLE"), QString::fromWCharArray(str)); + ret.insert(QLatin1String("TITLE"), QString::fromUtf16((const unsigned short*)str)); SysFreeString(str); } hr = mediaContent->get_Description(&str); if (SUCCEEDED(hr)) { - ret.insert(QLatin1String("DESCRIPTION"), QString::fromWCharArray(str)); + ret.insert(QLatin1String("DESCRIPTION"), QString::fromUtf16((const unsigned short*)str)); SysFreeString(str); } hr = mediaContent->get_Copyright(&str); if (SUCCEEDED(hr)) { - ret.insert(QLatin1String("COPYRIGHT"), QString::fromWCharArray(str)); + ret.insert(QLatin1String("COPYRIGHT"), QString::fromUtf16((const unsigned short*)str)); SysFreeString(str); } hr = mediaContent->get_MoreInfoText(&str); if (SUCCEEDED(hr)) { - ret.insert(QLatin1String("MOREINFO"), QString::fromWCharArray(str)); + ret.insert(QLatin1String("MOREINFO"), QString::fromUtf16((const unsigned short*)str)); SysFreeString(str); } } diff --git a/src/3rdparty/phonon/ds9/mediaobject.cpp b/src/3rdparty/phonon/ds9/mediaobject.cpp index 34f92c2..d1e15c0 100644 --- a/src/3rdparty/phonon/ds9/mediaobject.cpp +++ b/src/3rdparty/phonon/ds9/mediaobject.cpp @@ -23,10 +23,11 @@ along with this library. If not, see . #ifndef Q_CC_MSVC #include -#endif +#endif //Q_CC_MSVC #include #include #include +#include #include #include "mediaobject.h" @@ -49,7 +50,7 @@ namespace Phonon //first the definition of the WorkerThread class WorkerThread::WorkerThread() - : QThread(), m_finished(false), m_currentWorkId(1) + : QThread(), m_currentRenderId(0), m_finished(false), m_currentWorkId(1) { } @@ -57,6 +58,24 @@ namespace Phonon { } + WorkerThread::Work WorkerThread::dequeueWork() + { + QMutexLocker locker(&m_mutex); + if (m_finished) { + return Work(); + } + Work ret = m_queue.dequeue(); + + //we ensure to have the wait condition in the right state + if (m_queue.isEmpty()) { + m_waitCondition.reset(); + } else { + m_waitCondition.set(); + } + + return ret; + } + void WorkerThread::run() { while (m_finished == false) { @@ -70,6 +89,11 @@ namespace Phonon } DWORD result = ::WaitForMultipleObjects(count, handles, FALSE, INFINITE); if (result == WAIT_OBJECT_0) { + if (m_finished) { + //that's the end of the thread execution + return; + } + handleTask(); } else { //this is the event management @@ -157,7 +181,6 @@ namespace Phonon //we create a new graph w.graph = Graph(CLSID_FilterGraph, IID_IGraphBuilder); w.filter = filter; - w.graph->AddFilter(filter, 0); w.id = m_currentWorkId++; m_queue.enqueue(w); m_waitCondition.set(); @@ -177,29 +200,23 @@ namespace Phonon void WorkerThread::handleTask() { - QMutexLocker locker(Backend::directShowMutex); - { - QMutexLocker locker(&m_mutex); - if (m_finished || m_queue.isEmpty()) { - return; - } - - m_currentWork = m_queue.dequeue(); + const Work w = dequeueWork(); - //we ensure to have the wait condition in the right state - if (m_queue.isEmpty()) { - m_waitCondition.reset(); - } else { - m_waitCondition.set(); - } + if (m_finished) { + return; } HRESULT hr = S_OK; - if (m_currentWork.task == ReplaceGraph) { + m_currentRender = w.graph; + m_currentRenderId = w.id; + if (w.task == ReplaceGraph) { + QMutexLocker locker(&m_mutex); + HANDLE h; + int index = -1; for(int i = 0; i < FILTER_COUNT; ++i) { - if (m_graphHandle[i].graph == m_currentWork.oldGraph) { + if (m_graphHandle[i].graph == w.oldGraph) { m_graphHandle[i].graph = Graph(); index = i; break; @@ -212,40 +229,51 @@ namespace Phonon Q_ASSERT(index != -1); //add the new graph - HANDLE h; - if (SUCCEEDED(ComPointer(m_currentWork.graph, IID_IMediaEvent) + if (SUCCEEDED(ComPointer(w.graph, IID_IMediaEvent) ->GetEventHandle(reinterpret_cast(&h)))) { - m_graphHandle[index].graph = m_currentWork.graph; + m_graphHandle[index].graph = w.graph; m_graphHandle[index].handle = h; } - } else if (m_currentWork.task == Render) { - if (m_currentWork.filter) { + } else if (w.task == Render) { + if (w.filter) { //let's render pins - const QList outputs = BackendNode::pins(m_currentWork.filter, PINDIR_OUTPUT); - for (int i = 0; SUCCEEDED(hr) && i < outputs.count(); ++i) { - hr = m_currentWork.graph->Render(outputs.at(i)); + w.graph->AddFilter(w.filter, 0); + const QList outputs = BackendNode::pins(w.filter, PINDIR_OUTPUT); + for (int i = 0; i < outputs.count(); ++i) { + //blocking call + hr = w.graph->Render(outputs.at(i)); + if (FAILED(hr)) { + break; + } } - } else if (!m_currentWork.url.isEmpty()) { + } else if (!w.url.isEmpty()) { //let's render a url (blocking call) - hr = m_currentWork.graph->RenderFile(reinterpret_cast(m_currentWork.url.utf16()), 0); + hr = w.graph->RenderFile(reinterpret_cast(w.url.utf16()), 0); } if (hr != E_ABORT) { - emit asyncRenderFinished(m_currentWork.id, hr, m_currentWork.graph); + emit asyncRenderFinished(w.id, hr, w.graph); } - } else if (m_currentWork.task == Seek) { + } else if (w.task == Seek) { //that's a seekrequest - ComPointer mediaSeeking(m_currentWork.graph, IID_IMediaSeeking); - qint64 newtime = m_currentWork.time * 10000; + ComPointer mediaSeeking(w.graph, IID_IMediaSeeking); + qint64 newtime = w.time * 10000; hr = mediaSeeking->SetPositions(&newtime, AM_SEEKING_AbsolutePositioning, 0, AM_SEEKING_NoPositioning); - emit asyncSeekingFinished(m_currentWork.id, newtime / 10000); + qint64 currentTime = -1; + if (SUCCEEDED(hr)) { + hr = mediaSeeking->GetCurrentPosition(¤tTime); + if (SUCCEEDED(hr)) { + currentTime /= 10000; //convert to ms + } + } + emit asyncSeekingFinished(w.id, currentTime); hr = E_ABORT; //to avoid emitting asyncRenderFinished - } else if (m_currentWork.task == ChangeState) { + } else if (w.task == ChangeState) { //remove useless decoders QList unused; - for (int i = 0; i < m_currentWork.decoders.count(); ++i) { - const Filter &filter = m_currentWork.decoders.at(i); + for (int i = 0; i < w.decoders.count(); ++i) { + const Filter &filter = w.decoders.at(i); bool used = false; const QList pins = BackendNode::pins(filter, PINDIR_OUTPUT); for( int i = 0; i < pins.count(); ++i) { @@ -262,15 +290,15 @@ namespace Phonon //we can get the state for (int i = 0; i < unused.count(); ++i) { //we should remove this filter from the graph - m_currentWork.graph->RemoveFilter(unused.at(i)); + w.graph->RemoveFilter(unused.at(i)); } //we can get the state - ComPointer mc(m_currentWork.graph, IID_IMediaControl); + ComPointer mc(w.graph, IID_IMediaControl); //we change the state here - switch(m_currentWork.state) + switch(w.state) { case State_Stopped: mc->Stop(); @@ -288,38 +316,36 @@ namespace Phonon if (SUCCEEDED(hr)) { if (s == State_Stopped) { - emit stateReady(m_currentWork.graph, Phonon::StoppedState); + emit stateReady(w.graph, Phonon::StoppedState); } else if (s == State_Paused) { - emit stateReady(m_currentWork.graph, Phonon::PausedState); + emit stateReady(w.graph, Phonon::PausedState); } else /*if (s == State_Running)*/ { - emit stateReady(m_currentWork.graph, Phonon::PlayingState); + emit stateReady(w.graph, Phonon::PlayingState); } } } - { - QMutexLocker locker(&m_mutex); - m_currentWork = Work(); //reinitialize - } + m_currentRender = Graph(); + m_currentRenderId = 0; + } - void WorkerThread::abortCurrentRender(qint16 renderId) - { + void WorkerThread::abortCurrentRender(qint16 renderId) + { QMutexLocker locker(&m_mutex); - if (m_currentWork.id == renderId) { - m_currentWork.graph->Abort(); - } bool found = false; + //we try to see if there is already an attempt to seek and we remove it for(int i = 0; !found && i < m_queue.size(); ++i) { const Work &w = m_queue.at(i); if (w.id == renderId) { found = true; m_queue.removeAt(i); - if (m_queue.isEmpty()) { - m_waitCondition.reset(); - } } } + + if (m_currentRender && m_currentRenderId == renderId) { + m_currentRender->Abort(); + } } //tells the thread to stop processing @@ -327,9 +353,9 @@ namespace Phonon { QMutexLocker locker(&m_mutex); m_queue.clear(); - if (m_currentWork.graph) { + if (m_currentRender) { //in case we're currently rendering something - m_currentWork.graph->Abort(); + m_currentRender->Abort(); } @@ -361,17 +387,17 @@ namespace Phonon m_graphs[i] = new MediaGraph(this, i); } - connect(&m_thread, SIGNAL(stateReady(Graph,Phonon::State)), - SLOT(slotStateReady(Graph,Phonon::State))); + connect(&m_thread, SIGNAL(stateReady(Graph, Phonon::State)), + SLOT(slotStateReady(Graph, Phonon::State))); - connect(&m_thread, SIGNAL(eventReady(Graph,long,long)), - SLOT(handleEvents(Graph,long,long))); + connect(&m_thread, SIGNAL(eventReady(Graph, long, long)), + SLOT(handleEvents(Graph, long, long))); - connect(&m_thread, SIGNAL(asyncRenderFinished(quint16,HRESULT,Graph)), - SLOT(finishLoading(quint16,HRESULT,Graph))); + connect(&m_thread, SIGNAL(asyncRenderFinished(quint16, HRESULT, Graph)), + SLOT(finishLoading(quint16, HRESULT, Graph))); - connect(&m_thread, SIGNAL(asyncSeekingFinished(quint16,qint64)), - SLOT(finishSeeking(quint16,qint64))); + connect(&m_thread, SIGNAL(asyncSeekingFinished(quint16, qint64)), + SLOT(finishSeeking(quint16, qint64))); //really special case m_mediaObject = this; m_thread.start(); @@ -494,18 +520,6 @@ namespace Phonon qSwap(m_graphs[0], m_graphs[1]); //swap the graphs - if (m_transitionTime >= 0) - m_graphs[1]->stop(); //make sure we stop the previous graph - - if (currentGraph()->mediaSource().type() != Phonon::MediaSource::Invalid && - catchComError(currentGraph()->renderResult())) { - setState(Phonon::ErrorState); - return; - } - - //we need to play the next media - play(); - //we tell the video widgets to switch now to the new source #ifndef QT_NO_PHONON_VIDEO for (int i = 0; i < m_videoWidgets.count(); ++i) { @@ -514,6 +528,15 @@ namespace Phonon #endif //QT_NO_PHONON_VIDEO emit currentSourceChanged(currentGraph()->mediaSource()); + + if (currentGraph()->isLoading()) { + //will simply tell that when loading is finished + //it should start the playback + play(); + } + + + emit metaDataChanged(currentGraph()->metadata()); if (nextGraph()->hasVideo() != currentGraph()->hasVideo()) { @@ -526,6 +549,15 @@ namespace Phonon #ifndef QT_NO_PHONON_MEDIACONTROLLER setTitles(currentGraph()->titles()); #endif //QT_NO_PHONON_MEDIACONTROLLER + + //this manages only gapless transitions + if (currentGraph()->mediaSource().type() != Phonon::MediaSource::Invalid) { + if (catchComError(currentGraph()->renderResult())) { + setState(Phonon::ErrorState); + } else { + play(); + } + } } Phonon::State MediaObject::state() const @@ -760,16 +792,15 @@ namespace Phonon case Phonon::PausedState: pause(); break; + case Phonon::StoppedState: + stop(); + break; case Phonon::PlayingState: play(); break; case Phonon::ErrorState: setState(Phonon::ErrorState); break; - case Phonon::StoppedState: - default: - stop(); - break; } } } @@ -817,11 +848,11 @@ namespace Phonon #endif LPAMGETERRORTEXT getErrorText = (LPAMGETERRORTEXT)QLibrary::resolve(QLatin1String("quartz"), "AMGetErrorTextW"); - WCHAR buffer[MAX_ERROR_TEXT_LEN]; - if (getErrorText && getErrorText(hr, buffer, MAX_ERROR_TEXT_LEN)) { - m_errorString = QString::fromWCharArray(buffer); + ushort buffer[MAX_ERROR_TEXT_LEN]; + if (getErrorText && getErrorText(hr, (WCHAR*)buffer, MAX_ERROR_TEXT_LEN)) { + m_errorString = QString::fromUtf16(buffer); } else { - m_errorString = QString::fromLatin1("Unknown error"); + m_errorString = QString::fromUtf16((ushort*)_com_error(hr).ErrorMessage()); } const QString comError = QString::number(uint(hr), 16); if (!m_errorString.toLower().contains(comError.toLower())) { diff --git a/src/3rdparty/phonon/ds9/mediaobject.h b/src/3rdparty/phonon/ds9/mediaobject.h index 34aa666..2c34ffc 100644 --- a/src/3rdparty/phonon/ds9/mediaobject.h +++ b/src/3rdparty/phonon/ds9/mediaobject.h @@ -114,7 +114,6 @@ namespace Phonon enum Task { - None, Render, Seek, ChangeState, @@ -123,7 +122,6 @@ namespace Phonon struct Work { - Work() : task(None), id(0), time(0) { } Task task; quint16 id; Graph graph; @@ -137,14 +135,16 @@ namespace Phonon }; QList decoders; //for the state change requests }; + Work dequeueWork(); void handleTask(); - Work m_currentWork; + Graph m_currentRender; + qint16 m_currentRenderId; QQueue m_queue; bool m_finished; quint16 m_currentWorkId; QWinWaitCondition m_waitCondition; - QMutex m_mutex; // mutex for the m_queue, m_finished and m_currentWorkId + QMutex m_mutex; //this is for WaitForMultipleObjects struct diff --git a/src/3rdparty/phonon/ds9/qasyncreader.cpp b/src/3rdparty/phonon/ds9/qasyncreader.cpp index a3f9cda..68ec1f8 100644 --- a/src/3rdparty/phonon/ds9/qasyncreader.cpp +++ b/src/3rdparty/phonon/ds9/qasyncreader.cpp @@ -15,6 +15,8 @@ You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ +#include + #include "qasyncreader.h" #include "qbasefilter.h" @@ -78,7 +80,8 @@ namespace Phonon STDMETHODIMP QAsyncReader::Request(IMediaSample *sample,DWORD_PTR user) { - QMutexLocker locker(&m_mutex); + QMutexLocker mutexLocker(&m_mutexWait); + QWriteLocker locker(&m_lock); if (m_flushing) { return VFW_E_WRONG_STATE; } @@ -90,28 +93,33 @@ namespace Phonon STDMETHODIMP QAsyncReader::WaitForNext(DWORD timeout, IMediaSample **sample, DWORD_PTR *user) { - QMutexLocker locker(&m_mutex); + QMutexLocker locker(&m_mutexWait); if (!sample ||!user) { return E_POINTER; } - //msdn says to return immediately if we're flushing but that doesn't seem to be true - //since it triggers a dead-lock somewhere inside directshow (see task 258830) - *sample = 0; *user = 0; - if (m_requestQueue.isEmpty()) { - if (m_requestWait.wait(&m_mutex, timeout) == false) { - return VFW_E_TIMEOUT; - } - if (m_requestQueue.isEmpty()) { + AsyncRequest r = getNextRequest(); + + if (r.sample == 0) { + //there is no request in the queue + if (isFlushing()) { return VFW_E_WRONG_STATE; + } else { + //First we need to lock the mutex + if (m_requestWait.wait(&m_mutexWait, timeout) == false) { + return VFW_E_TIMEOUT; + } + if (isFlushing()) { + return VFW_E_WRONG_STATE; + } + + r = getNextRequest(); } } - AsyncRequest r = m_requestQueue.dequeue(); - //at this point we're sure to have a request to proceed if (r.sample == 0) { return E_FAIL; @@ -119,12 +127,14 @@ namespace Phonon *sample = r.sample; *user = r.user; - return syncReadAlignedUnlocked(r.sample); + + return SyncReadAligned(r.sample); } STDMETHODIMP QAsyncReader::BeginFlush() { - QMutexLocker locker(&m_mutex); + QMutexLocker mutexLocker(&m_mutexWait); + QWriteLocker locker(&m_lock); m_flushing = true; m_requestWait.wakeOne(); return S_OK; @@ -132,28 +142,13 @@ namespace Phonon STDMETHODIMP QAsyncReader::EndFlush() { - QMutexLocker locker(&m_mutex); + QWriteLocker locker(&m_lock); m_flushing = false; return S_OK; } STDMETHODIMP QAsyncReader::SyncReadAligned(IMediaSample *sample) { - QMutexLocker locker(&m_mutex); - return syncReadAlignedUnlocked(sample); - } - - STDMETHODIMP QAsyncReader::SyncRead(LONGLONG pos, LONG length, BYTE *buffer) - { - QMutexLocker locker(&m_mutex); - return read(pos, length, buffer, 0); - } - - - STDMETHODIMP QAsyncReader::syncReadAlignedUnlocked(IMediaSample *sample) - { - Q_ASSERT(!m_mutex.tryLock()); - if (!sample) { return E_POINTER; } @@ -180,6 +175,23 @@ namespace Phonon return sample->SetActualDataLength(actual); } + STDMETHODIMP QAsyncReader::SyncRead(LONGLONG pos, LONG length, BYTE *buffer) + { + return read(pos, length, buffer, 0); + } + + + //addition + QAsyncReader::AsyncRequest QAsyncReader::getNextRequest() + { + QWriteLocker locker(&m_lock); + AsyncRequest ret; + if (!m_requestQueue.isEmpty()) { + ret = m_requestQueue.dequeue(); + } + + return ret; + } } } diff --git a/src/3rdparty/phonon/ds9/qasyncreader.h b/src/3rdparty/phonon/ds9/qasyncreader.h index 95872f9..cb789ee 100644 --- a/src/3rdparty/phonon/ds9/qasyncreader.h +++ b/src/3rdparty/phonon/ds9/qasyncreader.h @@ -48,12 +48,11 @@ namespace Phonon STDMETHODIMP WaitForNext(DWORD,IMediaSample **,DWORD_PTR *); STDMETHODIMP SyncReadAligned(IMediaSample *); STDMETHODIMP SyncRead(LONGLONG,LONG,BYTE *); - STDMETHODIMP Length(LONGLONG *,LONGLONG *) = 0; + virtual STDMETHODIMP Length(LONGLONG *,LONGLONG *) = 0; STDMETHODIMP BeginFlush(); STDMETHODIMP EndFlush(); protected: - STDMETHODIMP syncReadAlignedUnlocked(IMediaSample *); virtual HRESULT read(LONGLONG pos, LONG length, BYTE *buffer, LONG *actual) = 0; private: @@ -63,6 +62,9 @@ namespace Phonon IMediaSample *sample; DWORD_PTR user; }; + AsyncRequest getNextRequest(); + + QMutex m_mutexWait; QQueue m_requestQueue; QWaitCondition m_requestWait; diff --git a/src/3rdparty/phonon/ds9/qaudiocdreader.cpp b/src/3rdparty/phonon/ds9/qaudiocdreader.cpp index 6d0f335..b9f9fd6 100644 --- a/src/3rdparty/phonon/ds9/qaudiocdreader.cpp +++ b/src/3rdparty/phonon/ds9/qaudiocdreader.cpp @@ -103,8 +103,8 @@ namespace Phonon private: HANDLE m_cddrive; - CDROM_TOC m_toc; - WaveStructure m_waveHeader; + CDROM_TOC *m_toc; + WaveStructure *m_waveHeader; qint64 m_trackAddress; }; @@ -112,8 +112,19 @@ namespace Phonon #define SECTOR_SIZE 2352 #define NB_SECTORS_READ 20 - static const AM_MEDIA_TYPE audioCDMediaType = { MEDIATYPE_Stream, MEDIASUBTYPE_WAVE, TRUE, FALSE, 1, GUID_NULL, 0, 0, 0}; - + static AM_MEDIA_TYPE getAudioCDMediaType() + { + AM_MEDIA_TYPE mt; + qMemSet(&mt, 0, sizeof(AM_MEDIA_TYPE)); + mt.majortype = MEDIATYPE_Stream; + mt.subtype = MEDIASUBTYPE_WAVE; + mt.bFixedSizeSamples = TRUE; + mt.bTemporalCompression = FALSE; + mt.lSampleSize = 1; + mt.formattype = GUID_NULL; + return mt; + } + int addressToSectors(UCHAR address[4]) { return ((address[0] * 60 + address[1]) * 60 + address[2]) * 75 + address[3] - 150; @@ -130,8 +141,11 @@ namespace Phonon } - QAudioCDReader::QAudioCDReader(QBaseFilter *parent, QChar drive) : QAsyncReader(parent, QVector() << audioCDMediaType) + QAudioCDReader::QAudioCDReader(QBaseFilter *parent, QChar drive) : QAsyncReader(parent, QVector() << getAudioCDMediaType()) { + m_toc = new CDROM_TOC; + m_waveHeader = new WaveStructure; + //now open the cd-drive QString path; if (drive.isNull()) { @@ -140,30 +154,36 @@ namespace Phonon path = QString::fromLatin1("\\\\.\\%1:").arg(drive); } - m_cddrive = ::CreateFile((const wchar_t *)path.utf16(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); + m_cddrive = QT_WA_INLINE ( + ::CreateFile( (TCHAR*)path.utf16(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL ), + ::CreateFileA( path.toLocal8Bit().constData(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL ) + ); - qMemSet(&m_toc, 0, sizeof(CDROM_TOC)); + qMemSet(m_toc, 0, sizeof(CDROM_TOC)); //read the TOC DWORD bytesRead = 0; - bool tocRead = ::DeviceIoControl(m_cddrive, IOCTL_CDROM_READ_TOC, 0, 0, &m_toc, sizeof(CDROM_TOC), &bytesRead, 0); + bool tocRead = ::DeviceIoControl(m_cddrive, IOCTL_CDROM_READ_TOC, 0, 0, m_toc, sizeof(CDROM_TOC), &bytesRead, 0); if (!tocRead) { qWarning("unable to load the TOC from the CD"); return; } - m_trackAddress = addressToSectors(m_toc.TrackData[0].Address); - const qint32 nbSectorsToRead = (addressToSectors(m_toc.TrackData[m_toc.LastTrack + 1 - m_toc.FirstTrack].Address) + m_trackAddress = addressToSectors(m_toc->TrackData[0].Address); + const qint32 nbSectorsToRead = (addressToSectors(m_toc->TrackData[m_toc->LastTrack + 1 - m_toc->FirstTrack].Address) - m_trackAddress); const qint32 dataLength = nbSectorsToRead * SECTOR_SIZE; - m_waveHeader.chunksize = 4 + (8 + m_waveHeader.chunksize2) + (8 + dataLength); - m_waveHeader.dataLength = dataLength; + m_waveHeader->chunksize = 4 + (8 + m_waveHeader->chunksize2) + (8 + dataLength); + m_waveHeader->dataLength = dataLength; } QAudioCDReader::~QAudioCDReader() { ::CloseHandle(m_cddrive); + delete m_toc; + delete m_waveHeader; + } STDMETHODIMP_(ULONG) QAudioCDReader::AddRef() @@ -179,7 +199,7 @@ namespace Phonon STDMETHODIMP QAudioCDReader::Length(LONGLONG *total,LONGLONG *available) { - const LONGLONG length = sizeof(WaveStructure) + m_waveHeader.dataLength; + const LONGLONG length = sizeof(WaveStructure) + m_waveHeader->dataLength; if (total) { *total = length; } @@ -218,11 +238,11 @@ namespace Phonon if (pos < sizeof(WaveStructure)) { //we first copy the content of the structure nbRead = qMin(LONG(sizeof(WaveStructure) - pos), length); - qMemCopy(buffer, reinterpret_cast(&m_waveHeader) + pos, nbRead); + qMemCopy(buffer, reinterpret_cast(m_waveHeader) + pos, nbRead); } const LONGLONG posInTrack = pos - sizeof(WaveStructure) + nbRead; - const int bytesLeft = qMin(m_waveHeader.dataLength - posInTrack, LONGLONG(length - nbRead)); + const int bytesLeft = qMin(m_waveHeader->dataLength - posInTrack, LONGLONG(length - nbRead)); if (bytesLeft > 0) { @@ -277,8 +297,8 @@ namespace Phonon { QList ret; ret << 0; - for(int i = m_toc.FirstTrack; i <= m_toc.LastTrack ; ++i) { - const uchar *address = m_toc.TrackData[i].Address; + for(int i = m_toc->FirstTrack; i <= m_toc->LastTrack ; ++i) { + const uchar *address = m_toc->TrackData[i].Address; ret << ((address[0] * 60 + address[1]) * 60 + address[2]) * 1000 + address[3]*1000/75 - 2000; } diff --git a/src/3rdparty/phonon/ds9/qaudiocdreader.h b/src/3rdparty/phonon/ds9/qaudiocdreader.h index eff845d..9049b66 100644 --- a/src/3rdparty/phonon/ds9/qaudiocdreader.h +++ b/src/3rdparty/phonon/ds9/qaudiocdreader.h @@ -31,7 +31,7 @@ namespace Phonon { struct CDROM_TOC; struct WaveStructure; - EXTERN_C const IID IID_ITitleInterface; + extern const IID IID_ITitleInterface; //interface for the Titles struct ITitleInterface : public IUnknown diff --git a/src/3rdparty/phonon/ds9/qbasefilter.cpp b/src/3rdparty/phonon/ds9/qbasefilter.cpp index 78b8b8f..95cab92 100644 --- a/src/3rdparty/phonon/ds9/qbasefilter.cpp +++ b/src/3rdparty/phonon/ds9/qbasefilter.cpp @@ -92,8 +92,8 @@ namespace Phonon return E_POINTER; } - uint nbfetched = 0; - while (nbfetched < count && m_index < m_pins.count()) { + int nbfetched = 0; + while (nbfetched < int(count) && m_index < m_pins.count()) { IPin *current = m_pins[m_index]; current->AddRef(); ret[nbfetched] = current; @@ -166,19 +166,19 @@ namespace Phonon const QList QBaseFilter::pins() const { - QMutexLocker locker(&m_mutex); + QReadLocker locker(&m_lock); return m_pins; } void QBaseFilter::addPin(QPin *pin) { - QMutexLocker locker(&m_mutex); + QWriteLocker locker(&m_lock); m_pins.append(pin); } void QBaseFilter::removePin(QPin *pin) { - QMutexLocker locker(&m_mutex); + QWriteLocker locker(&m_lock); m_pins.removeAll(pin); } @@ -211,8 +211,7 @@ namespace Phonon } else if (iid == IID_IMediaPosition || iid == IID_IMediaSeeking) { if (inputPins().isEmpty()) { - *out = getUpStreamInterface(iid); - if (*out) { + if (*out = getUpStreamInterface(iid)) { return S_OK; //we return here to avoid adding a reference } else { hr = E_NOINTERFACE; @@ -251,35 +250,35 @@ namespace Phonon STDMETHODIMP QBaseFilter::GetClassID(CLSID *clsid) { - QMutexLocker locker(&m_mutex); + QReadLocker locker(&m_lock); *clsid = m_clsid; return S_OK; } STDMETHODIMP QBaseFilter::Stop() { - QMutexLocker locker(&m_mutex); + QWriteLocker locker(&m_lock); m_state = State_Stopped; return S_OK; } STDMETHODIMP QBaseFilter::Pause() { - QMutexLocker locker(&m_mutex); + QWriteLocker locker(&m_lock); m_state = State_Paused; return S_OK; } STDMETHODIMP QBaseFilter::Run(REFERENCE_TIME) { - QMutexLocker locker(&m_mutex); + QWriteLocker locker(&m_lock); m_state = State_Running; return S_OK; } STDMETHODIMP QBaseFilter::GetState(DWORD, FILTER_STATE *state) { - QMutexLocker locker(&m_mutex); + QReadLocker locker(&m_lock); if (!state) { return E_POINTER; } @@ -290,7 +289,7 @@ namespace Phonon STDMETHODIMP QBaseFilter::SetSyncSource(IReferenceClock *clock) { - QMutexLocker locker(&m_mutex); + QWriteLocker locker(&m_lock); if (clock) { clock->AddRef(); } @@ -303,7 +302,7 @@ namespace Phonon STDMETHODIMP QBaseFilter::GetSyncSource(IReferenceClock **clock) { - QMutexLocker locker(&m_mutex); + QReadLocker locker(&m_lock); if (!clock) { return E_POINTER; } @@ -342,7 +341,7 @@ namespace Phonon STDMETHODIMP QBaseFilter::QueryFilterInfo(FILTER_INFO *info ) { - QMutexLocker locker(&m_mutex); + QReadLocker locker(&m_lock); if (!info) { return E_POINTER; } @@ -356,9 +355,9 @@ namespace Phonon STDMETHODIMP QBaseFilter::JoinFilterGraph(IFilterGraph *graph, LPCWSTR name) { - QMutexLocker locker(&m_mutex); + QWriteLocker locker(&m_lock); m_graph = graph; - m_name = QString::fromWCharArray(name); + m_name = QString::fromUtf16((const unsigned short*)name); return S_OK; } diff --git a/src/3rdparty/phonon/ds9/qbasefilter.h b/src/3rdparty/phonon/ds9/qbasefilter.h index a72d6fe..85f1431 100644 --- a/src/3rdparty/phonon/ds9/qbasefilter.h +++ b/src/3rdparty/phonon/ds9/qbasefilter.h @@ -22,7 +22,7 @@ along with this library. If not, see . #include #include -#include +#include #include @@ -127,7 +127,7 @@ namespace Phonon IFilterGraph *m_graph; FILTER_STATE m_state; QList m_pins; - mutable QMutex m_mutex; + mutable QReadWriteLock m_lock; }; } } diff --git a/src/3rdparty/phonon/ds9/qevr9.h b/src/3rdparty/phonon/ds9/qevr9.h deleted file mode 100644 index 8599fce..0000000 --- a/src/3rdparty/phonon/ds9/qevr9.h +++ /dev/null @@ -1,143 +0,0 @@ -/* This file is part of the KDE project. - -Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). - -This library is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation, either version 2.1 or 3 of the License. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with this library. If not, see . -*/ - -#include - -#define DXVA2_ProcAmp_Brightness 1 -#define DXVA2_ProcAmp_Contrast 2 -#define DXVA2_ProcAmp_Hue 4 -#define DXVA2_ProcAmp_Saturation 8 - -typedef enum { - MFVideoARMode_None = 0x00000000, - MFVideoARMode_PreservePicture = 0x00000001, - MFVideoARMode_PreservePixel = 0x00000002, - MFVideoARMode_NonLinearStretch = 0x00000004, - MFVideoARMode_Mask = 0x00000007 -} MFVideoAspectRatioMode; - -typedef struct { - float left; - float top; - float right; - float bottom; -} MFVideoNormalizedRect; - -typedef struct { - UINT DeviceCaps; - D3DPOOL InputPool; - UINT NumForwardRefSamples; - UINT NumBackwardRefSamples; - UINT Reserved; - UINT DeinterlaceTechnology; - UINT ProcAmpControlCaps; - UINT VideoProcessorOperations; - UINT NoiseFilterTechnology; - UINT DetailFilterTechnology; -} DXVA2_VideoProcessorCaps; - -typedef struct { - union { - struct { - USHORT Fraction; - SHORT Value; - }; - LONG ll; - }; -} DXVA2_Fixed32; - -typedef struct { - DXVA2_Fixed32 MinValue; - DXVA2_Fixed32 MaxValue; - DXVA2_Fixed32 DefaultValue; - DXVA2_Fixed32 StepSize; -} DXVA2_ValueRange; - -typedef struct { - DXVA2_Fixed32 Brightness; - DXVA2_Fixed32 Contrast; - DXVA2_Fixed32 Hue; - DXVA2_Fixed32 Saturation; -} DXVA2_ProcAmpValues; - -DXVA2_Fixed32 DXVA2FloatToFixed(const float _float_) -{ - DXVA2_Fixed32 _fixed_; - _fixed_.Fraction = LOWORD(_float_ * 0x10000); - _fixed_.Value = HIWORD(_float_ * 0x10000); - return _fixed_; -} - -float DXVA2FixedToFloat(const DXVA2_Fixed32 _fixed_) -{ - return (FLOAT)_fixed_.Value + (FLOAT)_fixed_.Fraction / 0x10000; -} - -#undef INTERFACE -#define INTERFACE IMFVideoDisplayControl -DECLARE_INTERFACE_(IMFVideoDisplayControl, IUnknown) -{ - STDMETHOD(GetNativeVideoSize)(THIS_ SIZE* pszVideo, SIZE* pszARVideo) PURE; - STDMETHOD(GetIdealVideoSize)(THIS_ SIZE* pszMin, SIZE* pszMax) PURE; - STDMETHOD(SetVideoPosition)(THIS_ const MFVideoNormalizedRect* pnrcSource, const LPRECT prcDest) PURE; - STDMETHOD(GetVideoPosition)(THIS_ MFVideoNormalizedRect* pnrcSource, LPRECT prcDest) PURE; - STDMETHOD(SetAspectRatioMode)(THIS_ DWORD dwAspectRatioMode) PURE; - STDMETHOD(GetAspectRatioMode)(THIS_ DWORD* pdwAspectRatioMode) PURE; - STDMETHOD(SetVideoWindow)(THIS_ HWND hwndVideo) PURE; - STDMETHOD(GetVideoWindow)(THIS_ HWND* phwndVideo) PURE; - STDMETHOD(RepaintVideo)(THIS_) PURE; - STDMETHOD(GetCurrentImage)(THIS_ BITMAPINFOHEADER* pBih, BYTE** pDib, DWORD* pcbDib, LONGLONG* pTimeStamp) PURE; - STDMETHOD(SetBorderColor)(THIS_ COLORREF Clr) PURE; - STDMETHOD(GetBorderColor)(THIS_ COLORREF* pClr) PURE; - STDMETHOD(SetRenderingPrefs)(THIS_ DWORD dwRenderFlags) PURE; - STDMETHOD(GetRenderingPrefs)(THIS_ DWORD* pdwRenderFlags) PURE; - STDMETHOD(SetFullScreen)(THIS_ BOOL fFullscreen) PURE; - STDMETHOD(GetFullScreen)(THIS_ BOOL* pfFullscreen) PURE; -}; -#undef INTERFACE -#define INTERFACE IMFVideoMixerControl -DECLARE_INTERFACE_(IMFVideoMixerControl, IUnknown) -{ - STDMETHOD(SetStreamZOrder)(THIS_ DWORD dwStreamID, DWORD dwZ) PURE; - STDMETHOD(GetStreamZOrder)(THIS_ DWORD dwStreamID, DWORD* pdwZ) PURE; - STDMETHOD(SetStreamOutputRect)(THIS_ DWORD dwStreamID, const MFVideoNormalizedRect* pnrcOutput) PURE; - STDMETHOD(GetStreamOutputRect)(THIS_ DWORD dwStreamID, MFVideoNormalizedRect* pnrcOutput) PURE; -}; -#undef INTERFACE -#define INTERFACE IMFVideoProcessor -DECLARE_INTERFACE_(IMFVideoProcessor, IUnknown) -{ - STDMETHOD(GetAvailableVideoProcessorModes)(THIS_ UINT* lpdwNumProcessingModes, GUID** ppVideoProcessingModes) PURE; - STDMETHOD(GetVideoProcessorCaps)(THIS_ LPGUID lpVideoProcessorMode, DXVA2_VideoProcessorCaps* lpVideoProcessorCaps) PURE; - STDMETHOD(GetVideoProcessorMode)(THIS_ LPGUID lpMode) PURE; - STDMETHOD(SetVideoProcessorMode)(THIS_ LPGUID lpMode) PURE; - STDMETHOD(GetProcAmpRange)(THIS_ DWORD dwProperty, DXVA2_ValueRange* pPropRange) PURE; - STDMETHOD(GetProcAmpValues)(THIS_ DWORD dwFlags, DXVA2_ProcAmpValues* Values) PURE; - STDMETHOD(SetProcAmpValues)(THIS_ DWORD dwFlags, DXVA2_ProcAmpValues* pValues) PURE; - STDMETHOD(GetFilteringRange)(THIS_ DWORD dwProperty, DXVA2_ValueRange* pPropRange) PURE; - STDMETHOD(GetFilteringValue)(THIS_ DWORD dwProperty, DXVA2_Fixed32* pValue) PURE; - STDMETHOD(SetFilteringValue)(THIS_ DWORD dwProperty, DXVA2_Fixed32* pValue) PURE; - STDMETHOD(GetBackgroundColor)(THIS_ COLORREF* lpClrBkg) PURE; - STDMETHOD(SetBackgroundColor)(THIS_ COLORREF ClrBkg) PURE; -}; -#undef INTERFACE -#define INTERFACE IMFGetService -DECLARE_INTERFACE_(IMFGetService, IUnknown) -{ - STDMETHOD(GetService)(THIS_ REFGUID guidService, REFIID riid, LPVOID* ppvObject) PURE; -}; -#undef INTERFACE diff --git a/src/3rdparty/phonon/ds9/qmeminputpin.cpp b/src/3rdparty/phonon/ds9/qmeminputpin.cpp index a21fbe7..dca99db 100644 --- a/src/3rdparty/phonon/ds9/qmeminputpin.cpp +++ b/src/3rdparty/phonon/ds9/qmeminputpin.cpp @@ -28,8 +28,8 @@ namespace Phonon namespace DS9 { - QMemInputPin::QMemInputPin(QBaseFilter *parent, const QVector &mt, bool transform, QPin *output) : - QPin(parent, PINDIR_INPUT, mt), m_shouldDuplicateSamples(true), m_transform(transform), m_output(output) + QMemInputPin::QMemInputPin(QBaseFilter *parent, const QVector &mt, bool transform) : + QPin(parent, PINDIR_INPUT, mt), m_shouldDuplicateSamples(true), m_transform(transform) { } @@ -66,9 +66,11 @@ namespace Phonon { //this allows to serialize with Receive calls QMutexLocker locker(&m_mutexReceive); - IPin *conn = m_output ? m_output->connected() : 0; - if (conn) { - conn->EndOfStream(); + for(int i = 0; i < m_outputs.count(); ++i) { + IPin *conn = m_outputs.at(i)->connected(); + if (conn) { + conn->EndOfStream(); + } } return S_OK; } @@ -76,11 +78,13 @@ namespace Phonon STDMETHODIMP QMemInputPin::BeginFlush() { //pass downstream - IPin *conn = m_output ? m_output->connected() : 0; - if (conn) { - conn->BeginFlush(); + for(int i = 0; i < m_outputs.count(); ++i) { + IPin *conn = m_outputs.at(i)->connected(); + if (conn) { + conn->BeginFlush(); + } } - QMutexLocker locker(&m_mutex); + QWriteLocker locker(&m_lock); m_flushing = true; return S_OK; } @@ -88,19 +92,22 @@ namespace Phonon STDMETHODIMP QMemInputPin::EndFlush() { //pass downstream - IPin *conn = m_output ? m_output->connected() : 0; - if (conn) { - conn->EndFlush(); + for(int i = 0; i < m_outputs.count(); ++i) { + IPin *conn = m_outputs.at(i)->connected(); + if (conn) { + conn->EndFlush(); + } } - QMutexLocker locker(&m_mutex); + QWriteLocker locker(&m_lock); m_flushing = false; return S_OK; } STDMETHODIMP QMemInputPin::NewSegment(REFERENCE_TIME start, REFERENCE_TIME stop, double rate) { - if (m_output) - m_output->NewSegment(start, stop, rate); + for(int i = 0; i < m_outputs.count(); ++i) { + m_outputs.at(i)->NewSegment(start, stop, rate); + } return S_OK; } @@ -112,9 +119,14 @@ namespace Phonon if (hr == S_OK && mt->majortype != MEDIATYPE_NULL && mt->subtype != MEDIASUBTYPE_NULL && - mt->formattype != GUID_NULL && m_output) { - //we tell the output pin that it should connect with this type - hr = m_output->setAcceptedMediaType(connectedType()); + mt->formattype != GUID_NULL) { + //we tell the output pins that they should connect with this type + for(int i = 0; i < m_outputs.count(); ++i) { + hr = m_outputs.at(i)->setAcceptedMediaType(connectedType()); + if (FAILED(hr)) { + break; + } + } } return hr; } @@ -125,8 +137,7 @@ namespace Phonon return E_POINTER; } - *alloc = memoryAllocator(true); - if (*alloc) { + if (*alloc = memoryAllocator(true)) { return S_OK; } @@ -140,15 +151,18 @@ namespace Phonon } { - QMutexLocker locker(&m_mutex); + QWriteLocker locker(&m_lock); m_shouldDuplicateSamples = m_transform && readonly; } setMemoryAllocator(alloc); - if (m_output) { - ComPointer input(m_output, IID_IMemInputPin); - input->NotifyAllocator(alloc, m_shouldDuplicateSamples); + for(int i = 0; i < m_outputs.count(); ++i) { + IPin *pin = m_outputs.at(i)->connected(); + if (pin) { + ComPointer input(pin, IID_IMemInputPin); + input->NotifyAllocator(alloc, m_shouldDuplicateSamples); + } } return S_OK; @@ -187,18 +201,22 @@ namespace Phonon } } - if (m_output) { + for (int i = 0; i < m_outputs.count(); ++i) { + QPin *current = m_outputs.at(i); IMediaSample *outSample = m_shouldDuplicateSamples ? - duplicateSampleForOutput(sample, m_output->memoryAllocator()) + duplicateSampleForOutput(sample, current->memoryAllocator()) : sample; if (m_shouldDuplicateSamples) { m_parent->processSample(outSample); } - ComPointer input(m_output->connected(), IID_IMemInputPin); - if (input) { - input->Receive(outSample); + IPin *pin = current->connected(); + if (pin) { + ComPointer input(pin, IID_IMemInputPin); + if (input) { + input->Receive(outSample); + } } if (m_shouldDuplicateSamples) { @@ -229,16 +247,39 @@ namespace Phonon STDMETHODIMP QMemInputPin::ReceiveCanBlock() { - //we test the output to see if it can block - if (m_output) { - ComPointer meminput(m_output->connected(), IID_IMemInputPin); - if (meminput && meminput->ReceiveCanBlock() != S_FALSE) { - return S_OK; + //we test the output to see if they can block + for(int i = 0; i < m_outputs.count(); ++i) { + IPin *input = m_outputs.at(i)->connected(); + if (input) { + ComPointer meminput(input, IID_IMemInputPin); + if (meminput && meminput->ReceiveCanBlock() != S_FALSE) { + return S_OK; + } } } return S_FALSE; } + //addition + //this should be used by the filter to tell its input pins to which output they should route the samples + + void QMemInputPin::addOutput(QPin *output) + { + QWriteLocker locker(&m_lock); + m_outputs += output; + } + + void QMemInputPin::removeOutput(QPin *output) + { + QWriteLocker locker(&m_lock); + m_outputs.removeOne(output); + } + + QList QMemInputPin::outputs() const + { + QReadLocker locker(&m_lock); + return m_outputs; + } ALLOCATOR_PROPERTIES QMemInputPin::getDefaultAllocatorProperties() const { @@ -253,7 +294,7 @@ namespace Phonon LONG length = sample->GetActualDataLength(); HRESULT hr = alloc->Commit(); - if (hr == HRESULT(VFW_E_SIZENOTSET)) { + if (hr == VFW_E_SIZENOTSET) { ALLOCATOR_PROPERTIES prop = getDefaultAllocatorProperties(); prop.cbBuffer = qMax(prop.cbBuffer, length); ALLOCATOR_PROPERTIES actual; @@ -283,7 +324,7 @@ namespace Phonon { LONGLONG start, end; hr = sample->GetMediaTime(&start, &end); - if (hr != HRESULT(VFW_E_MEDIA_TIME_NOT_SET)) { + if (hr != VFW_E_MEDIA_TIME_NOT_SET) { hr = out->SetMediaTime(&start, &end); Q_ASSERT(SUCCEEDED(hr)); } diff --git a/src/3rdparty/phonon/ds9/qmeminputpin.h b/src/3rdparty/phonon/ds9/qmeminputpin.h index d74c451..c449721 100644 --- a/src/3rdparty/phonon/ds9/qmeminputpin.h +++ b/src/3rdparty/phonon/ds9/qmeminputpin.h @@ -37,7 +37,7 @@ namespace Phonon class QMemInputPin : public QPin, public IMemInputPin { public: - QMemInputPin(QBaseFilter *, const QVector &, bool transform, QPin *output); + QMemInputPin(QBaseFilter *, const QVector &, bool transform); ~QMemInputPin(); //reimplementation from IUnknown @@ -60,13 +60,18 @@ namespace Phonon STDMETHODIMP ReceiveMultiple(IMediaSample **,long,long *); STDMETHODIMP ReceiveCanBlock(); + //addition + void addOutput(QPin *output); + void removeOutput(QPin *output); + QList outputs() const; + private: IMediaSample *duplicateSampleForOutput(IMediaSample *, IMemAllocator *); ALLOCATOR_PROPERTIES getDefaultAllocatorProperties() const; bool m_shouldDuplicateSamples; const bool m_transform; //defines if the pin is transforming the samples - QPin* const m_output; + QList m_outputs; QMutex m_mutexReceive; }; } diff --git a/src/3rdparty/phonon/ds9/qpin.cpp b/src/3rdparty/phonon/ds9/qpin.cpp index b4afd10..37fe48d 100644 --- a/src/3rdparty/phonon/ds9/qpin.cpp +++ b/src/3rdparty/phonon/ds9/qpin.cpp @@ -28,7 +28,20 @@ namespace Phonon namespace DS9 { - static const AM_MEDIA_TYPE defaultMediaType = { MEDIATYPE_NULL, MEDIASUBTYPE_NULL, TRUE, FALSE, 1, GUID_NULL, 0, 0, 0}; + static const AM_MEDIA_TYPE defaultMediaType() + { + AM_MEDIA_TYPE ret; + ret.majortype = MEDIATYPE_NULL; + ret.subtype = MEDIASUBTYPE_NULL; + ret.bFixedSizeSamples = TRUE; + ret.bTemporalCompression = FALSE; + ret.lSampleSize = 1; + ret.formattype = GUID_NULL; + ret.pUnk = 0; + ret.cbFormat = 0; + ret.pbFormat = 0; + return ret; + } class QEnumMediaTypes : public IEnumMediaTypes { @@ -91,8 +104,8 @@ namespace Phonon return E_INVALIDARG; } - uint nbFetched = 0; - while (nbFetched < count && m_index < m_pin->mediaTypes().count()) { + int nbFetched = 0; + while (nbFetched < int(count) && m_index < m_pin->mediaTypes().count()) { //the caller will deallocate the memory *out = static_cast(::CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE))); const AM_MEDIA_TYPE original = m_pin->mediaTypes().at(m_index); @@ -145,9 +158,9 @@ namespace Phonon QPin::QPin(QBaseFilter *parent, PIN_DIRECTION dir, const QVector &mt) : - m_parent(parent), m_flushing(false), m_refCount(1), m_connected(0), - m_direction(dir), m_mediaTypes(mt), m_connectedType(defaultMediaType), - m_memAlloc(0) + m_memAlloc(0), m_parent(parent), m_refCount(1), m_connected(0), + m_direction(dir), m_mediaTypes(mt), m_connectedType(defaultMediaType()), + m_flushing(false) { Q_ASSERT(m_parent); m_parent->addPin(this); @@ -260,7 +273,7 @@ namespace Phonon if (FAILED(hr)) { setConnected(0); - setConnectedType(defaultMediaType); + setConnectedType(defaultMediaType()); } else { ComPointer input(pin, IID_IMemInputPin); if (input) { @@ -302,8 +315,10 @@ namespace Phonon } setConnected(0); - setConnectedType(defaultMediaType); - setMemoryAllocator(0); + setConnectedType(defaultMediaType()); + if (m_direction == PINDIR_INPUT) { + setMemoryAllocator(0); + } return S_OK; } @@ -323,7 +338,7 @@ namespace Phonon STDMETHODIMP QPin::ConnectionMediaType(AM_MEDIA_TYPE *type) { - QMutexLocker locker(&m_mutex); + QReadLocker locker(&m_lock); if (!type) { return E_POINTER; } @@ -338,6 +353,7 @@ namespace Phonon STDMETHODIMP QPin::QueryPinInfo(PIN_INFO *info) { + QReadLocker locker(&m_lock); if (!info) { return E_POINTER; } @@ -345,12 +361,14 @@ namespace Phonon info->dir = m_direction; info->pFilter = m_parent; m_parent->AddRef(); - info->achName[0] = 0; + qMemCopy(info->achName, m_name.utf16(), qMin(MAX_FILTER_NAME, m_name.length()+1) *2); + return S_OK; } STDMETHODIMP QPin::QueryDirection(PIN_DIRECTION *dir) { + QReadLocker locker(&m_lock); if (!dir) { return E_POINTER; } @@ -361,18 +379,20 @@ namespace Phonon STDMETHODIMP QPin::QueryId(LPWSTR *id) { + QReadLocker locker(&m_lock); if (!id) { return E_POINTER; } - *id = static_cast(::CoTaskMemAlloc(2)); - *id[0] = 0; + int nbBytes = (m_name.length()+1)*2; + *id = static_cast(::CoTaskMemAlloc(nbBytes)); + qMemCopy(*id, m_name.utf16(), nbBytes); return S_OK; } STDMETHODIMP QPin::QueryAccept(const AM_MEDIA_TYPE *type) { - QMutexLocker locker(&m_mutex); + QReadLocker locker(&m_lock); if (!type) { return E_POINTER; } @@ -419,7 +439,7 @@ namespace Phonon STDMETHODIMP QPin::NewSegment(REFERENCE_TIME start, REFERENCE_TIME stop, double rate) { - QMutexLocker locker(&m_mutex); + QReadLocker locker(&m_lock); if (m_direction == PINDIR_OUTPUT && m_connected) { //we deliver this downstream m_connected->NewSegment(start, stop, rate); @@ -436,8 +456,8 @@ namespace Phonon HRESULT QPin::checkOutputMediaTypesConnection(IPin *pin) { - ComPointer emt; - HRESULT hr = pin->EnumMediaTypes(emt.pparam()); + IEnumMediaTypes *emt = 0; + HRESULT hr = pin->EnumMediaTypes(&emt); if (hr != S_OK) { return hr; } @@ -450,7 +470,7 @@ namespace Phonon freeMediaType(type); return S_OK; } else { - setConnectedType(defaultMediaType); + setConnectedType(defaultMediaType()); freeMediaType(type); } } @@ -500,7 +520,7 @@ namespace Phonon void QPin::setConnectedType(const AM_MEDIA_TYPE &type) { - QMutexLocker locker(&m_mutex); + QWriteLocker locker(&m_lock); //1st we free memory freeMediaType(m_connectedType); @@ -510,13 +530,13 @@ namespace Phonon const AM_MEDIA_TYPE &QPin::connectedType() const { - QMutexLocker locker(&m_mutex); + QReadLocker locker(&m_lock); return m_connectedType; } void QPin::setConnected(IPin *pin) { - QMutexLocker locker(&m_mutex); + QWriteLocker locker(&m_lock); if (pin) { pin->AddRef(); } @@ -528,7 +548,7 @@ namespace Phonon IPin *QPin::connected(bool addref) const { - QMutexLocker locker(&m_mutex); + QReadLocker locker(&m_lock); if (addref && m_connected) { m_connected->AddRef(); } @@ -537,12 +557,13 @@ namespace Phonon bool QPin::isFlushing() const { - QMutexLocker locker(&m_mutex); + QReadLocker locker(&m_lock); return m_flushing; } FILTER_STATE QPin::filterState() const { + QReadLocker locker(&m_lock); FILTER_STATE fstate = State_Stopped; m_parent->GetState(0, &fstate); return fstate; @@ -550,7 +571,7 @@ namespace Phonon QVector QPin::mediaTypes() const { - QMutexLocker locker(&m_mutex); + QReadLocker locker(&m_lock); return m_mediaTypes; } @@ -586,7 +607,7 @@ namespace Phonon void QPin::setMemoryAllocator(IMemAllocator *alloc) { - QMutexLocker locker(&m_mutex); + QWriteLocker locker(&m_lock); if (alloc) { alloc->AddRef(); } @@ -598,7 +619,7 @@ namespace Phonon IMemAllocator *QPin::memoryAllocator(bool addref) const { - QMutexLocker locker(&m_mutex); + QReadLocker locker(&m_lock); if (addref && m_memAlloc) { m_memAlloc->AddRef(); } diff --git a/src/3rdparty/phonon/ds9/qpin.h b/src/3rdparty/phonon/ds9/qpin.h index 280ad61..a3287c4 100644 --- a/src/3rdparty/phonon/ds9/qpin.h +++ b/src/3rdparty/phonon/ds9/qpin.h @@ -22,7 +22,7 @@ along with this library. If not, see . #include #include -#include +#include #include @@ -85,8 +85,8 @@ namespace Phonon protected: //this can be used by sub-classes - mutable QMutex m_mutex; - QBaseFilter * const m_parent; + mutable QReadWriteLock m_lock; + QBaseFilter *m_parent; bool m_flushing; private: @@ -98,6 +98,7 @@ namespace Phonon const PIN_DIRECTION m_direction; QVector m_mediaTypes; //accepted media types AM_MEDIA_TYPE m_connectedType; + QString m_name; IMemAllocator *m_memAlloc; }; diff --git a/src/3rdparty/phonon/ds9/videorenderer_default.cpp b/src/3rdparty/phonon/ds9/videorenderer_default.cpp deleted file mode 100644 index 0045a49..0000000 --- a/src/3rdparty/phonon/ds9/videorenderer_default.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/* This file is part of the KDE project. - -Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). - -This library is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation, either version 2.1 or 3 of the License. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with this library. If not, see . -*/ - - -#include "videorenderer_default.h" - -#ifndef QT_NO_PHONON_VIDEO - -#include -#include - -#include - -QT_BEGIN_NAMESPACE - - -namespace Phonon -{ - namespace DS9 - { - VideoRendererDefault::~VideoRendererDefault() - { - } - - bool VideoRendererDefault::isNative() const - { - return true; - } - - - VideoRendererDefault::VideoRendererDefault(QWidget *target) : m_target(target) - { - m_target->setAttribute(Qt::WA_PaintOnScreen, true); - m_filter = Filter(CLSID_VideoRenderer, IID_IBaseFilter); - } - - QSize VideoRendererDefault::videoSize() const - { - LONG w = 0, - h = 0; - ComPointer basic(m_filter, IID_IBasicVideo); - if (basic) { - basic->GetVideoSize( &w, &h); - } - return QSize(w, h); - } - - void VideoRendererDefault::repaintCurrentFrame(QWidget * /*target*/, const QRect & /*rect*/) - { - //nothing to do here: the renderer paints everything - } - - void VideoRendererDefault::notifyResize(const QSize &size, Phonon::VideoWidget::AspectRatio aspectRatio, - Phonon::VideoWidget::ScaleMode scaleMode) - { - if (!isActive()) { - ComPointer basic(m_filter, IID_IBasicVideo); - if (basic) { - basic->SetDestinationPosition(0, 0, 0, 0); - } - return; - } - - ComPointer video(m_filter, IID_IVideoWindow); - - OAHWND owner; - HRESULT hr = video->get_Owner(&owner); - if (FAILED(hr)) { - return; - } - - const OAHWND newOwner = reinterpret_cast(m_target->winId()); - if (owner != newOwner) { - video->put_Owner(newOwner); - video->put_MessageDrain(newOwner); - video->put_WindowStyle(WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS); - } - - //make sure the widget takes the whole size of the parent - video->SetWindowPosition(0, 0, size.width(), size.height()); - - const QSize vsize = videoSize(); - internalNotifyResize(size, vsize, aspectRatio, scaleMode); - - ComPointer basic(m_filter, IID_IBasicVideo); - if (basic) { - basic->SetDestinationPosition(m_dstX, m_dstY, m_dstWidth, m_dstHeight); - } - } - - void VideoRendererDefault::applyMixerSettings(qreal /*brightness*/, qreal /*contrast*/, qreal /*m_hue*/, qreal /*saturation*/) - { - //this can't be supported for the default renderer - } - - QImage VideoRendererDefault::snapshot() const - { - ComPointer basic(m_filter, IID_IBasicVideo); - if (basic) { - LONG bufferSize = 0; - //1st we get the buffer size - basic->GetCurrentImage(&bufferSize, 0); - - QByteArray buffer; - buffer.resize(bufferSize); - HRESULT hr = basic->GetCurrentImage(&bufferSize, reinterpret_cast(buffer.data())); - - if (SUCCEEDED(hr)) { - - const BITMAPINFOHEADER *bmi = reinterpret_cast(buffer.constData()); - - const int w = qAbs(bmi->biWidth), - h = qAbs(bmi->biHeight); - - // Create image and copy data into image. - QImage ret(w, h, QImage::Format_RGB32); - - if (!ret.isNull()) { - const char *data = buffer.constData() + bmi->biSize; - const int bytes_per_line = w * sizeof(QRgb); - for (int y = h - 1; y >= 0; --y) { - qMemCopy(ret.scanLine(y), //destination - data, //source - bytes_per_line); - data += bytes_per_line; - } - } - return ret; - } - } - return QImage(); - } - - } -} - -QT_END_NAMESPACE - -#endif //QT_NO_PHONON_VIDEO diff --git a/src/3rdparty/phonon/ds9/videorenderer_default.h b/src/3rdparty/phonon/ds9/videorenderer_default.h deleted file mode 100644 index 43768d9..0000000 --- a/src/3rdparty/phonon/ds9/videorenderer_default.h +++ /dev/null @@ -1,55 +0,0 @@ -/* This file is part of the KDE project. - -Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). - -This library is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation, either version 2.1 or 3 of the License. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with this library. If not, see . -*/ - -#ifndef PHONON_VIDEORENDERER_DEFAULT_H -#define PHONON_VIDEORENDERER_DEFAULT_H - -#include "abstractvideorenderer.h" - -QT_BEGIN_NAMESPACE - -#ifndef QT_NO_PHONON_VIDEO - -namespace Phonon -{ - namespace DS9 - { - class VideoRendererDefault : public AbstractVideoRenderer - { - public: - VideoRendererDefault(QWidget *target); - ~VideoRendererDefault(); - - //Implementation from AbstractVideoRenderer - void repaintCurrentFrame(QWidget *target, const QRect &rect); - void notifyResize(const QSize&, Phonon::VideoWidget::AspectRatio, Phonon::VideoWidget::ScaleMode); - QSize videoSize() const; - QImage snapshot() const; - void applyMixerSettings(qreal brightness, qreal contrast, qreal m_hue, qreal saturation); - bool isNative() const; - private: - QWidget *m_target; - }; - } -} - -#endif //QT_NO_PHONON_VIDEO - -QT_END_NAMESPACE - -#endif - diff --git a/src/3rdparty/phonon/ds9/videorenderer_evr.cpp b/src/3rdparty/phonon/ds9/videorenderer_evr.cpp deleted file mode 100644 index d23d9ce..0000000 --- a/src/3rdparty/phonon/ds9/videorenderer_evr.cpp +++ /dev/null @@ -1,215 +0,0 @@ -/* This file is part of the KDE project. - -Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). - -This library is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation, either version 2.1 or 3 of the License. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with this library. If not, see . -*/ - - -#include "videorenderer_evr.h" -#include "qevr9.h" - -#ifndef QT_NO_PHONON_VIDEO - -#include -#include - -QT_BEGIN_NAMESPACE - -namespace Phonon -{ - namespace DS9 - { - //we have to define them here because not all compilers/sdk have them - static const GUID MR_VIDEO_RENDER_SERVICE = {0x1092a86c, 0xab1a, 0x459a, {0xa3, 0x36, 0x83, 0x1f, 0xbc, 0x4d, 0x11, 0xff} }; - static const GUID MR_VIDEO_MIXER_SERVICE = { 0x73cd2fc, 0x6cf4, 0x40b7, {0x88, 0x59, 0xe8, 0x95, 0x52, 0xc8, 0x41, 0xf8} }; - static const IID IID_IMFVideoDisplayControl = {0xa490b1e4, 0xab84, 0x4d31, {0xa1, 0xb2, 0x18, 0x1e, 0x03, 0xb1, 0x07, 0x7a} }; - static const IID IID_IMFVideoMixerControl = {0xA5C6C53F, 0xC202, 0x4aa5, {0x96, 0x95, 0x17, 0x5B, 0xA8, 0xC5, 0x08, 0xA5} }; - static const IID IID_IMFVideoProcessor = {0x6AB0000C, 0xFECE, 0x4d1f, {0xA2, 0xAC, 0xA9, 0x57, 0x35, 0x30, 0x65, 0x6E} }; - static const IID IID_IMFGetService = {0xFA993888, 0x4383, 0x415A, {0xA9, 0x30, 0xDD, 0x47, 0x2A, 0x8C, 0xF6, 0xF7} }; - static const GUID CLSID_EnhancedVideoRenderer = {0xfa10746c, 0x9b63, 0x4b6c, {0xbc, 0x49, 0xfc, 0x30, 0xe, 0xa5, 0xf2, 0x56} }; - - template ComPointer getService(const Filter &filter, REFGUID guidService, REFIID riid) - { - //normally we should use IID_IMFGetService but this introduces another dependency - //so here we simply define our own IId with the same value - ComPointer getService(filter, IID_IMFGetService); - Q_ASSERT(getService); - T *ptr = 0; - HRESULT hr = getService->GetService(guidService, riid, reinterpret_cast(&ptr)); - if (!SUCCEEDED(hr) || ptr == 0) - Q_ASSERT(!SUCCEEDED(hr) && ptr != 0); - ComPointer service(ptr); - return service; - } - - VideoRendererEVR::~VideoRendererEVR() - { - } - - bool VideoRendererEVR::isNative() const - { - return true; - } - - VideoRendererEVR::VideoRendererEVR(QWidget *target) : m_target(target) - { - m_filter = Filter(CLSID_EnhancedVideoRenderer, IID_IBaseFilter); - if (!m_filter) { - return; - } - - ComPointer filterControl = getService(m_filter, MR_VIDEO_RENDER_SERVICE, IID_IMFVideoDisplayControl); - - filterControl->SetVideoWindow(reinterpret_cast(target->winId())); - filterControl->SetAspectRatioMode(MFVideoARMode_None); // We're in control of the size - } - - QImage VideoRendererEVR::snapshot() const - { - // This will always capture black areas where no video is drawn, if any are present. - // Due to the hack in notifyResize() - ComPointer filterControl = getService(m_filter, MR_VIDEO_RENDER_SERVICE, IID_IMFVideoDisplayControl); - if (filterControl) { - BITMAPINFOHEADER bmi; - BYTE *buffer = 0; - DWORD bufferSize; - LONGLONG timeStamp; - - bmi.biSize = sizeof(BITMAPINFOHEADER); - - HRESULT hr = filterControl->GetCurrentImage(&bmi, &buffer, &bufferSize, &timeStamp); - if (SUCCEEDED(hr)) { - - const int w = qAbs(bmi.biWidth), - h = qAbs(bmi.biHeight); - - // Create image and copy data into image. - QImage ret(w, h, QImage::Format_RGB32); - - if (!ret.isNull()) { - uchar *data = buffer; - const int bytes_per_line = w * sizeof(QRgb); - for (int y = h - 1; y >= 0; --y) { - qMemCopy(ret.scanLine(y), //destination - data, //source - bytes_per_line); - data += bytes_per_line; - } - } - ::CoTaskMemFree(buffer); - return ret; - } - } - return QImage(); - } - - QSize VideoRendererEVR::videoSize() const - { - SIZE nativeSize; - SIZE aspectRatioSize; - - ComPointer filterControl = getService(m_filter, MR_VIDEO_RENDER_SERVICE, IID_IMFVideoDisplayControl); - - filterControl->GetNativeVideoSize(&nativeSize, &aspectRatioSize); - - return QSize(nativeSize.cx, nativeSize.cy); - } - - void VideoRendererEVR::repaintCurrentFrame(QWidget *target, const QRect &rect) - { - // repaint the video - ComPointer filterControl = getService(m_filter, MR_VIDEO_RENDER_SERVICE, IID_IMFVideoDisplayControl); - // All failed results can be safely ignored - filterControl->RepaintVideo(); - } - - void VideoRendererEVR::notifyResize(const QSize &size, Phonon::VideoWidget::AspectRatio aspectRatio, - Phonon::VideoWidget::ScaleMode scaleMode) - { - if (!isActive()) { - RECT dummyRect = { 0, 0, 0, 0}; - ComPointer filterControl = getService(m_filter, MR_VIDEO_RENDER_SERVICE, IID_IMFVideoDisplayControl); - filterControl->SetVideoPosition(0, &dummyRect); - return; - } - - const QSize vsize = videoSize(); - internalNotifyResize(size, vsize, aspectRatio, scaleMode); - - RECT dstRectWin = { 0, 0, size.width(), size.height()}; - - // Resize the Stream output rect instead of the destination rect. - // Hacky workaround for flicker in the areas outside of the destination rect - // This way these areas don't exist - MFVideoNormalizedRect streamOutputRect = { float(m_dstX) / float(size.width()), float(m_dstY) / float(size.height()), - float(m_dstWidth + m_dstX) / float(size.width()), float(m_dstHeight + m_dstY) / float(size.height())}; - - ComPointer filterMixer = getService(m_filter, MR_VIDEO_MIXER_SERVICE, IID_IMFVideoMixerControl); - ComPointer filterControl = getService(m_filter, MR_VIDEO_RENDER_SERVICE, IID_IMFVideoDisplayControl); - - filterMixer->SetStreamOutputRect(0, &streamOutputRect); - filterControl->SetVideoPosition(0, &dstRectWin); - } - - void VideoRendererEVR::applyMixerSettings(qreal brightness, qreal contrast, qreal hue, qreal saturation) - { - InputPin sink = BackendNode::pins(m_filter, PINDIR_INPUT).first(); - OutputPin source; - if (FAILED(sink->ConnectedTo(source.pparam()))) { - return; //it must be connected to work - } - - // Get the "Video Processor" (used for brightness/contrast/saturation/hue) - ComPointer processor = getService(m_filter, MR_VIDEO_MIXER_SERVICE, IID_IMFVideoProcessor); - Q_ASSERT(processor); - - DXVA2_ValueRange contrastRange; - DXVA2_ValueRange brightnessRange; - DXVA2_ValueRange saturationRange; - DXVA2_ValueRange hueRange; - - if (FAILED(processor->GetProcAmpRange(DXVA2_ProcAmp_Contrast, &contrastRange))) - return; - if (FAILED(processor->GetProcAmpRange(DXVA2_ProcAmp_Brightness, &brightnessRange))) - return; - if (FAILED(processor->GetProcAmpRange(DXVA2_ProcAmp_Saturation, &saturationRange))) - return; - if (FAILED(processor->GetProcAmpRange(DXVA2_ProcAmp_Hue, &hueRange))) - return; - - DXVA2_ProcAmpValues values; - - values.Contrast = DXVA2FloatToFixed(((contrast < 0 - ? DXVA2FixedToFloat(contrastRange.MinValue) : DXVA2FixedToFloat(contrastRange.MaxValue)) - - DXVA2FixedToFloat(contrastRange.DefaultValue)) * qAbs(contrast) + DXVA2FixedToFloat(contrastRange.DefaultValue)); - values.Brightness = DXVA2FloatToFixed(((brightness < 0 - ? DXVA2FixedToFloat(brightnessRange.MinValue) : DXVA2FixedToFloat(brightnessRange.MaxValue)) - - DXVA2FixedToFloat(brightnessRange.DefaultValue)) * qAbs(brightness) + DXVA2FixedToFloat(brightnessRange.DefaultValue)); - values.Saturation = DXVA2FloatToFixed(((saturation < 0 - ? DXVA2FixedToFloat(saturationRange.MinValue) : DXVA2FixedToFloat(saturationRange.MaxValue)) - - DXVA2FixedToFloat(saturationRange.DefaultValue)) * qAbs(saturation) + DXVA2FixedToFloat(saturationRange.DefaultValue)); - values.Hue = DXVA2FloatToFixed(((hue < 0 - ? DXVA2FixedToFloat(hueRange.MinValue) : DXVA2FixedToFloat(hueRange.MaxValue)) - - DXVA2FixedToFloat(hueRange.DefaultValue)) * qAbs(hue) + DXVA2FixedToFloat(hueRange.DefaultValue)); - - //finally set the settings - processor->SetProcAmpValues(DXVA2_ProcAmp_Contrast | DXVA2_ProcAmp_Brightness | DXVA2_ProcAmp_Saturation | DXVA2_ProcAmp_Hue, &values); - - } - } -} - -QT_END_NAMESPACE - -#endif //QT_NO_PHONON_VIDEO diff --git a/src/3rdparty/phonon/ds9/videorenderer_evr.h b/src/3rdparty/phonon/ds9/videorenderer_evr.h deleted file mode 100644 index 229c36d..0000000 --- a/src/3rdparty/phonon/ds9/videorenderer_evr.h +++ /dev/null @@ -1,56 +0,0 @@ -/* This file is part of the KDE project. - -Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). - -This library is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation, either version 2.1 or 3 of the License. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with this library. If not, see . -*/ - -#ifndef PHONON_VIDEORENDERER_EVR_H -#define PHONON_VIDEORENDERER_EVR_H - -#include "abstractvideorenderer.h" -#include "compointer.h" - -QT_BEGIN_NAMESPACE - -#ifndef QT_NO_PHONON_VIDEO - -namespace Phonon -{ - namespace DS9 - { - class VideoRendererEVR : public AbstractVideoRenderer - { - public: - VideoRendererEVR(QWidget *target); - ~VideoRendererEVR(); - - //Implementation from AbstractVideoRenderer - void repaintCurrentFrame(QWidget *target, const QRect &rect); - void notifyResize(const QSize&, Phonon::VideoWidget::AspectRatio, Phonon::VideoWidget::ScaleMode); - QSize videoSize() const; - QImage snapshot() const; - void applyMixerSettings(qreal brightness, qreal contrast, qreal m_hue, qreal saturation); - bool isNative() const; - private: - QWidget *m_target; - }; - } -} - -#endif //QT_NO_PHONON_VIDEO - -QT_END_NAMESPACE - -#endif - diff --git a/src/3rdparty/phonon/ds9/videorenderer_soft.cpp b/src/3rdparty/phonon/ds9/videorenderer_soft.cpp index 9c7993c..491d1bd 100644 --- a/src/3rdparty/phonon/ds9/videorenderer_soft.cpp +++ b/src/3rdparty/phonon/ds9/videorenderer_soft.cpp @@ -194,8 +194,8 @@ namespace Phonon m_sampleBuffer = ComPointer(); #ifndef QT_NO_OPENGL freeGLResources(); - m_textureUploaded = false; #endif // QT_NO_OPENGL + m_textureUploaded = false; } void endOfStream() @@ -314,6 +314,7 @@ namespace Phonon REFERENCE_TIME m_start; HANDLE m_renderEvent, m_receiveCanWait; // Signals sample to render QSize m_size; + bool m_textureUploaded; //mixer settings qreal m_brightness, @@ -355,7 +356,6 @@ namespace Phonon bool m_checkedPrograms; bool m_usingOpenGL; - bool m_textureUploaded; GLuint m_program[2]; GLuint m_texture[3]; #endif @@ -365,7 +365,7 @@ namespace Phonon { public: VideoRendererSoftPin(VideoRendererSoftFilter *parent) : - QMemInputPin(parent, videoMediaTypes(), false /*no transformation of the samples*/, 0), + QMemInputPin(parent, videoMediaTypes(), false /*no transformation of the samples*/), m_renderer(parent) { } @@ -436,7 +436,7 @@ namespace Phonon QBaseFilter(CLSID_NULL), m_inputPin(new VideoRendererSoftPin(this)), m_renderer(renderer), m_start(0) #ifndef QT_NO_OPENGL - , m_checkedPrograms(false), m_usingOpenGL(false), m_textureUploaded(false) + ,m_usingOpenGL(false), m_checkedPrograms(false), m_textureUploaded(false) #endif { m_renderEvent = ::CreateEvent(0, 0, 0, 0); @@ -661,10 +661,7 @@ namespace Phonon #ifndef QT_NO_OPENGL - if (painter.paintEngine() && - (painter.paintEngine()->type() == QPaintEngine::OpenGL || painter.paintEngine()->type() == QPaintEngine::OpenGL2) - && checkGLPrograms()) { - + if (painter.paintEngine() && painter.paintEngine()->type() == QPaintEngine::OpenGL && checkGLPrograms()) { //for now we only support YUV (both YV12 and YUY2) updateTexture(); @@ -676,7 +673,6 @@ namespace Phonon } //let's draw the texture - painter.beginNativePainting(); //Let's pass the other arguments const Program prog = (m_inputPin->connectedType().subtype == MEDIASUBTYPE_YV12) ? YV12toRGB : YUY2toRGB; @@ -726,7 +722,6 @@ namespace Phonon glDisableClientState(GL_VERTEX_ARRAY); glDisable(GL_FRAGMENT_PROGRAM_ARB); - painter.endNativePainting(); return; } else #endif diff --git a/src/3rdparty/phonon/ds9/videorenderer_vmr9.cpp b/src/3rdparty/phonon/ds9/videorenderer_vmr9.cpp index 545b31e..298e9fa 100644 --- a/src/3rdparty/phonon/ds9/videorenderer_vmr9.cpp +++ b/src/3rdparty/phonon/ds9/videorenderer_vmr9.cpp @@ -22,9 +22,14 @@ along with this library. If not, see . #include #include +#include +#ifndef Q_OS_WINCE #include #include +#else +#include +#endif QT_BEGIN_NAMESPACE @@ -43,10 +48,116 @@ namespace Phonon } +#ifdef Q_OS_WINCE + VideoRendererVMR9::VideoRendererVMR9(QWidget *target) : m_target(target) + { + m_target->setAttribute(Qt::WA_PaintOnScreen, true); + m_filter = Filter(CLSID_VideoRenderer, IID_IBaseFilter); + } + + QSize VideoRendererVMR9::videoSize() const + { + LONG w = 0, + h = 0; + ComPointer basic(m_filter, IID_IBasicVideo); + if (basic) { + basic->GetVideoSize( &w, &h); + } + return QSize(w, h); + } + + void VideoRendererVMR9::repaintCurrentFrame(QWidget * /*target*/, const QRect & /*rect*/) + { + //nothing to do here: the renderer paints everything + } + + void VideoRendererVMR9::notifyResize(const QSize &size, Phonon::VideoWidget::AspectRatio aspectRatio, + Phonon::VideoWidget::ScaleMode scaleMode) + { + if (!isActive()) { + ComPointer basic(m_filter, IID_IBasicVideo); + if (basic) { + basic->SetDestinationPosition(0, 0, 0, 0); + } + return; + } + + ComPointer video(m_filter, IID_IVideoWindow); + + OAHWND owner; + HRESULT hr = video->get_Owner(&owner); + if (FAILED(hr)) { + return; + } + + const OAHWND newOwner = reinterpret_cast(m_target->winId()); + if (owner != newOwner) { + video->put_Owner(newOwner); + video->put_MessageDrain(newOwner); + video->put_WindowStyle(WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS); + } + + //make sure the widget takes the whole size of the parent + video->SetWindowPosition(0, 0, size.width(), size.height()); + + const QSize vsize = videoSize(); + internalNotifyResize(size, vsize, aspectRatio, scaleMode); + + ComPointer basic(m_filter, IID_IBasicVideo); + if (basic) { + basic->SetDestinationPosition(m_dstX, m_dstY, m_dstWidth, m_dstHeight); + } + } + + void VideoRendererVMR9::applyMixerSettings(qreal /*brightness*/, qreal /*contrast*/, qreal /*m_hue*/, qreal /*saturation*/) + { + //this can't be supported for WinCE + } + + QImage VideoRendererVMR9::snapshot() const + { + ComPointer basic(m_filter, IID_IBasicVideo); + if (basic) { + LONG bufferSize = 0; + //1st we get the buffer size + basic->GetCurrentImage(&bufferSize, 0); + + QByteArray buffer; + buffer.resize(bufferSize); + HRESULT hr = basic->GetCurrentImage(&bufferSize, reinterpret_cast(buffer.data())); + + if (SUCCEEDED(hr)) { + + const BITMAPINFOHEADER *bmi = reinterpret_cast(buffer.constData()); + + const int w = qAbs(bmi->biWidth), + h = qAbs(bmi->biHeight); + + // Create image and copy data into image. + QImage ret(w, h, QImage::Format_RGB32); + + if (!ret.isNull()) { + const char *data = buffer.constData() + bmi->biSize; + const int bytes_per_line = w * sizeof(QRgb); + for (int y = h - 1; y >= 0; --y) { + qMemCopy(ret.scanLine(y), //destination + data, //source + bytes_per_line); + data += bytes_per_line; + } + } + return ret; + } + } + return QImage(); + } + +#else VideoRendererVMR9::VideoRendererVMR9(QWidget *target) : m_target(target) { m_filter = Filter(CLSID_VideoMixingRenderer9, IID_IBaseFilter); if (!m_filter) { + qWarning("the video widget could not be initialized correctly"); return; } @@ -58,7 +169,6 @@ namespace Phonon Q_ASSERT(SUCCEEDED(hr)); ComPointer windowlessControl(m_filter, IID_IVMRWindowlessControl9); windowlessControl->SetVideoClippingWindow(reinterpret_cast(target->winId())); - windowlessControl->SetAspectRatioMode(VMR9ARMode_None); //we're in control of the size } QImage VideoRendererVMR9::snapshot() const @@ -214,6 +324,7 @@ namespace Phonon //finally set the settings mixer->SetProcAmpControl(0, &ctrl); } +#endif } } diff --git a/src/3rdparty/phonon/ds9/videorenderer_vmr9.h b/src/3rdparty/phonon/ds9/videorenderer_vmr9.h index 516d79d..4eb237e 100644 --- a/src/3rdparty/phonon/ds9/videorenderer_vmr9.h +++ b/src/3rdparty/phonon/ds9/videorenderer_vmr9.h @@ -19,6 +19,7 @@ along with this library. If not, see . #define PHONON_VIDEORENDERER_VMR9_H #include "abstractvideorenderer.h" +#include "compointer.h" QT_BEGIN_NAMESPACE diff --git a/src/3rdparty/phonon/ds9/videowidget.cpp b/src/3rdparty/phonon/ds9/videowidget.cpp index 09d42a4..de7ce5f 100644 --- a/src/3rdparty/phonon/ds9/videowidget.cpp +++ b/src/3rdparty/phonon/ds9/videowidget.cpp @@ -24,12 +24,7 @@ along with this library. If not, see . #include "mediaobject.h" -#ifndef Q_OS_WINCE -#include "videorenderer_evr.h" #include "videorenderer_vmr9.h" -#else -#include "videorenderer_default.h" -#endif #include "videorenderer_soft.h" QT_BEGIN_NAMESPACE @@ -89,19 +84,7 @@ namespace Phonon void setCurrentRenderer(AbstractVideoRenderer *renderer) { m_currentRenderer = renderer; - //we disallow repaint on that widget for just a fraction of second - //this allows better transition between videos - setUpdatesEnabled(false); - m_flickerFreeTimer.start(20, this); - } - - void timerEvent(QTimerEvent *e) - { - if (e->timerId() == m_flickerFreeTimer.timerId()) { - m_flickerFreeTimer.stop(); - setUpdatesEnabled(true); - } - QWidget::timerEvent(e); + update(); } QSize sizeHint() const @@ -123,8 +106,6 @@ namespace Phonon void paintEvent(QPaintEvent *e) { - if (!updatesEnabled()) - return; //this avoids repaint from native events checkCurrentRenderingMode(); m_currentRenderer->repaintCurrentFrame(this, e->rect()); } @@ -172,14 +153,13 @@ namespace Phonon } } else if (!isEmbedded()) { m_currentRenderer = m_node->switchRendering(m_currentRenderer); - setAttribute(Qt::WA_PaintOnScreen, false); + setAttribute(Qt::WA_PaintOnScreen, true); } } VideoWidget *m_node; AbstractVideoRenderer *m_currentRenderer; QVariant m_restoreScreenSaverActive; - QBasicTimer m_flickerFreeTimer; }; VideoWidget::VideoWidget(QWidget *parent) @@ -223,9 +203,6 @@ namespace Phonon if (toNative && m_noNativeRendererSupported) return current; //no switch here - if (!mediaObject()) - return current; - //firt we delete the renderer //initialization of the widgets for(int i = 0; i < FILTER_COUNT; ++i) { @@ -284,7 +261,6 @@ namespace Phonon { m_aspectRatio = aspectRatio; updateVideoSize(); - m_widget->update(); } Phonon::VideoWidget::ScaleMode VideoWidget::scaleMode() const @@ -303,7 +279,6 @@ namespace Phonon { m_scaleMode = scaleMode; updateVideoSize(); - m_widget->update(); } void VideoWidget::setBrightness(qreal b) @@ -357,29 +332,14 @@ namespace Phonon int index = graphIndex * 2 + type; if (m_renderers[index] == 0 && autoCreate) { AbstractVideoRenderer *renderer = 0; - if (type == Native) { -#ifndef Q_OS_WINCE - renderer = new VideoRendererEVR(m_widget); - if (renderer->getFilter() == 0) { - delete renderer; - //EVR not present, let's try VMR - renderer = new VideoRendererVMR9(m_widget); - if (renderer->getFilter() == 0) { - //instanciating the renderer might fail - m_noNativeRendererSupported = true; - delete renderer; - renderer = 0; - } - } -#else - renderer = new VideoRendererDefault(m_widget); + if (type == Native) { + renderer = new VideoRendererVMR9(m_widget); if (renderer->getFilter() == 0) { - //instanciating the renderer might fail + //instanciating the renderer might fail with error VFW_E_DDRAW_CAPS_NOT_SUITABLE (0x80040273) m_noNativeRendererSupported = true; delete renderer; renderer = 0; } -#endif } if (renderer == 0) { diff --git a/src/3rdparty/phonon/ds9/volumeeffect.cpp b/src/3rdparty/phonon/ds9/volumeeffect.cpp index a93b074..b9a5fce 100644 --- a/src/3rdparty/phonon/ds9/volumeeffect.cpp +++ b/src/3rdparty/phonon/ds9/volumeeffect.cpp @@ -76,7 +76,7 @@ namespace Phonon class VolumeMemInputPin : public QMemInputPin { public: - VolumeMemInputPin(QBaseFilter *parent, const QVector &mt, QPin *output) : QMemInputPin(parent, mt, true /*transform*/, output) + VolumeMemInputPin(QBaseFilter *parent, const QVector &mt) : QMemInputPin(parent, mt, true /*transform*/) { } @@ -139,7 +139,8 @@ namespace Phonon //then creating the input mt << audioMediaType(); - m_input = new VolumeMemInputPin(this, mt, m_output); + m_input = new VolumeMemInputPin(this, mt); + m_input->addOutput(m_output); //make the connection here } void VolumeEffectFilter::treatOneSamplePerChannel(BYTE **buffer, int sampleSize, int channelCount, int frequency) diff --git a/src/3rdparty/phonon/ds9/volumeeffect.h b/src/3rdparty/phonon/ds9/volumeeffect.h index d1b0186..39b20d0 100644 --- a/src/3rdparty/phonon/ds9/volumeeffect.h +++ b/src/3rdparty/phonon/ds9/volumeeffect.h @@ -47,7 +47,7 @@ namespace Phonon private: float m_volume; - //paramaters used to fade + //parameters used to fade Phonon::VolumeFaderEffect::FadeCurve m_fadeCurve; bool m_fading; //determines if we should be fading. -- 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 b7add13a0c363c9ca435256d879b398b15cb8dca Mon Sep 17 00:00:00 2001 From: Justin McPherson Date: Thu, 25 Mar 2010 14:28:49 +1000 Subject: Update Phonon qt7 backend to 4.4.0. --- src/3rdparty/phonon/qt7/audionode.h | 2 +- src/3rdparty/phonon/qt7/audionode.mm | 16 +- src/3rdparty/phonon/qt7/backendinfo.mm | 1 - src/3rdparty/phonon/qt7/mediaobject.h | 40 +--- src/3rdparty/phonon/qt7/mediaobject.mm | 286 +++++++----------------- src/3rdparty/phonon/qt7/quicktimemetadata.h | 8 +- src/3rdparty/phonon/qt7/quicktimemetadata.mm | 41 ++-- src/3rdparty/phonon/qt7/quicktimevideoplayer.h | 28 +-- src/3rdparty/phonon/qt7/quicktimevideoplayer.mm | 265 +++------------------- src/3rdparty/phonon/qt7/videoframe.mm | 24 +- 10 files changed, 137 insertions(+), 574 deletions(-) diff --git a/src/3rdparty/phonon/qt7/audionode.h b/src/3rdparty/phonon/qt7/audionode.h index 2498e49..dfec817f 100644 --- a/src/3rdparty/phonon/qt7/audionode.h +++ b/src/3rdparty/phonon/qt7/audionode.h @@ -72,7 +72,7 @@ namespace QT7 AudioUnit m_audioUnit; // Only the following methods needs to - // be overidden by only_one-audio-unit nodes: + // be overridden by only_one-audio-unit nodes: virtual ComponentDescription getAudioNodeDescription() const; virtual void initializeAudioUnit(); diff --git a/src/3rdparty/phonon/qt7/audionode.mm b/src/3rdparty/phonon/qt7/audionode.mm index 961230c..cb9e82f 100644 --- a/src/3rdparty/phonon/qt7/audionode.mm +++ b/src/3rdparty/phonon/qt7/audionode.mm @@ -68,15 +68,13 @@ void AudioNode::createAndConnectAUNodes() << QString(!FindNextComponent(0, &description) ? "ERROR: COMPONENT NOT FOUND!" : "OK!")) OSStatus err = noErr; - - // The proper function to call here is AUGraphAddNode() but the type has - // changed between 10.5 and 10.6. it's still OK to call this function, but - // if we want to use the proper thing we need to move over to - // AudioComponentDescription everywhere, which is very similar to the - // ComponentDescription, but a different size. however, - // AudioComponentDescription only exists on 10.6+. More fun than we need to - // deal with at the moment, so we'll take the "deprecated" warning instead. - err = AUGraphNewNode(m_audioGraph->audioGraphRef(), &description, 0, 0, &m_auNode); +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 + if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) + err = AUGraphAddNode(m_audioGraph->audioGraphRef(), &description, &m_auNode); + else +#endif + err = AUGraphNewNode(m_audioGraph->audioGraphRef(), &description, 0, 0, &m_auNode); + BACKEND_ASSERT2(err != kAUGraphErr_OutputNodeErr, "A MediaObject can only be connected to one audio output device.", FATAL_ERROR) BACKEND_ASSERT2(err == noErr, "Could not create new AUNode.", FATAL_ERROR) } diff --git a/src/3rdparty/phonon/qt7/backendinfo.mm b/src/3rdparty/phonon/qt7/backendinfo.mm index 0d51db0..e173f05 100644 --- a/src/3rdparty/phonon/qt7/backendinfo.mm +++ b/src/3rdparty/phonon/qt7/backendinfo.mm @@ -22,7 +22,6 @@ #include #include -#include #import #ifdef QUICKTIME_C_API_AVAILABLE diff --git a/src/3rdparty/phonon/qt7/mediaobject.h b/src/3rdparty/phonon/qt7/mediaobject.h index c93eddc..27949ec 100644 --- a/src/3rdparty/phonon/qt7/mediaobject.h +++ b/src/3rdparty/phonon/qt7/mediaobject.h @@ -25,10 +25,6 @@ #include "medianode.h" -#if QT_ALLOW_QUICKTIME - #include -#endif - QT_BEGIN_NAMESPACE namespace Phonon @@ -42,10 +38,7 @@ namespace QT7 class MediaObjectAudioNode; class MediaObject : public MediaNode, - public Phonon::MediaObjectInterface -#ifndef QT_NO_PHONON_MEDIACONTROLLER - , public Phonon::AddonInterface -#endif + public Phonon::MediaObjectInterface, public Phonon::AddonInterface { Q_OBJECT Q_INTERFACES(Phonon::MediaObjectInterface Phonon::AddonInterface) @@ -99,10 +92,6 @@ namespace QT7 int videoOutputCount(); -#if QT_ALLOW_QUICKTIME - void displayLinkEvent(); -#endif - signals: void stateChanged(Phonon::State,Phonon::State); void tick(qint64); @@ -116,16 +105,6 @@ namespace QT7 void metaDataChanged(QMultiMap); void currentSourceChanged(const MediaSource &newSource); - // Add-on interface: - void availableSubtitlesChanged(); - void availableAudioChannelsChanged(); - void titleChanged(int); - void availableTitlesChanged(int); - void chapterChanged(int); - void availableChaptersChanged(int); - void angleChanged(int); - void availableAnglesChanged(int); - protected: void mediaNodeEvent(const MediaNodeEvent *event); bool event(QEvent *event); @@ -139,14 +118,7 @@ namespace QT7 QuickTimeVideoPlayer *m_nextVideoPlayer; QuickTimeAudioPlayer *m_nextAudioPlayer; MediaObjectAudioNode *m_mediaObjectAudioNode; - -#if QT_ALLOW_QUICKTIME - CVDisplayLinkRef m_displayLink; - QMutex m_displayLinkMutex; - bool m_pendingDisplayLinkEvent; - void startDisplayLink(); - void stopDisplayLink(); -#endif + QuickTimeMetaData *m_metaData; qint32 m_tickInterval; qint32 m_transitionTime; @@ -155,14 +127,12 @@ namespace QT7 float m_percentageLoaded; int m_tickTimer; - int m_videoTimer; - int m_audioTimer; + int m_bufferTimer; int m_rapidTimer; bool m_waitNextSwap; int m_swapTimeLeft; QTime m_swapTime; - bool m_autoplayTitles; void synchAudioVideo(); void updateCurrentTime(); @@ -171,7 +141,8 @@ namespace QT7 void pause_internal(); void play_internal(); void setupAudioSystem(); - void restartAudioVideoTimers(); + void updateTimer(int &timer, int interval); + void bufferAudioVideo(); void updateRapidly(); void updateCrossFade(); void updateAudioBuffers(); @@ -183,7 +154,6 @@ namespace QT7 void inspectVideoGraphRecursive(MediaNode *node, int &effectCount, int &outputCount); void inspectGraph(); bool isCrossFading(); - void setCurrentTrack(int track); QString m_errorString; Phonon::ErrorType m_errorType; diff --git a/src/3rdparty/phonon/qt7/mediaobject.mm b/src/3rdparty/phonon/qt7/mediaobject.mm index 677640c..f8d635a 100644 --- a/src/3rdparty/phonon/qt7/mediaobject.mm +++ b/src/3rdparty/phonon/qt7/mediaobject.mm @@ -46,6 +46,7 @@ MediaObject::MediaObject(QObject *parent) : MediaNode(AudioSource | VideoSource, m_mediaObjectAudioNode = new MediaObjectAudioNode(m_audioPlayer, m_nextAudioPlayer); setAudioNode(m_mediaObjectAudioNode); + m_metaData = new QuickTimeMetaData(); m_audioGraph = new AudioGraph(this); m_tickInterval = 0; @@ -54,7 +55,6 @@ MediaObject::MediaObject(QObject *parent) : MediaNode(AudioSource | VideoSource, m_transitionTime = 0; m_percentageLoaded = 0; m_waitNextSwap = false; - m_autoplayTitles = true; m_audioEffectCount = 0; m_audioOutputCount = 0; m_videoEffectCount = 0; @@ -63,28 +63,20 @@ MediaObject::MediaObject(QObject *parent) : MediaNode(AudioSource | VideoSource, m_errorType = Phonon::NoError; m_tickTimer = 0; - m_videoTimer = 0; - m_audioTimer = 0; + m_bufferTimer = 0; m_rapidTimer = 0; -#if QT_ALLOW_QUICKTIME - m_displayLink = 0; - m_pendingDisplayLinkEvent = false; -#endif - checkForError(); } MediaObject::~MediaObject() -{ - // m_mediaObjectAudioNode is owned by super class. -#if QT_ALLOW_QUICKTIME - stopDisplayLink(); -#endif +{ + // m_mediaObjectAudioNode is owned by super class. m_audioPlayer->unsetVideoPlayer(); m_nextAudioPlayer->unsetVideoPlayer(); delete m_videoPlayer; delete m_nextVideoPlayer; + delete m_metaData; checkForError(); } @@ -222,28 +214,28 @@ void MediaObject::setSource(const MediaSource &source) IMPLEMENTED; PhononAutoReleasePool pool; setState(Phonon::LoadingState); - + // Save current state for event/signal handling below: bool prevHasVideo = m_videoPlayer->hasVideo(); qint64 prevTotalTime = totalTime(); - int prevTrackCount = m_videoPlayer->trackCount(); m_waitNextSwap = false; - + // Cancel cross-fade if any: m_nextVideoPlayer->pause(); m_nextAudioPlayer->pause(); m_mediaObjectAudioNode->cancelCrossFade(); - + // Set new source: m_audioPlayer->unsetVideoPlayer(); m_videoPlayer->setMediaSource(source); m_audioPlayer->setVideoPlayer(m_videoPlayer); + m_metaData->setVideo(m_videoPlayer); - m_audioGraph->updateStreamSpecifications(); + m_audioGraph->updateStreamSpecifications(); m_nextAudioPlayer->unsetVideoPlayer(); - m_nextVideoPlayer->unsetCurrentMediaSource(); + m_nextVideoPlayer->unsetVideo(); m_currentTime = 0; - + // Emit/notify information about the new source: QRect videoRect = m_videoPlayer->videoRect(); MediaNodeEvent e1(MediaNodeEvent::VideoFrameSizeChanged, &videoRect); @@ -254,14 +246,12 @@ void MediaObject::setSource(const MediaSource &source) updateVideo(emptyFrame); emit currentSourceChanged(source); - emit metaDataChanged(m_videoPlayer->metaData()); + emit metaDataChanged(m_metaData->metaData()); if (prevHasVideo != m_videoPlayer->hasVideo()) - emit hasVideoChanged(m_videoPlayer->hasVideo()); + emit hasVideoChanged(m_videoPlayer->hasVideo()); if (prevTotalTime != totalTime()) - emit totalTimeChanged(totalTime()); - if (prevTrackCount != m_videoPlayer->trackCount()) - emit availableTitlesChanged(m_videoPlayer->trackCount()); + emit totalTimeChanged(totalTime()); if (checkForError()) return; if (!m_videoPlayer->isDrmAuthorized()) @@ -297,30 +287,28 @@ void MediaObject::swapCurrentWithNext(qint32 transitionTime) // Save current state for event/signal handling below: bool prevHasVideo = m_videoPlayer->hasVideo(); qint64 prevTotalTime = totalTime(); - int prevTrackCount = m_videoPlayer->trackCount(); qSwap(m_audioPlayer, m_nextAudioPlayer); qSwap(m_videoPlayer, m_nextVideoPlayer); m_mediaObjectAudioNode->startCrossFade(transitionTime); m_audioGraph->updateStreamSpecifications(); + m_metaData->setVideo(m_videoPlayer); m_waitNextSwap = false; m_currentTime = 0; - + // Emit/notify information about the new source: QRect videoRect = m_videoPlayer->videoRect(); MediaNodeEvent e1(MediaNodeEvent::VideoFrameSizeChanged, &videoRect); notify(&e1); emit currentSourceChanged(m_videoPlayer->mediaSource()); - emit metaDataChanged(m_videoPlayer->metaData()); + emit metaDataChanged(m_metaData->metaData()); if (prevHasVideo != m_videoPlayer->hasVideo()) - emit hasVideoChanged(m_videoPlayer->hasVideo()); + emit hasVideoChanged(m_videoPlayer->hasVideo()); if (prevTotalTime != totalTime()) emit totalTimeChanged(totalTime()); - if (prevTrackCount != m_videoPlayer->trackCount()) - emit availableTitlesChanged(m_videoPlayer->trackCount()); if (checkForError()) return; if (!m_videoPlayer->isDrmAuthorized()) @@ -339,107 +327,28 @@ void MediaObject::swapCurrentWithNext(qint32 transitionTime) } } -#if QT_ALLOW_QUICKTIME -static CVReturn displayLinkCallback(CVDisplayLinkRef /*displayLink*/, - const CVTimeStamp */*inNow*/, - const CVTimeStamp */*inOutputTime*/, - CVOptionFlags /*flagsIn*/, - CVOptionFlags */*flagsOut*/, - void *userData) +void MediaObject::updateTimer(int &timer, int interval) { - MediaObject *mediaObject = static_cast(userData); - mediaObject->displayLinkEvent(); - return kCVReturnSuccess; -} - -void MediaObject::displayLinkEvent() -{ - // This function is called from a - // thread != gui thread. So we post the event. - // But we need to make sure that we don't post faster - // than the event loop can eat: - m_displayLinkMutex.lock(); - bool pending = m_pendingDisplayLinkEvent; - m_pendingDisplayLinkEvent = true; - m_displayLinkMutex.unlock(); - - if (!pending) - qApp->postEvent(this, new QEvent(QEvent::User), Qt::HighEventPriority); -} - -void MediaObject::startDisplayLink() -{ - if (m_displayLink) - return; - OSStatus err = CVDisplayLinkCreateWithCGDisplay(kCGDirectMainDisplay, &m_displayLink); - if (err != noErr) - goto fail; - err = CVDisplayLinkSetCurrentCGDisplay(m_displayLink, kCGDirectMainDisplay); - if (err != noErr) - goto fail; - err = CVDisplayLinkSetOutputCallback(m_displayLink, displayLinkCallback, this); - if (err != noErr) - goto fail; - err = CVDisplayLinkStart(m_displayLink); - if (err != noErr) - goto fail; - return; -fail: - stopDisplayLink(); -} - -void MediaObject::stopDisplayLink() -{ - if (!m_displayLink) - return; - CVDisplayLinkStop(m_displayLink); - CFRelease(m_displayLink); - m_displayLink = 0; -} -#endif - -void MediaObject::restartAudioVideoTimers() -{ - if (m_videoTimer) - killTimer(m_videoTimer); - if (m_audioTimer) - killTimer(m_audioTimer); - -#if QT_ALLOW_QUICKTIME - // We prefer to use a display link as timer if available, since - // it is more steady, and results in better and smoother frame drawing: - startDisplayLink(); - if (!m_displayLink){ - float fps = m_videoPlayer->staticFps(); - long videoUpdateFrequency = fps ? long(1000.0f / fps) : 0.001; - m_videoTimer = startTimer(videoUpdateFrequency); - } -#else - float fps = m_videoPlayer->staticFps(); - long videoUpdateFrequency = fps ? long(1000.0f / fps) : 0.001; - m_videoTimer = startTimer(videoUpdateFrequency); -#endif - - long audioUpdateFrequency = m_audioPlayer->regularTaskFrequency(); - m_audioTimer = startTimer(audioUpdateFrequency); - updateVideoFrames(); - updateAudioBuffers(); + if (timer) + killTimer(timer); + timer = 0; + if (interval >= 0) + timer = startTimer(interval); } void MediaObject::play_internal() { // Play main audio/video: m_videoPlayer->play(); - m_audioPlayer->play(); + m_audioPlayer->play(); updateLipSynch(0); // Play old audio/video to finish cross-fade: if (m_nextVideoPlayer->currentTime() > 0){ m_nextVideoPlayer->play(); m_nextAudioPlayer->play(); } - restartAudioVideoTimers(); - if (!m_rapidTimer) - m_rapidTimer = startTimer(100); + bufferAudioVideo(); + updateTimer(m_rapidTimer, 100); } void MediaObject::pause_internal() @@ -449,15 +358,9 @@ void MediaObject::pause_internal() m_nextAudioPlayer->pause(); m_videoPlayer->pause(); m_nextVideoPlayer->pause(); - killTimer(m_rapidTimer); - killTimer(m_videoTimer); - killTimer(m_audioTimer); - m_rapidTimer = 0; - m_videoTimer = 0; - m_audioTimer = 0; -#if QT_ALLOW_QUICKTIME - stopDisplayLink(); -#endif + updateTimer(m_rapidTimer, -1); + updateTimer(m_bufferTimer, -1); + if (m_waitNextSwap) m_swapTimeLeft = m_swapTime.msecsTo(QTime::currentTime()); } @@ -520,7 +423,7 @@ void MediaObject::stop() if (!setState(Phonon::StoppedState)) return; m_waitNextSwap = false; - m_nextVideoPlayer->unsetCurrentMediaSource(); + m_nextVideoPlayer->unsetVideo(); m_nextAudioPlayer->unsetVideoPlayer(); pause_internal(); seek(0); @@ -532,9 +435,9 @@ void MediaObject::seek(qint64 milliseconds) IMPLEMENTED; if (m_state == Phonon::ErrorState) return; - + // Stop cross-fade if any: - m_nextVideoPlayer->unsetCurrentMediaSource(); + m_nextVideoPlayer->unsetVideo(); m_nextAudioPlayer->unsetVideoPlayer(); m_mediaObjectAudioNode->cancelCrossFade(); @@ -664,24 +567,19 @@ void MediaObject::updateCurrentTime() m_currentTime = (m_audioSystem == AS_Graph) ? m_audioPlayer->currentTime() : m_videoPlayer->currentTime(); quint64 total = m_videoPlayer->duration(); - if (m_videoPlayer->currentTrack() < m_videoPlayer->trackCount() - 1){ - // There are still more tracks to play after the current track. - if (m_autoplayTitles) { - if (lastUpdateTime < m_currentTime && m_currentTime == total) - setCurrentTrack(m_videoPlayer->currentTrack() + 1); - } - } else if (m_nextVideoPlayer->state() == QuickTimeVideoPlayer::NoMedia){ - // There is no more sources or tracks to play after the current source. - // Check if it's time to emit aboutToFinish: - quint32 mark = qMax(quint64(0), qMin(total, total + m_transitionTime - 2000)); - if (lastUpdateTime < mark && mark <= m_currentTime) - emit aboutToFinish(); - - // Check if it's time to emit prefinishMarkReached: - mark = qMax(quint64(0), total - m_prefinishMark); - if (lastUpdateTime < mark && mark <= m_currentTime) - emit prefinishMarkReached(total - m_currentTime); + // Check if it's time to emit aboutToFinish: + quint32 mark = qMax(quint64(0), qMin(total, total + m_transitionTime - 2000)); + if (lastUpdateTime < mark && mark <= m_currentTime) + emit aboutToFinish(); + + // Check if it's time to emit prefinishMarkReached: + mark = qMax(quint64(0), total - m_prefinishMark); + if (lastUpdateTime < mark && mark <= m_currentTime) + emit prefinishMarkReached(total - m_currentTime); + if (m_nextVideoPlayer->state() == QuickTimeVideoPlayer::NoMedia){ + // There is no next source in que. + // Check if it's time to emit finished: if (lastUpdateTime < m_currentTime && m_currentTime == total){ emit finished(); m_currentTime = (m_audioSystem == AS_Graph) ? m_audioPlayer->currentTime() : m_videoPlayer->currentTime(); @@ -691,7 +589,7 @@ void MediaObject::updateCurrentTime() } else { // We have a next source. // Check if it's time to swap to next source: - quint32 mark = qMax(quint64(0), total + m_transitionTime); + mark = qMax(quint64(0), total + m_transitionTime); if (m_waitNextSwap && m_state == Phonon::PlayingState && m_transitionTime < m_swapTime.msecsTo(QTime::currentTime())){ swapCurrentWithNext(0); @@ -794,14 +692,14 @@ bool MediaObject::setAudioDeviceOnMovie(int id) void MediaObject::updateCrossFade() { - m_mediaObjectAudioNode->updateCrossFade(m_currentTime); + m_mediaObjectAudioNode->updateCrossFade(m_currentTime); // Clean-up previous movie if done fading: if (m_mediaObjectAudioNode->m_fadeDuration == 0){ if (m_nextVideoPlayer->isPlaying() || m_nextAudioPlayer->isPlaying()){ - m_nextVideoPlayer->unsetCurrentMediaSource(); + m_nextVideoPlayer->unsetVideo(); m_nextAudioPlayer->unsetVideoPlayer(); } - } + } } void MediaObject::updateBufferStatus() @@ -830,7 +728,7 @@ void MediaObject::updateVideoFrames() // Draw next frame if awailable: if (m_videoPlayer->videoFrameChanged()){ updateLipSynch(50); - VideoFrame frame(m_videoPlayer); + VideoFrame frame(m_videoPlayer); if (m_nextVideoPlayer->isPlaying() && m_nextVideoPlayer->hasVideo() && isCrossFading()){ @@ -838,9 +736,9 @@ void MediaObject::updateVideoFrames() frame.setBackgroundFrame(bgFrame); frame.setBaseOpacity(m_mediaObjectAudioNode->m_volume1); } - + // Send the frame through the graph: - updateVideo(frame); + updateVideo(frame); checkForError(); } } @@ -851,7 +749,7 @@ void MediaObject::updateLipSynch(int allowedOffset) return; if (m_videoSinkList.isEmpty() || m_audioSinkList.isEmpty()) return; - + if (m_videoPlayer->hasVideo()){ qint64 diff = m_audioPlayer->currentTime() - m_videoPlayer->currentTime(); if (-allowedOffset > diff || diff > allowedOffset) @@ -865,6 +763,16 @@ void MediaObject::updateLipSynch(int allowedOffset) } } +void MediaObject::bufferAudioVideo() +{ + long nextVideoUpdate = m_videoPlayer->hasVideo() ? 30 : INT_MAX; + long nextAudioUpdate = m_audioPlayer->regularTaskFrequency(); + updateAudioBuffers(); + updateVideoFrames(); + if (m_state == Phonon::PlayingState) + updateTimer(m_bufferTimer, qMin(nextVideoUpdate, nextAudioUpdate)); +} + void MediaObject::updateRapidly() { updateCurrentTime(); @@ -889,8 +797,8 @@ void MediaObject::mediaNodeEvent(const MediaNodeEvent *event) synchAudioVideo(); checkForError(); m_mediaObjectAudioNode->setMute(false); - if (m_state == Phonon::PlayingState) - restartAudioVideoTimers(); + if (m_state == Phonon::PlayingState) + bufferAudioVideo(); break; case MediaNodeEvent::AudioGraphCannotPlay: case MediaNodeEvent::AudioGraphInitialized: @@ -901,7 +809,7 @@ void MediaObject::mediaNodeEvent(const MediaNodeEvent *event) checkForError(); m_mediaObjectAudioNode->setMute(false); } - break; + break; default: break; } @@ -910,67 +818,29 @@ void MediaObject::mediaNodeEvent(const MediaNodeEvent *event) bool MediaObject::event(QEvent *event) { switch (event->type()){ -#if QT_ALLOW_QUICKTIME - case QEvent::User:{ - m_displayLinkMutex.lock(); - m_pendingDisplayLinkEvent = false; - m_displayLinkMutex.unlock(); - updateVideoFrames(); - break; } -#endif - case QEvent::Timer:{ - int timerId = static_cast(event)->timerId(); - if (timerId == m_rapidTimer) + case QEvent::Timer: { + QTimerEvent *timerEvent = static_cast(event); + if (timerEvent->timerId() == m_rapidTimer) updateRapidly(); - else if (timerId == m_tickTimer) + else if (timerEvent->timerId() == m_tickTimer) emit tick(currentTime()); - else if (timerId == m_videoTimer) - updateVideoFrames(); - else if (timerId == m_audioTimer) - updateAudioBuffers(); - break; } + else if (timerEvent->timerId() == m_bufferTimer) + bufferAudioVideo(); + } + break; default: break; } return QObject::event(event); } -void MediaObject::setCurrentTrack(int track) -{ - if (track == m_videoPlayer->currentTrack() || track < 0 || track >= m_videoPlayer->trackCount()) - return; - - m_videoPlayer->setCurrentTrack(track); - emit titleChanged(track); - emit metaDataChanged(m_videoPlayer->metaData()); -} - -bool MediaObject::hasInterface(Interface iface) const +bool MediaObject::hasInterface(Interface /*interface*/) const { - return iface == AddonInterface::TitleInterface; + return false; } -QVariant MediaObject::interfaceCall(Interface iface, int command, const QList ¶ms) +QVariant MediaObject::interfaceCall(Interface /*interface*/, int /*command*/, const QList &/*arguments*/) { - switch (iface) { - case TitleInterface: - switch (command) { - case availableTitles: - return m_videoPlayer->trackCount(); - case title: - return m_videoPlayer->currentTrack(); - case setTitle: - setCurrentTrack(params.first().toInt()); - break; - case autoplayTitles: - return m_autoplayTitles; - case setAutoplayTitles: - m_autoplayTitles = params.first().toBool(); - break; - } - default: - break; - } return QVariant(); } diff --git a/src/3rdparty/phonon/qt7/quicktimemetadata.h b/src/3rdparty/phonon/qt7/quicktimemetadata.h index c589535..d524183 100644 --- a/src/3rdparty/phonon/qt7/quicktimemetadata.h +++ b/src/3rdparty/phonon/qt7/quicktimemetadata.h @@ -38,8 +38,10 @@ namespace QT7 class QuickTimeMetaData { public: - QuickTimeMetaData(QuickTimeVideoPlayer *videoPlayer); - void update(); + QuickTimeMetaData(); + virtual ~QuickTimeMetaData(); + + void setVideo(QuickTimeVideoPlayer *videoPlayer); QMultiMap metaData(); private: @@ -47,8 +49,6 @@ namespace QT7 bool m_movieChanged; QuickTimeVideoPlayer *m_videoPlayer; void readMetaData(); - void guessMetaDataForCD(); - void readMetaDataFromMovie(); #ifdef QUICKTIME_C_API_AVAILABLE QString stripCopyRightSymbol(const QString &key); diff --git a/src/3rdparty/phonon/qt7/quicktimemetadata.mm b/src/3rdparty/phonon/qt7/quicktimemetadata.mm index 2dcc152..851e707 100644 --- a/src/3rdparty/phonon/qt7/quicktimemetadata.mm +++ b/src/3rdparty/phonon/qt7/quicktimemetadata.mm @@ -15,7 +15,6 @@ along with this library. If not, see . */ -#include #include "quicktimemetadata.h" #include "quicktimevideoplayer.h" @@ -26,14 +25,19 @@ namespace Phonon namespace QT7 { -QuickTimeMetaData::QuickTimeMetaData(QuickTimeVideoPlayer *videoPlayer) +QuickTimeMetaData::QuickTimeMetaData() { - m_videoPlayer = videoPlayer; + m_videoPlayer = 0; m_movieChanged = false; } -void QuickTimeMetaData::update() +QuickTimeMetaData::~QuickTimeMetaData() { +} + +void QuickTimeMetaData::setVideo(QuickTimeVideoPlayer *videoPlayer) +{ + m_videoPlayer = videoPlayer; m_movieChanged = true; m_metaData.clear(); } @@ -141,22 +145,14 @@ void QuickTimeMetaData::readFormattedData(QTMetaDataRef metaDataRef, OSType form #endif // QUICKTIME_C_API_AVAILABLE -void QuickTimeMetaData::guessMetaDataForCD() -{ - QString album = QFileInfo(m_videoPlayer->movieCompactDiscPath()).fileName(); - QString title = QFileInfo(m_videoPlayer->currentTrackPath()).fileName(); - title = title.left(title.lastIndexOf('.')); - m_metaData.insert(QLatin1String("ALBUM"), album); - m_metaData.insert(QLatin1String("TITLE"), title); - m_metaData.insert(QLatin1String("TRACKNUMBER"), QString::number(m_videoPlayer->currentTrack())); -} - -void QuickTimeMetaData::readMetaDataFromMovie() +void QuickTimeMetaData::readMetaData() { + if (!m_videoPlayer) + return; QMultiMap metaMap; - + #ifdef QUICKTIME_C_API_AVAILABLE - QTMetaDataRef metaDataRef; + QTMetaDataRef metaDataRef; OSStatus err = QTCopyMovieMetaData([m_videoPlayer->qtMovie() quickTimeMovie], &metaDataRef); BACKEND_ASSERT2(err == noErr, "Could not read QuickTime meta data", NORMAL_ERROR) @@ -177,17 +173,6 @@ void QuickTimeMetaData::readMetaDataFromMovie() m_metaData.insert(QLatin1String("DESCRIPTION"), metaMap.value(QLatin1String("des"))); } -void QuickTimeMetaData::readMetaData() -{ - if (!m_videoPlayer) - return; - - if (m_videoPlayer->mediaSource().type() == Phonon::MediaSource::Disc) - guessMetaDataForCD(); - else - readMetaDataFromMovie(); -} - QMultiMap QuickTimeMetaData::metaData() { if (m_videoPlayer && m_videoPlayer->hasMovie() && m_movieChanged) diff --git a/src/3rdparty/phonon/qt7/quicktimevideoplayer.h b/src/3rdparty/phonon/qt7/quicktimevideoplayer.h index 98eacb5..0b3aec2 100644 --- a/src/3rdparty/phonon/qt7/quicktimevideoplayer.h +++ b/src/3rdparty/phonon/qt7/quicktimevideoplayer.h @@ -20,7 +20,6 @@ #include "backendheader.h" -#include #import #import @@ -39,7 +38,6 @@ namespace Phonon namespace QT7 { class QuickTimeStreamReader; - class QuickTimeMetaData; class VideoRenderWidgetQTMovieView; class QuickTimeVideoPlayer : QObject @@ -57,7 +55,7 @@ namespace QT7 void setMediaSource(const MediaSource &source); MediaSource mediaSource() const; - void unsetCurrentMediaSource(); + void unsetVideo(); void play(); void pause(); @@ -68,13 +66,11 @@ namespace QT7 GLuint currentFrameAsGLTexture(); void *currentFrameAsCIImage(); QImage currentFrameAsQImage(); - void releaseImageCache(); QRect videoRect() const; quint64 duration() const; quint64 currentTime() const; long timeScale() const; - float staticFps(); QString currentTimeString(); void setColors(qreal brightness = 0, qreal contrast = 1, qreal hue = 0, qreal saturation = 1); @@ -87,7 +83,6 @@ namespace QT7 bool setAudioDevice(int id); void setPlaybackRate(float rate); QTMovie *qtMovie() const; - QMultiMap metaData(); float playbackRate() const; float prefferedPlaybackRate() const; @@ -107,12 +102,6 @@ namespace QT7 float percentageLoaded(); quint64 timeLoaded(); - int trackCount() const; - int currentTrack() const; - void setCurrentTrack(int track); - QString movieCompactDiscPath() const; - QString currentTrackPath() const; - static QString timeToString(quint64 ms); // Help functions when drawing to more that one widget in cocoa 64: @@ -126,10 +115,6 @@ namespace QT7 QTMovie *m_QTMovie; State m_state; QGLPixelBuffer *m_QImagePixelBuffer; - QuickTimeMetaData *m_metaData; - - CVOpenGLTextureRef m_cachedCVTextureRef; - QImage m_cachedQImage; bool m_playbackRateSat; bool m_isDrmProtected; @@ -140,18 +125,13 @@ namespace QT7 float m_masterVolume; float m_relativeVolume; float m_playbackRate; - float m_staticFps; quint64 m_currentTime; MediaSource m_mediaSource; - void *m_primaryRenderingCIImage; qreal m_brightness; qreal m_contrast; qreal m_hue; qreal m_saturation; - NSArray *m_folderTracks; - int m_currentTrack; - QString m_movieCompactDiscPath; #ifdef QUICKTIME_C_API_AVAILABLE QTVisualContextRef m_visualContext; @@ -159,26 +139,20 @@ namespace QT7 VideoFrame m_currentFrame; QuickTimeStreamReader *m_streamReader; - void prepareCurrentMovieForPlayback(); void createVisualContext(); void openMovieFromCurrentMediaSource(); void openMovieFromDataRef(QTDataReference *dataRef); void openMovieFromFile(); void openMovieFromUrl(); void openMovieFromStream(); - void openMovieFromCompactDisc(); void openMovieFromData(QByteArray *data, char *fileType); void openMovieFromDataGuessType(QByteArray *data); QString mediaSourcePath(); bool codecExistsAccordingToSuffix(const QString &fileName); - NSString* pathToCompactDisc(); - bool isCompactDisc(NSString *path); - NSArray* scanFolder(NSString *path); void setError(NSError *error); bool errorOccured(); void readProtection(); - void calculateStaticFps(); void checkIfVideoAwailable(); bool movieNotLoaded(); void waitStatePlayable(); diff --git a/src/3rdparty/phonon/qt7/quicktimevideoplayer.mm b/src/3rdparty/phonon/qt7/quicktimevideoplayer.mm index 23c76e3..3f76132 100644 --- a/src/3rdparty/phonon/qt7/quicktimevideoplayer.mm +++ b/src/3rdparty/phonon/qt7/quicktimevideoplayer.mm @@ -20,7 +20,6 @@ #include "videowidget.h" #include "audiodevice.h" #include "quicktimestreamreader.h" -#include "quicktimemetadata.h" #include #include @@ -53,7 +52,6 @@ QuickTimeVideoPlayer::QuickTimeVideoPlayer() : QObject(0) { m_state = NoMedia; m_mediaSource = MediaSource(); - m_metaData = new QuickTimeMetaData(this); m_QTMovie = 0; m_streamReader = 0; m_playbackRate = 1.0f; @@ -63,16 +61,12 @@ QuickTimeVideoPlayer::QuickTimeVideoPlayer() : QObject(0) m_mute = false; m_audioEnabled = false; m_hasVideo = false; - m_staticFps = 0; m_playbackRateSat = false; m_isDrmProtected = false; m_isDrmAuthorized = true; m_primaryRenderingTarget = 0; m_primaryRenderingCIImage = 0; m_QImagePixelBuffer = 0; - m_cachedCVTextureRef = 0; - m_folderTracks = 0; - m_currentTrack = 0; #ifdef QUICKTIME_C_API_AVAILABLE OSStatus err = EnterMovies(); @@ -83,9 +77,7 @@ QuickTimeVideoPlayer::QuickTimeVideoPlayer() : QObject(0) QuickTimeVideoPlayer::~QuickTimeVideoPlayer() { - PhononAutoReleasePool pool; - unsetCurrentMediaSource(); - delete m_metaData; + unsetVideo(); [(NSObject*)m_primaryRenderingTarget release]; m_primaryRenderingTarget = 0; #ifdef QUICKTIME_C_API_AVAILABLE @@ -94,15 +86,6 @@ QuickTimeVideoPlayer::~QuickTimeVideoPlayer() #endif } -void QuickTimeVideoPlayer::releaseImageCache() -{ - if (m_cachedCVTextureRef){ - CVOpenGLTextureRelease(m_cachedCVTextureRef); - m_cachedCVTextureRef = 0; - } - m_cachedQImage = QImage(); -} - void QuickTimeVideoPlayer::createVisualContext() { #ifdef QUICKTIME_C_API_AVAILABLE @@ -142,10 +125,7 @@ bool QuickTimeVideoPlayer::videoFrameChanged() return false; QTVisualContextTask(m_visualContext); - bool changed = QTVisualContextIsNewImageAvailable(m_visualContext, 0); - if (changed) - releaseImageCache(); - return changed; + return QTVisualContextIsNewImageAvailable(m_visualContext, 0); #elif defined(QT_MAC_USE_COCOA) return true; @@ -160,11 +140,10 @@ CVOpenGLTextureRef QuickTimeVideoPlayer::currentFrameAsCVTexture() #ifdef QUICKTIME_C_API_AVAILABLE if (!m_visualContext) return 0; - if (!m_cachedCVTextureRef){ - OSStatus err = QTVisualContextCopyImageForTime(m_visualContext, 0, 0, &m_cachedCVTextureRef); - BACKEND_ASSERT3(err == noErr, "Could not copy image for time in QuickTime player", FATAL_ERROR, 0) - } - return m_cachedCVTextureRef; + CVOpenGLTextureRef texture = 0; + OSStatus err = QTVisualContextCopyImageForTime(m_visualContext, 0, 0, &texture); + BACKEND_ASSERT3(err == noErr, "Could not copy image for time in QuickTime player", FATAL_ERROR, 0) + return texture; #else return 0; @@ -173,9 +152,6 @@ CVOpenGLTextureRef QuickTimeVideoPlayer::currentFrameAsCVTexture() QImage QuickTimeVideoPlayer::currentFrameAsQImage() { - if (!m_cachedQImage.isNull()) - return m_cachedQImage; - #ifdef QUICKTIME_C_API_AVAILABLE QGLContext *prevContext = const_cast(QGLContext::currentContext()); CVOpenGLTextureRef texture = currentFrameAsCVTexture(); @@ -205,11 +181,12 @@ QImage QuickTimeVideoPlayer::currentFrameAsQImage() glVertex2i(-1, -1); glEnd(); - m_cachedQImage = m_QImagePixelBuffer->toImage(); + QImage image = m_QImagePixelBuffer->toImage(); + CVOpenGLTextureRelease(texture); // Because of QuickTime, m_QImagePixelBuffer->doneCurrent() will fail. // So we store, and restore, the context our selves: prevContext->makeCurrent(); - return m_cachedQImage; + return image; #else CIImage *img = (CIImage *)currentFrameAsCIImage(); if (!img) @@ -218,10 +195,10 @@ QImage QuickTimeVideoPlayer::currentFrameAsQImage() NSBitmapImageRep* bitmap = [[NSBitmapImageRep alloc] initWithCIImage:img]; CGRect bounds = [img extent]; QImage qImg([bitmap bitmapData], bounds.size.width, bounds.size.height, QImage::Format_ARGB32); - m_cachedQImage = qImg.rgbSwapped(); + QImage swapped = qImg.rgbSwapped(); [bitmap release]; [img release]; - return m_cachedQImage; + return swapped; #endif } @@ -273,7 +250,8 @@ void *QuickTimeVideoPlayer::currentFrameAsCIImage() #ifdef QUICKTIME_C_API_AVAILABLE CVOpenGLTextureRef cvImg = currentFrameAsCVTexture(); CIImage *img = [[CIImage alloc] initWithCVImageBuffer:cvImg]; - return img; + CVOpenGLTextureRelease(cvImg); + return img; #else return 0; #endif @@ -295,7 +273,7 @@ GLuint QuickTimeVideoPlayer::currentFrameAsGLTexture() int samplesPerPixel = [bitmap samplesPerPixel]; if (![bitmap isPlanar] && (samplesPerPixel == 3 || samplesPerPixel == 4)){ - glTexImage2D(GL_TEXTURE_RECTANGLE_EXT, 0, + glTexImage2D(GL_TEXTURE_RECTANGLE_EXT, 0, samplesPerPixel == 4 ? GL_RGBA8 : GL_RGB8, [bitmap pixelsWide], [bitmap pixelsHigh], 0, samplesPerPixel == 4 ? GL_RGBA : GL_RGB, @@ -324,7 +302,7 @@ void QuickTimeVideoPlayer::setVolume(float masterVolume, float relativeVolume) m_masterVolume = masterVolume; m_relativeVolume = relativeVolume; if (!m_QTMovie || !m_audioEnabled || m_mute) - return; + return; [m_QTMovie setVolume:(m_masterVolume * m_relativeVolume)]; } @@ -335,7 +313,7 @@ void QuickTimeVideoPlayer::setMute(bool mute) return; // Work-around bug that happends if you set/unset mute - // before movie is playing, and audio is not played + // before movie is playing, and audio is not played // through graph. Then audio is delayed. [m_QTMovie setMuted:mute]; [m_QTMovie setVolume:(mute ? 0 : m_masterVolume * m_relativeVolume)]; @@ -348,7 +326,7 @@ void QuickTimeVideoPlayer::enableAudio(bool enable) return; // Work-around bug that happends if you set/unset mute - // before movie is playing, and audio is not played + // before movie is playing, and audio is not played // through graph. Then audio is delayed. [m_QTMovie setMuted:(!enable || m_mute)]; [m_QTMovie setVolume:((!enable || m_mute) ? 0 : m_masterVolume * m_relativeVolume)]; @@ -367,7 +345,7 @@ bool QuickTimeVideoPlayer::setAudioDevice(int id) #ifdef QUICKTIME_C_API_AVAILABLE // The following code will not work for some media codecs that // typically mingle audio/video frames (e.g mpeg). - CFStringRef idString = PhononCFString::toCFStringRef(AudioDevice::deviceUID(id)); + CFStringRef idString = PhononCFString::toCFStringRef(AudioDevice::deviceUID(id)); QTAudioContextRef context; QTAudioContextCreateForAudioDevice(kCFAllocatorDefault, idString, 0, &context); OSStatus err = SetMovieAudioContext([m_QTMovie quickTimeMovie], context); @@ -391,16 +369,11 @@ void QuickTimeVideoPlayer::setColors(qreal brightness, qreal contrast, qreal hue contrast += 1; saturation += 1; - if (m_brightness == brightness - && m_contrast == contrast - && m_hue == hue - && m_saturation == saturation) - return; - m_brightness = brightness; m_contrast = contrast; m_hue = hue; m_saturation = saturation; + #ifdef QUICKTIME_C_API_AVAILABLE Float32 value; value = brightness; @@ -412,7 +385,6 @@ void QuickTimeVideoPlayer::setColors(qreal brightness, qreal contrast, qreal hue value = saturation; SetMovieVisualSaturation([m_QTMovie quickTimeMovie], value, 0); #endif - releaseImageCache(); } QRect QuickTimeVideoPlayer::videoRect() const @@ -425,7 +397,7 @@ QRect QuickTimeVideoPlayer::videoRect() const return QRect(0, 0, size.width, size.height); } -void QuickTimeVideoPlayer::unsetCurrentMediaSource() +void QuickTimeVideoPlayer::unsetVideo() { if (!m_QTMovie) return; @@ -438,17 +410,11 @@ void QuickTimeVideoPlayer::unsetCurrentMediaSource() m_state = NoMedia; m_isDrmProtected = false; m_isDrmAuthorized = true; - m_hasVideo = false; - m_staticFps = 0; m_mediaSource = MediaSource(); - m_movieCompactDiscPath.clear(); [(CIImage *)m_primaryRenderingCIImage release]; m_primaryRenderingCIImage = 0; delete m_QImagePixelBuffer; m_QImagePixelBuffer = 0; - releaseImageCache(); - [m_folderTracks release]; - m_folderTracks = 0; } QuickTimeVideoPlayer::State QuickTimeVideoPlayer::state() const @@ -558,25 +524,18 @@ bool QuickTimeVideoPlayer::codecExistsAccordingToSuffix(const QString &fileName) void QuickTimeVideoPlayer::setMediaSource(const MediaSource &mediaSource) { PhononAutoReleasePool pool; - unsetCurrentMediaSource(); - + unsetVideo(); m_mediaSource = mediaSource; if (mediaSource.type() == MediaSource::Empty || mediaSource.type() == MediaSource::Invalid){ m_state = NoMedia; return; } - openMovieFromCurrentMediaSource(); if (errorOccured()){ - unsetCurrentMediaSource(); + unsetVideo(); return; } - prepareCurrentMovieForPlayback(); -} - -void QuickTimeVideoPlayer::prepareCurrentMovieForPlayback() -{ #ifdef QUICKTIME_C_API_AVAILABLE if (m_visualContext) SetMovieVisualContext([m_QTMovie quickTimeMovie], m_visualContext); @@ -584,25 +543,23 @@ void QuickTimeVideoPlayer::prepareCurrentMovieForPlayback() waitStatePlayable(); if (errorOccured()){ - unsetCurrentMediaSource(); + unsetVideo(); return; } readProtection(); preRollMovie(); if (errorOccured()){ - unsetCurrentMediaSource(); + unsetVideo(); return; } if (!m_playbackRateSat) m_playbackRate = prefferedPlaybackRate(); checkIfVideoAwailable(); - calculateStaticFps(); enableAudio(m_audioEnabled); setMute(m_mute); setVolume(m_masterVolume, m_relativeVolume); - m_metaData->update(); pause(); } @@ -616,7 +573,7 @@ void QuickTimeVideoPlayer::openMovieFromCurrentMediaSource() openMovieFromUrl(); break; case MediaSource::Disc: - openMovieFromCompactDisc(); + CASE_UNSUPPORTED("Could not open media source.", FATAL_ERROR) break; case MediaSource::Stream: openMovieFromStream(); @@ -678,7 +635,7 @@ void QuickTimeVideoPlayer::openMovieFromDataGuessType(QByteArray *data) // than using e.g [QTMovie movieFileTypes:QTIncludeCommonTypes]. Some // codecs *think* they can decode the stream, and crash... #define TryOpenMovieWithCodec(type) gClearError(); \ - openMovieFromData(data, (char *)"."type); \ + openMovieFromData(data, "."type); \ if (m_QTMovie) return; TryOpenMovieWithCodec("avi"); @@ -718,50 +675,6 @@ void QuickTimeVideoPlayer::openMovieFromStream() openMovieFromDataGuessType(m_streamReader->pointerToData()); } -typedef void (*qt_sighandler_t)(int); -static void sigtest(int) { - qApp->exit(0); -} - -void QuickTimeVideoPlayer::openMovieFromCompactDisc() -{ - // Interrupting the application while the device is open - // causes the application to hang. So we need to handle - // this in a more graceful way: - qt_sighandler_t hndl = signal(SIGINT, sigtest); - if (hndl) - signal(SIGINT, hndl); - - PhononAutoReleasePool pool; - NSString *cd = 0; - QString devName = m_mediaSource.deviceName(); - if (devName.isEmpty()) { - cd = pathToCompactDisc(); - if (!cd) { - SET_ERROR("Could not open media source.", NORMAL_ERROR) - return; - } - m_movieCompactDiscPath = PhononCFString::toQString(reinterpret_cast(cd)); - } else { - if (!QFileInfo(devName).isAbsolute()) - devName = QLatin1String("/Volumes/") + devName; - cd = [reinterpret_cast(PhononCFString::toCFStringRef(devName)) autorelease]; - if (!isCompactDisc(cd)) { - SET_ERROR("Could not open media source.", NORMAL_ERROR) - return; - } - m_movieCompactDiscPath = devName; - } - - m_folderTracks = [scanFolder(cd) retain]; - setCurrentTrack(0); -} - -QString QuickTimeVideoPlayer::movieCompactDiscPath() const -{ - return m_movieCompactDiscPath; -} - MediaSource QuickTimeVideoPlayer::mediaSource() const { return m_mediaSource; @@ -807,44 +720,6 @@ long QuickTimeVideoPlayer::timeScale() const return [[m_QTMovie attributeForKey:@"QTMovieTimeScaleAttribute"] longValue]; } -float QuickTimeVideoPlayer::staticFps() -{ - return m_staticFps; -} - -void QuickTimeVideoPlayer::calculateStaticFps() -{ - if (!m_hasVideo){ - m_staticFps = 0; - return; - } - -#ifdef QT_ALLOW_QUICKTIME - Boolean isMpeg = false; - Track videoTrack = GetMovieIndTrackType([m_QTMovie quickTimeMovie], 1, - FOUR_CHAR_CODE('vfrr'), // 'vfrr' means: has frame rate - movieTrackCharacteristic | movieTrackEnabledOnly); - Media media = GetTrackMedia(videoTrack); - MediaHandler mediaH = GetMediaHandler(media); - MediaHasCharacteristic(mediaH, FOUR_CHAR_CODE('mpeg'), &isMpeg); - - if (isMpeg){ - MHInfoEncodedFrameRateRecord frameRate; - Size frameRateSize = sizeof(frameRate); - MediaGetPublicInfo(mediaH, kMHInfoEncodedFrameRate, &frameRate, &frameRateSize); - m_staticFps = float(Fix2X(frameRate.encodedFrameRate)); - } else { - Media media = GetTrackMedia(videoTrack); - long sampleCount = GetMediaSampleCount(media); - TimeValue64 duration = GetMediaDisplayDuration(media); - TimeValue64 timeScale = GetMediaTimeScale(media); - m_staticFps = float((double)sampleCount * (double)timeScale / (double)duration); - } -#else - m_staticFps = 30.0f; -#endif -} - QString QuickTimeVideoPlayer::timeToString(quint64 ms) { int sec = ms/1000; @@ -1075,94 +950,6 @@ void QuickTimeVideoPlayer::readProtection() } } -QMultiMap QuickTimeVideoPlayer::metaData() -{ - return m_metaData->metaData(); -} - -int QuickTimeVideoPlayer::trackCount() const -{ - if (!m_folderTracks) - return 0; - return [m_folderTracks count]; -} - -int QuickTimeVideoPlayer::currentTrack() const -{ - return m_currentTrack; -} - -QString QuickTimeVideoPlayer::currentTrackPath() const -{ - if (!m_folderTracks) - return QString(); - - PhononAutoReleasePool pool; - NSString *trackPath = [m_folderTracks objectAtIndex:m_currentTrack]; - return PhononCFString::toQString(reinterpret_cast(trackPath)); -} - -NSString* QuickTimeVideoPlayer::pathToCompactDisc() -{ - PhononAutoReleasePool pool; - NSArray *devices = [[NSWorkspace sharedWorkspace] mountedRemovableMedia]; - for (unsigned int i=0; i<[devices count]; ++i) { - NSString *dev = [devices objectAtIndex:i]; - if (isCompactDisc(dev)) - return [dev retain]; - } - return 0; -} - -bool QuickTimeVideoPlayer::isCompactDisc(NSString *path) -{ - PhononAutoReleasePool pool; - NSString *type = [NSString string]; - [[NSWorkspace sharedWorkspace] getFileSystemInfoForPath:path - isRemovable:0 - isWritable:0 - isUnmountable:0 - description:0 - type:&type]; - return [type hasPrefix:@"cdd"]; -} - -NSArray* QuickTimeVideoPlayer::scanFolder(NSString *path) -{ - NSMutableArray *tracks = [NSMutableArray arrayWithCapacity:20]; - if (!path) - return tracks; - - NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtPath:path]; - while (NSString *track = [enumerator nextObject]) { - if (![track hasPrefix:@"."]) - [tracks addObject:[path stringByAppendingPathComponent:track]]; - } - return tracks; -} - -void QuickTimeVideoPlayer::setCurrentTrack(int track) -{ - PhononAutoReleasePool pool; - [m_QTMovie release]; - m_QTMovie = 0; - m_currentTime = 0; - m_currentTrack = track; - - if (!m_folderTracks) - return; - if (track < 0 || track >= (int)[m_folderTracks count]) - return; - - NSString *trackPath = [m_folderTracks objectAtIndex:track]; - QTDataReference *dataRef = [QTDataReference dataReferenceWithReferenceToFile:trackPath]; - State currentState = m_state; - openMovieFromDataRef(dataRef); - prepareCurrentMovieForPlayback(); - if (currentState == Playing) - play(); -} - }} QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/qt7/videoframe.mm b/src/3rdparty/phonon/qt7/videoframe.mm index 7b67b5e..92a3cd5 100644 --- a/src/3rdparty/phonon/qt7/videoframe.mm +++ b/src/3rdparty/phonon/qt7/videoframe.mm @@ -20,8 +20,6 @@ #import #import -//#define CACHE_CV_TEXTURE - QT_BEGIN_NAMESPACE namespace Phonon @@ -72,9 +70,7 @@ namespace QT7 void VideoFrame::copyMembers(const VideoFrame& frame) { -#ifdef CACHE_CV_TEXTURE m_cachedCVTextureRef = frame.m_cachedCVTextureRef; -#endif m_cachedCIImage = frame.m_cachedCIImage; m_cachedQImage = frame.m_cachedQImage; m_cachedNSBitmap = frame.m_cachedNSBitmap; @@ -109,20 +105,11 @@ namespace QT7 CVOpenGLTextureRef VideoFrame::cachedCVTexture() const { -#ifdef CACHE_CV_TEXTURE if (!m_cachedCVTextureRef && m_videoPlayer){ m_videoPlayer->setColors(m_brightness, m_contrast, m_hue, m_saturation); (const_cast(this))->m_cachedCVTextureRef = m_videoPlayer->currentFrameAsCVTexture(); - CVOpenGLTextureRetain((const_cast(this))->m_cachedCVTextureRef); } return m_cachedCVTextureRef; -#else - if (m_videoPlayer){ - m_videoPlayer->setColors(m_brightness, m_contrast, m_hue, m_saturation); - return m_videoPlayer->currentFrameAsCVTexture(); - } - return 0; -#endif } void *VideoFrame::cachedCIImage() const @@ -342,12 +329,10 @@ namespace QT7 void VideoFrame::invalidateImage() const { -#ifdef CACHE_CV_TEXTURE if (m_cachedCVTextureRef){ CVOpenGLTextureRelease(m_cachedCVTextureRef); (const_cast(this))->m_cachedCVTextureRef = 0; } -#endif if (m_cachedCIImage){ [(CIImage *) m_cachedCIImage release]; (const_cast(this))->m_cachedCIImage = 0; @@ -361,10 +346,8 @@ namespace QT7 void VideoFrame::retain() const { -#ifdef CACHE_CV_TEXTURE if (m_cachedCVTextureRef) CVOpenGLTextureRetain(m_cachedCVTextureRef); -#endif if (m_cachedCIImage) [(CIImage *) m_cachedCIImage retain]; if (m_backgroundFrame) @@ -375,12 +358,8 @@ namespace QT7 void VideoFrame::release() const { -#ifdef CACHE_CV_TEXTURE - if (m_cachedCVTextureRef){ + if (m_cachedCVTextureRef) CVOpenGLTextureRelease(m_cachedCVTextureRef); - (const_cast(this))->m_cachedCVTextureRef = 0; - } -#endif if (m_cachedCIImage) [(CIImage *) m_cachedCIImage release]; if (m_backgroundFrame) @@ -389,6 +368,7 @@ namespace QT7 [m_cachedNSBitmap release]; (const_cast(this))->m_backgroundFrame = 0; + (const_cast(this))->m_cachedCVTextureRef = 0; (const_cast(this))->m_cachedCIImage = 0; (const_cast(this))->m_cachedNSBitmap = 0; } -- cgit v0.12 From 4931e0657af3f22478df8cb26faf178a9886e2d2 Mon Sep 17 00:00:00 2001 From: Justin McPherson Date: Thu, 25 Mar 2010 14:30:17 +1000 Subject: Update Phonon CMakeLists.txt. --- src/3rdparty/phonon/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/3rdparty/phonon/CMakeLists.txt b/src/3rdparty/phonon/CMakeLists.txt index a25ec5d..ff89edb 100644 --- a/src/3rdparty/phonon/CMakeLists.txt +++ b/src/3rdparty/phonon/CMakeLists.txt @@ -149,7 +149,7 @@ set(CMAKE_COLOR_MAKEFILE ON) set(PHONON_LIB_MAJOR_VERSION "4") set(PHONON_LIB_MINOR_VERSION "3") -set(PHONON_LIB_PATCH_VERSION "50") +set(PHONON_LIB_PATCH_VERSION "80") set(PHONON_LIB_VERSION "${PHONON_LIB_MAJOR_VERSION}.4.0") set(PHONON_LIB_SOVERSION ${PHONON_LIB_MAJOR_VERSION}) -- 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 9c4bfd1dbdda1a073be12cf6212492abc7e9472b Mon Sep 17 00:00:00 2001 From: Bill King Date: Thu, 25 Mar 2010 16:36:32 +1000 Subject: Unicode fixes for ODBC SQL Driver. Better unicode handling detection, plus turn off unicode if FreeTDS, plus handling of returning strings under non-unicode scenarios. Task-number: QTBUG-8846 Reviewed-by: Justin McPherson --- src/sql/drivers/odbc/qsql_odbc.cpp | 155 ++++++++++++++++++++++++++++--------- 1 file changed, 117 insertions(+), 38 deletions(-) diff --git a/src/sql/drivers/odbc/qsql_odbc.cpp b/src/sql/drivers/odbc/qsql_odbc.cpp index e75c19d..1506c3c 100644 --- a/src/sql/drivers/odbc/qsql_odbc.cpp +++ b/src/sql/drivers/odbc/qsql_odbc.cpp @@ -131,11 +131,10 @@ class QODBCDriverPrivate public: enum DefaultCase{Lower, Mixed, Upper, Sensitive}; QODBCDriverPrivate() - : hEnv(0), hDbc(0), useSchema(false), disconnectCount(0), isMySqlServer(false), - isMSSqlServer(false), hasSQLFetchScroll(true), hasMultiResultSets(false), - isQuoteInitialized(false), quote(QLatin1Char('"')) + : hEnv(0), hDbc(0), unicode(false), useSchema(false), disconnectCount(0), isMySqlServer(false), + isMSSqlServer(false), isFreeTDSDriver(false), hasSQLFetchScroll(true), + hasMultiResultSets(false), isQuoteInitialized(false), quote(QLatin1Char('"')) { - unicode = false; } SQLHANDLE hEnv; @@ -146,6 +145,7 @@ public: int disconnectCount; bool isMySqlServer; bool isMSSqlServer; + bool isFreeTDSDriver; bool hasSQLFetchScroll; bool hasMultiResultSets; @@ -172,7 +172,10 @@ public: QODBCPrivate(QODBCDriverPrivate *dpp) : hStmt(0), useSchema(false), hasSQLFetchScroll(true), driverPrivate(dpp), userForwardOnly(false) { - unicode = false; + unicode = dpp->unicode; + useSchema = dpp->useSchema; + disconnectCount = dpp->disconnectCount; + hasSQLFetchScroll = dpp->hasSQLFetchScroll; } inline void clearValues() @@ -374,44 +377,88 @@ static QString qGetStringData(SQLHANDLE hStmt, int column, int colSize, bool uni } else { colSize++; // make sure there is room for more than the 0 termination } - r = SQLGetData(hStmt, - column+1, - SQL_C_TCHAR, - NULL, - 0, - &lengthIndicator); - if ((r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) && lengthIndicator > 0) - colSize = lengthIndicator/sizeof(SQLTCHAR) + 1; - QVarLengthArray buf(colSize); - while (true) { + if(unicode) { r = SQLGetData(hStmt, column+1, SQL_C_TCHAR, - (SQLPOINTER)buf.data(), - colSize*sizeof(SQLTCHAR), + NULL, + 0, &lengthIndicator); - if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) { - if (lengthIndicator == SQL_NULL_DATA || lengthIndicator == SQL_NO_TOTAL) { + if ((r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) && lengthIndicator > 0) + colSize = lengthIndicator/sizeof(SQLTCHAR) + 1; + QVarLengthArray buf(colSize); + memset(buf.data(), 0, colSize*sizeof(SQLTCHAR)); + while (true) { + r = SQLGetData(hStmt, + column+1, + SQL_C_TCHAR, + (SQLPOINTER)buf.data(), + colSize*sizeof(SQLTCHAR), + &lengthIndicator); + if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) { + if (lengthIndicator == SQL_NULL_DATA || lengthIndicator == SQL_NO_TOTAL) { + fieldVal.clear(); + break; + } + // if SQL_SUCCESS_WITH_INFO is returned, indicating that + // more data can be fetched, the length indicator does NOT + // contain the number of bytes returned - it contains the + // total number of bytes that CAN be fetched + // colSize-1: remove 0 termination when there is more data to fetch + int rSize = (r == SQL_SUCCESS_WITH_INFO) ? colSize : lengthIndicator/sizeof(SQLTCHAR); + fieldVal += fromSQLTCHAR(buf, rSize); + if (lengthIndicator < (unsigned int)colSize*sizeof(SQLTCHAR)) { + // workaround for Drivermanagers that don't return SQL_NO_DATA + break; + } + } else if (r == SQL_NO_DATA) { + break; + } else { + qWarning() << "qGetStringData: Error while fetching data (" << qWarnODBCHandle(SQL_HANDLE_STMT, hStmt) << ')'; fieldVal.clear(); break; } - // if SQL_SUCCESS_WITH_INFO is returned, indicating that - // more data can be fetched, the length indicator does NOT - // contain the number of bytes returned - it contains the - // total number of bytes that CAN be fetched - // colSize-1: remove 0 termination when there is more data to fetch - int rSize = (r == SQL_SUCCESS_WITH_INFO) ? colSize : lengthIndicator/sizeof(SQLTCHAR); - fieldVal += fromSQLTCHAR(buf, rSize); - if (lengthIndicator < (unsigned int)colSize*sizeof(SQLTCHAR)) { - // workaround for Drivermanagers that don't return SQL_NO_DATA + } + } else { + r = SQLGetData(hStmt, + column+1, + SQL_C_CHAR, + NULL, + 0, + &lengthIndicator); + if ((r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) && lengthIndicator > 0) + colSize = lengthIndicator + 1; + QVarLengthArray buf(colSize); + while (true) { + r = SQLGetData(hStmt, + column+1, + SQL_C_CHAR, + (SQLPOINTER)buf.data(), + colSize, + &lengthIndicator); + if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) { + if (lengthIndicator == SQL_NULL_DATA || lengthIndicator == SQL_NO_TOTAL) { + fieldVal.clear(); + break; + } + // if SQL_SUCCESS_WITH_INFO is returned, indicating that + // more data can be fetched, the length indicator does NOT + // contain the number of bytes returned - it contains the + // total number of bytes that CAN be fetched + // colSize-1: remove 0 termination when there is more data to fetch + int rSize = (r == SQL_SUCCESS_WITH_INFO) ? colSize : lengthIndicator; + fieldVal += QString::fromUtf8((const char *)buf.constData(), rSize); + if (lengthIndicator < (unsigned int)colSize) { + // workaround for Drivermanagers that don't return SQL_NO_DATA + break; + } + } else if (r == SQL_NO_DATA) { + break; + } else { + qWarning() << "qGetStringData: Error while fetching data (" << qWarnODBCHandle(SQL_HANDLE_STMT, hStmt) << ')'; + fieldVal.clear(); break; } - } else if (r == SQL_NO_DATA) { - break; - } else { - qWarning() << "qGetStringData: Error while fetching data (" << qWarnODBCHandle(SQL_HANDLE_STMT, hStmt) << ')'; - fieldVal.clear(); - break; } } return fieldVal; @@ -866,10 +913,6 @@ QODBCResult::QODBCResult(const QODBCDriver * db, QODBCDriverPrivate* p) : QSqlResult(db) { d = new QODBCPrivate(p); - d->unicode = p->unicode; - d->useSchema = p->useSchema; - d->disconnectCount = p->disconnectCount; - d->hasSQLFetchScroll = p->hasSQLFetchScroll; } QODBCResult::~QODBCResult() @@ -1846,6 +1889,7 @@ bool QODBCDriver::open(const QString & db, SQLSMALLINT cb; QVarLengthArray connOut(1024); + memset(connOut.data(), 0, connOut.size() * sizeof(SQLTCHAR)); r = SQLDriverConnect(d->hDbc, NULL, #ifdef UNICODE @@ -1943,6 +1987,7 @@ void QODBCDriverPrivate::checkUnicode() NULL); if ((r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) && (fFunc & SQL_CVT_WCHAR)) { unicode = true; + return; } r = SQLGetInfo(hDbc, @@ -1952,6 +1997,7 @@ void QODBCDriverPrivate::checkUnicode() NULL); if ((r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) && (fFunc & SQL_CVT_WVARCHAR)) { unicode = true; + return; } r = SQLGetInfo(hDbc, @@ -1961,7 +2007,25 @@ void QODBCDriverPrivate::checkUnicode() NULL); if ((r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) && (fFunc & SQL_CVT_WLONGVARCHAR)) { unicode = true; + return; + } + SQLHANDLE hStmt; + r = SQLAllocHandle(SQL_HANDLE_STMT, + hDbc, + &hStmt); + + r = SQLExecDirect(hStmt, toSQLTCHAR(QLatin1String("select 'test'")).data(), SQL_NTS); + if(r == SQL_SUCCESS) { + r = SQLFetch(hStmt); + if(r == SQL_SUCCESS) { + QVarLengthArray buffer(10); + r = SQLGetData(hStmt, 1, SQL_C_WCHAR, buffer.data(), buffer.size() * sizeof(SQLWCHAR), NULL); + if(r == SQL_SUCCESS && fromSQLTCHAR(buffer) == QLatin1String("test")) { + unicode = true; + } + } } + r = SQLFreeHandle(SQL_HANDLE_STMT, hStmt); } bool QODBCDriverPrivate::checkDriver() const @@ -2053,6 +2117,21 @@ void QODBCDriverPrivate::checkSqlServer() isMySqlServer = serverType.contains(QLatin1String("mysql"), Qt::CaseInsensitive); isMSSqlServer = serverType.contains(QLatin1String("Microsoft SQL Server"), Qt::CaseInsensitive); } + r = SQLGetInfo(hDbc, + SQL_DRIVER_NAME, + serverString.data(), + serverString.size() * sizeof(SQLTCHAR), + &t); + if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) { + QString serverType; +#ifdef UNICODE + serverType = fromSQLTCHAR(serverString, t/sizeof(SQLTCHAR)); +#else + serverType = QString::fromUtf8((const char *)serverString.constData(), t); +#endif + isFreeTDSDriver = serverType.contains(QLatin1String("tdsodbc"), Qt::CaseInsensitive); + unicode = isFreeTDSDriver == false; + } } void QODBCDriverPrivate::checkHasSQLFetchScroll() -- 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 194bbeed0152d541527059bb0f1dae60a8573912 Mon Sep 17 00:00:00 2001 From: Bill King Date: Thu, 25 Mar 2010 16:44:32 +1000 Subject: Fix ODBC compilation for ODBC versions < 3.5 Task-number: QTBUG-8488 Reviewed-by: Justin McPherson --- src/sql/drivers/odbc/qsql_odbc.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/sql/drivers/odbc/qsql_odbc.cpp b/src/sql/drivers/odbc/qsql_odbc.cpp index 1506c3c..f41a914 100644 --- a/src/sql/drivers/odbc/qsql_odbc.cpp +++ b/src/sql/drivers/odbc/qsql_odbc.cpp @@ -352,7 +352,9 @@ static QVariant::Type qDecodeODBCType(SQLSMALLINT sqltype, const T* p, bool isSi #endif case SQL_CHAR: case SQL_VARCHAR: +#if (ODBCVER >= 0x0350) case SQL_GUID: +#endif case SQL_LONGVARCHAR: type = QVariant::String; break; -- cgit v0.12 From 92607e19c79fcdfb82e42fa45353004f85d1adf9 Mon Sep 17 00:00:00 2001 From: Bill King Date: Thu, 25 Mar 2010 16:50:32 +1000 Subject: Sql Autotest cleanup and tweaking. --- tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp | 178 +++++++++++++++-------------- tests/auto/qsqlquery/tst_qsqlquery.cpp | 9 +- 2 files changed, 95 insertions(+), 92 deletions(-) diff --git a/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp b/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp index f837564..f3c2c09 100644 --- a/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp +++ b/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp @@ -44,7 +44,7 @@ #include #include #include - +#include #include "../qsqldatabase/tst_databases.h" @@ -122,7 +122,7 @@ void tst_Q3SqlCursor::generic_data(const QString &engine) { if ( dbs.fillTestTable(engine) == 0 ) { if(engine.isEmpty()) - QSKIP( "No database drivers are available in this Qt configuration", SkipAll ); + QSKIP( "No database drivers are available in this Qt configuration", SkipAll ); else QSKIP( (QString("No database drivers of type %1 are available in this Qt configuration").arg(engine)).toLocal8Bit(), SkipAll ); } @@ -131,7 +131,7 @@ void tst_Q3SqlCursor::generic_data(const QString &engine) void tst_Q3SqlCursor::createTestTables( QSqlDatabase db ) { if ( !db.isValid() ) - return; + return; QSqlQuery q( db ); if (tst_Databases::isSqlServer(db)) { @@ -143,20 +143,20 @@ void tst_Q3SqlCursor::createTestTables( QSqlDatabase db ) // please never ever change this table; otherwise fix all tests ;) if ( tst_Databases::isMSAccess( db ) ) { - QVERIFY_SQL(q, exec( "create table " + qtest + " ( id int not null, t_varchar varchar(40) not null," - "t_char char(40), t_numeric number, primary key (id, t_varchar) )" )); + QVERIFY_SQL(q, exec( "create table " + qtest + " ( id int not null, t_varchar varchar(40) not null," + "t_char char(40), t_numeric number, primary key (id, t_varchar) )" )); } else { - QVERIFY_SQL(q, exec( "create table " + qtest + " ( id int not null, t_varchar varchar(40) not null," - "t_char char(40), t_numeric numeric(6, 3), primary key (id, t_varchar) )" )); + QVERIFY_SQL(q, exec( "create table " + qtest + " ( id int not null, t_varchar varchar(40) not null," + "t_char char(40), t_numeric numeric(6, 3), primary key (id, t_varchar) )" )); } if ( tst_Databases::isSqlServer( db ) ) { - //workaround for SQL SERVER since he can store unicode only in nvarchar fields - QVERIFY_SQL(q, exec("create table " + qTableName("qtest_unicode", __FILE__) + " (id int not null, " - "t_varchar nvarchar(80) not null, t_char nchar(80) )" )); + //workaround for SQL SERVER since he can store unicode only in nvarchar fields + QVERIFY_SQL(q, exec("create table " + qTableName("qtest_unicode", __FILE__) + " (id int not null, " + "t_varchar nvarchar(80) not null, t_char nchar(80) )" )); } else { - QVERIFY_SQL(q, exec("create table " + qTableName("qtest_unicode", __FILE__) + " (id int not null, " - "t_varchar varchar(100) not null," "t_char char(100))" )); + QVERIFY_SQL(q, exec("create table " + qTableName("qtest_unicode", __FILE__) + " (id int not null, " + "t_varchar varchar(100) not null," "t_char char(100))" )); } if (tst_Databases::isMSAccess(db)) { @@ -169,7 +169,7 @@ void tst_Q3SqlCursor::createTestTables( QSqlDatabase db ) void tst_Q3SqlCursor::dropTestTables( QSqlDatabase db ) { if ( !db.isValid() ) - return; + return; QStringList tableNames; tableNames << qtest << qTableName( "qtest_unicode", __FILE__ ) @@ -183,7 +183,7 @@ void tst_Q3SqlCursor::dropTestTables( QSqlDatabase db ) void tst_Q3SqlCursor::populateTestTables( QSqlDatabase db ) { if (!db.isValid()) - return; + return; QSqlQuery q( db ); q.exec( "delete from " + qtest ); //not fatal @@ -200,21 +200,21 @@ void tst_Q3SqlCursor::initTestCase() dbs.open(); for ( QStringList::ConstIterator it = dbs.dbNames.begin(); it != dbs.dbNames.end(); ++it ) { - QSqlDatabase db = QSqlDatabase::database( (*it) ); - CHECK_DATABASE( db ); + QSqlDatabase db = QSqlDatabase::database( (*it) ); + CHECK_DATABASE( db ); - dropTestTables( db ); //in case of leftovers - createTestTables( db ); - populateTestTables( db ); + dropTestTables( db ); //in case of leftovers + createTestTables( db ); + populateTestTables( db ); } } void tst_Q3SqlCursor::cleanupTestCase() { for ( QStringList::ConstIterator it = dbs.dbNames.begin(); it != dbs.dbNames.end(); ++it ) { - QSqlDatabase db = QSqlDatabase::database( (*it) ); - CHECK_DATABASE( db ); - dropTestTables( db ); + QSqlDatabase db = QSqlDatabase::database( (*it) ); + CHECK_DATABASE( db ); + dropTestTables( db ); } dbs.close(); @@ -230,9 +230,9 @@ void tst_Q3SqlCursor::cleanup() QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); if ( QTest::currentTestFailed() ) { - //since Oracle ODBC totally craps out on error, we init again - db.close(); - db.open(); + //since Oracle ODBC totally craps out on error, we init again + db.close(); + db.open(); } } @@ -244,10 +244,10 @@ void tst_Q3SqlCursor::copyConstructor() Q3SqlCursor cur2; { - Q3SqlCursor cur( qtest, true, db ); - QVERIFY_SQL(cur, select( cur.index( QString("id") ) )); - cur2 = Q3SqlCursor( cur ); - // let "cur" run out of scope... + Q3SqlCursor cur( qtest, true, db ); + QVERIFY_SQL(cur, select( cur.index( QString("id") ) )); + cur2 = Q3SqlCursor( cur ); + // let "cur" run out of scope... } QSqlRecord* rec = cur2.primeUpdate(); @@ -256,8 +256,8 @@ void tst_Q3SqlCursor::copyConstructor() int i = 0; while ( cur2.next() ) { - QVERIFY( cur2.value("id").toInt() == i ); - i++; + QVERIFY( cur2.value("id").toInt() == i ); + i++; } } @@ -271,8 +271,8 @@ void tst_Q3SqlCursor::value() QVERIFY_SQL(cur, select( cur.index( QString("id") ) )); int i = 0; while ( cur.next() ) { - QCOMPARE(cur.value("id").toInt(), i); - i++; + QCOMPARE(cur.value("id").toInt(), i); + i++; } } @@ -285,11 +285,11 @@ void tst_Q3SqlCursor::primaryIndex() Q3SqlCursor cur( qtest, true, db ); QSqlIndex index = cur.primaryIndex(); if ( tst_Databases::isMSAccess( db ) ) { - QCOMPARE( index.fieldName(1).upper(), QString( "ID" ) ); - QCOMPARE( index.fieldName(0).upper(), QString( "T_VARCHAR" ) ); + QCOMPARE( index.fieldName(1).upper(), QString( "ID" ) ); + QCOMPARE( index.fieldName(0).upper(), QString( "T_VARCHAR" ) ); } else { - QCOMPARE( index.fieldName(0).upper(), QString( "ID" ) ); - QCOMPARE( index.fieldName(1).upper(), QString( "T_VARCHAR" ) ); + QCOMPARE( index.fieldName(0).upper(), QString( "ID" ) ); + QCOMPARE( index.fieldName(1).upper(), QString( "T_VARCHAR" ) ); } QVERIFY(!index.isDescending(0)); QVERIFY(!index.isDescending(1)); @@ -308,10 +308,10 @@ void tst_Q3SqlCursor::insert() // check that primeInsert returns a valid QSqlRecord QCOMPARE( (int)irec->count(), 4 ); if ( ( irec->field( 0 ).type() != QVariant::Int ) && - ( irec->field( 0 ).type() != QVariant::String ) && + ( irec->field( 0 ).type() != QVariant::String ) && ( irec->field( 0 ).type() != QVariant::Double ) ) { - QFAIL( QString( "Wrong datatype %1 for field 'ID'" - " (expected Int or String)" ).arg( QVariant::typeToName( irec->field( 0 ).type() ) ) ); + QFAIL( QString( "Wrong datatype %1 for field 'ID'" + " (expected Int or String)" ).arg( QVariant::typeToName( irec->field( 0 ).type() ) ) ); } QCOMPARE( QVariant::typeToName( irec->field( 1 ).type() ), QVariant::typeToName( QVariant::String ) ); QCOMPARE( QVariant::typeToName( irec->field( 2 ).type() ), QVariant::typeToName( QVariant::String ) ); @@ -327,7 +327,9 @@ void tst_Q3SqlCursor::insert() irec->setValue( "t_char", "SomeChar" ); irec->setValue( "t_numeric", 400.400 ); - QCOMPARE( cur.insert(), 1 ); + QSet validReturns(QSet() << -1 << 1); + + QVERIFY( validReturns.contains(cur.insert()) ); // restore old test-tables populateTestTables( db ); @@ -338,6 +340,7 @@ void tst_Q3SqlCursor::insertSpecial() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); + QSet validReturns(QSet() << -1 << 1); Q3SqlCursor cur( qtest, true, db ); QSqlRecord* irec = cur.primeInsert(); @@ -355,25 +358,25 @@ void tst_Q3SqlCursor::insertSpecial() // INSERT the strings QStringList::Iterator it; for ( it = strings.begin(); it != strings.end(); ++it ) { - QSqlRecord* irec = cur.primeInsert(); - QVERIFY( irec != 0 ); - irec->setValue( "id", i ); - irec->setValue( "t_varchar", (*it) ); - irec->setValue( "t_char", (*it) ); - irec->setValue( "t_numeric", (double)i ); - ++i; - QCOMPARE( cur.insert(), 1 ); + QSqlRecord* irec = cur.primeInsert(); + QVERIFY( irec != 0 ); + irec->setValue( "id", i ); + irec->setValue( "t_varchar", (*it) ); + irec->setValue( "t_char", (*it) ); + irec->setValue( "t_numeric", (double)i ); + ++i; + QVERIFY( validReturns.contains(cur.insert()) ); } QVERIFY( cur.select( "id >= 800 and id < 900" ) ); int i2 = 800; while( cur.next() ) { - QCOMPARE( cur.value( "id" ).toInt(), i2 ); - QCOMPARE( cur.value( "t_varchar" ).toString().stripWhiteSpace(), strings.at( i2 - 800 ) ); - QCOMPARE( cur.value( "t_char" ).toString().stripWhiteSpace(), strings.at( i2 - 800 ) ); - QCOMPARE( cur.value( "t_numeric" ).toDouble(), (double)i2 ); - ++i2; + QCOMPARE( cur.value( "id" ).toInt(), i2 ); + QCOMPARE( cur.value( "t_varchar" ).toString().stripWhiteSpace(), strings.at( i2 - 800 ) ); + QCOMPARE( cur.value( "t_char" ).toString().stripWhiteSpace(), strings.at( i2 - 800 ) ); + QCOMPARE( cur.value( "t_numeric" ).toDouble(), (double)i2 ); + ++i2; } QCOMPARE( i, i2 ); @@ -385,6 +388,7 @@ void tst_Q3SqlCursor::batchInsert() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); + QSet validReturns(QSet() << -1 << 1); QSqlQuery q( db ); q.exec( "delete from " + qtest ); @@ -393,16 +397,16 @@ void tst_Q3SqlCursor::batchInsert() int i = 0; for ( ; i < 100; ++i ) { - QSqlRecord* irec = cur.primeInsert(); - Q_ASSERT( irec ); - irec->setValue( "id", i ); - irec->setValue( "t_varchar", "blah" ); - irec->setValue( "t_char", "blah" ); - irec->setValue( "t_numeric", 1.1 ); - if ( db.driverName().startsWith( "QSQLITE" ) ) { - QVERIFY( cur.insert( true ) ); - } else { - QCOMPARE( cur.insert( true ), 1 ); + QSqlRecord* irec = cur.primeInsert(); + Q_ASSERT( irec ); + irec->setValue( "id", i ); + irec->setValue( "t_varchar", "blah" ); + irec->setValue( "t_char", "blah" ); + irec->setValue( "t_numeric", 1.1 ); + if ( db.driverName().startsWith( "QSQLITE" ) ) { + QVERIFY( cur.insert( true ) ); + } else { + QVERIFY( validReturns.contains(cur.insert( true )) ); } } @@ -413,18 +417,18 @@ void tst_Q3SqlCursor::batchInsert() irec->setValue( "t_varchar", "blah" ); irec->setValue( "t_char", "blah" ); irec->setValue( "t_numeric", 1.1 ); - if ( db.driverName().startsWith( "QSQLITE" ) ) { - QVERIFY( cur.insert( false ) ); - } else { - QCOMPARE( cur.insert( false ), 1 ); + if ( db.driverName().startsWith( "QSQLITE" ) ) { + QVERIFY( cur.insert( false ) ); + } else { + QVERIFY( validReturns.contains(cur.insert( false )) ); } } i = 0; QVERIFY_SQL(q, exec( "select * from " + qtest + " order by id" )); while ( q.next() ) { - QCOMPARE( q.value( 0 ).toInt(), i ); - i++; + QCOMPARE( q.value( 0 ).toInt(), i ); + i++; } QCOMPARE( i, 200 ); @@ -436,7 +440,7 @@ static QString dumpUtf8( const QString& str ) { QString res; for ( int i = 0; i < (int)str.length(); ++i ) { - res += "0x" + QString::number( str[ i ].unicode(), 16 ) + ' '; + res += "0x" + QString::number( str[ i ].unicode(), 16 ) + ' '; } return res; } @@ -448,7 +452,7 @@ void tst_Q3SqlCursor::insertORA() CHECK_DATABASE( db ); if (tst_Databases::getOraVersion(db) < 9) - QSKIP("Need Oracle >= 9", SkipSingle); + QSKIP("Need Oracle >= 9", SkipSingle); /****** CHARSET TEST ******/ @@ -466,8 +470,8 @@ void tst_Q3SqlCursor::insertORA() QVERIFY_SQL(cur, select()); QVERIFY( cur.next() ); if ( cur.value( "t_char" ).toString() != val1 ) - qDebug( QString( "Wrong value for t_char: expected '%1', got '%2'" ).arg( val1 ).arg( - cur.value( "t_char" ).toString() ) ); + qDebug( QString( "Wrong value for t_char: expected '%1', got '%2'" ).arg( val1 ).arg( + cur.value( "t_char" ).toString() ) ); static const unsigned short utf8arr[] = { 0xd792,0xd79c,0xd792,0xd79c,0xd799,0x00 }; static const QString utf8str = QString::fromUcs2( utf8arr ); @@ -524,7 +528,7 @@ void tst_Q3SqlCursor::unicode() static const QString utf8str = QString::fromUtf8( "ὕαλον ϕαγεῖν δύναμαι· τοῦτο οὔ με βλάπτει." ); if ( !db.driver()->hasFeature( QSqlDriver::Unicode ) ) { - QSKIP( "DBMS not Unicode capable", SkipSingle ); + QSKIP( "DBMS not Unicode capable", SkipSingle ); } // ascii in the data storage, can't transliterate properly. invalid test. if(db.driverName().startsWith("QIBASE") && (db.databaseName() == "silence.nokia.troll.no:c:\\ibase\\testdb_ascii" || db.databaseName() == "/opt/interbase/qttest.gdb")) @@ -640,11 +644,11 @@ void tst_Q3SqlCursor::select() QSqlIndex idx = cur4.primaryIndex( false ); QCOMPARE( (int)idx.count(), 2 ); if ( tst_Databases::isMSAccess( db ) ) { - QCOMPARE( idx.field( 1 ).name().upper(), QString("ID") ); - QCOMPARE( idx.field( 0 ).name().upper(), QString("T_VARCHAR") ); + QCOMPARE( idx.field( 1 ).name().upper(), QString("ID") ); + QCOMPARE( idx.field( 0 ).name().upper(), QString("T_VARCHAR") ); } else { - QCOMPARE( idx.field( 0 ).name().upper(), QString("ID") ); - QCOMPARE( idx.field( 1 ).name().upper(), QString("T_VARCHAR") ); + QCOMPARE( idx.field( 0 ).name().upper(), QString("ID") ); + QCOMPARE( idx.field( 1 ).name().upper(), QString("T_VARCHAR") ); } #ifdef QT_DEBUG @@ -688,17 +692,18 @@ void tst_Q3SqlCursor::updateNoPK() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - + QSet validReturns(QSet() << -1 << 1); + QSqlQuery q(db); QVERIFY_SQL(q, exec("create table " + qTableName( "qtestPK", __FILE__ ) + " (id int, name varchar(20), num numeric)")); - + Q3SqlCursor cur(qTableName("qtestPK", __FILE__), true, db); QSqlRecord* rec = cur.primeInsert(); Q_ASSERT(rec); rec->setNull(0); rec->setNull(1); rec->setNull(2); - QVERIFY_SQL(cur, insert() == 1); + QVERIFY(validReturns.contains(cur.insert())); if (!db.driver()->hasFeature(QSqlDriver::PreparedQueries)) { // Only QPSQL, QMYSQL, QODBC and QOCI drivers currently use escape identifiers for column names @@ -713,8 +718,8 @@ void tst_Q3SqlCursor::updateNoPK() + " values (NULL,NULL,NULL)"); QCOMPARE(cur.lastQuery(), query); } else { - QCOMPARE(cur.lastQuery(), QString::fromLatin1("insert into " + qTableName("qtestPK", __FILE__) + - " (\"id\",\"name\",\"num\") values (NULL,NULL,NULL)")); + QCOMPARE(cur.lastQuery(), QString::fromLatin1("insert into " + qTableName("qtestPK", __FILE__) + + " (\"id\",\"name\",\"num\") values (NULL,NULL,NULL)")); } } @@ -733,7 +738,7 @@ void tst_Q3SqlCursor::updateNoPK() qTableName("qtestPK", __FILE__) + ".num IS NULL"; if (!db.driver()->hasFeature(QSqlDriver::PreparedQueries)) { if (!db.driverName().startsWith("QSQLITE")) { - QCOMPARE(cur.lastQuery(), expect); + QCOMPARE(cur.lastQuery(), expect); } } QVERIFY(cur.select(cur.index(QString("id")))); @@ -750,6 +755,7 @@ void tst_Q3SqlCursor::insertFieldNameContainsWS() { QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); + QSet validReturns(QSet() << -1 << 1); // The bugfix (and this test) depends on QSqlDriver::escapeIdentifier(...) // to be implemented, which is currently only the case for the @@ -778,7 +784,7 @@ void tst_Q3SqlCursor::insertFieldNameContainsWS() { r->setValue("firsT NaMe", "Kong"); r->setValue("lastNaMe", "Harald"); - QVERIFY(cur.insert() == 1); + QVERIFY(validReturns.contains(cur.insert())); cur.select(); cur.next(); diff --git a/tests/auto/qsqlquery/tst_qsqlquery.cpp b/tests/auto/qsqlquery/tst_qsqlquery.cpp index b9ab73f..db3a929 100644 --- a/tests/auto/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/qsqlquery/tst_qsqlquery.cpp @@ -1137,17 +1137,14 @@ void tst_QSqlQuery::last() QVERIFY( q.last() ); - if ( !tst_Databases::isMSAccess( db ) ) - // Access doesn't return the correct position - QCOMPARE( q.at(), ( i-1 ) ); + QSet validReturns(QSet() << -1 << i-1); + QVERIFY( validReturns.contains(q.at()) ); QSqlQuery q2( "select * from " + qtest, db ); QVERIFY( q2.last() ); - if ( !tst_Databases::isMSAccess( db ) ) - // Access doesn't return the correct position - QCOMPARE( q.at(), ( i-1 ) ); + QVERIFY( validReturns.contains(q.at()) ); } void tst_QSqlQuery::seek() -- cgit v0.12 From 9d324a07c9c87f972b165a43956424f5c92f80ad Mon Sep 17 00:00:00 2001 From: Justin McPherson Date: Thu, 25 Mar 2010 16:58:42 +1000 Subject: Phonon; complete integration. --- src/3rdparty/phonon/CMakeLists.txt | 4 + src/3rdparty/phonon/gstreamer/backend.cpp | 27 +- src/3rdparty/phonon/phonon/audiodataoutput.cpp | 68 ++ src/3rdparty/phonon/phonon/audiodataoutput.h | 129 +++ src/3rdparty/phonon/phonon/audiodataoutput_p.h | 48 + .../phonon/phonon/audiodataoutputinterface.h | 44 + src/3rdparty/phonon/phonon/globalconfig.h | 71 ++ src/3rdparty/phonon/phonon/pulsesupport.cpp | 1040 ++++++++++++++++++++ src/3rdparty/phonon/phonon/pulsesupport.h | 78 ++ src/3rdparty/phonon/phonon/swiftslider.cpp | 103 ++ src/3rdparty/phonon/phonon/swiftslider_p.h | 68 ++ src/3rdparty/phonon/qt7/mediaobject.mm | 20 +- 12 files changed, 1678 insertions(+), 22 deletions(-) create mode 100644 src/3rdparty/phonon/phonon/audiodataoutput.cpp create mode 100644 src/3rdparty/phonon/phonon/audiodataoutput.h create mode 100644 src/3rdparty/phonon/phonon/audiodataoutput_p.h create mode 100644 src/3rdparty/phonon/phonon/audiodataoutputinterface.h create mode 100644 src/3rdparty/phonon/phonon/globalconfig.h create mode 100644 src/3rdparty/phonon/phonon/pulsesupport.cpp create mode 100644 src/3rdparty/phonon/phonon/pulsesupport.h create mode 100644 src/3rdparty/phonon/phonon/swiftslider.cpp create mode 100644 src/3rdparty/phonon/phonon/swiftslider_p.h diff --git a/src/3rdparty/phonon/CMakeLists.txt b/src/3rdparty/phonon/CMakeLists.txt index ff89edb..ef7d6f5 100644 --- a/src/3rdparty/phonon/CMakeLists.txt +++ b/src/3rdparty/phonon/CMakeLists.txt @@ -70,6 +70,10 @@ if (CMAKE_COMPILER_IS_GNUCXX) add_definitions(-DQT_NO_DEBUG) endif (MINGW) + if (QT_USE_FRAMEWORKS) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -F${QT_LIBRARY_DIR}") + endif (QT_USE_FRAMEWORKS) + check_cxx_compiler_flag(-fPIE HAVE_FPIE_SUPPORT) if(KDE4_ENABLE_FPIE) if(HAVE_FPIE_SUPPORT) diff --git a/src/3rdparty/phonon/gstreamer/backend.cpp b/src/3rdparty/phonon/gstreamer/backend.cpp index 8c2b42f..729a1d3 100644 --- a/src/3rdparty/phonon/gstreamer/backend.cpp +++ b/src/3rdparty/phonon/gstreamer/backend.cpp @@ -220,14 +220,14 @@ QStringList Backend::availableMimeTypes() const GstPluginFeature *feature = GST_PLUGIN_FEATURE(iter->data); QString klass = gst_element_factory_get_klass(GST_ELEMENT_FACTORY(feature)); - if (klass == QLatin1String("Codec/Decoder") || - klass == QLatin1String("Codec/Decoder/Audio") || - klass == QLatin1String("Codec/Decoder/Video") || - klass == QLatin1String("Codec/Demuxer") || - klass == QLatin1String("Codec/Demuxer/Audio") || - klass == QLatin1String("Codec/Demuxer/Video") || - klass == QLatin1String("Codec/Parser") || - klass == QLatin1String("Codec/Parser/Audio") || + if (klass == QLatin1String("Codec/Decoder") || + klass == QLatin1String("Codec/Decoder/Audio") || + klass == QLatin1String("Codec/Decoder/Video") || + klass == QLatin1String("Codec/Demuxer") || + klass == QLatin1String("Codec/Demuxer/Audio") || + klass == QLatin1String("Codec/Demuxer/Video") || + klass == QLatin1String("Codec/Parser") || + klass == QLatin1String("Codec/Parser/Audio") || klass == QLatin1String("Codec/Parser/Video")) { const GList *static_templates; @@ -240,10 +240,13 @@ QStringList Backend::availableMimeTypes() const GstCaps *caps = gst_static_pad_template_get_caps (padTemplate); if (caps) { - const GstStructure* capsStruct = gst_caps_get_structure (caps, 0); - QString mime = QString::fromUtf8(gst_structure_get_name (capsStruct)); - if (!availableMimeTypes.contains(mime)) - availableMimeTypes.append(mime); + for (unsigned int struct_idx = 0; struct_idx < gst_caps_get_size (caps); struct_idx++) { + + const GstStructure* capsStruct = gst_caps_get_structure (caps, struct_idx); + QString mime = QString::fromUtf8(gst_structure_get_name (capsStruct)); + if (!availableMimeTypes.contains(mime)) + availableMimeTypes.append(mime); + } } } } diff --git a/src/3rdparty/phonon/phonon/audiodataoutput.cpp b/src/3rdparty/phonon/phonon/audiodataoutput.cpp new file mode 100644 index 0000000..6c737c2 --- /dev/null +++ b/src/3rdparty/phonon/phonon/audiodataoutput.cpp @@ -0,0 +1,68 @@ +/* This file is part of the KDE project + Copyright (C) 2005 Matthias Kretz + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) version 3, or any + later version accepted by the membership of KDE e.V. (or its + successor approved by the membership of KDE e.V.), Nokia Corporation + (or its successors, if any) and the KDE Free Qt Foundation, which shall + act as a proxy defined in Section 6 of version 3 of the license. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library. If not, see . + +*/ + +#include "audiodataoutput.h" +#include "audiodataoutput_p.h" +#include "factory_p.h" + +#define PHONON_CLASSNAME AudioDataOutput + +namespace Phonon +{ + +PHONON_HEIR_IMPL(AbstractAudioOutput) + +PHONON_GETTER(int, dataSize, d->dataSize) +PHONON_GETTER(int, sampleRate, -1) +PHONON_SETTER(setDataSize, dataSize, int) + +bool AudioDataOutputPrivate::aboutToDeleteBackendObject() +{ + Q_ASSERT(m_backendObject); + pBACKEND_GET(int, dataSize, "dataSize"); + + return AbstractAudioOutputPrivate::aboutToDeleteBackendObject(); +} + +void AudioDataOutputPrivate::setupBackendObject() +{ + Q_Q(AudioDataOutput); + Q_ASSERT(m_backendObject); + AbstractAudioOutputPrivate::setupBackendObject(); + + // set up attributes + pBACKEND_CALL1("setDataSize", int, dataSize); + + qRegisterMetaType > >("QMap >"); + + QObject::connect(m_backendObject, + SIGNAL(dataReady(const QMap > &)), + q, SIGNAL(dataReady(const QMap > &))); + QObject::connect(m_backendObject, SIGNAL(endOfMedia(int)), q, SIGNAL(endOfMedia(int))); +} + +} // namespace Phonon + +#include "audiodataoutput.moc" + +#undef PHONON_CLASSNAME +// vim: sw=4 ts=4 tw=80 diff --git a/src/3rdparty/phonon/phonon/audiodataoutput.h b/src/3rdparty/phonon/phonon/audiodataoutput.h new file mode 100644 index 0000000..8e8f8e0 --- /dev/null +++ b/src/3rdparty/phonon/phonon/audiodataoutput.h @@ -0,0 +1,129 @@ +/* This file is part of the KDE project + Copyright (C) 2005-2006 Matthias Kretz + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) version 3, or any + later version accepted by the membership of KDE e.V. (or its + successor approved by the membership of KDE e.V.), Nokia Corporation + (or its successors, if any) and the KDE Free Qt Foundation, which shall + act as a proxy defined in Section 6 of version 3 of the license. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library. If not, see . + +*/ +#ifndef Phonon_AUDIODATAOUTPUT_H +#define Phonon_AUDIODATAOUTPUT_H + +#include "phonon_export.h" +#include "abstractaudiooutput.h" +#include "phonondefs.h" + +#ifndef DOXYGEN_SHOULD_SKIP_THIS +template class QVector; +template class QMap; +#endif + +namespace Phonon +{ + class AudioDataOutputPrivate; + + /** + * \short This class gives you the audio data (for visualizations). + * + * This class implements a special AbstractAudioOutput that gives your + * application the audio data. Don't expect realtime performance. But + * the latencies should be low enough to use the audio data for + * visualizations. You can also use the audio data for further processing + * (e.g. encoding and saving to a file). + * + * \author Matthias Kretz + */ + class PHONON_EXPORT AudioDataOutput : public AbstractAudioOutput + { + Q_OBJECT + K_DECLARE_PRIVATE(AudioDataOutput) + Q_ENUMS(Channel) + Q_PROPERTY(int dataSize READ dataSize WRITE setDataSize) + PHONON_HEIR(AudioDataOutput) + public: + /** + * Specifies the channel the audio data belongs to. + */ + enum Channel + { + LeftChannel, + RightChannel, + CenterChannel, + LeftSurroundChannel, + RightSurroundChannel, + SubwooferChannel + }; + + /** + * Returns the currently used number of samples passed through + * the signal. + * + * \see setDataSize + */ + int dataSize() const; + + /** + * Returns the sample rate in Hz. Common sample rates are 44100 Hz + * and 48000 Hz. AudioDataOutput will not do any sample rate + * conversion for you. If you need to convert the sample rate you + * might want to take a look at libsamplerate. For visualizations it + * is often enough to do simple interpolation or even drop/duplicate + * samples. + * + * \return The sample rate as reported by the backend. If the + * backend is unavailable -1 is returned. + */ + int sampleRate() const; + + public Q_SLOTS: + /** + * Sets the number of samples to be passed in one signal emission. + * + * Defaults to 512 samples per emitted signal. + * + * \param size the number of samples + */ + void setDataSize(int size); + + Q_SIGNALS: + /** + * Emitted whenever another dataSize number of samples are ready. + * + * \param data A mapping of Channel to a vector holding the audio data. + */ + void dataReady(const QMap > &data); + + + /** + * This signal is emitted before the last dataReady signal of a + * media is emitted. + * + * If, for example, the playback of a media file has finished and the + * last audio data of that file is going to be passed with the next + * dataReady signal, and only the 28 first samples of the data + * vector are from that media file endOfMedia will be emitted right + * before dataReady with \p remainingSamples = 28. + * + * \param remainingSamples The number of samples in the next + * dataReady vector that belong to the media that was playing to + * this point. + */ + void endOfMedia(int remainingSamples); + }; +} // namespace Phonon + +// vim: sw=4 ts=4 tw=80 +#endif // Phonon_AUDIODATAOUTPUT_H diff --git a/src/3rdparty/phonon/phonon/audiodataoutput_p.h b/src/3rdparty/phonon/phonon/audiodataoutput_p.h new file mode 100644 index 0000000..91103a9 --- /dev/null +++ b/src/3rdparty/phonon/phonon/audiodataoutput_p.h @@ -0,0 +1,48 @@ +/* This file is part of the KDE project + Copyright (C) 2006 Matthias Kretz + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) version 3, or any + later version accepted by the membership of KDE e.V. (or its + successor approved by the membership of KDE e.V.), Nokia Corporation + (or its successors, if any) and the KDE Free Qt Foundation, which shall + act as a proxy defined in Section 6 of version 3 of the license. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library. If not, see . + +*/ + +#ifndef AUDIODATAOUTPUT_P_H +#define AUDIODATAOUTPUT_P_H + +#include "audiodataoutput.h" +#include "abstractaudiooutput_p.h" + +namespace Phonon +{ + +class AudioDataOutputPrivate : public AbstractAudioOutputPrivate +{ + Q_DECLARE_PUBLIC(AudioDataOutput) + PHONON_PRIVATECLASS + protected: + AudioDataOutputPrivate() + : dataSize(512) + { + } + + int dataSize; +}; + +} // namespace Phonon + +#endif // AUDIODATAOUTPUT_P_H +// vim: sw=4 ts=4 tw=80 diff --git a/src/3rdparty/phonon/phonon/audiodataoutputinterface.h b/src/3rdparty/phonon/phonon/audiodataoutputinterface.h new file mode 100644 index 0000000..bc1aad0 --- /dev/null +++ b/src/3rdparty/phonon/phonon/audiodataoutputinterface.h @@ -0,0 +1,44 @@ +/* This file is part of the KDE project + Copyright (C) 2008 Matthias Kretz + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) version 3, or any + later version accepted by the membership of KDE e.V. (or its + successor approved by the membership of KDE e.V.), Nokia Corporation + (or its successors, if any) and the KDE Free Qt Foundation, which shall + act as a proxy defined in Section 6 of version 3 of the license. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library. If not, see . + +*/ + +#ifndef PHONON_AUDIODATAOUTPUTINTERFACE_H +#define PHONON_AUDIODATAOUTPUTINTERFACE_H + +namespace Phonon +{ + +class AudioDataOutput; + +class AudioDataOutputInterface +{ + public: + virtual ~AudioDataOutputInterface() {} + + virtual AudioDataOutput *frontendObject() const = 0; + virtual void setFrontendObject(AudioDataOutput *) = 0; +}; + +} // namespace Phonon + +Q_DECLARE_INTERFACE(Phonon::AudioDataOutputInterface, "0AudioDataOutputInterface.phonon.kde.org") + +#endif // PHONON_AUDIODATAOUTPUTINTERFACE_H diff --git a/src/3rdparty/phonon/phonon/globalconfig.h b/src/3rdparty/phonon/phonon/globalconfig.h new file mode 100644 index 0000000..5233c7b --- /dev/null +++ b/src/3rdparty/phonon/phonon/globalconfig.h @@ -0,0 +1,71 @@ +/* This file is part of the KDE project +Copyright (C) 2006-2008 Matthias Kretz + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) version 3, or any + later version accepted by the membership of KDE e.V. (or its + successor approved by the membership of KDE e.V.), Nokia Corporation + (or its successors, if any) and the KDE Free Qt Foundation, which shall + act as a proxy defined in Section 6 of version 3 of the license. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library. If not, see . + +*/ + +#ifndef PHONON_GLOBALCONFIG_H +#define PHONON_GLOBALCONFIG_H + +#include "phonon_export.h" +#include "phononnamespace.h" +#include "phonondefs.h" + +QT_BEGIN_HEADER +QT_BEGIN_NAMESPACE + +namespace Phonon +{ + class GlobalConfigPrivate; + + class PHONON_EXPORT GlobalConfig + { + K_DECLARE_PRIVATE(GlobalConfig) + public: + GlobalConfig(); + virtual ~GlobalConfig(); + + enum DevicesToHideFlag { + ShowUnavailableDevices = 0, + ShowAdvancedDevices = 0, + HideAdvancedDevices = 1, + AdvancedDevicesFromSettings = 2, + HideUnavailableDevices = 4 + }; + bool hideAdvancedDevices() const; + void setHideAdvancedDevices(bool hide = true); + void setAudioOutputDeviceListFor(Phonon::Category category, QList order); + QList audioOutputDeviceListFor(Phonon::Category category, int override = AdvancedDevicesFromSettings) const; + int audioOutputDeviceFor(Phonon::Category category, int override = AdvancedDevicesFromSettings) const; + +#ifndef QT_NO_PHONON_AUDIOCAPTURE + void setAudioCaptureDeviceListFor(Phonon::Category category, QList order); + QList audioCaptureDeviceListFor(Phonon::Category category, int override = AdvancedDevicesFromSettings) const; + int audioCaptureDeviceFor(Phonon::Category category, int override = AdvancedDevicesFromSettings) const; +#endif //QT_NO_PHONON_AUDIOCAPTURE + + protected: + GlobalConfigPrivate *const k_ptr; + }; +} // namespace Phonon + +QT_END_NAMESPACE +QT_END_HEADER + +#endif // PHONON_GLOBALCONFIG_H diff --git a/src/3rdparty/phonon/phonon/pulsesupport.cpp b/src/3rdparty/phonon/phonon/pulsesupport.cpp new file mode 100644 index 0000000..642843f --- /dev/null +++ b/src/3rdparty/phonon/phonon/pulsesupport.cpp @@ -0,0 +1,1040 @@ +/* This file is part of the KDE project + Copyright (C) 2009 Colin Guthrie + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) version 3, or any + later version accepted by the membership of KDE e.V. (or its + successor approved by the membership of KDE e.V.), Nokia Corporation + (or its successors, if any) and the KDE Free Qt Foundation, which shall + act as a proxy defined in Section 6 of version 3 of the license. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library. If not, see . + +*/ + +#include +#include +#include +#include + +#ifdef HAVE_PULSEAUDIO +#include +#include +#include +#include +#ifdef HAVE_PULSEAUDIO_DEVICE_MANAGER +# include +#endif +#endif // HAVE_PULSEAUDIO + +#include "pulsesupport.h" + +QT_BEGIN_NAMESPACE + +namespace Phonon +{ + +static PulseSupport* s_instance = NULL; + +#ifdef HAVE_PULSEAUDIO +/*** +* Prints a conditional debug message based on the current debug level +* If obj is provided, classname and objectname will be printed as well +* +* see debugLevel() +*/ + +static int debugLevel() { + static int level = -1; + if (level < 1) { + level = 0; + QString pulseenv = qgetenv("PHONON_PULSEAUDIO_DEBUG"); + int l = pulseenv.toInt(); + if (l > 0) + level = (l > 2 ? 2 : l); + } + return level; +} + +static void logMessage(const QString &message, int priority = 2, QObject *obj=0); +static void logMessage(const QString &message, int priority, QObject *obj) +{ + if (debugLevel() > 0) { + QString output; + if (obj) { + // Strip away namespace from className + QString className(obj->metaObject()->className()); + int nameLength = className.length() - className.lastIndexOf(':') - 1; + className = className.right(nameLength); + output.sprintf("%s %s (%s %p)", message.toLatin1().constData(), + obj->objectName().toLatin1().constData(), + className.toLatin1().constData(), obj); + } + else { + output = message; + } + if (priority <= debugLevel()) { + qDebug() << QString("PulseSupport(%1): %2").arg(priority).arg(output); + } + } +} + + +class AudioDevice +{ + public: + inline + AudioDevice(QString name, QString desc, QString icon, uint32_t index) + : pulseName(name), pulseIndex(index) + { + properties["name"] = desc; + properties["description"] = ""; // We don't have descriptions (well we do, but we use them as the name!) + properties["icon"] = icon; + properties["available"] = (index != PA_INVALID_INDEX); + properties["isAdvanced"] = false; // Nothing is advanced! + } + + // Needed for QMap + inline AudioDevice() {} + + QString pulseName; + uint32_t pulseIndex; + QHash properties; +}; +bool operator!=(const AudioDevice &a, const AudioDevice &b) +{ + return !(a.pulseName == b.pulseName && a.properties == b.properties); +} + +class PulseUserData +{ + public: + inline + PulseUserData() + { + } + + QMap newOutputDevices; + QMap > newOutputDevicePriorities; // prio, device + + QMap newCaptureDevices; + QMap > newCaptureDevicePriorities; // prio, device +}; + +static QMap s_roleCategoryMap; + +static bool s_pulseActive = false; + +static pa_glib_mainloop *s_mainloop = NULL; +static pa_context *s_context = NULL; + + + +static int s_deviceIndexCounter = 0; + +static QMap s_outputDeviceIndexes; +static QMap s_outputDevices; +static QMap > s_outputDevicePriorities; // prio, device +static QMap s_outputStreamIndexMap; + +static QMap s_captureDeviceIndexes; +static QMap s_captureDevices; +static QMap > s_captureDevicePriorities; // prio, device +static QMap s_captureStreamIndexMap; + +static void createGenericDevices() +{ + // OK so we don't have the device manager extension, but we can show a single device and fake it. + int index; + s_outputDeviceIndexes.clear(); + s_outputDevices.clear(); + s_outputDevicePriorities.clear(); + index = s_deviceIndexCounter++; + s_outputDeviceIndexes.insert("sink:default", index); + s_outputDevices.insert(index, AudioDevice("sink:default", QObject::tr("PulseAudio Sound Server").toUtf8(), "audio-backend-pulseaudio", 0)); + for (int i = Phonon::NoCategory; i <= Phonon::LastCategory; ++i) { + Phonon::Category cat = static_cast(i); + s_outputDevicePriorities[cat].insert(0, index); + } + + s_captureDeviceIndexes.clear(); + s_captureDevices.clear(); + s_captureDevicePriorities.clear(); + index = s_deviceIndexCounter++; + s_captureDeviceIndexes.insert("source:default", index); + s_captureDevices.insert(index, AudioDevice("source:default", QObject::tr("PulseAudio Sound Server").toUtf8(), "audio-backend-pulseaudio", 0)); + for (int i = Phonon::NoCategory; i <= Phonon::LastCategory; ++i) { + Phonon::Category cat = static_cast(i); + s_captureDevicePriorities[cat].insert(0, index); + } +} + +#ifdef HAVE_PULSEAUDIO_DEVICE_MANAGER +static void ext_device_manager_read_cb(pa_context *c, const pa_ext_device_manager_info *info, int eol, void *userdata) { + Q_ASSERT(c); + Q_ASSERT(userdata); + + PulseUserData *u = reinterpret_cast(userdata); + + if (eol < 0) { + logMessage(QString("Failed to initialize device manager extension: %1").arg(pa_strerror(pa_context_errno(c)))); + logMessage("Falling back to single device mode"); + createGenericDevices(); + delete u; + + // If this is our probe phase, exit now + if (s_context != c) + pa_context_disconnect(c); + + return; + } + + if (eol) { + // We're done reading the data, so order it by priority and copy it into the + // static variables where it can then be accessed by those classes that need it. + + QMap::iterator newdev_it; + + // Check for new output devices or things changing about known output devices. + bool output_changed = false; + for (newdev_it = u->newOutputDevices.begin(); newdev_it != u->newOutputDevices.end(); ++newdev_it) { + QString name = newdev_it.key(); + + // The name + index map is always written when a new device is added. + Q_ASSERT(s_outputDeviceIndexes.contains(name)); + + int index = s_outputDeviceIndexes[name]; + if (!s_outputDevices.contains(index)) { + // This is a totally new device + output_changed = true; + logMessage(QString("Brand New Output Device Found.")); + s_outputDevices.insert(index, *newdev_it); + } else if (s_outputDevices[index] != *newdev_it) { + // We have this device already, but is it different? + output_changed = true; + logMessage(QString("Change to Existing Output Device (may be Added/Removed or something else)")); + s_outputDevices.remove(index); + s_outputDevices.insert(index, *newdev_it); + } + } + // Go through the output devices we know about and see if any are no longer mentioned in the list. + QMutableMapIterator output_existing_it(s_outputDeviceIndexes); + while (output_existing_it.hasNext()) { + output_existing_it.next(); + if (!u->newOutputDevices.contains(output_existing_it.key())) { + output_changed = true; + logMessage(QString("Output Device Completely Removed")); + s_outputDevices.remove(output_existing_it.value()); + output_existing_it.remove(); + } + } + + // Check for new capture devices or things changing about known capture devices. + bool capture_changed = false; + for (newdev_it = u->newCaptureDevices.begin(); newdev_it != u->newCaptureDevices.end(); ++newdev_it) { + QString name = newdev_it.key(); + + // The name + index map is always written when a new device is added. + Q_ASSERT(s_captureDeviceIndexes.contains(name)); + + int index = s_captureDeviceIndexes[name]; + if (!s_captureDevices.contains(index)) { + // This is a totally new device + capture_changed = true; + logMessage(QString("Brand New Capture Device Found.")); + s_captureDevices.insert(index, *newdev_it); + } else if (s_captureDevices[index] != *newdev_it) { + // We have this device already, but is it different? + capture_changed = true; + logMessage(QString("Change to Existing Capture Device (may be Added/Removed or something else)")); + s_captureDevices.remove(index); + s_captureDevices.insert(index, *newdev_it); + } + } + // Go through the capture devices we know about and see if any are no longer mentioned in the list. + QMutableMapIterator capture_existing_it(s_captureDeviceIndexes); + while (capture_existing_it.hasNext()) { + capture_existing_it.next(); + if (!u->newCaptureDevices.contains(capture_existing_it.key())) { + capture_changed = true; + logMessage(QString("Capture Device Completely Removed")); + s_captureDevices.remove(capture_existing_it.value()); + capture_existing_it.remove(); + } + } + + // Just copy accross the new priority lists as we know they are valid + if (s_outputDevicePriorities != u->newOutputDevicePriorities) { + output_changed = true; + s_outputDevicePriorities = u->newOutputDevicePriorities; + } + if (s_captureDevicePriorities != u->newCaptureDevicePriorities) { + capture_changed = true; + s_captureDevicePriorities = u->newCaptureDevicePriorities; + } + + if (s_instance) { + // This wont be emitted durring the connection probe phase + // which is intensional + if (output_changed) + s_instance->emitObjectDescriptionChanged(AudioOutputDeviceType); + if (capture_changed) + s_instance->emitObjectDescriptionChanged(AudioCaptureDeviceType); + } + + // We can free the user data as we will not be called again. + delete u; + + // Some debug + logMessage(QString("Output Device Priority List:")); + for (int i = Phonon::NoCategory; i <= Phonon::LastCategory; ++i) { + Phonon::Category cat = static_cast(i); + if (s_outputDevicePriorities.contains(cat)) { + logMessage(QString(" Phonon Category %1").arg(cat)); + int count = 0; + foreach (int j, s_outputDevicePriorities[cat]) { + QHash &props = s_outputDevices[j].properties; + logMessage(QString(" %1. %2 (Available: %3)").arg(++count).arg(props["name"].toString()).arg(props["available"].toBool())); + } + } + } + logMessage(QString("Capture Device Priority List:")); + for (int i = Phonon::NoCategory; i <= Phonon::LastCategory; ++i) { + Phonon::Category cat = static_cast(i); + if (s_captureDevicePriorities.contains(cat)) { + logMessage(QString(" Phonon Category %1").arg(cat)); + int count = 0; + foreach (int j, s_captureDevicePriorities[cat]) { + QHash &props = s_captureDevices[j].properties; + logMessage(QString(" %1. %2 (Available: %3)").arg(++count).arg(props["name"].toString()).arg(props["available"].toBool())); + } + } + } + + // If this is our probe phase, exit now as we're finished reading + // our device info and can exit and reconnect + if (s_context != c) + pa_context_disconnect(c); + } + + if (!info) + return; + + Q_ASSERT(info->name); + Q_ASSERT(info->description); + Q_ASSERT(info->icon); + + // QString wrapper + QString name(info->name); + int index; + QMap > *new_prio_map_cats; // prio, device + QMap *new_devices; + + if (name.startsWith("sink:")) { + new_devices = &u->newOutputDevices; + new_prio_map_cats = &u->newOutputDevicePriorities; + + if (s_outputDeviceIndexes.contains(name)) + index = s_outputDeviceIndexes[name]; + else + index = s_outputDeviceIndexes[name] = s_deviceIndexCounter++; + } else if (name.startsWith("source:")) { + new_devices = &u->newCaptureDevices; + new_prio_map_cats = &u->newCaptureDevicePriorities; + + if (s_captureDeviceIndexes.contains(name)) + index = s_captureDeviceIndexes[name]; + else + index = s_captureDeviceIndexes[name] = s_deviceIndexCounter++; + } else { + // This indicates a bug in pulseaudio. + return; + } + + // Add the new device itself. + new_devices->insert(name, AudioDevice(name, info->description, info->icon, info->index)); + + // For each role in the priority, map it to a phonon category and store the order. + for (uint32_t i = 0; i < info->n_role_priorities; ++i) { + pa_ext_device_manager_role_priority_info* role_prio = &info->role_priorities[i]; + Q_ASSERT(role_prio->role); + + if (s_roleCategoryMap.contains(role_prio->role)) { + Phonon::Category cat = s_roleCategoryMap[role_prio->role]; + + (*new_prio_map_cats)[cat].insert(role_prio->priority, index); + } + } +} + +static void ext_device_manager_subscribe_cb(pa_context *c, void *) { + Q_ASSERT(c); + + pa_operation *o; + PulseUserData *u = new PulseUserData; + if (!(o = pa_ext_device_manager_read(c, ext_device_manager_read_cb, u))) { + logMessage(QString("pa_ext_device_manager_read() failed.")); + delete u; + return; + } + pa_operation_unref(o); +} +#endif + +void sink_input_cb(pa_context *c, const pa_sink_input_info *i, int eol, void *userdata) { + Q_UNUSED(userdata); + Q_ASSERT(c); + + if (eol < 0) { + if (pa_context_errno(c) == PA_ERR_NOENTITY) + return; + + logMessage(QString("Sink input callback failure")); + return; + } + + if (eol > 0) + return; + + Q_ASSERT(i); + + // loop through (*i) and extract phonon->streamindex... + const char *t; + if ((t = pa_proplist_gets(i->proplist, "phonon.streamid"))) { + logMessage(QString("Found PulseAudio stream index %1 for Phonon Output Stream %2").arg(i->index).arg(t)); + s_outputStreamIndexMap[QString(t)] = i->index; + + // Find the sink's phonon index and notify whoever cares... + if (PA_INVALID_INDEX != i->sink) { + bool found = false; + int device; + QMap::iterator it; + for (it = s_outputDevices.begin(); it != s_outputDevices.end(); ++it) { + if ((*it).pulseIndex == i->sink) { + found = true; + device = it.key(); + break; + } + } + if (found) { + // OK so we just emit our signal + logMessage(QString("Letting the rest of phonon know about this")); + s_instance->emitUsingDevice(QString(t), device); + } + } + } +} + +void source_output_cb(pa_context *c, const pa_source_output_info *i, int eol, void *userdata) { + Q_UNUSED(userdata); + Q_ASSERT(c); + + if (eol < 0) { + if (pa_context_errno(c) == PA_ERR_NOENTITY) + return; + + logMessage(QString("Source output callback failure")); + return; + } + + if (eol > 0) + return; + + Q_ASSERT(i); + + // loop through (*i) and extract phonon->streamindex... + const char *t; + if ((t = pa_proplist_gets(i->proplist, "phonon.streamid"))) { + logMessage(QString("Found PulseAudio stream index %1 for Phonon Capture Stream %2").arg(i->index).arg(t)); + s_captureStreamIndexMap[QString(t)] = i->index; + + // Find the source's phonon index and notify whoever cares... + if (PA_INVALID_INDEX != i->source) { + bool found = false; + int device; + QMap::iterator it; + for (it = s_captureDevices.begin(); it != s_captureDevices.end(); ++it) { + if ((*it).pulseIndex == i->source) { + found = true; + device = it.key(); + break; + } + } + if (found) { + // OK so we just emit our signal + logMessage(QString("Letting the rest of phonon know about this")); + s_instance->emitUsingDevice(QString(t), device); + } + } + } +} + +static void subscribe_cb(pa_context *c, pa_subscription_event_type_t t, uint32_t index, void *userdata) { + Q_UNUSED(userdata); + + switch (t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) { + case PA_SUBSCRIPTION_EVENT_SINK_INPUT: + if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) { + QString phononid = s_outputStreamIndexMap.key(index); + if (!phononid.isEmpty()) { + if (s_outputStreamIndexMap.contains(phononid)) { + logMessage(QString("Phonon Output Stream %1 is gone at the PA end. Marking it as invalid in our cache as we may reuse it.").arg(phononid)); + s_outputStreamIndexMap[phononid] = PA_INVALID_INDEX; + } else { + logMessage(QString("Removing Phonon Output Stream %1 (it's gone!)").arg(phononid)); + s_outputStreamIndexMap.remove(phononid); + } + } + } else { + pa_operation *o; + if (!(o = pa_context_get_sink_input_info(c, index, sink_input_cb, NULL))) { + logMessage(QString("pa_context_get_sink_input_info() failed")); + return; + } + pa_operation_unref(o); + } + break; + + case PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT: + if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) { + QString phononid = s_captureStreamIndexMap.key(index); + if (!phononid.isEmpty()) { + if (s_captureStreamIndexMap.contains(phononid)) { + logMessage(QString("Phonon Capture Stream %1 is gone at the PA end. Marking it as invalid in our cache as we may reuse it.").arg(phononid)); + s_captureStreamIndexMap[phononid] = PA_INVALID_INDEX; + } else { + logMessage(QString("Removing Phonon Capture Stream %1 (it's gone!)").arg(phononid)); + s_captureStreamIndexMap.remove(phononid); + } + } + } else { + pa_operation *o; + if (!(o = pa_context_get_source_output_info(c, index, source_output_cb, NULL))) { + logMessage(QString("pa_context_get_sink_input_info() failed")); + return; + } + pa_operation_unref(o); + } + break; + } +} + + +static const char* statename(pa_context_state_t state) +{ + switch (state) + { + case PA_CONTEXT_UNCONNECTED: return "Unconnected"; + case PA_CONTEXT_CONNECTING: return "Connecting"; + case PA_CONTEXT_AUTHORIZING: return "Authorizing"; + case PA_CONTEXT_SETTING_NAME: return "Setting Name"; + case PA_CONTEXT_READY: return "Ready"; + case PA_CONTEXT_FAILED: return "Failed"; + case PA_CONTEXT_TERMINATED: return "Terminated"; + } + + static QString unknown; + unknown = QString("Unknown state: %0").arg(state); + return unknown.toAscii().constData(); +} + +static void context_state_callback(pa_context *c, void *) +{ + Q_ASSERT(c); + + logMessage(QString("context_state_callback %1").arg(statename(pa_context_get_state(c)))); + pa_context_state_t state = pa_context_get_state(c); + if (state == PA_CONTEXT_READY) { + // We've connected to PA, so it is active + s_pulseActive = true; + + // Attempt to load things up + pa_operation *o; + + // 1. Register for the stream changes (except during probe) + if (s_context == c) { + pa_context_set_subscribe_callback(c, subscribe_cb, NULL); + + if (!(o = pa_context_subscribe(c, (pa_subscription_mask_t) + (PA_SUBSCRIPTION_MASK_SINK_INPUT| + PA_SUBSCRIPTION_MASK_SOURCE_OUTPUT), NULL, NULL))) { + logMessage(QString("pa_context_subscribe() failed")); + return; + } + pa_operation_unref(o); + } + +#ifdef HAVE_PULSEAUDIO_DEVICE_MANAGER + // 2a. Attempt to initialise Device Manager info (except during probe) + if (s_context == c) { + pa_ext_device_manager_set_subscribe_cb(c, ext_device_manager_subscribe_cb, NULL); + if (!(o = pa_ext_device_manager_subscribe(c, 1, NULL, NULL))) { + logMessage(QString("pa_ext_device_manager_subscribe() failed")); + return; + } + pa_operation_unref(o); + } + + // 3. Attempt to read info from Device Manager + PulseUserData *u = new PulseUserData; + if (!(o = pa_ext_device_manager_read(c, ext_device_manager_read_cb, u))) { + logMessage(QString("pa_ext_device_manager_read() failed. Attempting to continue without device manager support")); + createGenericDevices(); + delete u; + + // If this is our probe phase, exit immediately + if (s_context != c) + pa_context_disconnect(c); + + return; + } + pa_operation_unref(o); + +#else + // If we know do not have Device Manager support, we just create our dummy devices now + createGenericDevices(); + + // If this is our probe phase, exit immediately + if (s_context != c) + pa_context_disconnect(c); +#endif + } else if (!PA_CONTEXT_IS_GOOD(state)) { + /// @todo Deal with reconnection... + //logMessage("Connection to PulseAudio lost"); + + // If this is our probe phase, exit our context immediately + if (s_context != c) + pa_context_disconnect(c); + } +} +#endif // HAVE_PULSEAUDIO + + +PulseSupport* PulseSupport::getInstance() +{ + if (NULL == s_instance) { + s_instance = new PulseSupport(); + } + return s_instance; +} + +void PulseSupport::shutdown() +{ + if (NULL != s_instance) { + delete s_instance; + s_instance = NULL; + } +} + +PulseSupport::PulseSupport() + : QObject(), mEnabled(false) +{ +#ifdef HAVE_PULSEAUDIO + // Initialise our map (is there a better way to do this?) + s_roleCategoryMap["none"] = Phonon::NoCategory; + s_roleCategoryMap["video"] = Phonon::VideoCategory; + s_roleCategoryMap["music"] = Phonon::MusicCategory; + s_roleCategoryMap["game"] = Phonon::GameCategory; + s_roleCategoryMap["event"] = Phonon::NotificationCategory; + s_roleCategoryMap["phone"] = Phonon::CommunicationCategory; + //s_roleCategoryMap["animation"]; // No Mapping + //s_roleCategoryMap["production"]; // No Mapping + s_roleCategoryMap["a11y"] = Phonon::AccessibilityCategory; + + // To allow for easy debugging, give an easy way to disable this pulseaudio check + QString pulseenv = qgetenv("PHONON_PULSEAUDIO_DISABLE"); + if (pulseenv.toInt()) { + logMessage("PulseAudio support disabled: PHONON_PULSEAUDIO_DISABLE is set"); + return; + } + + // We require a glib event loop + if (QLatin1String(QAbstractEventDispatcher::instance()->metaObject()->className()) + != "QGuiEventDispatcherGlib") { + logMessage("Disabling PulseAudio integration for lack of GLib event loop."); + return; + } + + // First of all conenct to PA via simple/blocking means and if that succeeds, + // use a fully async integrated mainloop method to connect and get proper support. + pa_mainloop *p_test_mainloop; + if (!(p_test_mainloop = pa_mainloop_new())) { + logMessage("PulseAudio support disabled: Unable to create mainloop"); + return; + } + + pa_context *p_test_context; + if (!(p_test_context = pa_context_new(pa_mainloop_get_api(p_test_mainloop), "libphonon-probe"))) { + logMessage("PulseAudio support disabled: Unable to create context"); + pa_mainloop_free(p_test_mainloop); + return; + } + + logMessage("Probing for PulseAudio..."); + // (cg) Convert to PA_CONTEXT_NOFLAGS when PulseAudio 0.9.19 is required + if (pa_context_connect(p_test_context, NULL, static_cast(0), NULL) < 0) { + logMessage(QString("PulseAudio support disabled: %1").arg(pa_strerror(pa_context_errno(p_test_context)))); + pa_context_disconnect(p_test_context); + pa_context_unref(p_test_context); + pa_mainloop_free(p_test_mainloop); + return; + } + + pa_context_set_state_callback(p_test_context, &context_state_callback, NULL); + for (;;) { + pa_mainloop_iterate(p_test_mainloop, 1, NULL); + + if (!PA_CONTEXT_IS_GOOD(pa_context_get_state(p_test_context))) { + logMessage("PulseAudio probe complete."); + break; + } + } + pa_context_disconnect(p_test_context); + pa_context_unref(p_test_context); + pa_mainloop_free(p_test_mainloop); + + if (!s_pulseActive) { + logMessage("PulseAudio support is not available."); + return; + } + + // If we're still here, PA is available. + logMessage("PulseAudio support enabled"); + + // Now we connect for real using a proper main loop that we can forget + // all about processing. + s_mainloop = pa_glib_mainloop_new(NULL); + Q_ASSERT(s_mainloop); + pa_mainloop_api *api = pa_glib_mainloop_get_api(s_mainloop); + + s_context = pa_context_new(api, "libphonon"); + // (cg) Convert to PA_CONTEXT_NOFLAGS when PulseAudio 0.9.19 is required + if (pa_context_connect(s_context, NULL, static_cast(0), 0) >= 0) + pa_context_set_state_callback(s_context, &context_state_callback, NULL); +#endif +} + +PulseSupport::~PulseSupport() +{ +#ifdef HAVE_PULSEAUDIO + if (s_context) { + pa_context_disconnect(s_context); + s_context = NULL; + } + + if (s_mainloop) { + pa_glib_mainloop_free(s_mainloop); + s_mainloop = NULL; + } +#endif +} + +bool PulseSupport::isActive() +{ +#ifdef HAVE_PULSEAUDIO + return mEnabled && s_pulseActive; +#else + return false; +#endif +} + +void PulseSupport::enable(bool enabled) +{ + mEnabled = enabled; +} + +QList PulseSupport::objectDescriptionIndexes(ObjectDescriptionType type) const +{ + QList list; + + if (type != AudioOutputDeviceType && type != AudioCaptureDeviceType) + return list; + +#ifdef HAVE_PULSEAUDIO + if (s_pulseActive) { + switch (type) { + + case AudioOutputDeviceType: { + QMap::iterator it; + for (it = s_outputDeviceIndexes.begin(); it != s_outputDeviceIndexes.end(); ++it) { + list.append(*it); + } + break; + } + case AudioCaptureDeviceType: { + QMap::iterator it; + for (it = s_captureDeviceIndexes.begin(); it != s_captureDeviceIndexes.end(); ++it) { + list.append(*it); + } + break; + } + default: + break; + } + } +#endif + + return list; +} + +QHash PulseSupport::objectDescriptionProperties(ObjectDescriptionType type, int index) const +{ + QHash ret; + + if (type != AudioOutputDeviceType && type != AudioCaptureDeviceType) + return ret; + +#ifndef HAVE_PULSEAUDIO + Q_UNUSED(index); +#else + if (s_pulseActive) { + switch (type) { + + case AudioOutputDeviceType: + Q_ASSERT(s_outputDevices.contains(index)); + ret = s_outputDevices[index].properties; + break; + + case AudioCaptureDeviceType: + Q_ASSERT(s_captureDevices.contains(index)); + ret = s_captureDevices[index].properties; + break; + + default: + break; + } + } +#endif + + return ret; +} + +QList PulseSupport::objectIndexesByCategory(ObjectDescriptionType type, Category category) const +{ + QList ret; + + if (type != AudioOutputDeviceType && type != AudioCaptureDeviceType) + return ret; + +#ifndef HAVE_PULSEAUDIO + Q_UNUSED(category); +#else + if (s_pulseActive) { + switch (type) { + + case AudioOutputDeviceType: + if (s_outputDevicePriorities.contains(category)) + ret = s_outputDevicePriorities[category].values(); + break; + + case AudioCaptureDeviceType: + if (s_captureDevicePriorities.contains(category)) + ret = s_captureDevicePriorities[category].values(); + break; + + default: + break; + } + } +#endif + + return ret; +} + +#ifdef HAVE_PULSEAUDIO +static void setDevicePriority(Category category, QStringList list) +{ + QString role = s_roleCategoryMap.key(category); + if (role.isEmpty()) + return; + + logMessage(QString("Reindexing %1: %2").arg(role).arg(list.join(", "))); + + char **devices; + devices = pa_xnew(char *, list.size()+1); + int i = 0; + foreach (QString str, list) { + devices[i++] = pa_xstrdup(str.toUtf8().constData()); + } + devices[list.size()] = NULL; + +#ifdef HAVE_PULSEAUDIO_DEVICE_MANAGER + pa_operation *o; + if (!(o = pa_ext_device_manager_reorder_devices_for_role(s_context, role.toUtf8().constData(), (const char**)devices, NULL, NULL))) + logMessage(QString("pa_ext_device_manager_reorder_devices_for_role() failed")); + else + pa_operation_unref(o); +#endif + + for (i = 0; i < list.size(); ++i) + pa_xfree(devices[i]); + pa_xfree(devices); +} +#endif + +void PulseSupport::setOutputDevicePriorityForCategory(Category category, QList order) +{ +#ifndef HAVE_PULSEAUDIO + Q_UNUSED(category); + Q_UNUSED(order); +#else + QStringList list; + QList::iterator it; + + for (it = order.begin(); it != order.end(); ++it) { + if (s_outputDevices.contains(*it)) { + list << s_outputDeviceIndexes.key(*it); + } + } + setDevicePriority(category, list); +#endif +} + +void PulseSupport::setCaptureDevicePriorityForCategory(Category category, QList order) +{ +#ifndef HAVE_PULSEAUDIO + Q_UNUSED(category); + Q_UNUSED(order); +#else + QStringList list; + QList::iterator it; + + for (it = order.begin(); it != order.end(); ++it) { + if (s_captureDevices.contains(*it)) { + list << s_captureDeviceIndexes.key(*it); + } + } + setDevicePriority(category, list); +#endif +} + +void PulseSupport::setStreamPropList(Category category, QString streamUuid) +{ +#ifndef HAVE_PULSEAUDIO + Q_UNUSED(category); + Q_UNUSED(streamUuid); +#else + QString role = s_roleCategoryMap.key(category); + if (role.isEmpty()) + return; + + logMessage(QString("Setting role to %1 for streamindex %2").arg(role).arg(streamUuid)); + setenv("PULSE_PROP_media.role", role.toLatin1().constData(), 1); + setenv("PULSE_PROP_phonon.streamid", streamUuid.toLatin1().constData(), 1); +#endif +} + +void PulseSupport::emitObjectDescriptionChanged(ObjectDescriptionType type) +{ + emit objectDescriptionChanged(type); +} + +void PulseSupport::emitUsingDevice(QString streamUuid, int device) +{ + emit usingDevice(streamUuid, device); +} + +bool PulseSupport::setOutputDevice(QString streamUuid, int device) { +#ifndef HAVE_PULSEAUDIO + Q_UNUSED(streamUuid); + Q_UNUSED(device); + return false; +#else + if (s_outputDevices.size() < 2) + return true; + + if (!s_outputDevices.contains(device)) { + logMessage(QString("Attempting to set Output Device for invalid device id %1.").arg(device)); + return false; + } + const QVariant var = s_outputDevices[device].properties["name"]; + logMessage(QString("Attempting to set Output Device to '%1' for Output Stream %2").arg(var.toString()).arg(streamUuid)); + + // Attempt to look up the pulse stream index. + if (s_outputStreamIndexMap.contains(streamUuid) && s_outputStreamIndexMap[streamUuid] != PA_INVALID_INDEX) { + logMessage(QString("... Found in map. Moving now")); + + uint32_t pulse_device_index = s_outputDevices[device].pulseIndex; + uint32_t pulse_stream_index = s_outputStreamIndexMap[streamUuid]; + + logMessage(QString("Moving Pulse Sink Input %1 to '%2' (Pulse Sink %3)").arg(pulse_stream_index).arg(var.toString()).arg(pulse_device_index)); + + /// @todo Find a way to move the stream without saving it... We don't want to pollute the stream restore db. + pa_operation* o; + if (!(o = pa_context_move_sink_input_by_index(s_context, pulse_stream_index, pulse_device_index, NULL, NULL))) { + logMessage(QString("pa_context_move_sink_input_by_index() failed")); + return false; + } + pa_operation_unref(o); + } else { + logMessage(QString("... Not found in map. We will be notified of the device when the stream appears and we can process any moves needed then")); + } + return true; +#endif +} + +bool PulseSupport::setCaptureDevice(QString streamUuid, int device) { +#ifndef HAVE_PULSEAUDIO + Q_UNUSED(streamUuid); + Q_UNUSED(device); + return false; +#else + if (s_captureDevices.size() < 2) + return true; + + if (!s_captureDevices.contains(device)) { + logMessage(QString("Attempting to set Capture Device for invalid device id %1.").arg(device)); + return false; + } + const QVariant var = s_captureDevices[device].properties["name"]; + logMessage(QString("Attempting to set Capture Device to '%1' for Capture Stream %2").arg(var.toString()).arg(streamUuid)); + + // Attempt to look up the pulse stream index. + if (s_captureStreamIndexMap.contains(streamUuid) && s_captureStreamIndexMap[streamUuid] == PA_INVALID_INDEX) { + logMessage(QString("... Found in map. Moving now")); + + uint32_t pulse_device_index = s_captureDevices[device].pulseIndex; + uint32_t pulse_stream_index = s_captureStreamIndexMap[streamUuid]; + + logMessage(QString("Moving Pulse Source Output %1 to '%2' (Pulse Sink %3)").arg(pulse_stream_index).arg(var.toString()).arg(pulse_device_index)); + + /// @todo Find a way to move the stream without saving it... We don't want to pollute the stream restore db. + pa_operation* o; + if (!(o = pa_context_move_source_output_by_index(s_context, pulse_stream_index, pulse_device_index, NULL, NULL))) { + logMessage(QString("pa_context_move_source_output_by_index() failed")); + return false; + } + pa_operation_unref(o); + } else { + logMessage(QString("... Not found in map. We will be notified of the device when the stream appears and we can process any moves needed then")); + } + return true; +#endif +} + +void PulseSupport::clearStreamCache(QString streamUuid) { +#ifndef HAVE_PULSEAUDIO + Q_UNUSED(streamUuid); + return; +#else + logMessage(QString("Clearing stream cache for stream %1").arg(streamUuid)); + s_outputStreamIndexMap.remove(streamUuid); + s_captureStreamIndexMap.remove(streamUuid); +#endif +} + +} // namespace Phonon + +QT_END_NAMESPACE + +#include "moc_pulsesupport.cpp" + +// vim: sw=4 ts=4 diff --git a/src/3rdparty/phonon/phonon/pulsesupport.h b/src/3rdparty/phonon/phonon/pulsesupport.h new file mode 100644 index 0000000..c38bece --- /dev/null +++ b/src/3rdparty/phonon/phonon/pulsesupport.h @@ -0,0 +1,78 @@ +/* This file is part of the KDE project + Copyright (C) 2009 Colin Guthrie + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) version 3, or any + later version accepted by the membership of KDE e.V. (or its + successor approved by the membership of KDE e.V.), Nokia Corporation + (or its successors, if any) and the KDE Free Qt Foundation, which shall + act as a proxy defined in Section 6 of version 3 of the license. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library. If not, see . + +*/ + +#ifndef PHONON_PULSESUPPORT_H +#define PHONON_PULSESUPPORT_H + +#include "phonon_export.h" +#include "phononnamespace.h" +#include "objectdescription.h" + +#include +#include + +QT_BEGIN_HEADER +QT_BEGIN_NAMESPACE + +namespace Phonon +{ + class PHONON_EXPORT PulseSupport : public QObject + { + Q_OBJECT + public: + static PulseSupport* getInstance(); + static void shutdown(); + + bool isActive(); + void enable(bool enabled = true); + + QList objectDescriptionIndexes(ObjectDescriptionType type) const; + QHash objectDescriptionProperties(ObjectDescriptionType type, int index) const; + QList objectIndexesByCategory(ObjectDescriptionType type, Category category) const; + + void setOutputDevicePriorityForCategory(Category category, QList order); + void setCaptureDevicePriorityForCategory(Category category, QList order); + + void setStreamPropList(Category category, QString streamUuid); + void emitObjectDescriptionChanged(ObjectDescriptionType); + void emitUsingDevice(QString streamUuid, int device); + + bool setOutputDevice(QString streamUuid, int device); + bool setCaptureDevice(QString streamUuid, int device); + void clearStreamCache(QString streamUuid); + + signals: + void objectDescriptionChanged(ObjectDescriptionType); + void usingDevice(QString streamUuid, int device); + + private: + PulseSupport(); + ~PulseSupport(); + + bool mEnabled; + }; +} // namespace Phonon + +QT_END_NAMESPACE +QT_END_HEADER + +#endif // PHONON_PULSESUPPORT_H diff --git a/src/3rdparty/phonon/phonon/swiftslider.cpp b/src/3rdparty/phonon/phonon/swiftslider.cpp new file mode 100644 index 0000000..1e274aa --- /dev/null +++ b/src/3rdparty/phonon/phonon/swiftslider.cpp @@ -0,0 +1,103 @@ +/* This file is part of the KDE project + Copyright (C) 2006-2008 Ricardo Villalba + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) version 3, or any + later version accepted by the membership of KDE e.V. (or its + successor approved by the membership of KDE e.V.), Nokia Corporation + (or its successors, if any) and the KDE Free Qt Foundation, which shall + act as a proxy defined in Section 6 of version 3 of the license. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library. If not, see . + +*/ + +#include "swiftslider_p.h" + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +#if !defined(QT_NO_PHONON_SEEKSLIDER) && !defined(QT_NO_PHONON_VOLUMESLIDER) + +namespace Phonon +{ + +SwiftSlider::SwiftSlider(Qt::Orientation orientation, QWidget * parent) + : QSlider(orientation, parent) +{ +} + +SwiftSlider::~SwiftSlider() +{ +} + +// Function copied from qslider.cpp +inline int SwiftSlider::pick(const QPoint &pt) const +{ + return orientation() == Qt::Horizontal ? pt.x() : pt.y(); +} + +// Function copied from qslider.cpp and modified to make it compile +int SwiftSlider::pixelPosToRangeValue(int pos) const +{ + QStyleOptionSlider opt; + initStyleOption(&opt); + QRect gr = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderGroove, this); + QRect sr = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this); + int sliderMin, sliderMax, sliderLength; + + if (orientation() == Qt::Horizontal) { + sliderLength = sr.width(); + sliderMin = gr.x(); + sliderMax = gr.right() - sliderLength + 1; + } else { + sliderLength = sr.height(); + sliderMin = gr.y(); + sliderMax = gr.bottom() - sliderLength + 1; + } + return QStyle::sliderValueFromPosition(minimum(), maximum(), pos - sliderMin, + sliderMax - sliderMin, opt.upsideDown); +} + +// Based on code from qslider.cpp +void SwiftSlider::mousePressEvent(QMouseEvent *event) +{ + if (event->button() == Qt::LeftButton) { + QStyleOptionSlider opt; + initStyleOption(&opt); + const QRect sliderRect = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this); + const QPoint center = sliderRect.center() - sliderRect.topLeft(); + // to take half of the slider off for the setSliderPosition call we use the center - topLeft + + if (!sliderRect.contains(event->pos())) { + event->accept(); + + setSliderPosition(pixelPosToRangeValue(pick(event->pos() - center))); + triggerAction(SliderMove); + setRepeatAction(SliderNoAction); + } else { + QSlider::mousePressEvent(event); + } + } else { + QSlider::mousePressEvent(event); + } +} + +} // namespace Phonon + +#endif //QT_NO_PHONON_VOLUMESLIDER && QT_NO_PHONON_VOLUMESLIDER + +QT_END_NAMESPACE + +#include "moc_swiftslider_p.cpp" diff --git a/src/3rdparty/phonon/phonon/swiftslider_p.h b/src/3rdparty/phonon/phonon/swiftslider_p.h new file mode 100644 index 0000000..b063b47 --- /dev/null +++ b/src/3rdparty/phonon/phonon/swiftslider_p.h @@ -0,0 +1,68 @@ +/* This file is part of the KDE project + Copyright (C) 2006-2008 Ricardo Villalba + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) version 3, or any + later version accepted by the membership of KDE e.V. (or its + successor approved by the membership of KDE e.V.), Nokia Corporation + (or its successors, if any) and the KDE Free Qt Foundation, which shall + act as a proxy defined in Section 6 of version 3 of the license. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library. If not, see . + +*/ + +#ifndef SWIFTSLIDER_H +#define SWIFTSLIDER_H + +#include + +QT_BEGIN_NAMESPACE + +#if !defined(QT_NO_PHONON_SEEKSLIDER) && !defined(QT_NO_PHONON_VOLUMESLIDER) + +namespace Phonon +{ + +/** \class SwiftSlider swiftslider_p.h phonon/SwiftSlider + * \short Modified QSlider that allows sudden/quick moves instead of stepped moves ("Click'n'Go" QSlider) + * + * This is an internal class used by SeekSlider and VolumeSlider. + * + * Ricardo Villalba, the original author of MySlider.cpp (from the SMPlayer project) + * gave his permission for the inclusion of this code inside Phonon by + * switching MySlider.cpp to the LGPLv2.1+ license. + * See http://smplayer.svn.sourceforge.net/viewvc/smplayer/smplayer/trunk/src/myslider.cpp?revision=2406&view=markup + * + * The original discussion about a "Click'n'Go QSlider": http://lists.trolltech.com/qt-interest/2006-11/msg00363.html + * + * \ingroup PhononWidgets + */ +class SwiftSlider : public QSlider +{ + Q_OBJECT +public: + SwiftSlider(Qt::Orientation orientation, QWidget * parent); + ~SwiftSlider(); + +private: + void mousePressEvent(QMouseEvent *event); + inline int pick(const QPoint &pt) const; + int pixelPosToRangeValue(int pos) const; +}; + +} // namespace Phonon + +#endif //QT_NO_PHONON_VOLUMESLIDER && QT_NO_PHONON_VOLUMESLIDER + +QT_END_NAMESPACE + +#endif //SWIFTSLIDER_H diff --git a/src/3rdparty/phonon/qt7/mediaobject.mm b/src/3rdparty/phonon/qt7/mediaobject.mm index f8d635a..002c337 100644 --- a/src/3rdparty/phonon/qt7/mediaobject.mm +++ b/src/3rdparty/phonon/qt7/mediaobject.mm @@ -88,7 +88,7 @@ bool MediaObject::setState(Phonon::State state) emit stateChanged(m_state, prevState); if (m_state != state){ // End-application did something - // upon receiving the signal. + // upon receiving the signal. return false; } } @@ -122,7 +122,7 @@ void MediaObject::inspectGraph() // Inspect the graph to check wether there are any // effects or outputs connected. This will have // influence on the audio system and video system that ends up beeing used: - int prevVideoOutputCount = m_videoOutputCount; + int prevVideoOutputCount = m_videoOutputCount; m_audioEffectCount = 0; m_audioOutputCount = 0; m_videoEffectCount = 0; @@ -134,7 +134,7 @@ void MediaObject::inspectGraph() if (m_videoOutputCount != prevVideoOutputCount){ MediaNodeEvent e1(MediaNodeEvent::VideoOutputCountChanged, &m_videoOutputCount); notify(&e1); - } + } } void MediaObject::setupAudioSystem() @@ -167,14 +167,14 @@ void MediaObject::setupAudioSystem() if (newAudioSystem == m_audioSystem) return; - + // Enable selected audio system: - m_audioSystem = newAudioSystem; + m_audioSystem = newAudioSystem; switch (newAudioSystem){ case AS_Silent: m_audioGraph->stop(); m_videoPlayer->enableAudio(false); - m_nextVideoPlayer->enableAudio(false); + m_nextVideoPlayer->enableAudio(false); m_audioPlayer->enableAudio(false); m_nextAudioPlayer->enableAudio(false); break; @@ -260,7 +260,7 @@ void MediaObject::setSource(const MediaSource &source) return; if (!m_videoPlayer->canPlayMedia()) SET_ERROR("Cannot play media.", FATAL_ERROR) - + // The state might have changed from LoadingState // as a response to an error state change. So we // need to check it before stopping: @@ -382,7 +382,7 @@ void MediaObject::play() if (!m_videoPlayer->canPlayMedia()) return; if (!setState(Phonon::PlayingState)) - return; + return; if (m_audioSystem == AS_Graph){ m_audioGraph->start(); m_mediaObjectAudioNode->setMute(true); @@ -446,7 +446,7 @@ void MediaObject::seek(qint64 milliseconds) m_videoPlayer->seek(milliseconds); m_audioPlayer->seek(m_videoPlayer->currentTime()); m_mediaObjectAudioNode->setMute(false); - + // Update time and cancel pending swap: if (m_currentTime < m_videoPlayer->duration()) m_waitNextSwap = false; @@ -557,7 +557,7 @@ bool MediaObject::isSeekable() const qint64 MediaObject::currentTime() const { IMPLEMENTED_SILENT; - const_cast(this)->updateCurrentTime(); + const_cast(this)->updateCurrentTime(); return m_currentTime; } -- 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 From 870dbc7542beb07b84378f356cbe568a2ae8b7e1 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Thu, 25 Mar 2010 09:19:07 +0100 Subject: Tweak import behaviour The implicit import of types in the same directory/module now imports version -1 (which means all versions). This fixes the Twitter demo. Additionally, the current directory is not added to the imports path. No functionality is lost, as you can import local modules with relative paths for the same effect. Improved docs are on the way. Reviewed-by: mae --- demos/declarative/minehunt/minehunt.qml | 2 +- demos/declarative/photoviewer/photoviewer.qml | 2 +- demos/declarative/samegame/samegame.qml | 2 +- demos/declarative/twitter/twitter.qml | 2 +- .../data/lib/com/nokia/installedtest/InstalledTest.qml | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/demos/declarative/minehunt/minehunt.qml b/demos/declarative/minehunt/minehunt.qml index 9e99706..2ca6c4c 100644 --- a/demos/declarative/minehunt/minehunt.qml +++ b/demos/declarative/minehunt/minehunt.qml @@ -1,5 +1,5 @@ import Qt 4.6 -import MinehuntCore 1.0 +import "MinehuntCore" 1.0 Item { id: field diff --git a/demos/declarative/photoviewer/photoviewer.qml b/demos/declarative/photoviewer/photoviewer.qml index 8feee02..662ea12 100644 --- a/demos/declarative/photoviewer/photoviewer.qml +++ b/demos/declarative/photoviewer/photoviewer.qml @@ -1,5 +1,5 @@ import Qt 4.6 -import PhotoViewerCore 1.0 +import "PhotoViewerCore" 1.0 Rectangle { id: mainWindow diff --git a/demos/declarative/samegame/samegame.qml b/demos/declarative/samegame/samegame.qml index f084ff6..6c58d49 100644 --- a/demos/declarative/samegame/samegame.qml +++ b/demos/declarative/samegame/samegame.qml @@ -1,5 +1,5 @@ import Qt 4.6 -import SamegameCore 1.0 +import "SamegameCore" 1.0 import "SamegameCore/samegame.js" as Logic Rectangle { diff --git a/demos/declarative/twitter/twitter.qml b/demos/declarative/twitter/twitter.qml index 259f79a..94d53f1 100644 --- a/demos/declarative/twitter/twitter.qml +++ b/demos/declarative/twitter/twitter.qml @@ -1,5 +1,5 @@ import Qt 4.6 -import TwitterCore 1.0 as Twitter +import "TwitterCore" 1.0 as Twitter Item { id: screen; width: 320; height: 480 diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest.qml b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest.qml index d8a22a8..38cf6bb 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest.qml @@ -1,2 +1,2 @@ -import Qt 4.6 -Rectangle {} +import Qt 4.6 as Qt +Qt.Rectangle {} -- cgit v0.12 From 7c1fab0905357ece5746269140593794529e6724 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Thu, 25 Mar 2010 09:31:59 +0100 Subject: Add an initial attempt at docs on the new runtime and imports. --- doc/src/declarative/declarativeui.qdoc | 1 + doc/src/declarative/modules.qdoc | 137 ++++++++++++++++++++++----------- doc/src/declarative/qmlruntime.qdoc | 84 ++++++++++++++++---- 3 files changed, 161 insertions(+), 61 deletions(-) diff --git a/doc/src/declarative/declarativeui.qdoc b/doc/src/declarative/declarativeui.qdoc index ca4c5da..69a8216 100644 --- a/doc/src/declarative/declarativeui.qdoc +++ b/doc/src/declarative/declarativeui.qdoc @@ -94,6 +94,7 @@ completely new applications. QML is fully \l {Extending QML in C++}{extensible \o \l {qdeclarativefocus.html}{Keyboard Focus} \o \l {Extending types from QML} \o \l {Dynamic Object Creation} +\o \l {qmlruntime.html}{The Qt Declarative Runtime} \endlist \section1 Reference: diff --git a/doc/src/declarative/modules.qdoc b/doc/src/declarative/modules.qdoc index 53de32c..f90e23b 100644 --- a/doc/src/declarative/modules.qdoc +++ b/doc/src/declarative/modules.qdoc @@ -42,14 +42,79 @@ /*! \page qdeclarativemodules.html \title Modules +\section1 QML Modules. +QUERY: Is a directory with no qmldir really a module? Assumed NO. -A \bold module is a collection of QML types. +A \bold module is a collection of QML types. These types can be defined in QML, or in C++ +through a QDeclarativeExtensionPlugin. They can then be collected into a directory to comprise +a module. + +Additionally a module can also be a collection of types which was compiled into your application, see \l{Extending QML in C++}. + +While a directory containing types can be used to organize QML components, QML modules also contain a \c qmldir file. +This file provides a manifest of all types available in the module, +and allows versioned imports (among other things). A directory containing only QML files or plugins behaves similarly +to a module, but a QML module requires a \c qmldir file (unless it is written in C++ and compiled into your application). + +\section2 The \c qmldir File + +QML modules containing installed files and remote content require a file \c qmldir which specifies the +mapping from all type names to versioned QML files. It is a list of lines of the form: + +\code +# + +plugin [] +\endcode + +# lines are ignored, and can be used for comments. + + lines are used to add QML files as types. + is the type being made available; is a version +number like \c 4.0; is the (relative) +file name of the QML file defining the type. + +plugin [] lines are used to add plugins (QDeclarativeExtensionPlugin subclasses +written in C++) to the module. The line starts with the keyword 'plugin'; is the +name of the library; is an optional argument specifying the full path to the directory +containing the plugin file, if it is omitted then the directory is assumed to be the same as +the directory of the qmldir file. Note that is not usually the same as the file name +of the plugin binary, which is platform dependent e.g. the library MyAppTypes would produce a libMyAppTypes.so on linux and MyAppTypes.dll on windows. + +The same type can be provided by different files in different versions, in which +case later earlier versions (eg. 1.2) must precede earlier versions (eg. 1.0), +since the \e first name-version match is used. + +Installed files do not need to import the module of which they are a part, as they can refer +to the other QML files in the module as relative (local) files. +If the module is imported from a remote location, those files must nevertheless be listed in +the \c qmldir file. Internal files can be marked with the \c internal keyword, to ensure +they are not visible outside the module: + +\code +internal +\endcode + +Installed and remote files \e must be referred to by version information described above, +local files \e may have it. + +The versioning system ensures that a given QML file will work regardless of the version +of installed software, since a versioned import \e only imports types for that version, +leaving other identifiers available, even if the actual installed version might otherwise +use those identifiers. + +\section1 Importing Modules To use types from a module it must be imported using the \c import statement. Successive import statements override earlier import statements, however, since imports have version qualifiers, changes in modules do not alter the semantics of imports. -\section1 Importing Types Defined in C++ +While it is possible to import some modules without specifying a version this is only advisable +during prototyping, where version numbers mean very little. The rest of the time it is recommended that +you take advantage of the versioning capabilities of the language. + +You can import a directory in the same way that you import a module, except that you cannot specify a version +number. This will import all the types in that directory as QML files or as part of plugins. Types \link adding-types defined in C++\endlink can be from types your application defines, standard QML types, or types defined in plugins. To use any such types, you must import @@ -90,7 +155,7 @@ Installed plugins and QML files can both contribute types to the same module. The specification of types to versions is given by a special file, \c qmldir which must exist in the module directory. The syntax is described below. -The \c -L option to the \l {qmlviewer}{viewer} application also adds paths to the import path. +The \c -L option to the \l {qmlviewer}{runtime} application also adds paths to the import path. \section2 Local QML Files @@ -103,62 +168,31 @@ import "path" \endcode This allows all components defined in the directory \c path to be used in -the component where this statement appears. +the component where this statement appears. Because no version number is specified, +all types in the directory will be imported. -In this case, and only this case, it is not necessary for the module directory to include +In this case, and only this case, it is not necessary for the directory to include a \c qmldir file, nor is it necessary to provide a version qualifier. The basis of this is that the files in the subdirectory are assumed to be packaged with the importer, and therefore -they form a single versioned unit. - - -\section2 Remote QML Files - -To import types defined in QML file at arbitrary network locations, a quoted absolute URL is used: +they form a single versioned unit. It is however recommended that you add a qmldir file and create +a QML module, as this provides additional options such as more flexible versioning. If the directory +is a module then you can use a version qualifier, like below \code -import "http://url/.../" 1.0 +import "path" 1.0 \endcode -This works the same as for relative directory imports, except that the target location \e must -include a \c qmldir file, and a version qualifier must be given. - -\section2 The \c qmldir File - -Directories of installed files and remote content must include a file \c qmldir which specifies the -mapping from all type names to versioned QML files. It is a list of lines of the form: - -\code -# - -\endcode - - is the type being made available; is a version -number like \c 4.0; is the (relative) -file name of the QML file defining the type. - -The same type can be provided by different files in different versions, in which -case later earlier versions (eg. 1.2) must precede earlier versions (eg. 1.0), -since the \e first name-version match is used. +\section2 Remote QML Files -Installed files do not need to import the module of which they are a part, as they can refer -to the other QML files in the module as relative (local) files. -If the module is imported from a remote location, those files must nevertheless be listed in -the \c qmldir file. Internal files can be marked with the \c internal keyword, to ensure -they are not visible outside the module: +To import types defined in QML file at arbitrary network locations, a quoted absolute URL is used: \code -internal +import "http://url/.../" 1.0 \endcode -Installed and remote files \e must be referred to by version information described above, -local files \e may have it. - -The versioning system ensures that a given QML file will work regardless of the version -of installed software, since a versioned import \e only imports types for that version, -leaving other identifiers available, even if the actual installed version might otherwise -use those identifiers. - +This works the same as for relative directory imports, except that the target location contain a QML module (\e must +include a \c qmldir file), and a version qualifier must be given. \section1 Namespaces - Named Imports @@ -185,6 +219,17 @@ modules can be imported into the global namespace: import Qt 4.6 as Nokia import Ovi 1.0 as Nokia \endcode + +There is one special module, called Qt, which contains all of the types that are part of +Qt Declarative. While it still needs to be imported, this module can be used in all QML +files. + +While import statements are need to make any types available in QML, the directory of the +current file is implicitly loaded. This is the exact same as if you had added 'import "."' to +every QML file. The effect of this is that you can automatically use Types defined in C++ plugins +or QML files if they reside in the same directory. + + */ /* diff --git a/doc/src/declarative/qmlruntime.qdoc b/doc/src/declarative/qmlruntime.qdoc index 6d3e109..710a030 100644 --- a/doc/src/declarative/qmlruntime.qdoc +++ b/doc/src/declarative/qmlruntime.qdoc @@ -41,32 +41,82 @@ /*! \page qmlruntime.html - \title Qt Declarative UI Viewer (qmlviewer) + \title Qt Declarative UI Runtime \ingroup qttools \keyword qmlviewer - This page documents the \e{Declarative UI Viewer} for the Qt GUI - toolkit. The \c qmlviewer reads a declarative user interface definition + This page documents the \e{Declarative UI Runtime} for the Qt GUI + toolkit, and the \c qml executable which can be used to run apps + written for the runtime. The \c qml executable reads a declarative user interface definition (\c .qml) file and displays the user interface it describes. - qmlviewer is a development tool. It is not intended to be - installed in a production environment. + QML is a runtime, as you can run plain qml files which pull in their required modules. + To run apps with the QML runtime, you can either start the runtime + from your on application (using a QDeclarativeView) or with the simple \c qml application. + The \c qml application can be + installed in a production environment, assuming that it is not already + present in the system. It is generally packaged alongside Qt. - \section1 Options + To deploy an application using the QML runtime, you have two options. You can either write your + own Qt application including a QDeclarative view and deploy it the same as + any other Qt application (not discussed further on this page). Alternatively you can write a main QML file for + your application, and run your application using the \c qml executable. If a qml file + is passed as an argument to the \c qml executable, it will automatically run it. - When run with the \c -help option, qmlviewer shows available options. + Deploying a QML application via the \c qml executable allows for QML only deployments, but can also + include custom C++ modules just as easily. Below is an example of how you might structure + a complex application deployed via the qml runtime, it is a listing of the files that would + be included in the deployment package. - \section1 Dummy Data + \code + MyApp.qml + MyAppCore/qmldir + MyAppCore/libMyAppCore.so + MyAppCore/MyAppCore.dll + MyAppCore/AnAppElement.qml + MyAppCore/AnotherElement.qml + MyAppCore/images/Logo.png + OtherModule/qmldir + OtherModule/OtherElement.qml + \endcode + + Note that this example is for deploying the example to both windows and linux. You will still need to compile the C++ + modules for each target platform, but you can deploy multiple versions of the modules across platforms with different naming conventions, + as the appropriate module file is chosen based on platform naming conventions. The C++ + modules must contain a QDeclarativeExtentionPlugin subclass. + + The application would be executed either with your own application, the command 'qml MyApp.qml' or by + opening the qml file if your system has the \c qml executable registered as the handler for qml files. The MyApp.qml file would have access + to all of the deployed types using the import statements such as the following: - One use of qmlviewer is to allow QML files to be viewed stand-alone, - rather than being loaded from within a Qt program. Qt applications will - usually bind objects and properties into the execution context before - running the QML. To stand-in for such bindings, you can provide dummy - data: create a directory called "dummydata" in the same directory as + \code + import "MyAppCore" + import "OtherModule" 1.0 as Other + \endcode + + \section1 \c qml application functionality + The \c qml application implements some additional functionality to help it serve the role of a launcher + for myriad applications. If you implement your own launcher application, you may also wish to reimplement + some or all of this functionality. However, much of this functionality is intended to aid the prototyping of + qml applications and may not be necessary for a deployed application. + + \section2 Options + + When run with the \c -help option, qml shows available options. + + \section2 Dummy Data + + The secondary use of the qml runtime is to allow QML files to be viewed with + dummy data. This is useful when prototyping the UI, as the dummy data can + be later replaced with actual data and bindings from a C++ plugin. + To provide dummy data: create a directory called "dummydata" in the same directory as the target QML file and create files there with the "qml" extension. All such files will be loaded as QML objects and bound to the root context as a property with the name of the file (without ".qml"). + To replace this with real data, you simply bind the real object to + the root context in C++. + For example, if the Qt application has a "clock.time" property that is a qreal from 0 to 86400 representing the number of seconds since midnight, dummy data for this could be provided by \c dummydata/clock.qml: @@ -76,9 +126,9 @@ Any QML can be used in the dummy data files. You could even animate the fictional data! - \section1 Screen Orientation + \section2 Screen Orientation - A special piece of dummy data which is integrated into the viewer is + A special piece of dummy data which is integrated into the runtime is a simple orientation property. The orientation can be set via the settings menu in the application, or by pressing Ctrl+T to toggle it. @@ -96,4 +146,8 @@ } \endcode + This allows your application to respond to the orientation of the screen changing. The runtime + will automatically update this on some platforms (currently the N900 only) to match the physical + screen's orientation. On other plaforms orientation changes will only happen when explictly asked for. + */ -- cgit v0.12 From a701a744a1e292803823c43aad4d81a9cff25a32 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Thu, 25 Mar 2010 09:33:17 +0100 Subject: Forgot to add a file. Forgot to add these, the primary changes, to commit 870dbc7542beb07b84378f356cbe568a2ae8b7e1 --- src/declarative/qml/qdeclarativeengine.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index d4872e2..164fab7 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -1390,7 +1390,9 @@ struct QDeclarativeEnginePrivate::ImportedNamespace { foreach (const QDeclarativeDirParser::Component &c, qmldircomponents) { if (c.typeName == typeName) { typeWasDeclaredInQmldir = true; - if (c.majorVersion < vmaj || (c.majorVersion == vmaj && vmin >= c.minorVersion)) { + + // importing version -1 means import ALL versions + if ((vmaj == -1) || (c.majorVersion < vmaj || (c.majorVersion == vmaj && vmin >= c.minorVersion))) { QUrl candidate = url.resolved(QUrl(c.fileName)); if (c.internal && base) { if (base->resolved(QUrl(c.fileName)) != candidate) @@ -1479,10 +1481,10 @@ public: QStringList paths; - if (!base.isEmpty()) { - QString baseDir = QFileInfo(toLocalFileOrQrc(base)).path(); - paths += baseDir; - } +// if (!base.isEmpty()) { +// QString baseDir = QFileInfo(toLocalFileOrQrc(base)).path(); +// paths += baseDir; +// } QString applicationDirPath = QCoreApplication::applicationDirPath(); if (!applicationDirPath.isEmpty()) @@ -1542,9 +1544,9 @@ public: // user import paths QStringList paths; // base.. - QString localFileOrQrc = toLocalFileOrQrc(base); - QString localFileOrQrcPath = QFileInfo(localFileOrQrc).path(); - paths += localFileOrQrcPath; +// QString localFileOrQrc = toLocalFileOrQrc(base); +// QString localFileOrQrcPath = QFileInfo(localFileOrQrc).path(); +// paths += localFileOrQrcPath; paths += QDeclarativeEnginePrivate::get(engine)->fileImportPath; QString applicationDirPath = QCoreApplication::applicationDirPath(); -- cgit v0.12 From e38aef4eee8c6a32bd30632576aee17a3d333c2e Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Thu, 11 Mar 2010 13:27:17 +0100 Subject: Doc: Fix links in the ActiveQt framework, and also link to the tools. --- doc/src/frameworks-technologies/activeqt.qdoc | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/doc/src/frameworks-technologies/activeqt.qdoc b/doc/src/frameworks-technologies/activeqt.qdoc index 67b9bb3..5e8473f 100644 --- a/doc/src/frameworks-technologies/activeqt.qdoc +++ b/doc/src/frameworks-technologies/activeqt.qdoc @@ -57,6 +57,7 @@ \brief An overview of Qt's ActiveX and COM integration on Windows. \ingroup platform-specific + \ingroup frameworks-technologies \keyword ActiveQt Qt's ActiveX and COM support allows Qt for Windows developers to: @@ -69,19 +70,23 @@ controls. \endlist - The ActiveQt framework consists of two modules: + The ActiveQt framework consists of two frameworks: \list - \o The \l QAxContainer module is a static - library implementing QObject and QWidget subclasses, QAxObject and - QAxWidget, that act as containers for COM objects and ActiveX - controls. - \o The \l QAxServer module is a static library that implements + \o The \l{Using ActiveX controls and COM objects in Qt}{QAxContainer} + module is a static library implementing QObject and QWidget subclasses, + QAxObject and QAxWidget, that act as containers for COM objects and + ActiveX controls. + \o The \l{Building ActiveX servers and controls with Qt}{QAxServer} + module is a static library that implements functionality for in-process and executable COM servers. This module provides the QAxAggregated, QAxBindable and QAxFactory classes. \endlist + A set of \l{Tools for ActiveQt}{tools} is provided to simplify the + developing and building of Qt projects that use ActiveX. + To build the static libraries, change into the \c activeqt directory (usually \c QTDIR/src/activeqt), and run \c qmake and your make tool in both the \c container and the \c control subdirectory. -- cgit v0.12 From 80cf88a395d61c2dee83d484c91f24437be0c0e0 Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Thu, 25 Mar 2010 12:50:48 +0200 Subject: QMessageBox is smaller than native MessageBox Messageboxes are smaller than native ones. This is due to that native ones have a lot of empty space. To fix this, we define a new custom pixel metrics that is the minimum height of one text line messagebox (aka AknPopUp) on the native side. Then we ensure that the QMessageBox is at least of this height. Additionally we do some minor styling for QMessageBox: - the corners graphics are now as rounded as on native side - the font is set to match the native side - the top margin space is doubled for dialogs, which is rather good approximation of native side Task-number: QTBUG-4875 Reviewed-by: Janne Anttila --- src/gui/dialogs/qmessagebox.cpp | 14 ++++++++++++++ src/gui/styles/qs60style.cpp | 35 +++++++++++++++++++++------------- src/gui/styles/qs60style.h | 3 ++- src/gui/styles/qs60style_p.h | 6 +++--- src/gui/styles/qs60style_s60.cpp | 16 ++++++++++------ util/s60pixelmetrics/pixel_metrics.cpp | 11 +++++++++-- util/s60pixelmetrics/pixel_metrics.h | 4 +++- util/s60pixelmetrics/pm_mapperapp.cpp | 9 ++++++--- 8 files changed, 69 insertions(+), 29 deletions(-) diff --git a/src/gui/dialogs/qmessagebox.cpp b/src/gui/dialogs/qmessagebox.cpp index bd2df9c..ccc925c 100644 --- a/src/gui/dialogs/qmessagebox.cpp +++ b/src/gui/dialogs/qmessagebox.cpp @@ -65,6 +65,10 @@ #include #include +#ifndef QT_NO_STYLE_S60 +#include +#endif + #ifdef Q_WS_WINCE extern bool qt_wince_is_mobile(); //defined in qguifunctions_wince.cpp extern bool qt_wince_is_smartphone();//defined in qguifunctions_wince.cpp @@ -353,6 +357,16 @@ void QMessageBoxPrivate::updateSize() int height = (layout->hasHeightForWidth()) ? layout->totalHeightForWidth(width) : layout->totalMinimumSize().height(); + +#ifndef QT_NO_STYLE_S60 + QS60Style *s60Style = 0; + s60Style = qobject_cast(QApplication::style()); + + //use custom pixel metric to deduce the minimum height of the messagebox + if (s60Style) + height = qMax(height, s60Style->pixelMetric((QStyle::PixelMetric)PM_MessageBoxHeight)); +#endif + q->setFixedSize(width, height); QCoreApplication::removePostedEvents(q, QEvent::LayoutRequest); } diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index af37e6e..2c665fb 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -50,6 +50,7 @@ #include "qcalendarwidget.h" #include "qdial.h" #include "qdialog.h" +#include "qmessagebox.h" #include "qgroupbox.h" #include "qheaderview.h" #include "qlist.h" @@ -91,10 +92,10 @@ static const qreal goldenRatio = 1.618; const layoutHeader QS60StylePrivate::m_layoutHeaders[] = { // *** generated layout data *** -{240,320,1,16,"QVGA Landscape"}, -{320,240,1,16,"QVGA Portrait"}, -{360,640,1,16,"NHD Landscape"}, -{640,360,1,16,"NHD Portrait"}, +{240,320,1,17,"QVGA Landscape"}, +{320,240,1,17,"QVGA Portrait"}, +{360,640,1,17,"NHD Landscape"}, +{640,360,1,17,"NHD Portrait"}, {352,800,1,12,"E90 Landscape"} // *** End of generated data *** }; @@ -103,11 +104,11 @@ const int QS60StylePrivate::m_numberOfLayouts = const short QS60StylePrivate::data[][MAX_PIXELMETRICS] = { // *** generated pixel metrics *** -{5,0,-909,0,0,2,0,0,-1,7,12,19,13,13,6,200,-909,-909,-909,20,13,2,0,0,21,7,18,0,3,3,1,-909,-909,0,1,0,0,12,20,15,15,18,18,1,115,18,0,-909,-909,-909,-909,0,0,16,2,-909,0,0,-909,16,-909,-909,-909,-909,32,18,55,24,55,4,4,4,9,13,-909,5,51,11,5,0,3,3,6,8,3,3,-909,2,-909,-909,-909,-909,5,5,3,1}, -{5,0,-909,0,0,1,0,0,-1,8,14,22,15,15,7,164,-909,-909,-909,19,15,2,0,0,21,8,27,0,4,4,1,-909,-909,0,7,6,0,13,23,17,17,21,21,7,115,21,0,-909,-909,-909,-909,0,0,15,1,-909,0,0,-909,15,-909,-909,-909,-909,32,21,65,27,65,3,3,5,10,15,-909,5,58,13,5,0,4,4,7,9,4,4,-909,2,-909,-909,-909,-909,6,6,3,1}, -{7,0,-909,0,0,2,0,0,-1,25,69,28,19,19,9,258,-909,-909,-909,23,19,26,0,0,32,25,72,0,5,5,2,-909,-909,0,7,21,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,25,2,-909,0,0,-909,25,-909,-909,-909,-909,87,27,77,35,77,13,13,6,8,19,-909,7,74,19,7,0,5,5,8,12,5,5,-909,3,-909,-909,-909,-909,7,7,3,1}, -{7,0,-909,0,0,2,0,0,-1,25,68,28,19,19,9,258,-909,-909,-909,31,19,6,0,0,32,25,60,0,5,5,2,-909,-909,0,7,32,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,26,2,-909,0,0,-909,26,-909,-909,-909,-909,87,27,96,35,96,12,12,6,8,19,-909,7,74,22,7,0,5,5,8,12,5,5,-909,3,-909,-909,-909,-909,7,7,3,1}, -{7,0,-909,0,0,2,0,0,-1,10,20,27,18,18,9,301,-909,-909,-909,29,18,5,0,0,35,7,32,0,5,5,2,-909,-909,0,2,8,0,16,28,21,21,26,26,2,170,26,0,-909,-909,-909,-909,0,0,21,6,-909,0,0,-909,-909,-909,-909,-909,-909,54,26,265,34,265,5,5,6,3,18,-909,7,72,19,7,0,5,6,8,11,6,5,-909,2,-909,-909,-909,-909,5,5,3,1} +{5,0,-909,0,0,2,0,0,-1,7,12,19,13,13,6,200,-909,-909,-909,20,13,2,0,0,21,7,18,0,3,3,1,-909,-909,0,1,0,0,12,20,15,15,18,18,1,115,18,0,-909,-909,-909,-909,0,0,16,2,-909,0,0,-909,16,-909,-909,-909,-909,32,18,55,24,55,4,4,4,9,13,-909,5,51,11,5,0,3,3,6,8,3,3,-909,2,-909,-909,-909,-909,5,5,3,1, 106}, +{5,0,-909,0,0,1,0,0,-1,8,14,22,15,15,7,164,-909,-909,-909,19,15,2,0,0,21,8,27,0,4,4,1,-909,-909,0,7,6,0,13,23,17,17,21,21,7,115,21,0,-909,-909,-909,-909,0,0,15,1,-909,0,0,-909,15,-909,-909,-909,-909,32,21,65,27,65,3,3,5,10,15,-909,5,58,13,5,0,4,4,7,9,4,4,-909,2,-909,-909,-909,-909,6,6,3,1, 106}, +{7,0,-909,0,0,2,0,0,-1,25,69,28,19,19,9,258,-909,-909,-909,23,19,26,0,0,32,25,72,0,5,5,2,-909,-909,0,7,21,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,25,2,-909,0,0,-909,25,-909,-909,-909,-909,87,27,77,35,77,13,13,6,8,19,-909,7,74,19,7,0,5,5,8,12,5,5,-909,3,-909,-909,-909,-909,7,7,3,1, 135}, +{7,0,-909,0,0,2,0,0,-1,25,68,28,19,19,9,258,-909,-909,-909,31,19,6,0,0,32,25,60,0,5,5,2,-909,-909,0,7,32,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,26,2,-909,0,0,-909,26,-909,-909,-909,-909,87,27,96,35,96,12,12,6,8,19,-909,7,74,22,7,0,5,5,8,12,5,5,-909,3,-909,-909,-909,-909,7,7,3,1, 135}, +{7,0,-909,0,0,2,0,0,-1,10,20,27,18,18,9,301,-909,-909,-909,29,18,5,0,0,35,7,32,0,5,5,2,-909,-909,0,2,8,0,16,28,21,21,26,26,2,170,26,0,-909,-909,-909,-909,0,0,21,6,-909,0,0,-909,-909,-909,-909,-909,-909,54,26,265,34,265,5,5,6,3,18,-909,7,72,19,7,0,5,6,8,11,6,5,-909,2,-909,-909,-909,-909,5,5,3,1, 106} // *** End of generated data *** }; @@ -126,7 +127,7 @@ const struct QS60StylePrivate::frameElementCenter QS60StylePrivate::m_frameEleme {SE_ButtonPressed, QS60StyleEnums::SP_QsnFrButtonTbCenterPressed}, {SE_FrameLineEdit, QS60StyleEnums::SP_QsnFrInputCenter}, {SE_ListHighlight, QS60StyleEnums::SP_QsnFrListCenter}, - {SE_OptionsMenu, QS60StyleEnums::SP_QsnFrPopupCenter}, + {SE_PopupBackground, QS60StyleEnums::SP_QsnFrPopupCenter}, {SE_SettingsList, QS60StyleEnums::SP_QsnFrSetOptCenter}, {SE_TableItem, QS60StyleEnums::SP_QsnFrCaleCenter}, {SE_TableHeaderItem, QS60StyleEnums::SP_QsnFrCaleHeadingCenter}, @@ -249,8 +250,8 @@ void QS60StylePrivate::drawSkinElement(SkinElements element, QPainter *painter, case SE_ListHighlight: drawFrame(SF_ListHighlight, painter, rect, flags | SF_PointNorth); break; - case SE_OptionsMenu: - drawFrame(SF_OptionsMenu, painter, rect, flags | SF_PointNorth); + case SE_PopupBackground: + drawFrame(SF_PopupBackground, painter, rect, flags | SF_PointNorth); break; case SE_SettingsList: drawFrame(SF_SettingsList, painter, rect, flags | SF_PointNorth); @@ -636,6 +637,8 @@ void QS60StylePrivate::setFont(QWidget *widget) const fontCategory = QS60StyleEnums::FC_Secondary; } else if (qobject_cast(widget)){ fontCategory = QS60StyleEnums::FC_Title; + } else if (qobject_cast(widget)){ + fontCategory = QS60StyleEnums::FC_Primary; } if (fontCategory != QS60StyleEnums::FC_Undefined) { const bool resolveFontSize = widget->testAttribute(Qt::WA_SetFont) @@ -2215,7 +2218,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti if (QS60StylePrivate::canDrawThemeBackground(option->palette.base(), widget) && option->palette.window().texture().cacheKey() == QS60StylePrivate::m_themePalette->window().texture().cacheKey()) - QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_OptionsMenu, painter, option->rect, flags); + QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_PopupBackground, painter, option->rect, flags); else commonStyleDraws = true; } @@ -2400,6 +2403,12 @@ int QS60Style::pixelMetric(PixelMetric metric, const QStyleOption *option, const else if (metric == PM_LayoutRightMargin) metricValue = QS60StylePrivate::pixelMetric(PM_LayoutLeftMargin); } + + if (widget && (metric == PM_LayoutTopMargin)) + if (widget->windowType() == Qt::Dialog) + //double the top layout margin for dialogs, it is very close to real value + //without having to define custom pixel metric + metricValue *= 2; return metricValue; } diff --git a/src/gui/styles/qs60style.h b/src/gui/styles/qs60style.h index af17843..c878538 100644 --- a/src/gui/styles/qs60style.h +++ b/src/gui/styles/qs60style.h @@ -58,7 +58,8 @@ enum { PM_FrameCornerWidth = QStyle::PM_CustomBase + 1, PM_FrameCornerHeight, PM_BoldLineWidth, - PM_ThinLineWidth + PM_ThinLineWidth, + PM_MessageBoxHeight }; class QS60StylePrivate; diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h index 8bb2f7b..6ce4960 100644 --- a/src/gui/styles/qs60style_p.h +++ b/src/gui/styles/qs60style_p.h @@ -60,7 +60,7 @@ QT_BEGIN_NAMESPACE const int MAX_NON_CUSTOM_PIXELMETRICS = 92; -const int CUSTOMVALUESCOUNT = 4; +const int CUSTOMVALUESCOUNT = 5; const int MAX_PIXELMETRICS = MAX_NON_CUSTOM_PIXELMETRICS + CUSTOMVALUESCOUNT; @@ -411,7 +411,7 @@ public: SE_TabBarTabWestActive, SE_TabBarTabWestInactive, SE_ListHighlight, - SE_OptionsMenu, + SE_PopupBackground, SE_SettingsList, SE_TableItem, SE_TableHeaderItem, @@ -432,7 +432,7 @@ public: SF_ButtonPressed, SF_FrameLineEdit, SF_ListHighlight, - SF_OptionsMenu, + SF_PopupBackground, SF_SettingsList, SF_TableItem, SF_TableHeaderItem, diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index 75ed0c7..1138d20 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -983,16 +983,20 @@ TRect QS60StyleModeSpecifics::innerRectFromElement(QS60StylePrivate::SkinFrameEl switch(frameElement) { case QS60StylePrivate::SF_PanelBackground: // panel should have slightly slimmer border to enable thin line of background graphics between closest component - widthShrink = widthShrink-2; - heightShrink = heightShrink-2; + widthShrink = widthShrink - 2; + heightShrink = heightShrink - 2; break; case QS60StylePrivate::SF_ToolTip: - widthShrink = widthShrink>>1; - heightShrink = heightShrink>>1; + widthShrink = widthShrink >> 1; + heightShrink = heightShrink >> 1; break; case QS60StylePrivate::SF_ListHighlight: - widthShrink = widthShrink-2; - heightShrink = heightShrink-2; + widthShrink = widthShrink - 2; + heightShrink = heightShrink - 2; + break; + case QS60StylePrivate::SF_PopupBackground: + widthShrink = widthShrink + 5; + heightShrink = heightShrink + 5; break; default: break; diff --git a/util/s60pixelmetrics/pixel_metrics.cpp b/util/s60pixelmetrics/pixel_metrics.cpp index beb785e..814e185 100644 --- a/util/s60pixelmetrics/pixel_metrics.cpp +++ b/util/s60pixelmetrics/pixel_metrics.cpp @@ -50,7 +50,7 @@ // so that we can keep dynamic and static values inline. // Please adjust version data if correcting dynamic PM calculations. const TInt KPMMajorVersion = 1; -const TInt KPMMinorVersion = 16; +const TInt KPMMinorVersion = 17; TPixelMetricsVersion PixelMetrics::Version() { @@ -869,7 +869,7 @@ TInt PixelMetrics::PixelMetricValue(QStyle::PixelMetric metric) // The difference of center piece from border tell the frame width. if ( value == QStyle::PM_FocusFrameHMargin) { - //use topleft for horizontal as S60 uses different values for right and left borders + //use topleft for horizontal as S60 uses different values for right and left borders value = listSinglePaneText.TextRect().iTl.iX - highlightRect.Rect().iTl.iX; } else @@ -1003,6 +1003,13 @@ TInt PixelMetrics::PixelMetricValue(QStyle::PixelMetric metric) case QStyle::PM_Custom_ThinLineWidth: value = 1; break; + case QStyle::PM_Custom_MessageBoxHeight: + { + TAknLayoutRect popupRect; + popupRect.LayoutRect(mainPaneRect, AknLayoutScalable_Avkon::popup_window_general(0)); + value = popupRect.Rect().Height(); + } + break; case QStyle::PM_ButtonShiftHorizontal: case QStyle::PM_ButtonShiftVertical: value = 0; diff --git a/util/s60pixelmetrics/pixel_metrics.h b/util/s60pixelmetrics/pixel_metrics.h index 3536c0e..4b0f57e 100644 --- a/util/s60pixelmetrics/pixel_metrics.h +++ b/util/s60pixelmetrics/pixel_metrics.h @@ -185,7 +185,9 @@ NONSHARABLE_CLASS( QStyle ) // Bold line width PM_Custom_BoldLineWidth, // Thin line width - PM_Custom_ThinLineWidth + PM_Custom_ThinLineWidth, + // Height of a popup info messagebox + PM_Custom_MessageBoxHeight }; }; diff --git a/util/s60pixelmetrics/pm_mapperapp.cpp b/util/s60pixelmetrics/pm_mapperapp.cpp index acc6137..a88499d 100644 --- a/util/s60pixelmetrics/pm_mapperapp.cpp +++ b/util/s60pixelmetrics/pm_mapperapp.cpp @@ -155,7 +155,7 @@ void CPixelMetricsMapperAppUi::HandleCommandL( TInt aCommand ) Exit(); break; case ECmdSwitchOutput: - { + { HBufC* buffer = HBufC::NewLC( 100 ); TPtr bufferPtr = buffer->Des(); TBool last = ETrue; @@ -166,7 +166,7 @@ void CPixelMetricsMapperAppUi::HandleCommandL( TInt aCommand ) else bufferPtr.Append(_L("screen.")); ShowL( *buffer, last ); - } + } break; case ECmdStatus: { @@ -323,7 +323,7 @@ void CPixelMetricsMapperAppUi::HandleCommandL( TInt aCommand ) TInt myValue = KErrNotFound; for (;;) { - if (index==QStyle::PM_Custom_ThinLineWidth) + if (index==QStyle::PM_Custom_MessageBoxHeight) { last = ETrue; } @@ -656,6 +656,9 @@ void CPixelMetricsMapperAppUi::ShowSingleValueL(TInt& aPixelMetric, TInt& aValue case QStyle::PM_Custom_BoldLineWidth: bufferPtr.Append(_L("C_BoldLineWidth: ")); break; + case QStyle::PM_Custom_MessageBoxHeight: + bufferPtr.Append(_L("C_MsgBoxHeight: ")); + break; default: bufferPtr.Append(_L("Default: ")); break; -- cgit v0.12 From d7fe2d90fe5a1ac5a29a5bc65eb5657d4d539563 Mon Sep 17 00:00:00 2001 From: mread Date: Thu, 25 Mar 2010 10:58:57 +0000 Subject: Symbian event loop priority drop not used in Symbian^4 The priority drop hack used in the Symbian version of Qt's event dispatcher is not needed from Symbian^4, as the viewsrv panics, which it was designed to prevent, are disabled. This change disables the priority drop code when Qt is compiled in a Symbian^4 environment, using the SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS define as a key. This will improve system and performance predictability, as app priorities will be more stable. It also gives a slight performance boost to app startup in the order of 10ms. Reviewed-by: Jason Barron --- src/corelib/kernel/qeventdispatcher_symbian.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp index 191be6c..ca44264 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian.cpp +++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp @@ -50,6 +50,13 @@ QT_BEGIN_NAMESPACE +#ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS +// when the system UI is Qt based, priority drop is not needed as CPU starved processes will not be killed. +#undef QT_SYMBIAN_PRIORITY_DROP +#else +#define QT_SYMBIAN_PRIORITY_DROP +#endif + #define WAKE_UP_PRIORITY CActive::EPriorityStandard #define TIMER_PRIORITY CActive::EPriorityHigh #define NULLTIMER_PRIORITY CActive::EPriorityLow @@ -697,6 +704,7 @@ bool QEventDispatcherSymbian::processEvents ( QEventLoop::ProcessEventsFlags fla bool handledSymbianEvent = false; m_interrupt = false; +#ifdef QT_SYMBIAN_PRIORITY_DROP /* * This QTime variable is used to measure the time it takes to finish * the event loop. If we take too long in the loop, other processes @@ -714,6 +722,7 @@ bool QEventDispatcherSymbian::processEvents ( QEventLoop::ProcessEventsFlags fla } timeState = FirstRun; TProcessPriority priority; +#endif while (1) { if (block) { @@ -727,10 +736,12 @@ bool QEventDispatcherSymbian::processEvents ( QEventLoop::ProcessEventsFlags fla CActiveScheduler::Current()->WaitForAnyRequest(); } +#ifdef QT_SYMBIAN_PRIORITY_DROP if (timeState == SubsequentRun) { time.start(); timeState = TimeStarted; } +#endif TInt error; handledSymbianEvent = CActiveScheduler::RunIfReady(error, KMinTInt); @@ -747,6 +758,7 @@ bool QEventDispatcherSymbian::processEvents ( QEventLoop::ProcessEventsFlags fla break; } block = false; +#ifdef QT_SYMBIAN_PRIORITY_DROP if (timeState == TimeStarted && time.elapsed() > 100) { priority = m_processHandle.Priority(); m_processHandle.SetPriority(EPriorityBackground); @@ -759,6 +771,7 @@ bool QEventDispatcherSymbian::processEvents ( QEventLoop::ProcessEventsFlags fla } if (timeState == FirstRun) timeState = SubsequentRun; +#endif }; emit awake(); -- cgit v0.12 From 32c6e01bf00bc45363685eb10c51e8b68b4fde89 Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Thu, 25 Mar 2010 14:01:34 +0200 Subject: Fix for submenu placement for QMenus in Symbian. Task-number: QTBUG-5992 Reviewed-By: Sami Merila --- src/gui/styles/qs60style.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 2c665fb..65191a4 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -2389,13 +2389,6 @@ int QS60Style::pixelMetric(PixelMetric metric, const QStyleOption *option, const if (metricValue == KNotFound) metricValue = QCommonStyle::pixelMetric(metric, option, widget); - if (metric == PM_SubMenuOverlap && widget) { - const QMenu *menu = qobject_cast(widget); - if (menu && menu->activeAction() && menu->activeAction()->menu()) { - const int menuWidth = menu->activeAction()->menu()->sizeHint().width(); - metricValue = -menuWidth; - } - } //if layout direction is mirrored, switch left and right border margins if (option && option->direction == Qt::RightToLeft) { if (metric == PM_LayoutLeftMargin) -- cgit v0.12 From 96ac1964b827ef01ef2edb6411ecb7540ed76ce2 Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Thu, 25 Mar 2010 14:27:56 +0100 Subject: Prevents a useless repaint with QGraphicsItem cache mode. No repaint is triggered anymore when setting the cache mode to DeviceCoordinateMode when already using that mode. Also added an autotest for checking repaints when setting cache modes. Task-number: QTBUG-9391 Reviewed-by: ahanssen --- src/gui/graphicsview/qgraphicsitem.cpp | 3 +- tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 73 ++++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index f110a5c..1b707b0 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1883,7 +1883,8 @@ void QGraphicsItem::setCacheMode(CacheMode mode, const QSize &logicalCacheSize) d_ptr->cacheMode = mode; bool noVisualChange = (mode == NoCache && lastMode == NoCache) || (mode == NoCache && lastMode == DeviceCoordinateCache) - || (mode == DeviceCoordinateCache && lastMode == NoCache); + || (mode == DeviceCoordinateCache && lastMode == NoCache) + || (mode == DeviceCoordinateCache && lastMode == DeviceCoordinateCache); if (mode == NoCache) { d_ptr->removeExtraItemCache(); } else { diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 75fb337..2b507cb 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -384,6 +384,7 @@ private slots: void tabChangesFocus(); void tabChangesFocus_data(); void cacheMode(); + void cacheMode2(); void updateCachedItemAfterMove(); void deviceTransform_data(); void deviceTransform(); @@ -6926,6 +6927,78 @@ void tst_QGraphicsItem::cacheMode() QCOMPARE(testerChild2->repaints, 6); } +void tst_QGraphicsItem::cacheMode2() +{ + QGraphicsScene scene(0, 0, 100, 100); + QGraphicsView view(&scene); + view.resize(150, 150); + view.show(); + QApplication::setActiveWindow(&view); + QTest::qWaitForWindowShown(&view); + + // Increase the probability of window activation + // not causing another repaint of test items. + QTest::qWait(50); + + EventTester *tester = new EventTester; + scene.addItem(tester); + QTest::qWait(10); + QTRY_COMPARE(tester->repaints, 1); + + // Switching from NoCache to NoCache (no repaint) + tester->setCacheMode(QGraphicsItem::NoCache); + QTest::qWait(50); + QTRY_COMPARE(tester->repaints, 1); + + // Switching from NoCache to DeviceCoordinateCache (no repaint) + tester->setCacheMode(QGraphicsItem::DeviceCoordinateCache); + QTest::qWait(50); + QTRY_COMPARE(tester->repaints, 1); + + // Switching from DeviceCoordinateCache to DeviceCoordinateCache (no repaint) + tester->setCacheMode(QGraphicsItem::DeviceCoordinateCache); + QTest::qWait(50); + QTRY_COMPARE(tester->repaints, 1); + + // Switching from DeviceCoordinateCache to NoCache (no repaint) + tester->setCacheMode(QGraphicsItem::NoCache); + QTest::qWait(50); + QTRY_COMPARE(tester->repaints, 1); + + // Switching from NoCache to ItemCoordinateCache (repaint) + tester->setCacheMode(QGraphicsItem::ItemCoordinateCache); + QTest::qWait(50); + QTRY_COMPARE(tester->repaints, 2); + + // Switching from ItemCoordinateCache to ItemCoordinateCache (no repaint) + tester->setCacheMode(QGraphicsItem::ItemCoordinateCache); + QTest::qWait(50); + QTRY_COMPARE(tester->repaints, 2); + + // Switching from ItemCoordinateCache to ItemCoordinateCache with different size (repaint) + tester->setCacheMode(QGraphicsItem::ItemCoordinateCache, QSize(100, 100)); + QTest::qWait(50); + QTRY_COMPARE(tester->repaints, 3); + + // Switching from ItemCoordinateCache to NoCache (repaint) + tester->setCacheMode(QGraphicsItem::NoCache); + QTest::qWait(50); + QTRY_COMPARE(tester->repaints, 4); + + // Switching from DeviceCoordinateCache to ItemCoordinateCache (repaint) + tester->setCacheMode(QGraphicsItem::DeviceCoordinateCache); + QTest::qWait(50); + QTRY_COMPARE(tester->repaints, 4); + tester->setCacheMode(QGraphicsItem::ItemCoordinateCache); + QTest::qWait(50); + QTRY_COMPARE(tester->repaints, 5); + + // Switching from ItemCoordinateCache to DeviceCoordinateCache (repaint) + tester->setCacheMode(QGraphicsItem::DeviceCoordinateCache); + QTest::qWait(50); + QTRY_COMPARE(tester->repaints, 6); +} + void tst_QGraphicsItem::updateCachedItemAfterMove() { // A simple item that uses ItemCoordinateCache -- cgit v0.12 From 9a11225c71748ccd6ff7e5a3c1f8d8670e699ca8 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Thu, 25 Mar 2010 14:32:10 +0100 Subject: Correct documentation for ObjectReplacementCharacter and ReplacementCh. Reviewed-by: Marius Storm-Olsen --- src/corelib/tools/qchar.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/corelib/tools/qchar.cpp b/src/corelib/tools/qchar.cpp index 08cb863..3635e7b 100644 --- a/src/corelib/tools/qchar.cpp +++ b/src/corelib/tools/qchar.cpp @@ -381,8 +381,12 @@ QT_BEGIN_NAMESPACE \value Null A QChar with this value isNull(). \value Nbsp Non-breaking space. - \value ReplacementCharacter - \value ObjectReplacementCharacter The character shown when a font has no glyph for a certain codepoint. The square character is normally used. + \value ReplacementCharacter The character shown when a font has no glyph + for a certain codepoint. A special question mark character is often + used. Codecs use this codepoint when input data cannot be + represented in Unicode. + \value ObjectReplacementCharacter Used to represent an object such as an + image when such objects cannot be presented. \value ByteOrderMark \value ByteOrderSwapped \value ParagraphSeparator -- cgit v0.12 From 656c02f128c56177c48b3de47f7b1e17dbbfa4d3 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Thu, 25 Mar 2010 14:52:53 +0100 Subject: QNAM HTTP: Fix crazy crash when exiting application This fixes a crash in tst_qnetworkreply and in some QtWebKit based browsers. It was related to adding a QPointer on an already deleted QHttpNetworkConnection object. By converting an existing normal pointer to a QPointer we set it a 0-pointer and are safe. https://bugs.webkit.org/show_bug.cgi?id=36290 Reviewed-by: joao Reviewed-by: gabi --- src/network/access/qhttpnetworkconnectionchannel.cpp | 2 +- src/network/access/qhttpnetworkconnectionchannel_p.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index 82bc14f..0804498 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -939,7 +939,7 @@ void QHttpNetworkConnectionChannel::_q_error(QAbstractSocket::SocketError socket errorCode = QNetworkReply::UnknownNetworkError; break; } - QPointer that = connection; + QPointer that = connection; QString errorString = connection->d_func()->errorDetail(errorCode, socket, socket->errorString()); if (send2Reply) { if (reply) { diff --git a/src/network/access/qhttpnetworkconnectionchannel_p.h b/src/network/access/qhttpnetworkconnectionchannel_p.h index 5032d2b..6ec47c1 100644 --- a/src/network/access/qhttpnetworkconnectionchannel_p.h +++ b/src/network/access/qhttpnetworkconnectionchannel_p.h @@ -138,7 +138,7 @@ public: {} void setConnection(QHttpNetworkConnection *c) {connection = c;} - QHttpNetworkConnection *connection; + QPointer connection; void init(); void close(); -- cgit v0.12 From cc22a14f3d2159a8f760b44e3fe1636a3721ce95 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Thu, 25 Mar 2010 16:18:52 +0100 Subject: tst_qnetworkreply: Fix side effect, add another test Fix a test that had a side effect. But actually do the side effect in the last test: Have a QNetworkReply that is parented to the application so it gets destructed after the QNetworkAccessManager. Reviewed-by: gabi --- tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index 261e613..71ee2d0 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -275,6 +275,9 @@ private Q_SLOTS: void ignoreSslErrorsListWithSlot_data(); void ignoreSslErrorsListWithSlot(); #endif + + // NOTE: This test must be last! + void parentingRepliesToTheApp(); }; QT_BEGIN_NAMESPACE @@ -3831,7 +3834,7 @@ void tst_QNetworkReply::httpConnectionCount() for (int i = 0; i < 10; i++) { QNetworkRequest request (QUrl("http://127.0.0.1:" + QString::number(server.serverPort()) + "/" + QString::number(i))); QNetworkReply* reply = manager.get(request); - reply->setParent(this); + reply->setParent(&server); } int pendingConnectionCount = 0; @@ -4105,5 +4108,13 @@ void tst_QNetworkReply::ignoreSslErrorsListWithSlot() #endif // QT_NO_OPENSSL +// NOTE: This test must be last testcase in tst_qnetworkreply! +void tst_QNetworkReply::parentingRepliesToTheApp() +{ + QNetworkRequest request (QUrl("http://" + QtNetworkSettings::serverName())); + manager.get(request)->setParent(this); // parent to this object + manager.get(request)->setParent(qApp); // parent to the app +} + QTEST_MAIN(tst_QNetworkReply) #include "tst_qnetworkreply.moc" -- cgit v0.12 From 43e1cffb16c2eea54392f5c56210b10abb2f044e Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Thu, 25 Mar 2010 17:01:45 +0100 Subject: QNAM HTTP: Symbian compile fix --- src/network/access/qhttpnetworkconnectionchannel_p.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/network/access/qhttpnetworkconnectionchannel_p.h b/src/network/access/qhttpnetworkconnectionchannel_p.h index 6ec47c1..4a2f8ad 100644 --- a/src/network/access/qhttpnetworkconnectionchannel_p.h +++ b/src/network/access/qhttpnetworkconnectionchannel_p.h @@ -65,6 +65,7 @@ #include #include +#include "qhttpnetworkconnection_p.h" #ifndef QT_NO_HTTP -- cgit v0.12 From 7c36400a998b6d4cff34d7cb783f8e228a3e3621 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Fri, 26 Mar 2010 08:14:45 +1000 Subject: Fix OpenVG build on non-Symbian platforms. Reviewed-by: trustme --- src/openvg/qpixmapdata_vg.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/openvg/qpixmapdata_vg.cpp b/src/openvg/qpixmapdata_vg.cpp index d602790..7efec2b 100644 --- a/src/openvg/qpixmapdata_vg.cpp +++ b/src/openvg/qpixmapdata_vg.cpp @@ -45,8 +45,10 @@ #include "qvg_p.h" #include "qvgimagepool_p.h" +#if defined(Q_OS_SYMBIAN) #include #include +#endif #ifdef QT_SYMBIAN_SUPPORTS_SGIMAGE #include typedef EGLImageKHR (*pfnEglCreateImageKHR)(EGLDisplay, EGLContext, EGLenum, EGLClientBuffer, EGLint*); -- cgit v0.12 From 1e8eb507a7624a1847f3da067f45d1637d47150a Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Fri, 26 Mar 2010 08:27:02 +1000 Subject: Fix another off-by-1 error in OpenVG image painting. Off in the vertical direction this time; previously was horizontal. Task-number: QT-2999 Reviewed-by: Jason Barron --- src/openvg/qpaintengine_vg.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp index 4a97a6f..ce6e21b 100644 --- a/src/openvg/qpaintengine_vg.cpp +++ b/src/openvg/qpaintengine_vg.cpp @@ -538,7 +538,7 @@ void QVGPaintEnginePrivate::updateTransform(QPaintDevice *pdev) // adds 0.5 to each co-ordinate. QTransform viewport2(1.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, - 0.0f, devh, 1.0f); + 0.0f, devh + 1, 1.0f); imageTransform = transform * viewport2; // Calculate the scaling factor to use for turning cosmetic pens -- cgit v0.12 From de85d147d38acb1d9dd3feacf968c72cb74490e8 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Fri, 26 Mar 2010 09:12:26 +1000 Subject: Ensure both qMin() parameters are the same type. --- src/declarative/graphicsitems/qdeclarativepathview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp index f3d6137..c98b006 100644 --- a/src/declarative/graphicsitems/qdeclarativepathview.cpp +++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp @@ -772,7 +772,7 @@ void QDeclarativePathView::mouseReleaseEvent(QGraphicsSceneMouseEvent *) 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); + qreal dist = qMin(qreal(d->model->count()-1), qreal(d->model->count()) * v2 / (accel * 2.0) + 0.25); // round to nearest item. if (velocity > 0.) dist = qRound(dist + d->offset) - d->offset; -- cgit v0.12 From 75e793d0ff07fd094918cf00c4cd0e10dad6bfa8 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Thu, 25 Mar 2010 10:56:29 +1000 Subject: Remove int parameter from ListModel countChanged() to be consistent with other classes with countChanged() signals. --- src/declarative/util/qdeclarativelistmodel.cpp | 6 +++--- src/declarative/util/qdeclarativelistmodel_p.h | 2 +- src/declarative/util/qdeclarativelistmodelworkeragent.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp index 3e25234..3904458 100644 --- a/src/declarative/util/qdeclarativelistmodel.cpp +++ b/src/declarative/util/qdeclarativelistmodel.cpp @@ -365,7 +365,7 @@ void QDeclarativeListModel::clear() if (!m_isWorkerCopy) { emit itemsRemoved(0, cleared); - emit countChanged(0); + emit countChanged(); } } @@ -390,7 +390,7 @@ void QDeclarativeListModel::remove(int index) if (!m_isWorkerCopy) { emit itemsRemoved(index, 1); - emit countChanged(this->count()); + emit countChanged(); } } @@ -424,7 +424,7 @@ void QDeclarativeListModel::insert(int index, const QScriptValue& valuemap) bool ok = m_flat ? m_flat->insert(index, valuemap) : m_nested->insert(index, valuemap); if (ok && !m_isWorkerCopy) { emit itemsInserted(index, 1); - emit countChanged(this->count()); + emit countChanged(); } } diff --git a/src/declarative/util/qdeclarativelistmodel_p.h b/src/declarative/util/qdeclarativelistmodel_p.h index 6a0426b..d09062e 100644 --- a/src/declarative/util/qdeclarativelistmodel_p.h +++ b/src/declarative/util/qdeclarativelistmodel_p.h @@ -91,7 +91,7 @@ public: QDeclarativeListModelWorkerAgent *agent(); Q_SIGNALS: - void countChanged(int); + void countChanged(); private: friend class QDeclarativeListModelParser; diff --git a/src/declarative/util/qdeclarativelistmodelworkeragent.cpp b/src/declarative/util/qdeclarativelistmodelworkeragent.cpp index 2951262..0e38632 100644 --- a/src/declarative/util/qdeclarativelistmodelworkeragent.cpp +++ b/src/declarative/util/qdeclarativelistmodelworkeragent.cpp @@ -229,7 +229,7 @@ bool QDeclarativeListModelWorkerAgent::event(QEvent *e) } if (cc) - emit m_orig->countChanged(m_copy->count()); + emit m_orig->countChanged(); } } -- cgit v0.12 From 7b42ee836b8cc1ae345d1d24d4419f0c6b77c97d Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Thu, 25 Mar 2010 10:58:56 +1000 Subject: Clean up --- src/declarative/util/qdeclarativexmllistmodel.cpp | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp index f7beeaa..e148469 100644 --- a/src/declarative/util/qdeclarativexmllistmodel.cpp +++ b/src/declarative/util/qdeclarativexmllistmodel.cpp @@ -173,22 +173,6 @@ public: return job.queryId; } - QList > modelData() { - QMutexLocker locker(&m_mutex); - return m_modelData; - } - - QList insertedItemRanges() { - QMutexLocker locker(&m_mutex); - return m_insertedItemRanges; - } - - QList removedItemRanges() { - QMutexLocker locker(&m_mutex); - return m_removedItemRanges; - } - - Q_SIGNALS: void queryCompleted(const QDeclarativeXmlQueryResult &); @@ -254,13 +238,10 @@ void QDeclarativeXmlQuery::doQueryJob() query.setQuery(job.namespaces + job.query); query.evaluateTo(&r); - //qDebug() << r; - //always need a single root element QByteArray xml = "\n" + r.toUtf8() + ""; QBuffer b(&xml); b.open(QIODevice::ReadOnly); - //qDebug() << xml; QString namespaces = QLatin1String("declare namespace dummy=\"http://qtsotware.com/dummy\";\n") + job.namespaces; QString prefix = QLatin1String("doc($inputDocument)/dummy:items") + @@ -278,7 +259,6 @@ void QDeclarativeXmlQuery::doQueryJob() if (item.isAtomicValue()) count = item.toAtomicValue().toInt(); } - //qDebug() << count; job.data = xml; m_prefix = namespaces + prefix + QLatin1Char('/'); -- cgit v0.12 From 778e1fd21f5a6c94656dfbb99a7613656d0569a1 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Thu, 25 Mar 2010 14:44:35 +1000 Subject: Fix where data() is called before xml is loaded. Also add status tests. --- src/declarative/util/qdeclarativexmllistmodel.cpp | 6 ++- .../tst_qdeclarativexmllistmodel.cpp | 43 ++++++++++++++++++++++ 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp index e148469..3e08854 100644 --- a/src/declarative/util/qdeclarativexmllistmodel.cpp +++ b/src/declarative/util/qdeclarativexmllistmodel.cpp @@ -532,7 +532,7 @@ QHash QDeclarativeXmlListModel::data(int index, const QList & for (int i = 0; i < roles.size(); ++i) { int role = roles.at(i); int roleIndex = d->roles.indexOf(role); - rv.insert(role, roleIndex == -1 ? QVariant() : d->data.at(roleIndex).at(index)); + rv.insert(role, roleIndex == -1 ? QVariant() : d->data.value(roleIndex).value(index)); } return rv; } @@ -541,7 +541,7 @@ QVariant QDeclarativeXmlListModel::data(int index, int role) const { Q_D(const QDeclarativeXmlListModel); int roleIndex = d->roles.indexOf(role); - return (roleIndex == -1) ? QVariant() : d->data.at(roleIndex).at(index); + return (roleIndex == -1) ? QVariant() : d->data.value(roleIndex).value(index); } /*! @@ -728,6 +728,8 @@ void QDeclarativeXmlListModel::componentComplete() Otherwise, items are only added if the model does not already contain items with matching key role values. + + \sa XmlRole::isKey */ void QDeclarativeXmlListModel::reload() { diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp index 81cc922..e3aa5cc 100644 --- a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp +++ b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp @@ -69,6 +69,8 @@ private slots: void roles(); void roleErrors(); void uniqueRoleNames(); + void status(); + void data(); void reload(); void useKeys(); void useKeys_data(); @@ -247,6 +249,47 @@ void tst_qdeclarativexmllistmodel::uniqueRoleNames() delete model; } +void tst_qdeclarativexmllistmodel::status() +{ + QDeclarativeXmlListModel *model; + model = new QDeclarativeXmlListModel; + QCOMPARE(model->status(), QDeclarativeXmlListModel::Null); + + model->setXml(""); + QCOMPARE(model->status(), QDeclarativeXmlListModel::Ready); + delete model; + + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); + model = qobject_cast(component.create()); + QVERIFY(model != 0); + QCOMPARE(model->status(), QDeclarativeXmlListModel::Loading); + + QTRY_COMPARE(model->count(), 9); + QCOMPARE(model->status(), QDeclarativeXmlListModel::Ready); + + delete model; +} + +void tst_qdeclarativexmllistmodel::data() +{ + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); + QDeclarativeXmlListModel *model = qobject_cast(component.create()); + QVERIFY(model != 0); + + QHash blank; + for (int i=0; iroles().count(); i++) + blank.insert(model->roles()[i], QVariant()); + for (int i=0; i<9; i++) { + QCOMPARE(model->data(i, model->roles()), blank); + for (int j=0; jroles().count(); j++) { + QCOMPARE(model->data(i, j), QVariant()); + } + } + QTRY_COMPARE(model->count(), 9); + + delete model; +} + void tst_qdeclarativexmllistmodel::reload() { // If no keys are used, the model should be rebuilt from scratch when -- cgit v0.12 From f75961dfd20b82f2f5e2a4b7feaf59c841a93f6b Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Fri, 26 Mar 2010 09:49:39 +1000 Subject: Remove some Script {} docs --- src/declarative/graphicsitems/qdeclarativeitem.cpp | 16 ++-- src/declarative/qml/qdeclarativescript.cpp | 88 ---------------------- src/declarative/qml/qml.pri | 1 - src/declarative/util/qdeclarativestategroup.cpp | 12 ++- 4 files changed, 12 insertions(+), 105 deletions(-) delete mode 100644 src/declarative/qml/qdeclarativescript.cpp diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index f575fdb..dd6056e 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -1575,7 +1575,7 @@ void QDeclarativeItemPrivate::parentProperty(QObject *o, void *rv, QDeclarativeN Item { Text {} Rectangle {} - Script {} + Timer {} } \endqml @@ -1587,7 +1587,7 @@ void QDeclarativeItemPrivate::parentProperty(QObject *o, void *rv, QDeclarativeN Rectangle {} ] resources: [ - Script {} + Timer {} ] } \endqml @@ -2356,13 +2356,11 @@ QDeclarativeListProperty QDeclarativeItem::transitions() example: \qml - Script { - function toggle() { - if (button.state == 'On') - button.state = 'Off'; - else - button.state = 'On'; - } + function toggle() { + if (button.state == 'On') + button.state = 'Off'; + else + button.state = 'On'; } \endqml diff --git a/src/declarative/qml/qdeclarativescript.cpp b/src/declarative/qml/qdeclarativescript.cpp deleted file mode 100644 index ac4b2c1..0000000 --- a/src/declarative/qml/qdeclarativescript.cpp +++ /dev/null @@ -1,88 +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 QtDeclarative module 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$ -** -****************************************************************************/ - -// This is just a dummy file to include the documentation - -/*! - \qmlclass Script QDeclarativeScript - \since 4.7 - \brief The Script element provides a way to add JavaScript code snippets in QML. - \ingroup group_utility - - The Script element is used to add convenient JavaScript "glue" methods to - your Qt Declarative application or component. - - An example: - - \qml - Script { - function debugMyComponent() { - console.log(text.text); - console.log(otherinterestingitem.property); - } - } - MouseArea { onClicked: debugMyComponent() } - \endqml - - \note While it is possible to use any JavaScript code within a Script element, - it is recommended that the code be limited to defining functions. The Script - element executes JavaScript as soon as it is specified, so - when defining a component, this may be done before the execution context is - fully specified. As a result, some properties or items may not be - accessible. You can avoid this problem by limiting your JavaScript to - defining functions that are only executed later once the context is fully - defined. - - \sa {JavaScript Blocks} -*/ - -/*! - \qmlproperty string Script::script - \default - The JavaScript code to be executed. -*/ - -/*! - \qmlproperty url Script::source - - Specifies a source file containing JavaScript code. This can be used instead - of providing inline JavaScript code in the Script element. -*/ diff --git a/src/declarative/qml/qml.pri b/src/declarative/qml/qml.pri index fc8ba50..e2f0c67 100644 --- a/src/declarative/qml/qml.pri +++ b/src/declarative/qml/qml.pri @@ -36,7 +36,6 @@ SOURCES += \ $$PWD/qdeclarativesqldatabase.cpp \ $$PWD/qmetaobjectbuilder.cpp \ $$PWD/qdeclarativewatcher.cpp \ - $$PWD/qdeclarativescript.cpp \ $$PWD/qdeclarativecleanup.cpp \ $$PWD/qdeclarativepropertycache.cpp \ $$PWD/qdeclarativenotifier.cpp \ diff --git a/src/declarative/util/qdeclarativestategroup.cpp b/src/declarative/util/qdeclarativestategroup.cpp index 083e87d..bc4582c 100644 --- a/src/declarative/util/qdeclarativestategroup.cpp +++ b/src/declarative/util/qdeclarativestategroup.cpp @@ -206,13 +206,11 @@ QDeclarativeListProperty QDeclarativeStateGroup::transit example: \qml - Script { - function toggle() { - if (button.state == 'On') - button.state = 'Off'; - else - button.state = 'On'; - } + function toggle() { + if (button.state == 'On') + button.state = 'Off'; + else + button.state = 'On'; } \endqml -- cgit v0.12 From 1b10d66a05208ca24d12d062fd7c7d15a01df436 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Fri, 26 Mar 2010 10:06:23 +1000 Subject: Document Particles module import. --- doc/src/declarative/elements.qdoc | 1 - src/imports/particles/qdeclarativeparticles.cpp | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/doc/src/declarative/elements.qdoc b/doc/src/declarative/elements.qdoc index e35d67c..e62d546 100644 --- a/doc/src/declarative/elements.qdoc +++ b/doc/src/declarative/elements.qdoc @@ -97,7 +97,6 @@ The following table lists the QML elements provided by the Qt Declarative module \o \list -\o \l Script \o \l Connections \o \l Component \o \l Timer diff --git a/src/imports/particles/qdeclarativeparticles.cpp b/src/imports/particles/qdeclarativeparticles.cpp index 83be59b..e69c235 100644 --- a/src/imports/particles/qdeclarativeparticles.cpp +++ b/src/imports/particles/qdeclarativeparticles.cpp @@ -623,6 +623,8 @@ void QDeclarativeParticlesPrivate::updateOpacity(QDeclarativeParticle &p, int ag \brief The Particles object generates and moves particles. \inherits Item + Particles are available in the Qt.labs.particles 1.0 module. + This element provides preliminary support for particles in QML, and may be heavily changed or removed in later versions. @@ -640,6 +642,9 @@ void QDeclarativeParticlesPrivate::updateOpacity(QDeclarativeParticle &p, int ag snow, the lower one has particles expelled up like a fountain. \qml +import Qt 4.6 +import Qt.labs.particles 1.0 + Rectangle { width: 240 height: 320 -- cgit v0.12 From 9f6b271e942d48cef566891bd9d9712e147df3a2 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 26 Mar 2010 10:07:25 +1000 Subject: Add missing files from 72599ca45c416f2f0a9654412c14a148ca3d728c --- src/declarative/qml/qdeclarativefastproperties.cpp | 92 ++++++++++++++++++++++ src/declarative/qml/qdeclarativefastproperties_p.h | 75 ++++++++++++++++++ 2 files changed, 167 insertions(+) create mode 100644 src/declarative/qml/qdeclarativefastproperties.cpp create mode 100644 src/declarative/qml/qdeclarativefastproperties_p.h diff --git a/src/declarative/qml/qdeclarativefastproperties.cpp b/src/declarative/qml/qdeclarativefastproperties.cpp new file mode 100644 index 0000000..088d329 --- /dev/null +++ b/src/declarative/qml/qdeclarativefastproperties.cpp @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** 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 QtDeclarative module 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 "qdeclarativefastproperties_p.h" + +#include + +QT_BEGIN_NAMESPACE + +// Adding entries to the QDeclarativeFastProperties class allows the QML +// binding optimizer to bypass Qt's meta system and read and, more +// importantly, subscribe to properties directly. Any property that is +// primarily read from bindings is a candidate for inclusion as a fast +// property. + +QDeclarativeFastProperties::QDeclarativeFastProperties() +{ + add(&QDeclarativeItem::staticMetaObject, QDeclarativeItem::staticMetaObject.indexOfProperty("parent"), + QDeclarativeItemPrivate::parentProperty); +} + +int QDeclarativeFastProperties::accessorIndexForProperty(const QMetaObject *metaObject, int propertyIndex) +{ + Q_ASSERT(metaObject); + Q_ASSERT(propertyIndex >= 0); + + // Find the "real" metaObject + while (metaObject->propertyOffset() > propertyIndex) + metaObject = metaObject->superClass(); + + QHash, int>::Iterator iter = + m_index.find(qMakePair(metaObject, propertyIndex)); + if (iter != m_index.end()) + return *iter; + else + return -1; +} + +void QDeclarativeFastProperties::add(const QMetaObject *metaObject, int propertyIndex, Accessor accessor) +{ + Q_ASSERT(metaObject); + Q_ASSERT(propertyIndex >= 0); + + // Find the "real" metaObject + while (metaObject->propertyOffset() > propertyIndex) + metaObject = metaObject->superClass(); + + QPair data = qMakePair(metaObject, propertyIndex); + int accessorIndex = m_accessors.count(); + m_accessors.append(accessor); + m_index.insert(data, accessorIndex); +} + +QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativefastproperties_p.h b/src/declarative/qml/qdeclarativefastproperties_p.h new file mode 100644 index 0000000..60df947 --- /dev/null +++ b/src/declarative/qml/qdeclarativefastproperties_p.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** 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 QtDeclarative module 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$ +** +****************************************************************************/ + +#ifndef QDECLARATIVEFASTPROPERTIES_P_H +#define QDECLARATIVEFASTPROPERTIES_P_H + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +class QObject; +class QDeclarativeNotifierEndpoint; +class QDeclarativeFastProperties +{ +public: + typedef void (*Accessor)(QObject *object, void *output, QDeclarativeNotifierEndpoint *endpoint); + + QDeclarativeFastProperties(); + + Accessor accessor(int index) const { return m_accessors.at(index); } + int accessorIndexForProperty(const QMetaObject *, int); + +private: + void add(const QMetaObject *, int, Accessor); + + QHash, int> m_index; + QVector m_accessors; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QDECLARATIVEFASTPROPERTIES_P_H -- cgit v0.12 From 1dc40aa28ee93ee067c18349dc54e7b8b4f4dc4f Mon Sep 17 00:00:00 2001 From: Joona Petrell Date: Thu, 25 Mar 2010 15:55:30 +1000 Subject: Add Symbian deploy section for qml import plugins Task-number: QTBUG-9364 Reviewed-by: jbarron --- demos/declarative/minehunt/minehunt.pro | 15 +++++++++++++++ mkspecs/features/symbian/data_caging_paths.prf | 1 + src/imports/multimedia/multimedia.pro | 11 +++++++++++ src/imports/particles/particles.pro | 11 +++++++++++ src/imports/webkit/webkit.pro | 11 +++++++++++ src/imports/widgets/widgets.pro | 11 +++++++++++ 6 files changed, 60 insertions(+) diff --git a/demos/declarative/minehunt/minehunt.pro b/demos/declarative/minehunt/minehunt.pro index 2df33e6..03059c7 100644 --- a/demos/declarative/minehunt/minehunt.pro +++ b/demos/declarative/minehunt/minehunt.pro @@ -23,3 +23,18 @@ MinehuntCore_sources.path = $$[QT_INSTALL_DEMOS]/declarative/minehunt/MinehuntCo INSTALLS = sources MinehuntCore_sources target +symbian:{ + load(data_caging_paths) + TARGET.EPOCALLOWDLLDATA = 1 + TARGET.CAPABILITY = CAP_GENERAL_DLL + include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) + + importFiles.sources = minehunt.dll \ + MinehuntCore/Explosion.qml \ + MinehuntCore/pics \ + MinehuntCore/qmldir + importFiles.path = $$QT_IMPORTS_BASE_DIR/MinehuntCore + DEPLOYMENT = importFiles +} + +INSTALLS = sources MinehuntCore_sources target diff --git a/mkspecs/features/symbian/data_caging_paths.prf b/mkspecs/features/symbian/data_caging_paths.prf index 6f40bb5..ae9bc09 100644 --- a/mkspecs/features/symbian/data_caging_paths.prf +++ b/mkspecs/features/symbian/data_caging_paths.prf @@ -75,6 +75,7 @@ exists($${EPOCROOT}epoc32/include/data_caging_paths.prf) { } isEmpty(QT_PLUGINS_BASE_DIR): QT_PLUGINS_BASE_DIR = /$$RESOURCE_FILES_DIR/qt$${QT_LIBINFIX}/plugins +isEmpty(QT_IMPORTS_BASE_DIR): QT_IMPORTS_BASE_DIR = /$$RESOURCE_FILES_DIR/qt/imports isEmpty(HW_ZDIR): HW_ZDIR = epoc32/data/z isEmpty(REG_RESOURCE_DIR): REG_RESOURCE_DIR = /private/10003a3f/apps isEmpty(REG_RESOURCE_IMPORT_DIR): REG_RESOURCE_IMPORT_DIR = /private/10003a3f/import/apps \ No newline at end of file diff --git a/src/imports/multimedia/multimedia.pro b/src/imports/multimedia/multimedia.pro index 16b3ace..8792e2b 100644 --- a/src/imports/multimedia/multimedia.pro +++ b/src/imports/multimedia/multimedia.pro @@ -23,4 +23,15 @@ target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH qmldir.files += $$QT_BUILD_TREE/imports/$$TARGETPATH/qmldir qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH +symbian:{ + load(data_caging_paths) + include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) + + importFiles.sources = multimedia.dll \ + qmldir + importFiles.path = $$QT_IMPORTS_BASE_DIR/$$TARGETPATH + + DEPLOYMENT = importFiles +} + INSTALLS += target qmldir diff --git a/src/imports/particles/particles.pro b/src/imports/particles/particles.pro index 02d9ea6..53d9c24 100644 --- a/src/imports/particles/particles.pro +++ b/src/imports/particles/particles.pro @@ -17,4 +17,15 @@ target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH qmldir.files += $$QT_BUILD_TREE/imports/$$TARGETPATH/qmldir qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH +symbian:{ + load(data_caging_paths) + include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) + + importFiles.sources = particles.dll \ + qmldir + importFiles.path = $$QT_IMPORTS_BASE_DIR/$$TARGETPATH + + DEPLOYMENT = importFiles +} + INSTALLS += target qmldir diff --git a/src/imports/webkit/webkit.pro b/src/imports/webkit/webkit.pro index ef08efe..a11f87f 100644 --- a/src/imports/webkit/webkit.pro +++ b/src/imports/webkit/webkit.pro @@ -14,4 +14,15 @@ target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH qmldir.files += $$QT_BUILD_TREE/imports/$$TARGETPATH/qmldir qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH +symbian:{ + load(data_caging_paths) + include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) + + importFiles.sources = webkitqmlplugin.dll \ + qmldir + importFiles.path = $$QT_IMPORTS_BASE_DIR/$$TARGETPATH + + DEPLOYMENT = importFiles +} + INSTALLS += target qmldir diff --git a/src/imports/widgets/widgets.pro b/src/imports/widgets/widgets.pro index aa09b3c..bf2576d 100644 --- a/src/imports/widgets/widgets.pro +++ b/src/imports/widgets/widgets.pro @@ -18,4 +18,15 @@ target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH qmldir.files += $$QT_BUILD_TREE/imports/$$TARGETPATH/qmldir qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH +symbian:{ + load(data_caging_paths) + include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) + + importFiles.sources = widgets.dll \ + qmldir + importFiles.path = $$QT_IMPORTS_BASE_DIR/$$TARGETPATH + + DEPLOYMENT = importFiles +} + INSTALLS += target qmldir -- cgit v0.12 From 2fff42f7fa4a38e8f5b709493562a81b75762da6 Mon Sep 17 00:00:00 2001 From: Joona Petrell Date: Thu, 25 Mar 2010 18:06:19 +1000 Subject: Add declarative subdir to examples.pro Task-number: Reviewed-by: Martin Jones --- examples/examples.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/examples.pro b/examples/examples.pro index ec5cc5f9..b046167 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -57,6 +57,7 @@ embedded:SUBDIRS += qws contains(QT_CONFIG, opengl): SUBDIRS += opengl contains(QT_CONFIG, openvg): SUBDIRS += openvg contains(QT_CONFIG, dbus): SUBDIRS += dbus +contains(QT_CONFIG, declarative): SUBDIRS += declarative win32: SUBDIRS += activeqt contains(QT_CONFIG, xmlpatterns): SUBDIRS += xmlpatterns contains(DEFINES, QT_NO_CURSOR): SUBDIRS -= mainwindows -- cgit v0.12 From 4e5b463542385f4f4b3fc640926988dfb949ce54 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Fri, 26 Mar 2010 11:08:38 +1000 Subject: Really fix qMin() parameter types. --- src/declarative/graphicsitems/qdeclarativepathview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp index c98b006..783387c 100644 --- a/src/declarative/graphicsitems/qdeclarativepathview.cpp +++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp @@ -772,7 +772,7 @@ void QDeclarativePathView::mouseReleaseEvent(QGraphicsSceneMouseEvent *) 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), qreal(d->model->count()) * v2 / (accel * 2.0) + 0.25); + qreal dist = qMin(qreal(d->model->count()-1), qreal(qreal(d->model->count()) * v2 / (accel * 2.0) + 0.25)); // round to nearest item. if (velocity > 0.) dist = qRound(dist + d->offset) - d->offset; -- cgit v0.12 From 47c0d01115aebd4cbad3ceca463c74411eeef9f9 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 26 Mar 2010 11:25:20 +1000 Subject: Remove Q prefix from the validators. --- src/declarative/QmlChanges.txt | 1 + .../graphicsitems/qdeclarativeitemsmodule.cpp | 6 +++--- src/declarative/graphicsitems/qdeclarativetextinput.cpp | 17 +++++++++-------- .../qdeclarativetextinput/data/validators.qml | 7 +++---- .../qdeclarativetextinput/tst_qdeclarativetextinput.cpp | 1 - 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt index 9a55bde..d35a4c2 100644 --- a/src/declarative/QmlChanges.txt +++ b/src/declarative/QmlChanges.txt @@ -1,6 +1,7 @@ ============================================================================= The changes below are pre Qt 4.7.0 beta +Removed Q-prefix from validators (IntValidator, DoubleValidator, and RegExpValidator) PathView: offset property now uses range 0-1.0 rather than 0-100 ListView, GridView::positionViewAtIndex() gained a 'mode' parameter Removed Qt.playSound (replaced by SoundEffect element) diff --git a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp index 07d7f4d..f422365 100644 --- a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp @@ -114,10 +114,10 @@ void QDeclarativeItemModule::defineModule() qmlRegisterType("Qt",4,6,"PathPercent"); qmlRegisterType("Qt",4,6,"PathQuad"); qmlRegisterType("Qt",4,6,"PathView"); - qmlRegisterType("Qt",4,6,"QIntValidator"); + qmlRegisterType("Qt",4,6,"IntValidator"); #if (QT_VERSION >= QT_VERSION_CHECK(4,7,0)) - qmlRegisterType("Qt",4,7,"QDoubleValidator"); - qmlRegisterType("Qt",4,7,"QRegExpValidator"); + qmlRegisterType("Qt",4,7,"DoubleValidator"); + qmlRegisterType("Qt",4,7,"RegExpValidator"); #endif qmlRegisterType("Qt",4,6,"Rectangle"); qmlRegisterType("Qt",4,6,"Repeater"); diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index b049728..f57ffc1 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -428,20 +428,21 @@ void QDeclarativeTextInput::setFocusOnPress(bool b) } /*! - \qmlproperty QValidator* TextInput::validator + \qmlproperty Validator TextInput::validator - Allows you to set a QValidator on the TextInput. When a validator is set + Allows you to set a validator on the TextInput. When a validator is set the TextInput will only accept input which leaves the text property in an acceptable or intermediate state. The accepted signal will only be sent if the text is in an acceptable state when enter is pressed. - Currently supported validators are QIntValidator, QDoubleValidator and - QRegExpValidator. For details, refer to their C++ documentation and remember + Currently supported validators are IntValidator, DoubleValidator and + RegExpValidator. For details, refer to their C++ documentation (QIntValidator, + QDoubleValidator, and QRegExpValidator) and remember that all Q_PROPERTIES are accessible from Qml. A brief usage guide follows: - QIntValidator and QDoubleValidator both are controllable through two properties, - top and bottom. The difference is that for QIntValidator the top and bottom properties - should be integers, and for QDoubleValidator they should be doubles. QRegExpValidator + IntValidator and DoubleValidator both are controllable through two properties, + top and bottom. The difference is that for IntValidator the top and bottom properties + should be integers, and for DoubleValidator they should be doubles. RegExpValidator has a single string property, regExp, which should be set to the regular expression to be used for validation. An example of using validators is shown below, which allows input of integers between 11 and 31 into the text input: @@ -449,7 +450,7 @@ void QDeclarativeTextInput::setFocusOnPress(bool b) \code import Qt 4.6 TextInput{ - validator: QIntValidator{bottom: 11; top: 31;} + validator: IntValidator{bottom: 11; top: 31;} focus: true } \endcode diff --git a/tests/auto/declarative/qdeclarativetextinput/data/validators.qml b/tests/auto/declarative/qdeclarativetextinput/data/validators.qml index 0c81548..efe7570 100644 --- a/tests/auto/declarative/qdeclarativetextinput/data/validators.qml +++ b/tests/auto/declarative/qdeclarativetextinput/data/validators.qml @@ -9,14 +9,13 @@ Item { Column{ TextInput { id: intInput; - validator: QIntValidator{top: 11; bottom: 2} + validator: IntValidator{top: 11; bottom: 2} } TextInput { id: dblInput; - validator: QDoubleValidator{top: 12.12; bottom: 2.93; decimals: 2; notation: QDoubleValidator.StandardNotation} + validator: DoubleValidator{top: 12.12; bottom: 2.93; decimals: 2; notation: DoubleValidator.StandardNotation} } TextInput { id: strInput; - //Requires QTBUG-8025 to be implemented first - //validator: QRegExpValidator { regExp: /[a-zA-z]{2,4}/;} + validator: RegExpValidator { regExp: RegExp(/[a-zA-z]{2,4}/) } } } diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp index febcec3..84e7182 100644 --- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp +++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp @@ -463,7 +463,6 @@ void tst_qdeclarativetextinput::validators() QVERIFY(strInput->hasFocus() == true); QTest::keyPress(canvas, Qt::Key_1); QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10); - QEXPECT_FAIL("","Will not work until QTBUG-8025 is resolved", Abort); QCOMPARE(strInput->text(), QLatin1String("")); QCOMPARE(strInput->hasAcceptableInput(), false); QTest::keyPress(canvas, Qt::Key_A); -- cgit v0.12 From f096fb75c20b82e89e74bb48b7e82fcdfe3f06de Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 26 Mar 2010 12:22:01 +1000 Subject: Add autotest for QTBUG-9367. --- tests/auto/declarative/qdeclarativeecmascript/data/regExp.qml | 7 +++++++ tests/auto/declarative/qdeclarativeecmascript/testtypes.h | 5 +++++ .../qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp | 11 +++++++++++ 3 files changed, 23 insertions(+) create mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/regExp.qml diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/regExp.qml b/tests/auto/declarative/qdeclarativeecmascript/data/regExp.qml new file mode 100644 index 0000000..0dc404b --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/regExp.qml @@ -0,0 +1,7 @@ +import Qt.test 1.0 + +MyQmlObject{ + id: obj + objectName: "obj" + regExp: /[a-zA-z]/ +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h index 72dc3bb..faad8b7 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h +++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h @@ -90,6 +90,7 @@ class MyQmlObject : public QObject Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty NOTIFY objectChanged) Q_PROPERTY(QDeclarativeListProperty objectListProperty READ objectListProperty CONSTANT) Q_PROPERTY(int resettableProperty READ resettableProperty WRITE setResettableProperty RESET resetProperty) + Q_PROPERTY(QRegExp regExp READ regExp WRITE setRegExp) public: MyQmlObject(): m_methodCalled(false), m_methodIntCalled(false), m_object(0), m_value(0), m_resetProperty(13) {} @@ -138,6 +139,9 @@ public: void setResettableProperty(int v) { m_resetProperty = v; } void resetProperty() { m_resetProperty = 13; } + QRegExp regExp() { return m_regExp; } + void setRegExp(const QRegExp ®Exp) { m_regExp = regExp; } + signals: void basicSignal(); void argumentSignal(int a, QString b, qreal c); @@ -162,6 +166,7 @@ private: QList m_objectQList; int m_value; int m_resetProperty; + QRegExp m_regExp; }; QML_DECLARE_TYPEINFO(MyQmlObject, QML_HAS_ATTACHED_PROPERTIES) diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 87d73a0..041fd4d 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -131,6 +131,7 @@ private slots: void bug1(); void dynamicCreationCrash(); + void regExpBug(); void callQtInvokables(); private: @@ -1241,6 +1242,16 @@ void tst_qdeclarativeecmascript::dynamicCreationCrash() QVERIFY(created == 0); } +//QTBUG-9367 +void tst_qdeclarativeecmascript::regExpBug() +{ + QDeclarativeComponent component(&engine, TEST_FILE("regExp.qml")); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QEXPECT_FAIL("", "QTBUG-9367", Continue); + QCOMPARE(object->regExp().pattern(), QLatin1String("[a-zA-z]")); +} + void tst_qdeclarativeecmascript::callQtInvokables() { MyInvokableObject o; -- cgit v0.12 From 6da3b5b7e49c17cb7159eb9fd752abe45c1e2fac Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 26 Mar 2010 12:38:49 +1000 Subject: Update test. --- tests/auto/declarative/qdeclarativelistview/data/listviewtest.qml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/auto/declarative/qdeclarativelistview/data/listviewtest.qml b/tests/auto/declarative/qdeclarativelistview/data/listviewtest.qml index 1c1b3f8..cc64c3f 100644 --- a/tests/auto/declarative/qdeclarativelistview/data/listviewtest.qml +++ b/tests/auto/declarative/qdeclarativelistview/data/listviewtest.qml @@ -85,12 +85,10 @@ Rectangle { } color: ListView.isCurrentItem ? "lightsteelblue" : "white" ListView.onRemove: SequentialAnimation { - ScriptAction { script: console.log("Fix PropertyAction with attached properties") } -/* PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: true } NumberAnimation { target: wrapper; property: "scale"; to: 0; duration: 250; easing.type: "InOutQuad" } PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: false } -*/ + } } }, -- cgit v0.12 From 7e60531cc1b70c660dd5635b5d105894a49954f2 Mon Sep 17 00:00:00 2001 From: Justin McPherson Date: Fri, 26 Mar 2010 13:43:10 +1000 Subject: Phonon qt7; Compile fixes after merge. --- src/3rdparty/phonon/qt7/audionode.mm | 15 +++++++++------ src/3rdparty/phonon/qt7/backendinfo.mm | 12 ++++++------ src/3rdparty/phonon/qt7/mediaobjectaudionode.mm | 2 ++ src/3rdparty/phonon/qt7/quicktimeaudioplayer.mm | 2 ++ src/3rdparty/phonon/qt7/quicktimemetadata.mm | 2 ++ 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/3rdparty/phonon/qt7/audionode.mm b/src/3rdparty/phonon/qt7/audionode.mm index cb9e82f..77cd627 100644 --- a/src/3rdparty/phonon/qt7/audionode.mm +++ b/src/3rdparty/phonon/qt7/audionode.mm @@ -68,12 +68,15 @@ void AudioNode::createAndConnectAUNodes() << QString(!FindNextComponent(0, &description) ? "ERROR: COMPONENT NOT FOUND!" : "OK!")) OSStatus err = noErr; -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 - if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) - err = AUGraphAddNode(m_audioGraph->audioGraphRef(), &description, &m_auNode); - else -#endif - err = AUGraphNewNode(m_audioGraph->audioGraphRef(), &description, 0, 0, &m_auNode); + + // The proper function to call here is AUGraphAddNode() but the type has + // changed between 10.5 and 10.6. it's still OK to call this function, but + // if we want to use the proper thing we need to move over to + // AudioComponentDescription everywhere, which is very similar to the + // ComponentDescription, but a different size. however, + // AudioComponentDescription only exists on 10.6+. More fun than we need to + // deal with at the moment, so we'll take the "deprecated" warning instead. + err = AUGraphNewNode(m_audioGraph->audioGraphRef(), &description, 0, 0, &m_auNode); BACKEND_ASSERT2(err != kAUGraphErr_OutputNodeErr, "A MediaObject can only be connected to one audio output device.", FATAL_ERROR) BACKEND_ASSERT2(err == noErr, "Could not create new AUNode.", FATAL_ERROR) diff --git a/src/3rdparty/phonon/qt7/backendinfo.mm b/src/3rdparty/phonon/qt7/backendinfo.mm index e173f05..d84e014 100644 --- a/src/3rdparty/phonon/qt7/backendinfo.mm +++ b/src/3rdparty/phonon/qt7/backendinfo.mm @@ -15,6 +15,12 @@ along with this library. If not, see . */ +#import +#ifdef QUICKTIME_C_API_AVAILABLE + #include + #undef check // avoid name clash; +#endif + #include "backendinfo.h" #include "backendheader.h" @@ -22,12 +28,6 @@ #include #include -#import - -#ifdef QUICKTIME_C_API_AVAILABLE - #include - #undef check // avoid name clash; -#endif QT_BEGIN_NAMESPACE diff --git a/src/3rdparty/phonon/qt7/mediaobjectaudionode.mm b/src/3rdparty/phonon/qt7/mediaobjectaudionode.mm index 66d6041..39b0d4e 100644 --- a/src/3rdparty/phonon/qt7/mediaobjectaudionode.mm +++ b/src/3rdparty/phonon/qt7/mediaobjectaudionode.mm @@ -15,6 +15,8 @@ along with this library. If not, see . */ +#import + #include "mediaobjectaudionode.h" #include "quicktimeaudioplayer.h" #include "quicktimevideoplayer.h" diff --git a/src/3rdparty/phonon/qt7/quicktimeaudioplayer.mm b/src/3rdparty/phonon/qt7/quicktimeaudioplayer.mm index 61c97cc..aefec02 100644 --- a/src/3rdparty/phonon/qt7/quicktimeaudioplayer.mm +++ b/src/3rdparty/phonon/qt7/quicktimeaudioplayer.mm @@ -15,6 +15,8 @@ along with this library. If not, see . */ +#import + #include "quicktimeaudioplayer.h" #include "quicktimevideoplayer.h" #include "audiograph.h" diff --git a/src/3rdparty/phonon/qt7/quicktimemetadata.mm b/src/3rdparty/phonon/qt7/quicktimemetadata.mm index 851e707..4ae3e2c 100644 --- a/src/3rdparty/phonon/qt7/quicktimemetadata.mm +++ b/src/3rdparty/phonon/qt7/quicktimemetadata.mm @@ -15,6 +15,8 @@ along with this library. If not, see . */ +#import + #include "quicktimemetadata.h" #include "quicktimevideoplayer.h" -- cgit v0.12 From b66a253318de90e69ce864621b7c323d98c18783 Mon Sep 17 00:00:00 2001 From: Justin McPherson Date: Fri, 26 Mar 2010 13:43:32 +1000 Subject: Phonon core; compile fixes after merge. --- src/3rdparty/phonon/phonon/audiodataoutput.cpp | 2 -- src/3rdparty/phonon/phonon/audiooutput.cpp | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/3rdparty/phonon/phonon/audiodataoutput.cpp b/src/3rdparty/phonon/phonon/audiodataoutput.cpp index 6c737c2..3a7d3a1 100644 --- a/src/3rdparty/phonon/phonon/audiodataoutput.cpp +++ b/src/3rdparty/phonon/phonon/audiodataoutput.cpp @@ -62,7 +62,5 @@ void AudioDataOutputPrivate::setupBackendObject() } // namespace Phonon -#include "audiodataoutput.moc" - #undef PHONON_CLASSNAME // vim: sw=4 ts=4 tw=80 diff --git a/src/3rdparty/phonon/phonon/audiooutput.cpp b/src/3rdparty/phonon/phonon/audiooutput.cpp index 932a875..e94caad 100644 --- a/src/3rdparty/phonon/phonon/audiooutput.cpp +++ b/src/3rdparty/phonon/phonon/audiooutput.cpp @@ -31,6 +31,7 @@ #include "pulsesupport.h" #include +#include #define PHONON_CLASSNAME AudioOutput #define IFACES2 AudioOutputInterface42 -- cgit v0.12 From 33f7ae1c2edf7c414a5f8b3af79c9529718c29b1 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Fri, 26 Mar 2010 14:28:44 +1000 Subject: Do not call parent implementation if we accept the keyPressEvent in GridView and ListView delegates. --- src/declarative/graphicsitems/qdeclarativegridview.cpp | 6 +++--- src/declarative/graphicsitems/qdeclarativelistview.cpp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp index de0cb04..17f74db 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview.cpp +++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp @@ -1552,9 +1552,6 @@ qreal QDeclarativeGridView::maxXExtent() const void QDeclarativeGridView::keyPressEvent(QKeyEvent *event) { Q_D(QDeclarativeGridView); - QDeclarativeFlickable::keyPressEvent(event); - if (event->isAccepted()) - return; if (d->model && d->model->count() && d->interactive) { d->moveReason = QDeclarativeGridViewPrivate::SetIndex; int oldCurrent = currentIndex(); @@ -1580,6 +1577,9 @@ void QDeclarativeGridView::keyPressEvent(QKeyEvent *event) } } d->moveReason = QDeclarativeGridViewPrivate::Other; + QDeclarativeFlickable::keyPressEvent(event); + if (event->isAccepted()) + return; event->ignore(); } diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index 8a70c07..85fcc27 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -2124,9 +2124,6 @@ qreal QDeclarativeListView::maxXExtent() const void QDeclarativeListView::keyPressEvent(QKeyEvent *event) { Q_D(QDeclarativeListView); - QDeclarativeFlickable::keyPressEvent(event); - if (event->isAccepted()) - return; if (d->model && d->model->count() && d->interactive) { if ((d->orient == QDeclarativeListView::Horizontal && event->key() == Qt::Key_Left) @@ -2151,6 +2148,9 @@ void QDeclarativeListView::keyPressEvent(QKeyEvent *event) } } } + QDeclarativeFlickable::keyPressEvent(event); + if (event->isAccepted()) + return; event->ignore(); } -- cgit v0.12 From 09a40e13174b9f34007ce9fbd98e06b4e48c1954 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Fri, 26 Mar 2010 14:33:04 +1000 Subject: Control of image rendered size (esp. SVG). Add Translate transform. Image::sourceWidth and Image::sourceHeight read/write properties. Task-number: QTBUG-8984 --- examples/declarative/images/content/lemonade.jpg | Bin 0 -> 6645 bytes examples/declarative/images/images.qml | 70 +++++++++ src/declarative/graphicsitems/graphicsitems.pri | 2 + .../graphicsitems/qdeclarativeborderimage.cpp | 23 +-- .../graphicsitems/qdeclarativeimage.cpp | 26 ++++ .../graphicsitems/qdeclarativeimagebase.cpp | 58 ++++++- .../graphicsitems/qdeclarativeimagebase_p.h | 9 ++ .../graphicsitems/qdeclarativeimagebase_p_p.h | 2 + src/declarative/graphicsitems/qdeclarativeitem.cpp | 38 ++++- .../graphicsitems/qdeclarativeitemsmodule.cpp | 2 + .../graphicsitems/qdeclarativetranslate.cpp | 159 +++++++++++++++++++ .../graphicsitems/qdeclarativetranslate_p.h | 92 +++++++++++ src/declarative/util/qdeclarativepixmapcache.cpp | 172 ++++++++++++++------- src/declarative/util/qdeclarativepixmapcache_p.h | 9 +- .../declarative/qdeclarativeimage/data/big.jpeg | Bin 0 -> 1700081 bytes .../declarative/qdeclarativeimage/data/big256.png | Bin 0 -> 3566 bytes .../declarative/qdeclarativeimage/data/heart.png | Bin 0 -> 12577 bytes .../declarative/qdeclarativeimage/data/heart.svg | 55 +++++++ .../qdeclarativeimage/data/heart200.png | Bin 0 -> 8063 bytes .../qdeclarativeimage/tst_qdeclarativeimage.cpp | 65 +++++++- 20 files changed, 696 insertions(+), 86 deletions(-) create mode 100644 examples/declarative/images/content/lemonade.jpg create mode 100644 examples/declarative/images/images.qml create mode 100644 src/declarative/graphicsitems/qdeclarativetranslate.cpp create mode 100644 src/declarative/graphicsitems/qdeclarativetranslate_p.h create mode 100644 tests/auto/declarative/qdeclarativeimage/data/big.jpeg create mode 100644 tests/auto/declarative/qdeclarativeimage/data/big256.png create mode 100644 tests/auto/declarative/qdeclarativeimage/data/heart.png create mode 100644 tests/auto/declarative/qdeclarativeimage/data/heart.svg create mode 100644 tests/auto/declarative/qdeclarativeimage/data/heart200.png diff --git a/examples/declarative/images/content/lemonade.jpg b/examples/declarative/images/content/lemonade.jpg new file mode 100644 index 0000000..db445c9 Binary files /dev/null and b/examples/declarative/images/content/lemonade.jpg differ diff --git a/examples/declarative/images/images.qml b/examples/declarative/images/images.qml new file mode 100644 index 0000000..82848df --- /dev/null +++ b/examples/declarative/images/images.qml @@ -0,0 +1,70 @@ +import Qt 4.6 + +Rectangle { + color: "white" + width: grid.width + 50 + height: grid.height + 50 + + Grid { + x: 25; y: 25 + id: grid + columns: 3 + + Image { + source: "content/lemonade.jpg" + } + + Image { + sourceWidth: 50 + sourceHeight: 50 + source: "content/lemonade.jpg" + } + + Image { + sourceWidth: 50 + sourceHeight: 50 + smooth: true + source: "content/lemonade.jpg" + } + + Image { + scale: 1/3 + source: "content/lemonade.jpg" + } + + Image { + scale: 1/3 + sourceWidth: 50 + sourceHeight: 50 + source: "content/lemonade.jpg" + } + + Image { + scale: 1/3 + sourceWidth: 50 + sourceHeight: 50 + smooth: true + source: "content/lemonade.jpg" + } + + Image { + width: 50; height: 50; transform: Translate { x: 50 } + source: "content/lemonade.jpg" + } + + Image { + width: 50; height: 50; transform: Translate { x: 50 } + sourceWidth: 50 + sourceHeight: 50 + source: "content/lemonade.jpg" + } + + Image { + width: 50; height: 50; transform: Translate { x: 50 } + sourceWidth: 50 + sourceHeight: 50 + smooth: true + source: "content/lemonade.jpg" + } + } +} diff --git a/src/declarative/graphicsitems/graphicsitems.pri b/src/declarative/graphicsitems/graphicsitems.pri index d30651b..af76a67 100644 --- a/src/declarative/graphicsitems/graphicsitems.pri +++ b/src/declarative/graphicsitems/graphicsitems.pri @@ -39,6 +39,7 @@ HEADERS += \ $$PWD/qdeclarativerepeater_p.h \ $$PWD/qdeclarativerepeater_p_p.h \ $$PWD/qdeclarativescalegrid_p_p.h \ + $$PWD/qdeclarativetranslate_p.h \ $$PWD/qdeclarativetextinput_p.h \ $$PWD/qdeclarativetextinput_p_p.h \ $$PWD/qdeclarativetextedit_p.h \ @@ -75,6 +76,7 @@ SOURCES += \ $$PWD/qdeclarativerectangle.cpp \ $$PWD/qdeclarativerepeater.cpp \ $$PWD/qdeclarativescalegrid.cpp \ + $$PWD/qdeclarativetranslate.cpp \ $$PWD/qdeclarativetextinput.cpp \ $$PWD/qdeclarativetext.cpp \ $$PWD/qdeclarativetextedit.cpp \ diff --git a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp index f92c207..96f95f2 100644 --- a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp @@ -217,7 +217,8 @@ void QDeclarativeBorderImage::load() thisSciRequestFinished, Qt::DirectConnection); } } else { - QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(d->url, &d->pix, d->async); + QSize impsize; + QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(d->url, &d->pix, &impsize, d->async); if (status != QDeclarativePixmapReply::Ready && status != QDeclarativePixmapReply::Error) { QDeclarativePixmapReply *reply = QDeclarativePixmapCache::request(qmlEngine(this), d->url); d->pendingPixmapCache = true; @@ -226,8 +227,8 @@ void QDeclarativeBorderImage::load() this, SLOT(requestProgress(qint64,qint64))); } else { //### should be unified with requestFinished - setImplicitWidth(d->pix.width()); - setImplicitHeight(d->pix.height()); + setImplicitWidth(impsize.width()); + setImplicitHeight(impsize.height()); if (d->pix.isNull()) d->status = Error; @@ -336,7 +337,8 @@ void QDeclarativeBorderImage::setGridScaledImage(const QDeclarativeGridScaledIma d->verticalTileMode = sci.verticalTileRule(); d->sciurl = d->url.resolved(QUrl(sci.pixmapUrl())); - QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(d->sciurl, &d->pix, d->async); + QSize impsize; + QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(d->sciurl, &d->pix, &impsize, d->async); if (status != QDeclarativePixmapReply::Ready && status != QDeclarativePixmapReply::Error) { QDeclarativePixmapReply *reply = QDeclarativePixmapCache::request(qmlEngine(this), d->sciurl); d->sciPendingPixmapCache = true; @@ -362,8 +364,8 @@ void QDeclarativeBorderImage::setGridScaledImage(const QDeclarativeGridScaledIma thisRequestProgress, Qt::DirectConnection); } else { //### should be unified with requestFinished - setImplicitWidth(d->pix.width()); - setImplicitHeight(d->pix.height()); + setImplicitWidth(impsize.width()); + setImplicitHeight(impsize.height()); if (d->pix.isNull()) d->status = Error; @@ -381,16 +383,17 @@ void QDeclarativeBorderImage::requestFinished() { Q_D(QDeclarativeBorderImage); + QSize impsize; if (d->url.path().endsWith(QLatin1String(".sci"))) { d->sciPendingPixmapCache = false; - QDeclarativePixmapCache::get(d->sciurl, &d->pix, d->async); + QDeclarativePixmapCache::get(d->sciurl, &d->pix, &impsize, d->async); } else { d->pendingPixmapCache = false; - if (QDeclarativePixmapCache::get(d->url, &d->pix, d->async) != QDeclarativePixmapReply::Ready) + if (QDeclarativePixmapCache::get(d->url, &d->pix, &impsize, d->async) != QDeclarativePixmapReply::Ready) d->status = Error; } - setImplicitWidth(d->pix.width()); - setImplicitHeight(d->pix.height()); + setImplicitWidth(impsize.width()); + setImplicitHeight(impsize.height()); if (d->status == Loading) d->status = Ready; diff --git a/src/declarative/graphicsitems/qdeclarativeimage.cpp b/src/declarative/graphicsitems/qdeclarativeimage.cpp index 425976f..8b93063 100644 --- a/src/declarative/graphicsitems/qdeclarativeimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeimage.cpp @@ -266,6 +266,32 @@ qreal QDeclarativeImage::paintedHeight() const filtering at the beginning of the animation and reenable it at the conclusion. */ +/*! + \qmlproperty int Image::sourceWidth + \qmlproperty int Image::sourceHeight + + These properties are the size of the loaded image, in pixels. + + If you set these properties explicitly, you can to control the storage + used by a loaded image. The image will be scaled down if its intrinsic size + is greater than these values. + + Unlike setting the width and height properties, which merely scale the painting + of the image, these properties affect the number of pixels stored. + + \e{Changing these properties dynamically will lead to the image source being reloaded, + potentially even from the network if it is not in the disk cache.} + + If the source is an instrinsically scalable image (eg. SVG), these properties + determine the size of the loaded image regardless of intrinsic size. You should + avoid changing these properties dynamically - rendering an SVG is \e slow compared + to an image. + + If the source is a non-scalable image (eg. JPEG), the loaded image will + be no greater than these properties specify. For some formats (currently only JPEG), + the whole image will never actually be loaded into memory. +*/ + void QDeclarativeImage::updatePaintedGeometry() { Q_D(QDeclarativeImage); diff --git a/src/declarative/graphicsitems/qdeclarativeimagebase.cpp b/src/declarative/graphicsitems/qdeclarativeimagebase.cpp index e65c9d1..3b75a85 100644 --- a/src/declarative/graphicsitems/qdeclarativeimagebase.cpp +++ b/src/declarative/graphicsitems/qdeclarativeimagebase.cpp @@ -116,6 +116,41 @@ void QDeclarativeImageBase::setSource(const QUrl &url) load(); } +void QDeclarativeImageBase::setSourceWidth(int w) +{ + Q_D(QDeclarativeImageBase); + if (d->sourcewidth == w) + return; + d->sourcewidth = w; + emit sourceSizeChanged(); + if (isComponentComplete()) + load(); +} + +int QDeclarativeImageBase::sourceWidth() const +{ + Q_D(const QDeclarativeImageBase); + return d->sourcewidth <= 0 ? implicitWidth() : d->sourcewidth; +} + +void QDeclarativeImageBase::setSourceHeight(int h) +{ + Q_D(QDeclarativeImageBase); + if (d->sourceheight == h) + return; + d->sourceheight = h; + emit sourceSizeChanged(); + if (isComponentComplete()) + load(); +} + +int QDeclarativeImageBase::sourceHeight() const +{ + Q_D(const QDeclarativeImageBase); + return d->sourceheight <= 0 ? implicitHeight() : d->sourceheight; +} + + void QDeclarativeImageBase::load() { Q_D(QDeclarativeImageBase); @@ -134,9 +169,12 @@ void QDeclarativeImageBase::load() update(); } else { d->status = Loading; - QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(d->url, &d->pix, d->async); + int reqwidth = d->sourcewidth; + int reqheight = d->sourceheight; + QSize impsize; + QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(d->url, &d->pix, &impsize, d->async, reqwidth, reqheight); if (status != QDeclarativePixmapReply::Ready && status != QDeclarativePixmapReply::Error) { - QDeclarativePixmapReply *reply = QDeclarativePixmapCache::request(qmlEngine(this), d->url); + QDeclarativePixmapReply *reply = QDeclarativePixmapCache::request(qmlEngine(this), d->url, reqwidth, reqheight); d->pendingPixmapCache = true; static int replyDownloadProgress = -1; @@ -161,11 +199,14 @@ void QDeclarativeImageBase::load() } else { //### should be unified with requestFinished if (status == QDeclarativePixmapReply::Ready) { - setImplicitWidth(d->pix.width()); - setImplicitHeight(d->pix.height()); + setImplicitWidth(impsize.width()); + setImplicitHeight(impsize.height()); if (d->status == Loading) d->status = Ready; + + if (d->sourcewidth <= 0 || d->sourceheight <= 0) + emit sourceSizeChanged(); } else { d->status = Error; } @@ -186,16 +227,19 @@ void QDeclarativeImageBase::requestFinished() d->pendingPixmapCache = false; - if (QDeclarativePixmapCache::get(d->url, &d->pix, d->async) != QDeclarativePixmapReply::Ready) + QSize impsize; + if (QDeclarativePixmapCache::get(d->url, &d->pix, &impsize, d->async, d->sourcewidth, d->sourceheight) != QDeclarativePixmapReply::Ready) d->status = Error; - setImplicitWidth(d->pix.width()); - setImplicitHeight(d->pix.height()); + setImplicitWidth(impsize.width()); + setImplicitHeight(impsize.height()); if (d->status == Loading) d->status = Ready; d->progress = 1.0; emit statusChanged(d->status); emit progressChanged(1.0); + if (d->sourcewidth <= 0 || d->sourceheight <= 0) + emit sourceSizeChanged(); pixmapChange(); update(); } diff --git a/src/declarative/graphicsitems/qdeclarativeimagebase_p.h b/src/declarative/graphicsitems/qdeclarativeimagebase_p.h index b215193..2653d0a 100644 --- a/src/declarative/graphicsitems/qdeclarativeimagebase_p.h +++ b/src/declarative/graphicsitems/qdeclarativeimagebase_p.h @@ -59,6 +59,9 @@ class Q_DECLARATIVE_EXPORT QDeclarativeImageBase : public QDeclarativeItem Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged) Q_PROPERTY(bool asynchronous READ asynchronous WRITE setAsynchronous NOTIFY asynchronousChanged) + Q_PROPERTY(int sourceWidth READ sourceWidth WRITE setSourceWidth NOTIFY sourceSizeChanged) + Q_PROPERTY(int sourceHeight READ sourceHeight WRITE setSourceHeight NOTIFY sourceSizeChanged) + public: ~QDeclarativeImageBase(); enum Status { Null, Ready, Loading, Error }; @@ -71,8 +74,14 @@ public: bool asynchronous() const; void setAsynchronous(bool); + void setSourceWidth(int); + int sourceWidth() const; + void setSourceHeight(int); + int sourceHeight() const; + Q_SIGNALS: void sourceChanged(const QUrl &); + void sourceSizeChanged(); void statusChanged(Status); void progressChanged(qreal progress); void asynchronousChanged(); diff --git a/src/declarative/graphicsitems/qdeclarativeimagebase_p_p.h b/src/declarative/graphicsitems/qdeclarativeimagebase_p_p.h index c4a61f3..cced228 100644 --- a/src/declarative/graphicsitems/qdeclarativeimagebase_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativeimagebase_p_p.h @@ -68,6 +68,7 @@ public: QDeclarativeImageBasePrivate() : status(QDeclarativeImageBase::Null), progress(0.0), + sourcewidth(0), sourceheight(0), pendingPixmapCache(false), async(false) { @@ -78,6 +79,7 @@ public: QDeclarativeImageBase::Status status; QUrl url; qreal progress; + int sourcewidth, sourceheight; bool pendingPixmapCache : 1; bool async : 1; }; diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index dd6056e..c331af7 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -83,7 +83,43 @@ QT_BEGIN_NAMESPACE You can assign any number of Transform elements to an Item. Each Transform is applied in order, one at a time, to the Item it's assigned to. - \sa Rotation, Scale + \sa Rotation, Scale, Translate +*/ + +/*! + \qmlclass Translate QGraphicsTranslate + \since 4.7 + \brief The Translate object provides a way to move an Item without changing its x or y. + + The Translate object independent control over position in addition to the Item's x and y properties. + + The following example moves the X axis of the Rectangle, relative to its interior point 25, 25: + \qml + Row { + Rectangle { + width: 100; height: 100 + color: "blue" + transform: Translate { y: 20 } + } + Rectangle { + width: 100; height: 100 + color: "red" + transform: Translate { y: -20 } + } + } + \endqml +*/ + +/*! + \qmlproperty real Translate::x + + The translation along the X axis. +*/ + +/*! + \qmlproperty real Translate::yTranslate + + The translation along the Y axis. */ /*! diff --git a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp index 07d7f4d..1c458b1d4 100644 --- a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp @@ -69,6 +69,7 @@ #include "qdeclarativepathview_p.h" #include "qdeclarativerectangle_p.h" #include "qdeclarativerepeater_p.h" +#include "qdeclarativetranslate_p.h" #include "qdeclarativetext_p.h" #include "qdeclarativetextedit_p.h" #include "qdeclarativetextinput_p.h" @@ -123,6 +124,7 @@ void QDeclarativeItemModule::defineModule() qmlRegisterType("Qt",4,6,"Repeater"); qmlRegisterType("Qt",4,6,"Rotation"); qmlRegisterType("Qt",4,6,"Row"); + qmlRegisterType("Qt",4,6,"Translate"); qmlRegisterType("Qt",4,6,"Scale"); qmlRegisterType("Qt",4,6,"Text"); qmlRegisterType("Qt",4,6,"TextEdit"); diff --git a/src/declarative/graphicsitems/qdeclarativetranslate.cpp b/src/declarative/graphicsitems/qdeclarativetranslate.cpp new file mode 100644 index 0000000..57c47f0 --- /dev/null +++ b/src/declarative/graphicsitems/qdeclarativetranslate.cpp @@ -0,0 +1,159 @@ +/**************************************************************************** +** +** 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 QtDeclarative module 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 "qdeclarativetranslate_p.h" +#include +#include +#include + +class QDeclarativeTranslatePrivate : public QGraphicsTransformPrivate +{ +public: + QDeclarativeTranslatePrivate() + : x(0), y(0), z(0) {} + qreal x; + qreal y; + qreal z; +}; + +/*! + Constructs an empty QDeclarativeTranslate object with the given \a parent. +*/ +QDeclarativeTranslate::QDeclarativeTranslate(QObject *parent) + : QGraphicsTransform(*new QDeclarativeTranslatePrivate, parent) +{ +} + +/*! + Destroys the graphics scale. +*/ +QDeclarativeTranslate::~QDeclarativeTranslate() +{ +} + +/*! + \property QDeclarativeTranslate::x + \brief the horizontal translation. + + The translation can be any real number; the default value is 0.0. + + \sa y, z +*/ +qreal QDeclarativeTranslate::x() const +{ + Q_D(const QDeclarativeTranslate); + return d->x; +} +void QDeclarativeTranslate::setX(qreal x) +{ + Q_D(QDeclarativeTranslate); + if (d->x == x) + return; + d->x = x; + update(); + emit positionChanged(); +} + +/*! + \property QDeclarativeTranslate::y + \brief the vertical translation. + + The translation can be any real number; the default value is 0.0. + + \sa x, z +*/ +qreal QDeclarativeTranslate::y() const +{ + Q_D(const QDeclarativeTranslate); + return d->y; +} +void QDeclarativeTranslate::setY(qreal y) +{ + Q_D(QDeclarativeTranslate); + if (d->y == y) + return; + d->y = y; + update(); + emit positionChanged(); +} + +/*! + \property QDeclarativeTranslate::z + \brief the depth translation. + + The translation can be any real number; the default value is 0.0. + + \sa x, y +*/ +qreal QDeclarativeTranslate::z() const +{ + Q_D(const QDeclarativeTranslate); + return d->z; +} +void QDeclarativeTranslate::setZ(qreal z) +{ + Q_D(QDeclarativeTranslate); + if (d->z == z) + return; + d->z = z; + update(); + emit positionChanged(); +} + +/*! + \reimp +*/ +void QDeclarativeTranslate::applyTo(QMatrix4x4 *matrix) const +{ + Q_D(const QDeclarativeTranslate); + matrix->translate(d->x, d->y, d->z); +} + +/*! + \fn QDeclarativeTranslate::positionChanged() + + QDeclarativeTranslate emits this signal when its position changes. + + \sa QDeclarativeTranslate::x, QDeclarativeTranslate::y + \sa QDeclarativeTranslate::z +*/ + +//#include "moc_qdeclarativetranslate.cpp" diff --git a/src/declarative/graphicsitems/qdeclarativetranslate_p.h b/src/declarative/graphicsitems/qdeclarativetranslate_p.h new file mode 100644 index 0000000..54bfc3d --- /dev/null +++ b/src/declarative/graphicsitems/qdeclarativetranslate_p.h @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** 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 QtDeclarative module 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$ +** +****************************************************************************/ + +#ifndef QDECLARATIVETRANSLATE_H +#define QDECLARATIVETRANSLATE_H + +#include "qdeclarativeitem.h" + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QDeclarativeTranslatePrivate; + +class Q_GUI_EXPORT QDeclarativeTranslate : public QGraphicsTransform +{ + Q_OBJECT + + Q_PROPERTY(qreal x READ x WRITE setX NOTIFY positionChanged) + Q_PROPERTY(qreal y READ y WRITE setY NOTIFY positionChanged) + Q_PROPERTY(qreal z READ z WRITE setZ NOTIFY positionChanged) + +public: + QDeclarativeTranslate(QObject *parent = 0); + ~QDeclarativeTranslate(); + + qreal x() const; + void setX(qreal); + + qreal y() const; + void setY(qreal); + + qreal z() const; + void setZ(qreal); + + void applyTo(QMatrix4x4 *matrix) const; + +Q_SIGNALS: + void positionChanged(); + +private: + Q_DECLARE_PRIVATE(QDeclarativeTranslate) + Q_DISABLE_COPY(QDeclarativeTranslate) +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QDeclarativeTranslate) + +QT_END_HEADER + +#endif diff --git a/src/declarative/util/qdeclarativepixmapcache.cpp b/src/declarative/util/qdeclarativepixmapcache.cpp index e78fdf1..bbe86e7 100644 --- a/src/declarative/util/qdeclarativepixmapcache.cpp +++ b/src/declarative/util/qdeclarativepixmapcache.cpp @@ -106,7 +106,7 @@ public: QDeclarativeImageReader(QDeclarativeEngine *eng); ~QDeclarativeImageReader(); - QDeclarativePixmapReply *getImage(const QUrl &url); + QDeclarativePixmapReply *getImage(const QUrl &url, int req_width, int req_height); void cancel(QDeclarativePixmapReply *rep); static QDeclarativeImageReader *instance(QDeclarativeEngine *engine); @@ -140,7 +140,7 @@ public: QCoreApplication::postEvent(this, new QEvent(QEvent::User)); } - QDeclarativePixmapReply *getImage(const QUrl &url); + QDeclarativePixmapReply *getImage(const QUrl &url, int req_width, int req_height); void cancel(QDeclarativePixmapReply *reply); protected: @@ -170,11 +170,50 @@ private: //=========================================================================== +static bool readImage(const QUrl& url, QIODevice *dev, QImage *image, QString *errorString, QSize *impsize, int req_width, int req_height) +{ + QImageReader imgio(dev); + + bool force_scale = false; + if (url.path().endsWith(QLatin1String(".svg"),Qt::CaseInsensitive)) { + imgio.setFormat("svg"); // QSvgPlugin::capabilities bug QTBUG-9053 + force_scale = true; + } + + bool scaled = false; + if (req_width > 0 || req_height > 0) { + QSize s = imgio.size(); + if (req_width && (force_scale || req_width < s.width())) { s.setWidth(req_width); scaled = true; } + if (req_height && (force_scale || req_height < s.height())) { s.setHeight(req_height); scaled = true; } + if (scaled) { imgio.setScaledSize(s); } + } + + if (impsize) + *impsize = imgio.size(); + + if (imgio.read(image)) { + if (impsize && impsize->width() < 0) + *impsize = image->size(); + return true; + } else { + if (errorString) + *errorString = QLatin1String("Error decoding: ") + url.toString() + + QLatin1String(" \"") + imgio.errorString() + QLatin1String("\""); + return false; + } +} + + +//=========================================================================== + int QDeclarativeImageRequestHandler::replyDownloadProgress = -1; int QDeclarativeImageRequestHandler::replyFinished = -1; int QDeclarativeImageRequestHandler::downloadProgress = -1; int QDeclarativeImageRequestHandler::thisNetworkRequestDone = -1; +typedef QHash QDeclarativePixmapSizeHash; +Q_GLOBAL_STATIC(QDeclarativePixmapSizeHash, qmlOriginalSizes); + bool QDeclarativeImageRequestHandler::event(QEvent *event) { if (event->type() == QEvent::User) { @@ -238,10 +277,10 @@ bool QDeclarativeImageRequestHandler::event(QEvent *event) QString errorStr; QFile f(lf); if (f.open(QIODevice::ReadOnly)) { - QImageReader imgio(&f); - if (!imgio.read(&image)) { - errorStr = QLatin1String("Error decoding: ") + url.toString() - + QLatin1String(" \"") + imgio.errorString() + QLatin1String("\""); + QSize read_impsize; + if (readImage(url, &f, &image, &errorStr, &read_impsize, runningJob->forcedWidth(),runningJob->forcedHeight())) { + qmlOriginalSizes()->insert(url, read_impsize); + } else { errorCode = QDeclarativeImageReaderEvent::Loading; } } else { @@ -303,12 +342,11 @@ void QDeclarativeImageRequestHandler::networkRequestDone() error = QDeclarativeImageReaderEvent::Loading; errorString = reply->errorString(); } else { - QImageReader imgio(reply); - if (imgio.read(&image)) { + QSize read_impsize; + if (readImage(reply->url(), reply, &image, &errorString, &read_impsize, job->forcedWidth(), job->forcedHeight())) { + qmlOriginalSizes()->insert(reply->url(), read_impsize); error = QDeclarativeImageReaderEvent::NoError; } else { - errorString = QLatin1String("Error decoding: ") + reply->url().toString() - + QLatin1String(" \"") + imgio.errorString() + QLatin1String("\""); error = QDeclarativeImageReaderEvent::Decoding; } } @@ -352,10 +390,10 @@ QDeclarativeImageReader *QDeclarativeImageReader::instance(QDeclarativeEngine *e return reader; } -QDeclarativePixmapReply *QDeclarativeImageReader::getImage(const QUrl &url) +QDeclarativePixmapReply *QDeclarativeImageReader::getImage(const QUrl &url, int req_width, int req_height) { mutex.lock(); - QDeclarativePixmapReply *reply = new QDeclarativePixmapReply(this, url); + QDeclarativePixmapReply *reply = new QDeclarativePixmapReply(this, url, req_width, req_height); reply->addRef(); reply->setLoading(); jobs.append(reply); @@ -397,40 +435,6 @@ void QDeclarativeImageReader::run() //=========================================================================== -static bool readImage(QIODevice *dev, QPixmap *pixmap, QString &errorString) -{ - QImageReader imgio(dev); - -//#define QT_TEST_SCALED_SIZE -#ifdef QT_TEST_SCALED_SIZE - /* - Some mechanism is needed for loading images at a limited size, especially - for remote images. Loading only thumbnails of remote progressive JPEG - images can be efficient. (Qt jpeg handler does not do so currently) - */ - - QSize limit(60,60); - QSize sz = imgio.size(); - if (sz.width() > limit.width() || sz.height() > limit.height()) { - sz.scale(limit,Qt::KeepAspectRatio); - imgio.setScaledSize(sz); - } -#endif - - QImage img; - if (imgio.read(&img)) { -#ifdef QT_TEST_SCALED_SIZE - if (!sz.isValid()) - img = img.scaled(limit,Qt::KeepAspectRatio); -#endif - *pixmap = QPixmap::fromImage(img); - return true; - } else { - errorString = imgio.errorString(); - return false; - } -} - /*! \internal \class QDeclarativePixmapCache @@ -447,8 +451,10 @@ class QDeclarativePixmapReplyPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QDeclarativePixmapReply) public: - QDeclarativePixmapReplyPrivate(QDeclarativeImageReader *r, const QUrl &u) - : QObjectPrivate(), refCount(1), url(u), status(QDeclarativePixmapReply::Loading), loading(false), reader(r) { + QDeclarativePixmapReplyPrivate(QDeclarativeImageReader *r, const QUrl &u, int req_width, int req_height) + : QObjectPrivate(), refCount(1), url(u), status(QDeclarativePixmapReply::Loading), loading(false), reader(r), + forced_width(req_width), forced_height(req_height) + { } int refCount; @@ -457,11 +463,12 @@ public: QDeclarativePixmapReply::Status status; bool loading; QDeclarativeImageReader *reader; + int forced_width, forced_height; }; -QDeclarativePixmapReply::QDeclarativePixmapReply(QDeclarativeImageReader *reader, const QUrl &url) - : QObject(*new QDeclarativePixmapReplyPrivate(reader, url), 0) +QDeclarativePixmapReply::QDeclarativePixmapReply(QDeclarativeImageReader *reader, const QUrl &url, int req_width, int req_height) + : QObject(*new QDeclarativePixmapReplyPrivate(reader, url, req_width, req_height), 0) { } @@ -475,6 +482,28 @@ const QUrl &QDeclarativePixmapReply::url() const return d->url; } +int QDeclarativePixmapReply::forcedWidth() const +{ + Q_D(const QDeclarativePixmapReply); + return d->forced_width; +} + +int QDeclarativePixmapReply::forcedHeight() const +{ + Q_D(const QDeclarativePixmapReply); + return d->forced_height; +} + +QSize QDeclarativePixmapReply::implicitSize() const +{ + Q_D(const QDeclarativePixmapReply); + QDeclarativePixmapSizeHash::Iterator iter = qmlOriginalSizes()->find(d->url); + if (iter != qmlOriginalSizes()->end()) + return *iter; + else + return QSize(); +} + bool QDeclarativePixmapReply::event(QEvent *event) { Q_D(QDeclarativePixmapReply); @@ -554,13 +583,25 @@ bool QDeclarativePixmapReply::release(bool defer) If \a async is false the image will be loaded and decoded immediately; otherwise the image will be loaded and decoded in a separate thread. + If \a req_width and \a req_height are non-zero, they are used for + the size of the rendered pixmap rather than the intrinsic size of the image. + Different request sizes add different cache items. + Note that images sourced from the network will always be loaded and decoded asynchonously. */ -QDeclarativePixmapReply::Status QDeclarativePixmapCache::get(const QUrl& url, QPixmap *pixmap, bool async) +QDeclarativePixmapReply::Status QDeclarativePixmapCache::get(const QUrl& url, QPixmap *pixmap, QSize *impsize, bool async, int req_width, int req_height) { QDeclarativePixmapReply::Status status = QDeclarativePixmapReply::Unrequested; QByteArray key = url.toEncoded(QUrl::FormattingOption(0x100)); + + if (req_width > 0 && req_height > 0) { + key += ':'; + key += QByteArray::number(req_width); + key += 'x'; + key += QByteArray::number(req_height); + } + QString strKey = QString::fromLatin1(key.constData(), key.count()); #ifndef QT_NO_LOCALFILE_OPTIMIZED_QML @@ -570,11 +611,13 @@ QDeclarativePixmapReply::Status QDeclarativePixmapCache::get(const QUrl& url, QP status = QDeclarativePixmapReply::Ready; if (!QPixmapCache::find(strKey,pixmap)) { QFile f(lf); + QSize read_impsize; if (f.open(QIODevice::ReadOnly)) { QString errorString; - if (!readImage(&f, pixmap, errorString)) { - errorString = QLatin1String("Error decoding: ") + url.toString() - + QLatin1String(" \"") + errorString + QLatin1String("\""); + QImage image; + if (readImage(url, &f, &image, &errorString, &read_impsize, req_width, req_height)) { + *pixmap = QPixmap::fromImage(image); + } else { qWarning() << errorString; *pixmap = QPixmap(); status = QDeclarativePixmapReply::Error; @@ -584,8 +627,18 @@ QDeclarativePixmapReply::Status QDeclarativePixmapCache::get(const QUrl& url, QP *pixmap = QPixmap(); status = QDeclarativePixmapReply::Error; } - if (status == QDeclarativePixmapReply::Ready) + if (status == QDeclarativePixmapReply::Ready) { QPixmapCache::insert(strKey, *pixmap); + qmlOriginalSizes()->insert(url, read_impsize); + } + if (impsize) + *impsize = read_impsize; + } else { + if (impsize) { + QDeclarativePixmapSizeHash::Iterator iter = qmlOriginalSizes()->find(url); + if (iter != qmlOriginalSizes()->end()) + *impsize = *iter; + } } return status; } @@ -608,6 +661,11 @@ QDeclarativePixmapReply::Status QDeclarativePixmapCache::get(const QUrl& url, QP } else if (iter != qmlActivePixmapReplies()->end()) { status = QDeclarativePixmapReply::Loading; } + if (impsize) { + QDeclarativePixmapSizeHash::Iterator iter = qmlOriginalSizes()->find(url); + if (iter != qmlOriginalSizes()->end()) + *impsize = *iter; + } return status; } @@ -621,12 +679,12 @@ QDeclarativePixmapReply::Status QDeclarativePixmapCache::get(const QUrl& url, QP The returned QDeclarativePixmapReply will be deleted when all request() calls are matched by a corresponding get() call. */ -QDeclarativePixmapReply *QDeclarativePixmapCache::request(QDeclarativeEngine *engine, const QUrl &url) +QDeclarativePixmapReply *QDeclarativePixmapCache::request(QDeclarativeEngine *engine, const QUrl &url, int req_width, int req_height) { QDeclarativePixmapReplyHash::Iterator iter = qmlActivePixmapReplies()->find(url); if (iter == qmlActivePixmapReplies()->end()) { QDeclarativeImageReader *reader = QDeclarativeImageReader::instance(engine); - QDeclarativePixmapReply *item = reader->getImage(url); + QDeclarativePixmapReply *item = reader->getImage(url, req_width, req_height); iter = qmlActivePixmapReplies()->insert(url, item); } else { (*iter)->addRef(); diff --git a/src/declarative/util/qdeclarativepixmapcache_p.h b/src/declarative/util/qdeclarativepixmapcache_p.h index b8949db..0ccf469 100644 --- a/src/declarative/util/qdeclarativepixmapcache_p.h +++ b/src/declarative/util/qdeclarativepixmapcache_p.h @@ -66,6 +66,9 @@ public: Status status() const; const QUrl &url() const; + int forcedWidth() const; + int forcedHeight() const; + QSize implicitSize() const; Q_SIGNALS: void finished(); @@ -81,7 +84,7 @@ private: void setLoading(); private: - QDeclarativePixmapReply(QDeclarativeImageReader *reader, const QUrl &url); + QDeclarativePixmapReply(QDeclarativeImageReader *reader, const QUrl &url, int req_width, int req_height); Q_DISABLE_COPY(QDeclarativePixmapReply) Q_DECLARE_PRIVATE(QDeclarativePixmapReply) friend class QDeclarativeImageRequestHandler; @@ -92,8 +95,8 @@ private: class Q_DECLARATIVE_EXPORT QDeclarativePixmapCache { public: - static QDeclarativePixmapReply::Status get(const QUrl& url, QPixmap *pixmap, bool async=false); - static QDeclarativePixmapReply *request(QDeclarativeEngine *, const QUrl& url); + static QDeclarativePixmapReply::Status get(const QUrl& url, QPixmap *pixmap, QSize *impsize, bool async=false, int req_width=0, int req_height=0); + static QDeclarativePixmapReply *request(QDeclarativeEngine *, const QUrl& url, int req_width=0, int req_height=0); static void cancel(const QUrl& url, QObject *obj); static int pendingRequests(); }; diff --git a/tests/auto/declarative/qdeclarativeimage/data/big.jpeg b/tests/auto/declarative/qdeclarativeimage/data/big.jpeg new file mode 100644 index 0000000..bed7bd6 Binary files /dev/null and b/tests/auto/declarative/qdeclarativeimage/data/big.jpeg differ diff --git a/tests/auto/declarative/qdeclarativeimage/data/big256.png b/tests/auto/declarative/qdeclarativeimage/data/big256.png new file mode 100644 index 0000000..1dc1596 Binary files /dev/null and b/tests/auto/declarative/qdeclarativeimage/data/big256.png differ diff --git a/tests/auto/declarative/qdeclarativeimage/data/heart.png b/tests/auto/declarative/qdeclarativeimage/data/heart.png new file mode 100644 index 0000000..372b224 Binary files /dev/null and b/tests/auto/declarative/qdeclarativeimage/data/heart.png differ diff --git a/tests/auto/declarative/qdeclarativeimage/data/heart.svg b/tests/auto/declarative/qdeclarativeimage/data/heart.svg new file mode 100644 index 0000000..8c982cd --- /dev/null +++ b/tests/auto/declarative/qdeclarativeimage/data/heart.svg @@ -0,0 +1,55 @@ + + + + + +Heart Left-Highlight +This is a normal valentines day heart. + + +holiday +valentines + +valentine +hash(0x8a091c0) +hash(0x8a0916c) +signs_and_symbols +hash(0x8a091f0) +day + + + + +Jon Phillips + + + + +Jon Phillips + + + + +Jon Phillips + + + +image/svg+xml + + +en + + + + + + + + + + + + + + + diff --git a/tests/auto/declarative/qdeclarativeimage/data/heart200.png b/tests/auto/declarative/qdeclarativeimage/data/heart200.png new file mode 100644 index 0000000..786e75d Binary files /dev/null and b/tests/auto/declarative/qdeclarativeimage/data/heart200.png differ diff --git a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp index ed2095b..c7dcbea 100644 --- a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp +++ b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp @@ -82,6 +82,8 @@ private slots: void resized(); void smooth(); void pixmap(); + void svg(); + void big(); private: QDeclarativeEngine engine; @@ -111,24 +113,29 @@ void tst_qdeclarativeimage::noSource() void tst_qdeclarativeimage::imageSource_data() { QTest::addColumn("source"); + QTest::addColumn("width"); + QTest::addColumn("height"); QTest::addColumn("remote"); QTest::addColumn("async"); QTest::addColumn("error"); - QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/colors.png").toString() << false << false << ""; - QTest::newRow("local async") << QUrl::fromLocalFile(SRCDIR "/data/colors1.png").toString() << false << true << ""; - QTest::newRow("local not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString() << false + QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/colors.png").toString() << 120.0 << 120.0 << false << false << ""; + QTest::newRow("local async") << QUrl::fromLocalFile(SRCDIR "/data/colors1.png").toString() << 120.0 << 120.0 << false << true << ""; + QTest::newRow("local not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString() << 0.0 << 0.0 << false << false << "Cannot open QUrl( \"" + QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString() + "\" ) "; - QTest::newRow("local async not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file-1.png").toString() << false + QTest::newRow("local async not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file-1.png").toString() << 0.0 << 0.0 << false << true << "\"Cannot open: " + QUrl::fromLocalFile(SRCDIR "/data/no-such-file-1.png").toString() + "\" "; - QTest::newRow("remote") << SERVER_ADDR "/colors.png" << true << false << ""; - QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << true << false + QTest::newRow("remote") << SERVER_ADDR "/colors.png" << 120.0 << 120.0 << true << false << ""; + QTest::newRow("remote svg") << SERVER_ADDR "/heart.svg" << 550.0 << 500.0 << true << false << ""; + QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << 0.0 << 0.0 << true << false << "\"Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found\" "; } void tst_qdeclarativeimage::imageSource() { QFETCH(QString, source); + QFETCH(qreal, width); + QFETCH(qreal, height); QFETCH(bool, remote); QFETCH(bool, async); QFETCH(QString, error); @@ -156,8 +163,8 @@ void tst_qdeclarativeimage::imageSource() if (error.isEmpty()) { TRY_WAIT(obj->status() == QDeclarativeImage::Ready); - QCOMPARE(obj->width(), 120.); - QCOMPARE(obj->height(), 120.); + QCOMPARE(obj->width(), width); + QCOMPARE(obj->height(), height); QCOMPARE(obj->fillMode(), QDeclarativeImage::Stretch); QCOMPARE(obj->progress(), 1.0); } else { @@ -248,6 +255,48 @@ void tst_qdeclarativeimage::pixmap() delete obj; } +void tst_qdeclarativeimage::svg() +{ + QString componentStr = "import Qt 4.6\nImage { source: \"" SRCDIR "/data/heart.svg\"; sourceWidth: 300; sourceHeight: 300 }"; + QDeclarativeComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QDeclarativeImage *obj = qobject_cast(component.create()); + QVERIFY(obj != 0); + QCOMPARE(obj->pixmap().width(), 300); + QCOMPARE(obj->pixmap().height(), 300); + QCOMPARE(obj->width(), 550.0); + QCOMPARE(obj->height(), 500.0); + QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart.png")); + + obj->setSourceWidth(200); + obj->setSourceHeight(200); + + QCOMPARE(obj->pixmap().width(), 200); + QCOMPARE(obj->pixmap().height(), 200); + QCOMPARE(obj->width(), 550.0); + QCOMPARE(obj->height(), 500.0); + QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart200.png")); + + delete obj; +} + +void tst_qdeclarativeimage::big() +{ + QString componentStr = "import Qt 4.6\nImage { source: \"" SRCDIR "/data/big.jpeg\"; sourceWidth: 256; sourceHeight: 256 }"; + QDeclarativeComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QDeclarativeImage *obj = qobject_cast(component.create()); + QVERIFY(obj != 0); + QCOMPARE(obj->pixmap().width(), 256); + QCOMPARE(obj->pixmap().height(), 256); + QCOMPARE(obj->width(), 10240.0); + QCOMPARE(obj->height(), 10240.0); + QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/big256.png")); + + delete obj; +} + + QTEST_MAIN(tst_qdeclarativeimage) #include "tst_qdeclarativeimage.moc" -- cgit v0.12 From 7687d4cd76a9e22098be84126e01a6c94a91d9ce Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Fri, 26 Mar 2010 06:14:50 +0100 Subject: QDeclarativeItem don't need to emit childrenChanged anymore. It's done by QGraphicsItemPrivate::addChild and removeChild. Reviewed-by:akennedy --- src/declarative/graphicsitems/qdeclarativeitem.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index c331af7..048e1a8 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -2587,10 +2587,6 @@ QVariant QDeclarativeItem::itemChange(GraphicsItemChange change, emit parentChanged(parentItem()); d->parentNotifier.notify(); break; - case ItemChildAddedChange: - case ItemChildRemovedChange: - emit childrenChanged(); - break; case ItemVisibleHasChanged: { for(int ii = 0; ii < d->changeListeners.count(); ++ii) { const QDeclarativeItemPrivate::ChangeListener &change = d->changeListeners.at(ii); -- cgit v0.12 From f16d60399b996b09b779d2a719b5e6e6b9a80903 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Fri, 26 Mar 2010 15:18:54 +1000 Subject: sourceWidth/sourceHeight -> sourceSize --- examples/declarative/images/images.qml | 23 +++++++------ .../graphicsitems/qdeclarativeimage.cpp | 21 ++++++------ .../graphicsitems/qdeclarativeimagebase.cpp | 38 ++++++---------------- .../graphicsitems/qdeclarativeimagebase_p.h | 9 ++--- .../graphicsitems/qdeclarativeimagebase_p_p.h | 3 +- .../qdeclarativeimage/tst_qdeclarativeimage.cpp | 7 ++-- 6 files changed, 38 insertions(+), 63 deletions(-) diff --git a/examples/declarative/images/images.qml b/examples/declarative/images/images.qml index 82848df..35ce1ab 100644 --- a/examples/declarative/images/images.qml +++ b/examples/declarative/images/images.qml @@ -15,14 +15,14 @@ Rectangle { } Image { - sourceWidth: 50 - sourceHeight: 50 + sourceSize.width: 50 + sourceSize.height: 50 source: "content/lemonade.jpg" } Image { - sourceWidth: 50 - sourceHeight: 50 + sourceSize.width: 50 + sourceSize.height: 50 smooth: true source: "content/lemonade.jpg" } @@ -34,15 +34,15 @@ Rectangle { Image { scale: 1/3 - sourceWidth: 50 - sourceHeight: 50 + sourceSize.width: 50 + sourceSize.height: 50 source: "content/lemonade.jpg" } Image { scale: 1/3 - sourceWidth: 50 - sourceHeight: 50 + sourceSize.width: 50 + sourceSize.height: 50 smooth: true source: "content/lemonade.jpg" } @@ -54,15 +54,14 @@ Rectangle { Image { width: 50; height: 50; transform: Translate { x: 50 } - sourceWidth: 50 - sourceHeight: 50 + sourceSize.width: 50 + sourceSize.height: 50 source: "content/lemonade.jpg" } Image { width: 50; height: 50; transform: Translate { x: 50 } - sourceWidth: 50 - sourceHeight: 50 + sourceSize: "50x50" // syntactic sugar smooth: true source: "content/lemonade.jpg" } diff --git a/src/declarative/graphicsitems/qdeclarativeimage.cpp b/src/declarative/graphicsitems/qdeclarativeimage.cpp index 8b93063..23a2350 100644 --- a/src/declarative/graphicsitems/qdeclarativeimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeimage.cpp @@ -267,28 +267,27 @@ qreal QDeclarativeImage::paintedHeight() const */ /*! - \qmlproperty int Image::sourceWidth - \qmlproperty int Image::sourceHeight + \qmlproperty QSize Image::sourceSize - These properties are the size of the loaded image, in pixels. + This properties is the size of the loaded image, in pixels. - If you set these properties explicitly, you can to control the storage + If you set this property explicitly, you can to control the storage used by a loaded image. The image will be scaled down if its intrinsic size - is greater than these values. + is greater than this value. Unlike setting the width and height properties, which merely scale the painting - of the image, these properties affect the number of pixels stored. + of the image, this property affects the number of pixels stored. - \e{Changing these properties dynamically will lead to the image source being reloaded, + \e{Changing this property dynamically will lead to the image source being reloaded, potentially even from the network if it is not in the disk cache.} - If the source is an instrinsically scalable image (eg. SVG), these properties - determine the size of the loaded image regardless of intrinsic size. You should - avoid changing these properties dynamically - rendering an SVG is \e slow compared + If the source is an instrinsically scalable image (eg. SVG), this property + determines the size of the loaded image regardless of intrinsic size. You should + avoid changing this property dynamically - rendering an SVG is \e slow compared to an image. If the source is a non-scalable image (eg. JPEG), the loaded image will - be no greater than these properties specify. For some formats (currently only JPEG), + be no greater than this property specifies. For some formats (currently only JPEG), the whole image will never actually be loaded into memory. */ diff --git a/src/declarative/graphicsitems/qdeclarativeimagebase.cpp b/src/declarative/graphicsitems/qdeclarativeimagebase.cpp index 3b75a85..b8d67ff 100644 --- a/src/declarative/graphicsitems/qdeclarativeimagebase.cpp +++ b/src/declarative/graphicsitems/qdeclarativeimagebase.cpp @@ -116,41 +116,23 @@ void QDeclarativeImageBase::setSource(const QUrl &url) load(); } -void QDeclarativeImageBase::setSourceWidth(int w) +void QDeclarativeImageBase::setSourceSize(const QSize& size) { Q_D(QDeclarativeImageBase); - if (d->sourcewidth == w) + if (d->sourcesize == size) return; - d->sourcewidth = w; + d->sourcesize = size; emit sourceSizeChanged(); if (isComponentComplete()) load(); } -int QDeclarativeImageBase::sourceWidth() const +QSize QDeclarativeImageBase::sourceSize() const { Q_D(const QDeclarativeImageBase); - return d->sourcewidth <= 0 ? implicitWidth() : d->sourcewidth; + return d->sourcesize.isValid() ? d->sourcesize : QSize(implicitWidth(),implicitHeight()); } -void QDeclarativeImageBase::setSourceHeight(int h) -{ - Q_D(QDeclarativeImageBase); - if (d->sourceheight == h) - return; - d->sourceheight = h; - emit sourceSizeChanged(); - if (isComponentComplete()) - load(); -} - -int QDeclarativeImageBase::sourceHeight() const -{ - Q_D(const QDeclarativeImageBase); - return d->sourceheight <= 0 ? implicitHeight() : d->sourceheight; -} - - void QDeclarativeImageBase::load() { Q_D(QDeclarativeImageBase); @@ -169,8 +151,8 @@ void QDeclarativeImageBase::load() update(); } else { d->status = Loading; - int reqwidth = d->sourcewidth; - int reqheight = d->sourceheight; + int reqwidth = d->sourcesize.width(); + int reqheight = d->sourcesize.width(); QSize impsize; QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(d->url, &d->pix, &impsize, d->async, reqwidth, reqheight); if (status != QDeclarativePixmapReply::Ready && status != QDeclarativePixmapReply::Error) { @@ -205,7 +187,7 @@ void QDeclarativeImageBase::load() if (d->status == Loading) d->status = Ready; - if (d->sourcewidth <= 0 || d->sourceheight <= 0) + if (!d->sourcesize.isValid()) emit sourceSizeChanged(); } else { d->status = Error; @@ -228,7 +210,7 @@ void QDeclarativeImageBase::requestFinished() d->pendingPixmapCache = false; QSize impsize; - if (QDeclarativePixmapCache::get(d->url, &d->pix, &impsize, d->async, d->sourcewidth, d->sourceheight) != QDeclarativePixmapReply::Ready) + if (QDeclarativePixmapCache::get(d->url, &d->pix, &impsize, d->async, d->sourcesize.width(), d->sourcesize.height()) != QDeclarativePixmapReply::Ready) d->status = Error; setImplicitWidth(impsize.width()); setImplicitHeight(impsize.height()); @@ -238,7 +220,7 @@ void QDeclarativeImageBase::requestFinished() d->progress = 1.0; emit statusChanged(d->status); emit progressChanged(1.0); - if (d->sourcewidth <= 0 || d->sourceheight <= 0) + if (!d->sourcesize.isValid()) emit sourceSizeChanged(); pixmapChange(); update(); diff --git a/src/declarative/graphicsitems/qdeclarativeimagebase_p.h b/src/declarative/graphicsitems/qdeclarativeimagebase_p.h index 2653d0a..6c84456 100644 --- a/src/declarative/graphicsitems/qdeclarativeimagebase_p.h +++ b/src/declarative/graphicsitems/qdeclarativeimagebase_p.h @@ -59,8 +59,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativeImageBase : public QDeclarativeItem Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged) Q_PROPERTY(bool asynchronous READ asynchronous WRITE setAsynchronous NOTIFY asynchronousChanged) - Q_PROPERTY(int sourceWidth READ sourceWidth WRITE setSourceWidth NOTIFY sourceSizeChanged) - Q_PROPERTY(int sourceHeight READ sourceHeight WRITE setSourceHeight NOTIFY sourceSizeChanged) + Q_PROPERTY(QSize sourceSize READ sourceSize WRITE setSourceSize NOTIFY sourceSizeChanged) public: ~QDeclarativeImageBase(); @@ -74,10 +73,8 @@ public: bool asynchronous() const; void setAsynchronous(bool); - void setSourceWidth(int); - int sourceWidth() const; - void setSourceHeight(int); - int sourceHeight() const; + void setSourceSize(const QSize&); + QSize sourceSize() const; Q_SIGNALS: void sourceChanged(const QUrl &); diff --git a/src/declarative/graphicsitems/qdeclarativeimagebase_p_p.h b/src/declarative/graphicsitems/qdeclarativeimagebase_p_p.h index cced228..de8c93a 100644 --- a/src/declarative/graphicsitems/qdeclarativeimagebase_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativeimagebase_p_p.h @@ -68,7 +68,6 @@ public: QDeclarativeImageBasePrivate() : status(QDeclarativeImageBase::Null), progress(0.0), - sourcewidth(0), sourceheight(0), pendingPixmapCache(false), async(false) { @@ -79,7 +78,7 @@ public: QDeclarativeImageBase::Status status; QUrl url; qreal progress; - int sourcewidth, sourceheight; + QSize sourcesize; bool pendingPixmapCache : 1; bool async : 1; }; diff --git a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp index c7dcbea..9073750 100644 --- a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp +++ b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp @@ -257,7 +257,7 @@ void tst_qdeclarativeimage::pixmap() void tst_qdeclarativeimage::svg() { - QString componentStr = "import Qt 4.6\nImage { source: \"" SRCDIR "/data/heart.svg\"; sourceWidth: 300; sourceHeight: 300 }"; + QString componentStr = "import Qt 4.6\nImage { source: \"" SRCDIR "/data/heart.svg\"; sourceSize.width: 300; sourceSize.height: 300 }"; QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QDeclarativeImage *obj = qobject_cast(component.create()); @@ -268,8 +268,7 @@ void tst_qdeclarativeimage::svg() QCOMPARE(obj->height(), 500.0); QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart.png")); - obj->setSourceWidth(200); - obj->setSourceHeight(200); + obj->setSourceSize(QSize(200,200)); QCOMPARE(obj->pixmap().width(), 200); QCOMPARE(obj->pixmap().height(), 200); @@ -282,7 +281,7 @@ void tst_qdeclarativeimage::svg() void tst_qdeclarativeimage::big() { - QString componentStr = "import Qt 4.6\nImage { source: \"" SRCDIR "/data/big.jpeg\"; sourceWidth: 256; sourceHeight: 256 }"; + QString componentStr = "import Qt 4.6\nImage { source: \"" SRCDIR "/data/big.jpeg\"; sourceSize.width: 256; sourceSize.height: 256 }"; QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QDeclarativeImage *obj = qobject_cast(component.create()); -- cgit v0.12 From 70e50ecc276e063da2ebb26faa3d7c4152bbdea6 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Fri, 26 Mar 2010 15:54:23 +1000 Subject: Simple case, no size returned. Fixes Particles plugin. --- src/declarative/util/qdeclarativepixmapcache_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/util/qdeclarativepixmapcache_p.h b/src/declarative/util/qdeclarativepixmapcache_p.h index 0ccf469..df71d65 100644 --- a/src/declarative/util/qdeclarativepixmapcache_p.h +++ b/src/declarative/util/qdeclarativepixmapcache_p.h @@ -95,7 +95,7 @@ private: class Q_DECLARATIVE_EXPORT QDeclarativePixmapCache { public: - static QDeclarativePixmapReply::Status get(const QUrl& url, QPixmap *pixmap, QSize *impsize, bool async=false, int req_width=0, int req_height=0); + static QDeclarativePixmapReply::Status get(const QUrl& url, QPixmap *pixmap, QSize *impsize=0, bool async=false, int req_width=0, int req_height=0); static QDeclarativePixmapReply *request(QDeclarativeEngine *, const QUrl& url, int req_width=0, int req_height=0); static void cancel(const QUrl& url, QObject *obj); static int pendingRequests(); -- cgit v0.12 From a9f11eea6b4985c9ff2ebcbe1b52acc7a5c64250 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Fri, 26 Mar 2010 15:59:18 +1000 Subject: Fix namespace. --- src/declarative/graphicsitems/qdeclarativetranslate.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/declarative/graphicsitems/qdeclarativetranslate.cpp b/src/declarative/graphicsitems/qdeclarativetranslate.cpp index 57c47f0..dd6ca92 100644 --- a/src/declarative/graphicsitems/qdeclarativetranslate.cpp +++ b/src/declarative/graphicsitems/qdeclarativetranslate.cpp @@ -44,6 +44,8 @@ #include #include +QT_BEGIN_NAMESPACE + class QDeclarativeTranslatePrivate : public QGraphicsTransformPrivate { public: @@ -156,4 +158,4 @@ void QDeclarativeTranslate::applyTo(QMatrix4x4 *matrix) const \sa QDeclarativeTranslate::z */ -//#include "moc_qdeclarativetranslate.cpp" +QT_END_NAMESPACE -- cgit v0.12 From 56309fe1461c4ea3ca654e535a525165c28a0f12 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Fri, 26 Mar 2010 15:59:43 +1000 Subject: Test transforms. --- .../qdeclarativeitem/tst_qdeclarativeitem.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp index 7665e18..d800411 100644 --- a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp +++ b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp @@ -61,6 +61,8 @@ private slots: void mapCoordinates(); void mapCoordinates_data(); void propertyChanges(); + void transforms(); + void transforms_data(); private: template @@ -402,6 +404,25 @@ void tst_QDeclarativeItem::mapCoordinates_data() QTest::newRow(QTest::toString(i)) << i << i; } +void tst_QDeclarativeItem::transforms_data() +{ + QTest::addColumn("qml"); + QTest::addColumn("matrix"); + QTest::newRow("translate") << QByteArray("import Qt 4.6\nItem { transform: Translate { x: 10; y: 20 } }") << QMatrix(1,0,0,1,10,20); + QTest::newRow("rotation") << QByteArray("import Qt 4.6\nItem { transform: Rotation { angle: 90 } }") << QMatrix(0,1,-1,0,0,0); + QTest::newRow("scale") << QByteArray("import Qt 4.6\nItem { transform: Scale { xScale: 1.5; yScale: -2 } }") << QMatrix(1.5,0,0,-2,0,0); +} + +void tst_QDeclarativeItem::transforms() +{ + QFETCH(QByteArray, qml); + QFETCH(QMatrix, matrix); + QDeclarativeComponent component(&engine); + component.setData(qml, QUrl::fromLocalFile("")); + QDeclarativeItem *item = qobject_cast(component.create()); + QCOMPARE(item->sceneMatrix(), matrix); +} + void tst_QDeclarativeItem::propertyChanges() { QDeclarativeView *canvas = new QDeclarativeView(0); -- cgit v0.12 From b8952aef84c78949959728674db39eafb19efee7 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Fri, 26 Mar 2010 17:02:53 +1000 Subject: Test and fix order of transform application. Remove Translate.z since Qt cannot sensibly support it yet. --- src/declarative/graphicsitems/qdeclarativeitem.cpp | 9 +++--- .../graphicsitems/qdeclarativetranslate.cpp | 33 +++------------------- .../graphicsitems/qdeclarativetranslate_p.h | 4 --- src/gui/graphicsview/qgraphicsitem.cpp | 16 +++++++++++ src/gui/graphicsview/qgraphicsitem_p.h | 1 + .../qdeclarativeitem/tst_qdeclarativeitem.cpp | 14 ++++++--- 6 files changed, 36 insertions(+), 41 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index 048e1a8..611535c 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -89,11 +89,12 @@ QT_BEGIN_NAMESPACE /*! \qmlclass Translate QGraphicsTranslate \since 4.7 - \brief The Translate object provides a way to move an Item without changing its x or y. + \brief The Translate object provides a way to move an Item without changing its x or y properties. The Translate object independent control over position in addition to the Item's x and y properties. - The following example moves the X axis of the Rectangle, relative to its interior point 25, 25: + The following example moves the Y axis of the Rectangles while still allowing the Row element + to lay the items out as if they had not been transformed: \qml Row { Rectangle { @@ -1562,8 +1563,8 @@ int QDeclarativeItemPrivate::transform_count(QDeclarativeListProperty *list, QGraphicsTransform *item) { QGraphicsObject *object = qobject_cast(list->object); - if (object) - QGraphicsItemPrivate::get(object)->appendGraphicsTransform(item); + if (object) // QGraphicsItem applies the list in the wrong order, so we prepend. + QGraphicsItemPrivate::get(object)->prependGraphicsTransform(item); } QGraphicsTransform *QDeclarativeItemPrivate::transform_at(QDeclarativeListProperty *list, int idx) diff --git a/src/declarative/graphicsitems/qdeclarativetranslate.cpp b/src/declarative/graphicsitems/qdeclarativetranslate.cpp index dd6ca92..1c96fa4 100644 --- a/src/declarative/graphicsitems/qdeclarativetranslate.cpp +++ b/src/declarative/graphicsitems/qdeclarativetranslate.cpp @@ -50,10 +50,9 @@ class QDeclarativeTranslatePrivate : public QGraphicsTransformPrivate { public: QDeclarativeTranslatePrivate() - : x(0), y(0), z(0) {} + : x(0), y(0) {} qreal x; qreal y; - qreal z; }; /*! @@ -77,7 +76,7 @@ QDeclarativeTranslate::~QDeclarativeTranslate() The translation can be any real number; the default value is 0.0. - \sa y, z + \sa y */ qreal QDeclarativeTranslate::x() const { @@ -100,7 +99,7 @@ void QDeclarativeTranslate::setX(qreal x) The translation can be any real number; the default value is 0.0. - \sa x, z + \sa x */ qreal QDeclarativeTranslate::y() const { @@ -118,35 +117,12 @@ void QDeclarativeTranslate::setY(qreal y) } /*! - \property QDeclarativeTranslate::z - \brief the depth translation. - - The translation can be any real number; the default value is 0.0. - - \sa x, y -*/ -qreal QDeclarativeTranslate::z() const -{ - Q_D(const QDeclarativeTranslate); - return d->z; -} -void QDeclarativeTranslate::setZ(qreal z) -{ - Q_D(QDeclarativeTranslate); - if (d->z == z) - return; - d->z = z; - update(); - emit positionChanged(); -} - -/*! \reimp */ void QDeclarativeTranslate::applyTo(QMatrix4x4 *matrix) const { Q_D(const QDeclarativeTranslate); - matrix->translate(d->x, d->y, d->z); + matrix->translate(d->x, d->y, 0); } /*! @@ -155,7 +131,6 @@ void QDeclarativeTranslate::applyTo(QMatrix4x4 *matrix) const QDeclarativeTranslate emits this signal when its position changes. \sa QDeclarativeTranslate::x, QDeclarativeTranslate::y - \sa QDeclarativeTranslate::z */ QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qdeclarativetranslate_p.h b/src/declarative/graphicsitems/qdeclarativetranslate_p.h index 54bfc3d..1371f71 100644 --- a/src/declarative/graphicsitems/qdeclarativetranslate_p.h +++ b/src/declarative/graphicsitems/qdeclarativetranslate_p.h @@ -58,7 +58,6 @@ class Q_GUI_EXPORT QDeclarativeTranslate : public QGraphicsTransform Q_PROPERTY(qreal x READ x WRITE setX NOTIFY positionChanged) Q_PROPERTY(qreal y READ y WRITE setY NOTIFY positionChanged) - Q_PROPERTY(qreal z READ z WRITE setZ NOTIFY positionChanged) public: QDeclarativeTranslate(QObject *parent = 0); @@ -70,9 +69,6 @@ public: qreal y() const; void setY(qreal); - qreal z() const; - void setZ(qreal); - void applyTo(QMatrix4x4 *matrix) const; Q_SIGNALS: diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index b407eef..36203de 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -3843,6 +3843,22 @@ void QGraphicsItem::setTransformations(const QList &transf /*! \internal */ +void QGraphicsItemPrivate::prependGraphicsTransform(QGraphicsTransform *t) +{ + if (!transformData) + transformData = new QGraphicsItemPrivate::TransformData; + if (!transformData->graphicsTransforms.contains(t)) + transformData->graphicsTransforms.prepend(t); + + Q_Q(QGraphicsItem); + t->d_func()->setItem(q); + transformData->onlyTransform = false; + dirtySceneTransform = 1; +} + +/*! + \internal +*/ void QGraphicsItemPrivate::appendGraphicsTransform(QGraphicsTransform *t) { if (!transformData) diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index b53c545..b6be79d 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -276,6 +276,7 @@ public: virtual void setPosHelper(const QPointF &pos); void setTransformHelper(const QTransform &transform); + void prependGraphicsTransform(QGraphicsTransform *t); void appendGraphicsTransform(QGraphicsTransform *t); void setVisibleHelper(bool newVisible, bool explicitly, bool update = true); void setEnabledHelper(bool newEnabled, bool explicitly, bool update = true); diff --git a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp index d800411..46f3517 100644 --- a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp +++ b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp @@ -408,9 +408,14 @@ void tst_QDeclarativeItem::transforms_data() { QTest::addColumn("qml"); QTest::addColumn("matrix"); - QTest::newRow("translate") << QByteArray("import Qt 4.6\nItem { transform: Translate { x: 10; y: 20 } }") << QMatrix(1,0,0,1,10,20); - QTest::newRow("rotation") << QByteArray("import Qt 4.6\nItem { transform: Rotation { angle: 90 } }") << QMatrix(0,1,-1,0,0,0); - QTest::newRow("scale") << QByteArray("import Qt 4.6\nItem { transform: Scale { xScale: 1.5; yScale: -2 } }") << QMatrix(1.5,0,0,-2,0,0); + QTest::newRow("translate") << QByteArray("Translate { x: 10; y: 20 }") + << QMatrix(1,0,0,1,10,20); + QTest::newRow("rotation") << QByteArray("Rotation { angle: 90 }") + << QMatrix(0,1,-1,0,0,0); + QTest::newRow("scale") << QByteArray("Scale { xScale: 1.5; yScale: -2 }") + << QMatrix(1.5,0,0,-2,0,0); + QTest::newRow("sequence") << QByteArray("[ Translate { x: 10; y: 20 }, Scale { xScale: 1.5; yScale: -2 } ]") + << QMatrix(1,0,0,1,10,20) * QMatrix(1.5,0,0,-2,0,0); } void tst_QDeclarativeItem::transforms() @@ -418,8 +423,9 @@ void tst_QDeclarativeItem::transforms() QFETCH(QByteArray, qml); QFETCH(QMatrix, matrix); QDeclarativeComponent component(&engine); - component.setData(qml, QUrl::fromLocalFile("")); + component.setData("import Qt 4.6\nItem { transform: "+qml+"}", QUrl::fromLocalFile("")); QDeclarativeItem *item = qobject_cast(component.create()); + QVERIFY(item); QCOMPARE(item->sceneMatrix(), matrix); } -- cgit v0.12 From d432123cec9ac927ec9162fa8b3d16684483f994 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Fri, 26 Mar 2010 17:17:37 +1000 Subject: Use QThread IdlePriority rather than linux platform code. Task-number: QTBUG-9032 --- src/declarative/util/qdeclarativepixmapcache.cpp | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/declarative/util/qdeclarativepixmapcache.cpp b/src/declarative/util/qdeclarativepixmapcache.cpp index bbe86e7..54dccce 100644 --- a/src/declarative/util/qdeclarativepixmapcache.cpp +++ b/src/declarative/util/qdeclarativepixmapcache.cpp @@ -60,11 +60,6 @@ #include #include -#ifdef Q_OS_LINUX -#include -#include -#endif - // Maximum number of simultaneous image requests to send. static const int maxImageRequestCount = 8; @@ -364,7 +359,7 @@ void QDeclarativeImageRequestHandler::networkRequestDone() QDeclarativeImageReader::QDeclarativeImageReader(QDeclarativeEngine *eng) : QThread(eng), engine(eng), handler(0) { - start(QThread::LowPriority); + start(QThread::IdlePriority); } QDeclarativeImageReader::~QDeclarativeImageReader() @@ -417,14 +412,6 @@ void QDeclarativeImageReader::cancel(QDeclarativePixmapReply *reply) void QDeclarativeImageReader::run() { -#if defined(Q_OS_LINUX) && defined(SCHED_IDLE) - struct sched_param param; - int policy; - - pthread_getschedparam(pthread_self(), &policy, ¶m); - pthread_setschedparam(pthread_self(), SCHED_IDLE, ¶m); -#endif - handler = new QDeclarativeImageRequestHandler(this, engine); exec(); -- cgit v0.12 From c4448162a00b6a069b562756d5608d821f700546 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Fri, 26 Mar 2010 18:13:29 +1000 Subject: Added highlight ranges/modes to PathView Task-number: QT-319 --- src/declarative/QmlChanges.txt | 1 + .../graphicsitems/qdeclarativepathview.cpp | 286 +++++++++++++++++---- .../graphicsitems/qdeclarativepathview_p.h | 23 +- .../graphicsitems/qdeclarativepathview_p_p.h | 28 +- .../qdeclarativepathview/data/displaypath.qml | 1 - .../qdeclarativepathview/data/pathview0.qml | 1 - .../qdeclarativepathview/data/pathview3.qml | 4 +- .../qdeclarativepathview/data/propertychanges.qml | 3 +- .../tst_qdeclarativepathview.cpp | 19 +- 9 files changed, 297 insertions(+), 69 deletions(-) diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt index d35a4c2..6ab77a7 100644 --- a/src/declarative/QmlChanges.txt +++ b/src/declarative/QmlChanges.txt @@ -16,6 +16,7 @@ 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) +PathView: snapPosition replaced by preferredHighlightBegin, preferredHighlightEnd C++ API ------- diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp index 783387c..9b548d4 100644 --- a/src/declarative/graphicsitems/qdeclarativepathview.cpp +++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp @@ -44,6 +44,7 @@ #include #include +#include #include #include #include @@ -146,20 +147,23 @@ void QDeclarativePathViewPrivate::updateMappedRange() mappedRange = 1.0; } -qreal QDeclarativePathViewPrivate::positionOfIndex(int index) const +qreal QDeclarativePathViewPrivate::positionOfIndex(qreal index) const { qreal pos = -1.0; if (model && index >= 0 && index < model->count()) { - qreal globalPos = qreal(index) + offset; + qreal start = 0.0; + if (haveHighlightRange && highlightRangeMode != QDeclarativePathView::NoHighlightRange) + start = highlightRangeStart; + qreal globalPos = index + offset; globalPos = qmlMod(globalPos, qreal(model->count())) / model->count(); if (pathItems != -1 && pathItems < model->count()) { - globalPos += snapPos * mappedRange; + globalPos += start * mappedRange; globalPos = qmlMod(globalPos, 1.0); if (globalPos < mappedRange) pos = globalPos / mappedRange; } else { - pos = qmlMod(globalPos + snapPos, 1.0); + pos = qmlMod(globalPos + start, 1.0); } } @@ -169,6 +173,9 @@ qreal QDeclarativePathViewPrivate::positionOfIndex(int index) const void QDeclarativePathViewPrivate::createHighlight() { Q_Q(QDeclarativePathView); + if (!q->isComponentComplete()) + return; + bool changed = false; if (highlightItem) { delete highlightItem; @@ -203,10 +210,67 @@ void QDeclarativePathViewPrivate::createHighlight() void QDeclarativePathViewPrivate::updateHighlight() { Q_Q(QDeclarativePathView); - if (!q->isComponentComplete()) + if (!q->isComponentComplete() || !isValid()) return; - if (highlightItem) - updateItem(highlightItem, snapPos); + if (highlightItem) { + if (haveHighlightRange && highlightRangeMode == QDeclarativePathView::StrictlyEnforceRange) { + updateItem(highlightItem, highlightRangeStart); + } else { + qreal target = currentIndex; + + tl.reset(moveHighlight); + moveHighlight.setValue(highlightPosition); + + const int duration = 300; + + if (target - highlightPosition > model->count()/2) { + highlightUp = false; + qreal distance = model->count() - target + highlightPosition; + tl.move(moveHighlight, 0.0, QEasingCurve(QEasingCurve::InQuad), int(duration * highlightPosition / distance)); + tl.set(moveHighlight, model->count()-0.01); + tl.move(moveHighlight, target, QEasingCurve(QEasingCurve::OutQuad), int(duration * (model->count()-target) / distance)); + } else if (target - highlightPosition <= -model->count()/2) { + highlightUp = true; + qreal distance = model->count() - highlightPosition + target; + tl.move(moveHighlight, model->count()-0.01, QEasingCurve(QEasingCurve::InQuad), int(duration * (model->count()-highlightPosition) / distance)); + tl.set(moveHighlight, 0.0); + tl.move(moveHighlight, target, QEasingCurve(QEasingCurve::OutQuad), int(duration * target / distance)); + } else { + highlightUp = highlightPosition - target < 0; + tl.move(moveHighlight, target, QEasingCurve(QEasingCurve::InOutQuad), duration); + } + } + } +} + +void QDeclarativePathViewPrivate::setHighlightPosition(qreal pos) +{ + if (pos != highlightPosition) { + qreal start = 0.0; + qreal end = 1.0; + if (haveHighlightRange && highlightRangeMode != QDeclarativePathView::NoHighlightRange) { + start = highlightRangeStart; + end = highlightRangeEnd; + } + + qreal range = qreal(model->count()); + // calc normalized position of highlight relative to offset + qreal relativeHighlight = qmlMod(pos + offset, range) / range; + + if (!highlightUp && relativeHighlight > end * mappedRange) { + qreal diff = 1.0 - relativeHighlight; + setOffset(offset + diff * range); + } else if (highlightUp && relativeHighlight >= (end - start) * mappedRange) { + qreal diff = relativeHighlight - (end - start) * mappedRange; + setOffset(offset - diff * range - 0.00001); + } + + highlightPosition = pos; + qreal pathPos = positionOfIndex(pos); + updateItem(highlightItem, pathPos); + if (QDeclarativePathViewAttached *att = attached(highlightItem)) + att->setOnPath(pathPos != -1.0); + } } void QDeclarativePathViewPrivate::updateItem(QDeclarativeItem *item, qreal percent) @@ -437,9 +501,11 @@ void QDeclarativePathView::setCurrentIndex(int idx) } } } + d->moveReason = QDeclarativePathViewPrivate::SetIndex; d->currentIndex = idx; if (d->model->count()) { - d->snapToCurrent(); + if (d->haveHighlightRange && d->highlightRangeMode == QDeclarativePathView::StrictlyEnforceRange) + d->snapToCurrent(); int itemIndex = (idx - d->firstIndex + d->model->count()) % d->model->count(); if (itemIndex < d->items.count()) { QDeclarativeItem *item = d->items.at(itemIndex); @@ -447,6 +513,8 @@ void QDeclarativePathView::setCurrentIndex(int idx) if (QDeclarativePathViewAttached *att = d->attached(item)) att->setIsCurrentItem(true); } + d->currentItemOffset = d->positionOfIndex(d->currentIndex); + d->updateHighlight(); } emit currentIndexChanged(); } @@ -478,7 +546,7 @@ void QDeclarativePathViewPrivate::setOffset(qreal o) if (isValid() && q->isComponentComplete()) { offset = qmlMod(o, qreal(model->count())); if (offset < 0) - offset = model->count() + offset; + offset += qreal(model->count()); q->refill(); } else { offset = o; @@ -488,29 +556,28 @@ void QDeclarativePathViewPrivate::setOffset(qreal o) } /*! - \qmlproperty real PathView::snapPosition + \qmlproperty component PathView::highlight + This property holds the component to use as the highlight. - 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 -{ - Q_D(const QDeclarativePathView); - return d->snapPos; -} + An instance of the highlight component will be created for each view. + The geometry of the resultant component instance will be managed by the view + so as to stay with the current item. -void QDeclarativePathView::setSnapPosition(qreal pos) -{ - Q_D(QDeclarativePathView); - qreal normalizedPos = pos - int(pos); - if (qFuzzyCompare(normalizedPos, d->snapPos)) - return; - d->snapPos = normalizedPos; - d->updateHighlight(); - d->fixOffset(); - emit snapPositionChanged(); -} + The below example demonstrates how to make a simple highlight. Note the use + of the PathView.onPath property to ensure that the highlight is hidden + when flicked off of the path. + + \code + Component { + Rectangle { + visible: PathView.onPath + ... + } + } + \endcode + + \sa highlightItem, highlightRangeMode +*/ QDeclarativeComponent *QDeclarativePathView::highlight() const { @@ -529,11 +596,99 @@ void QDeclarativePathView::setHighlight(QDeclarativeComponent *highlight) } } +/*! + \qmlproperty Item PathView::highlightItem + + \c highlightItem holds the highlight item, which was created + from the \l highlight component. + + \sa highlight +*/ QDeclarativeItem *QDeclarativePathView::highlightItem() { Q_D(const QDeclarativePathView); return d->highlightItem; } +/*! + \qmlproperty real PathView::preferredHighlightBegin + \qmlproperty real PathView::preferredHighlightEnd + \qmlproperty enumeration PathView::highlightRangeMode + + These properties set the preferred range of the highlight (current item) + within the view. The preferred values must be in the range 0.0-1.0. + + If highlightRangeMode is set to \e ApplyRange the view will + attempt to maintain the highlight within the range, however + the highlight can move outside of the range at the ends of the path + or due to a mouse interaction. + + If highlightRangeMode is set to \e StrictlyEnforceRange the highlight will never + move outside of the range. This means that the current item will change + if a keyboard or mouse action would cause the highlight to move + outside of the range. + + Note that this is the correct way to influence where the + current item ends up when the view moves. For example, if you want the + currently selected item to be in the middle of the path, then set the + highlight range to be 0.5,0.5 and highlightRangeMode to StrictlyEnforceRange. + Then, when the path scrolls, + the currently selected item will be the item at that position. This also applies to + when the currently selected item changes - it will scroll to within the preferred + highlight range. Furthermore, the behaviour of the current item index will occur + whether or not a highlight exists. + + The default value is \e StrictlyEnforceRange. + + Note that a valid range requires preferredHighlightEnd to be greater + than or equal to preferredHighlightBegin. +*/ +qreal QDeclarativePathView::preferredHighlightBegin() const +{ + Q_D(const QDeclarativePathView); + return d->highlightRangeStart; +} + +void QDeclarativePathView::setPreferredHighlightBegin(qreal start) +{ + Q_D(QDeclarativePathView); + if (d->highlightRangeStart == start || start < 0 || start > 1.0) + return; + d->highlightRangeStart = start; + d->haveHighlightRange = d->highlightRangeMode != NoHighlightRange && d->highlightRangeStart <= d->highlightRangeEnd; + emit preferredHighlightBeginChanged(); +} + +qreal QDeclarativePathView::preferredHighlightEnd() const +{ + Q_D(const QDeclarativePathView); + return d->highlightRangeEnd; +} + +void QDeclarativePathView::setPreferredHighlightEnd(qreal end) +{ + Q_D(QDeclarativePathView); + if (d->highlightRangeEnd == end || end < 0 || end > 1.0) + return; + d->highlightRangeEnd = end; + d->haveHighlightRange = d->highlightRangeMode != NoHighlightRange && d->highlightRangeStart <= d->highlightRangeEnd; + emit preferredHighlightEndChanged(); +} + +QDeclarativePathView::HighlightRangeMode QDeclarativePathView::highlightRangeMode() const +{ + Q_D(const QDeclarativePathView); + return d->highlightRangeMode; +} + +void QDeclarativePathView::setHighlightRangeMode(HighlightRangeMode mode) +{ + Q_D(QDeclarativePathView); + if (d->highlightRangeMode == mode) + return; + d->highlightRangeMode = mode; + d->haveHighlightRange = d->highlightRangeMode != NoHighlightRange && d->highlightRangeStart <= d->highlightRangeEnd; + emit highlightRangeModeChanged(); +} /*! \qmlproperty real PathView::dragMargin @@ -770,16 +925,18 @@ void QDeclarativePathView::mouseReleaseEvent(QGraphicsSceneMouseEvent *) velocity = (velocity > 0 ? count : -count) * 2; // Calculate the distance to be travelled qreal v2 = velocity*velocity; - qreal accel = d->deceleration; + qreal accel = d->deceleration/10; // + 0.25 to encourage moving at least one item in the flick direction - qreal dist = qMin(qreal(d->model->count()-1), qreal(qreal(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)); + qreal dist = qMin(qreal(d->model->count()-1), qreal(v2 / (accel * 2.0) + 0.25)); + if (d->haveHighlightRange && d->highlightRangeMode == QDeclarativePathView::StrictlyEnforceRange) { + // 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)); @@ -862,6 +1019,7 @@ void QDeclarativePathView::componentComplete() { Q_D(QDeclarativePathView); QDeclarativeItem::componentComplete(); + d->createHighlight(); d->regenerate(); d->updateHighlight(); } @@ -872,7 +1030,7 @@ void QDeclarativePathView::refill() if (!d->isValid() || !isComponentComplete()) return; -// qDebug() << "offset" << d->_offset; + bool currentVisible = false; // first move existing items and remove items off path int idx = d->firstIndex; @@ -882,6 +1040,10 @@ void QDeclarativePathView::refill() QDeclarativeItem *item = *it; if (pos >= 0.0) { d->updateItem(item, pos); + if (idx == d->currentIndex) { + currentVisible = true; + d->currentItemOffset = pos; + } ++it; } else { // qDebug() << "release"; @@ -902,7 +1064,9 @@ void QDeclarativePathView::refill() 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; + qreal startPos = 0.0; + if (d->haveHighlightRange && d->highlightRangeMode != QDeclarativePathView::NoHighlightRange) + startPos = d->highlightRangeStart; if (d->firstIndex >= 0) { startPos = d->positionOfIndex(d->firstIndex); idx = (d->firstIndex + d->items.count()) % d->model->count(); @@ -917,6 +1081,8 @@ void QDeclarativePathView::refill() item->setFocus(true); if (QDeclarativePathViewAttached *att = d->attached(item)) att->setIsCurrentItem(true); + currentVisible = true; + d->currentItemOffset = pos; } if (d->items.count() == 0) d->firstIndex = idx; @@ -941,6 +1107,8 @@ void QDeclarativePathView::refill() item->setFocus(true); if (QDeclarativePathViewAttached *att = d->attached(item)) att->setIsCurrentItem(true); + currentVisible = true; + d->currentItemOffset = pos; } d->items.prepend(item); d->updateItem(item, pos); @@ -951,6 +1119,19 @@ void QDeclarativePathView::refill() pos = d->positionOfIndex(idx); } } + + if (!currentVisible) + d->currentItemOffset = 1.0; + + if (d->highlightItem && d->haveHighlightRange && d->highlightRangeMode == QDeclarativePathView::StrictlyEnforceRange) { + d->updateItem(d->highlightItem, d->highlightRangeStart); + if (QDeclarativePathViewAttached *att = d->attached(d->highlightItem)) + att->setOnPath(true); + } else if (d->moveReason != QDeclarativePathViewPrivate::SetIndex) { + d->updateItem(d->highlightItem, d->currentItemOffset); + if (QDeclarativePathViewAttached *att = d->attached(d->highlightItem)) + att->setOnPath(currentVisible); + } } void QDeclarativePathView::itemsInserted(int modelIndex, int count) @@ -962,6 +1143,10 @@ void QDeclarativePathView::itemsInserted(int modelIndex, int count) QList removedItems = d->items; d->items.clear(); + if (modelIndex <= d->currentIndex) { + d->currentIndex += count; + emit currentIndexChanged(); + } d->regenerate(); while (removedItems.count()) d->releaseItem(removedItems.takeLast()); @@ -980,6 +1165,7 @@ void QDeclarativePathView::itemsRemoved(int modelIndex, int count) d->items.clear(); if (d->offset >= d->model->count()) d->offset = d->model->count() - 1; + //XXX update currentIndex d->regenerate(); while (removedItems.count()) d->releaseItem(removedItems.takeLast()); @@ -995,6 +1181,7 @@ void QDeclarativePathView::itemsMoved(int from, int to, int count) QList removedItems = d->items; d->items.clear(); + //XXX update currentIndex d->regenerate(); while (removedItems.count()) d->releaseItem(removedItems.takeLast()); @@ -1047,6 +1234,9 @@ void QDeclarativePathViewPrivate::updateCurrent() Q_Q(QDeclarativePathView); if (moveReason != Mouse) return; + if (!haveHighlightRange || highlightRangeMode != QDeclarativePathView::StrictlyEnforceRange) + return; + int idx = calcCurrentIndex(); if (model && idx != currentIndex) { int itemIndex = (currentIndex - firstIndex + model->count()) % model->count(); @@ -1077,11 +1267,13 @@ void QDeclarativePathViewPrivate::fixOffset() { Q_Q(QDeclarativePathView); if (model && items.count()) { - int curr = calcCurrentIndex(); - if (curr != currentIndex) - q->setCurrentIndex(curr); - else - snapToCurrent(); + if (haveHighlightRange && highlightRangeMode == QDeclarativePathView::StrictlyEnforceRange) { + int curr = calcCurrentIndex(); + if (curr != currentIndex) + q->setCurrentIndex(curr); + else + snapToCurrent(); + } } } @@ -1093,7 +1285,7 @@ void QDeclarativePathViewPrivate::snapToCurrent() qreal targetOffset = model->count() - currentIndex; moveReason = Other; - tl.clear(); + tl.reset(moveOffset); moveOffset.setValue(offset); const int duration = 300; diff --git a/src/declarative/graphicsitems/qdeclarativepathview_p.h b/src/declarative/graphicsitems/qdeclarativepathview_p.h index 07b8f6f..0079891 100644 --- a/src/declarative/graphicsitems/qdeclarativepathview_p.h +++ b/src/declarative/graphicsitems/qdeclarativepathview_p.h @@ -61,11 +61,14 @@ class Q_DECLARATIVE_EXPORT QDeclarativePathView : public QDeclarativeItem Q_PROPERTY(QDeclarativePath *path READ path WRITE setPath NOTIFY pathChanged) 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 preferredHighlightBegin READ preferredHighlightBegin WRITE setPreferredHighlightBegin NOTIFY preferredHighlightBeginChanged) + Q_PROPERTY(qreal preferredHighlightEnd READ preferredHighlightEnd WRITE setPreferredHighlightEnd NOTIFY preferredHighlightEndChanged) + Q_PROPERTY(HighlightRangeMode highlightRangeMode READ highlightRangeMode WRITE setHighlightRangeMode NOTIFY highlightRangeModeChanged) + Q_PROPERTY(qreal dragMargin READ dragMargin WRITE setDragMargin NOTIFY dragMarginChanged) Q_PROPERTY(qreal flickDeceleration READ flickDeceleration WRITE setFlickDeceleration NOTIFY flickDecelerationChanged) Q_PROPERTY(bool interactive READ isInteractive WRITE setInteractive NOTIFY interactiveChanged) @@ -74,6 +77,8 @@ class Q_DECLARATIVE_EXPORT QDeclarativePathView : public QDeclarativeItem Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged) Q_PROPERTY(int pathItemCount READ pathItemCount WRITE setPathItemCount NOTIFY pathItemCountChanged) + Q_ENUMS(HighlightRangeMode); + public: QDeclarativePathView(QDeclarativeItem *parent=0); virtual ~QDeclarativePathView(); @@ -90,13 +95,20 @@ public: qreal offset() const; void setOffset(qreal offset); - qreal snapPosition() const; - void setSnapPosition(qreal pos); - QDeclarativeComponent *highlight() const; void setHighlight(QDeclarativeComponent *highlight); QDeclarativeItem *highlightItem(); + enum HighlightRangeMode { NoHighlightRange, ApplyRange, StrictlyEnforceRange }; + HighlightRangeMode highlightRangeMode() const; + void setHighlightRangeMode(HighlightRangeMode mode); + + qreal preferredHighlightBegin() const; + void setPreferredHighlightBegin(qreal); + + qreal preferredHighlightEnd() const; + void setPreferredHighlightEnd(qreal); + qreal dragMargin() const; void setDragMargin(qreal margin); @@ -122,6 +134,9 @@ Q_SIGNALS: void modelChanged(); void countChanged(); void pathChanged(); + void preferredHighlightBeginChanged(); + void preferredHighlightEndChanged(); + void highlightRangeModeChanged(); void dragMarginChanged(); void snapPositionChanged(); void delegateChanged(); diff --git a/src/declarative/graphicsitems/qdeclarativepathview_p_p.h b/src/declarative/graphicsitems/qdeclarativepathview_p_p.h index 1780869..90216c0 100644 --- a/src/declarative/graphicsitems/qdeclarativepathview_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativepathview_p_p.h @@ -74,12 +74,18 @@ class QDeclarativePathViewPrivate : public QDeclarativeItemPrivate public: QDeclarativePathViewPrivate() - : path(0), currentIndex(0), startPc(0), lastDist(0) - , lastElapsed(0), mappedRange(1.0), stealMouse(false), ownModel(false), interactive(true) - , snapPos(0), dragMargin(0), deceleration(100) + : path(0), currentIndex(0), currentItemOffset(0.0), startPc(0), lastDist(0) + , lastElapsed(0), mappedRange(1.0) + , stealMouse(false), ownModel(false), interactive(true), haveHighlightRange(true) + , autoHighlight(true), highlightUp(false), dragMargin(0), deceleration(100) , moveOffset(this, &QDeclarativePathViewPrivate::setOffset) + , moveHighlight(this, &QDeclarativePathViewPrivate::setHighlightPosition) , firstIndex(-1), pathItems(-1), requestedIndex(-1) , moveReason(Other), attType(0), highlightComponent(0), highlightItem(0) + , highlightPosition(0) + , highlightRangeStart(0), highlightRangeEnd(0) + , highlightRangeMode(QDeclarativePathView::StrictlyEnforceRange) + , highlightMoveSpeed(1.0) { } @@ -98,9 +104,10 @@ public: QDeclarativePathViewAttached *attached(QDeclarativeItem *item); void clear(); void updateMappedRange(); - qreal positionOfIndex(int index) const; + qreal positionOfIndex(qreal index) const; void createHighlight(); void updateHighlight(); + void setHighlightPosition(qreal pos); bool isValid() const { return model && model->count() > 0 && model->isValid() && path; } @@ -117,6 +124,7 @@ public: QDeclarativePath *path; int currentIndex; + qreal currentItemOffset; qreal startPc; QPointF startPoint; qreal lastDist; @@ -126,9 +134,11 @@ public: bool stealMouse : 1; bool ownModel : 1; bool interactive : 1; + bool haveHighlightRange : 1; + bool autoHighlight : 1; + bool highlightUp : 1; QTime lastPosTime; QPointF lastPos; - qreal snapPos; qreal dragMargin; qreal deceleration; QDeclarativeTimeLine tl; @@ -139,11 +149,17 @@ public: QList items; QDeclarativeGuard model; QVariant modelVariant; - enum MovementReason { Other, Key, Mouse }; + enum MovementReason { Other, SetIndex, Mouse }; MovementReason moveReason; QDeclarativeOpenMetaObjectType *attType; QDeclarativeComponent *highlightComponent; QDeclarativeItem *highlightItem; + QDeclarativeTimeLineValueProxy moveHighlight; + qreal highlightPosition; + qreal highlightRangeStart; + qreal highlightRangeEnd; + QDeclarativePathView::HighlightRangeMode highlightRangeMode; + qreal highlightMoveSpeed; }; QT_END_NAMESPACE diff --git a/tests/auto/declarative/qdeclarativepathview/data/displaypath.qml b/tests/auto/declarative/qdeclarativepathview/data/displaypath.qml index ab1538b..eded122 100644 --- a/tests/auto/declarative/qdeclarativepathview/data/displaypath.qml +++ b/tests/auto/declarative/qdeclarativepathview/data/displaypath.qml @@ -33,7 +33,6 @@ Rectangle { height: 320 model: testModel delegate: delegate - snapPosition: 0.0001 path: Path { startY: 120 startX: 160 diff --git a/tests/auto/declarative/qdeclarativepathview/data/pathview0.qml b/tests/auto/declarative/qdeclarativepathview/data/pathview0.qml index 8e2c251..1866875 100644 --- a/tests/auto/declarative/qdeclarativepathview/data/pathview0.qml +++ b/tests/auto/declarative/qdeclarativepathview/data/pathview0.qml @@ -48,7 +48,6 @@ Rectangle { height: 320 model: testModel delegate: delegate - snapPosition: 0.0001 highlight: Rectangle { width: 60 height: 20 diff --git a/tests/auto/declarative/qdeclarativepathview/data/pathview3.qml b/tests/auto/declarative/qdeclarativepathview/data/pathview3.qml index f1bc66e..b143294 100644 --- a/tests/auto/declarative/qdeclarativepathview/data/pathview3.qml +++ b/tests/auto/declarative/qdeclarativepathview/data/pathview3.qml @@ -3,7 +3,9 @@ import Qt 4.6 PathView { id: photoPathView y: 100; width: 800; height: 330; pathItemCount: 4; offset: 1 - dragMargin: 24; snapPosition: 0.50 + dragMargin: 24 + preferredHighlightBegin: 0.50 + preferredHighlightEnd: 0.50 path: Path { startX: -50; startY: 40; diff --git a/tests/auto/declarative/qdeclarativepathview/data/propertychanges.qml b/tests/auto/declarative/qdeclarativepathview/data/propertychanges.qml index db70b7b..1ae1ad2 100644 --- a/tests/auto/declarative/qdeclarativepathview/data/propertychanges.qml +++ b/tests/auto/declarative/qdeclarativepathview/data/propertychanges.qml @@ -17,7 +17,8 @@ Rectangle { } PathView { - snapPosition: 0.1 + preferredHighlightBegin: 0.1 + preferredHighlightEnd: 0.1 dragMargin: 5.0 id: pathView objectName: "pathView" diff --git a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp index 6d7cc0d..4d43c68 100644 --- a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp +++ b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp @@ -194,7 +194,7 @@ void tst_QDeclarativePathView::initValues() QCOMPARE(obj->model(), QVariant()); QCOMPARE(obj->currentIndex(), 0); QCOMPARE(obj->offset(), 0.); - QCOMPARE(obj->snapPosition(), 0.); + QCOMPARE(obj->preferredHighlightBegin(), 0.); QCOMPARE(obj->dragMargin(), 0.); QCOMPARE(obj->count(), 0); QCOMPARE(obj->pathItemCount(), -1); @@ -255,7 +255,7 @@ void tst_QDeclarativePathView::pathview2() QVERIFY(obj->model() != QVariant()); QCOMPARE(obj->currentIndex(), 0); QCOMPARE(obj->offset(), 0.); - QCOMPARE(obj->snapPosition(), 0.); + QCOMPARE(obj->preferredHighlightBegin(), 0.); QCOMPARE(obj->dragMargin(), 0.); QCOMPARE(obj->count(), 8); QCOMPARE(obj->pathItemCount(), 10); @@ -273,7 +273,7 @@ void tst_QDeclarativePathView::pathview3() QVERIFY(obj->model() != QVariant()); QCOMPARE(obj->currentIndex(), 0); QCOMPARE(obj->offset(), 1.0); - QCOMPARE(obj->snapPosition(), 0.5); + QCOMPARE(obj->preferredHighlightBegin(), 0.5); QCOMPARE(obj->dragMargin(), 24.); QCOMPARE(obj->count(), 8); QCOMPARE(obj->pathItemCount(), 4); @@ -534,22 +534,25 @@ void tst_QDeclarativePathView::propertyChanges() QDeclarativePathView *pathView = canvas->rootObject()->findChild("pathView"); QVERIFY(pathView); - QSignalSpy snapPositionSpy(pathView, SIGNAL(snapPositionChanged())); + QSignalSpy snapPositionSpy(pathView, SIGNAL(preferredHighlightBeginChanged())); QSignalSpy dragMarginSpy(pathView, SIGNAL(dragMarginChanged())); - QCOMPARE(pathView->snapPosition(), 0.1); + QCOMPARE(pathView->preferredHighlightBegin(), 0.1); QCOMPARE(pathView->dragMargin(), 5.0); - pathView->setSnapPosition(0.4); + pathView->setPreferredHighlightBegin(0.4); + pathView->setPreferredHighlightEnd(0.4); pathView->setDragMargin(20.0); - QCOMPARE(pathView->snapPosition(), 0.4); + QCOMPARE(pathView->preferredHighlightBegin(), 0.4); + QCOMPARE(pathView->preferredHighlightEnd(), 0.4); QCOMPARE(pathView->dragMargin(), 20.0); QCOMPARE(snapPositionSpy.count(), 1); QCOMPARE(dragMarginSpy.count(), 1); - pathView->setSnapPosition(0.4); + pathView->setPreferredHighlightBegin(0.4); + pathView->setPreferredHighlightEnd(0.4); pathView->setDragMargin(20.0); QCOMPARE(snapPositionSpy.count(), 1); -- cgit v0.12 From 8217da65cbe44261a83418017be311bb1a62725d Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Fri, 26 Mar 2010 09:37:14 +0100 Subject: Doc Augmentation Task-number: QTBUG-9396 --- doc/src/declarative/extending.qdoc | 13 +++++++++++++ src/declarative/graphicsitems/qdeclarativepositioners.cpp | 4 +++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/doc/src/declarative/extending.qdoc b/doc/src/declarative/extending.qdoc index 8c096da..3dce8c3 100644 --- a/doc/src/declarative/extending.qdoc +++ b/doc/src/declarative/extending.qdoc @@ -693,6 +693,19 @@ it in two steps, like this: myProperty: 10 \endcode +If a default value is not supplied or set later in the file, each type has a +default value for when none is explictly set. Below are the default values +of some of the types. For the remaining types the default values are undefined. + +\table +\header \o QML Type \o Default Value +\row \o bool \o false +\row \o int \o 0 +\row \o double, real \o 0.0 +\row \o string, url \o "" (an empty string) +\row \o color \o #000000 (black) +\endtable + If specified, the optional "default" attribute marks the new property as the types default property, overriding any existing default property. Using the default attribute twice in the same type block is an error. diff --git a/src/declarative/graphicsitems/qdeclarativepositioners.cpp b/src/declarative/graphicsitems/qdeclarativepositioners.cpp index 7a0d33a..5e91224 100644 --- a/src/declarative/graphicsitems/qdeclarativepositioners.cpp +++ b/src/declarative/graphicsitems/qdeclarativepositioners.cpp @@ -602,7 +602,9 @@ Grid { \qmlproperty Transition Grid::add This property holds the transition to apply when adding an item to the positioner. The transition is only applied to the added item(s). - Positioner transitions will only affect the position (x,y) of items. + Positioner transitions will only affect the position (x,y) of items, + as that is all the positioners affect. To animate other property change + you will have to do so based on how you have changed those properties. Added can mean that either the object has been created or reparented, and thus is now a child or the positioner, or that the -- cgit v0.12 From 15d9ab9a041ea9e81e444a8777e32e4f909320c1 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Fri, 26 Mar 2010 09:40:08 +0100 Subject: I've been told this fixes compilation on windows. --- src/declarative/graphicsitems/qdeclarativetranslate_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/graphicsitems/qdeclarativetranslate_p.h b/src/declarative/graphicsitems/qdeclarativetranslate_p.h index 1371f71..939692b 100644 --- a/src/declarative/graphicsitems/qdeclarativetranslate_p.h +++ b/src/declarative/graphicsitems/qdeclarativetranslate_p.h @@ -52,7 +52,7 @@ QT_MODULE(Declarative) class QDeclarativeTranslatePrivate; -class Q_GUI_EXPORT QDeclarativeTranslate : public QGraphicsTransform +class Q_DECLARATIVE_EXPORT QDeclarativeTranslate : public QGraphicsTransform { Q_OBJECT -- cgit v0.12 From c3a7d812d3cf30d23049cfd355c6290a7985f81d Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 25 Mar 2010 12:12:01 +0200 Subject: Enable armcc version specific compler options for Symbian VERSION_FLAGS.ARMCC variable is used in symbian.conf to define supported armcc compiler version flags. Values given to this variable must be directly usable as ifdef flags in mmp. QMAKE_CXXFLAGS. variables can now be used to add compiler options to specific compiler versions. Note that options added via QMAKE_CXXFLAGS.ARMCC flag will apply to all versions of armcc compiler. Task-number: QTBUG-8685 Reviewed-by: Iain --- mkspecs/common/symbian/symbian.conf | 5 ++++- qmake/generators/symbian/symmake.cpp | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/mkspecs/common/symbian/symbian.conf b/mkspecs/common/symbian/symbian.conf index c39b39d..d66d227 100644 --- a/mkspecs/common/symbian/symbian.conf +++ b/mkspecs/common/symbian/symbian.conf @@ -26,10 +26,13 @@ QMAKE_CFLAGS_RELEASE = QMAKE_CFLAGS_DEBUG = QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses + +VERSION_FLAGS.ARMCC = ARMCC_4_0 QMAKE_CXX = g++ QMAKE_CXXFLAGS = $$QMAKE_CFLAGS QMAKE_CXXFLAGS.CW = -QMAKE_CXXFLAGS.ARMCC = --visibility_inlines_hidden +QMAKE_CXXFLAGS.ARMCC = --visibility_inlines_hidden +QMAKE_CXXFLAGS.ARMCC_4_0 = --import_all_vtbl QMAKE_CXXFLAGS.GCCE = -fvisibility-inlines-hidden QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON diff --git a/qmake/generators/symbian/symmake.cpp b/qmake/generators/symbian/symmake.cpp index 1470a12..e1256d8 100644 --- a/qmake/generators/symbian/symmake.cpp +++ b/qmake/generators/symbian/symmake.cpp @@ -1246,6 +1246,16 @@ void SymbianMakefileGenerator::writeMmpFileCompilerOptionPart(QTextStream& t) t << MMP_OPTION_CW " " << cw << endl; if (!armcc.isEmpty()) t << MMP_OPTION_ARMCC " " << armcc << endl; + + foreach(QString armccVersion, project->values("VERSION_FLAGS.ARMCC")) { + QStringList currentValues = project->values("QMAKE_CXXFLAGS." + armccVersion); + if (currentValues.size()) { + t << "#if defined(" << armccVersion << ")" << endl; + t << MMP_OPTION_ARMCC " " << currentValues.join(" ") << endl; + t << "#endif" << endl; + } + } + if (!gcce.isEmpty()) t << MMP_OPTION_GCCE " " << gcce << endl; -- cgit v0.12 From aaf0f47930a44f5f36bb825e10a5067eeced6718 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Fri, 26 Mar 2010 10:41:35 +0200 Subject: Changed pkg_prerules to not use default_deployment for vendor ID Demos and examples used default_deployment to define vendor ID pkg rule, which is not what default_deployment should be used for. As these are supposed to serve as examples for developers, changed these declarations to use another deployment item. Reviewed-by: TrustMe --- demos/symbianpkgrules.pri | 3 ++- examples/symbianpkgrules.pri | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/demos/symbianpkgrules.pri b/demos/symbianpkgrules.pri index c511836..68a82cd 100644 --- a/demos/symbianpkgrules.pri +++ b/demos/symbianpkgrules.pri @@ -10,6 +10,7 @@ vendorinfo = \ ":\"Nokia, Qt\"" \ " " -default_deployment.pkg_prerules += vendorinfo +demos_deployment.pkg_prerules += vendorinfo +DEPLOYMENT += demos_deployment isEmpty(ICON):ICON = $$QT_SOURCE_TREE/src/s60installs/qt.svg diff --git a/examples/symbianpkgrules.pri b/examples/symbianpkgrules.pri index 35edbfb..a1b6634 100644 --- a/examples/symbianpkgrules.pri +++ b/examples/symbianpkgrules.pri @@ -10,6 +10,7 @@ vendorinfo = \ ":\"Nokia, Qt\"" \ " " -default_deployment.pkg_prerules += vendorinfo +examples_deployment.pkg_prerules += vendorinfo +DEPLOYMENT += examples_deployment isEmpty(ICON):ICON = $$QT_SOURCE_TREE/src/s60installs/qt.svg -- cgit v0.12 From a034773ce0e9d3fe3e7768da248d8c2e99cf132d Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Fri, 26 Mar 2010 08:38:43 +0100 Subject: Adds a way to clear the state list property in QDeclarativeStateGroup Needed by QmlDesigner, which needs to be able to remove states at runtime. Done my Marco Bubke Reviewed-by: Michael Brasser --- src/declarative/util/qdeclarativestategroup.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/declarative/util/qdeclarativestategroup.cpp b/src/declarative/util/qdeclarativestategroup.cpp index bc4582c..258a9e9 100644 --- a/src/declarative/util/qdeclarativestategroup.cpp +++ b/src/declarative/util/qdeclarativestategroup.cpp @@ -69,6 +69,7 @@ public: static void append_state(QDeclarativeListProperty *list, QDeclarativeState *state); static int count_state(QDeclarativeListProperty *list); static QDeclarativeState *at_state(QDeclarativeListProperty *list, int index); + static void clear_states(QDeclarativeListProperty *list); QList states; QList transitions; @@ -150,7 +151,8 @@ QDeclarativeListProperty QDeclarativeStateGroup::statesProper Q_D(QDeclarativeStateGroup); return QDeclarativeListProperty(this, &d->states, &QDeclarativeStateGroupPrivate::append_state, &QDeclarativeStateGroupPrivate::count_state, - &QDeclarativeStateGroupPrivate::at_state); + &QDeclarativeStateGroupPrivate::at_state, + &QDeclarativeStateGroupPrivate::clear_states); } void QDeclarativeStateGroupPrivate::append_state(QDeclarativeListProperty *list, QDeclarativeState *state) @@ -175,6 +177,16 @@ QDeclarativeState *QDeclarativeStateGroupPrivate::at_state(QDeclarativeListPrope return _this->d_func()->states.at(index); } +void QDeclarativeStateGroupPrivate::clear_states(QDeclarativeListProperty *list) +{ + QDeclarativeStateGroup *_this = static_cast(list->object); + _this->d_func()->setCurrentStateInternal(QString(), true); + for (int i = 0; i < _this->d_func()->states.count(); ++i) { + _this->d_func()->states.at(i)->setStateGroup(0); + } + _this->d_func()->states.clear(); +} + /*! \qmlproperty list StateGroup::transitions This property holds a list of transitions defined by the state group. -- cgit v0.12 From 31b972b12db4497f1c3ba1762d784c7315e75b62 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Fri, 26 Mar 2010 10:55:48 +0100 Subject: Recompute the source location of regexp literals. Task-number: QTBUG-9367 --- src/declarative/qml/parser/qdeclarativejs.g | 8 +++++++- src/declarative/qml/parser/qdeclarativejsparser.cpp | 8 +++++++- tests/auto/declarative/qdeclarativetextinput/data/validators.qml | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/declarative/qml/parser/qdeclarativejs.g b/src/declarative/qml/parser/qdeclarativejs.g index 0256c52..c7524a4 100644 --- a/src/declarative/qml/parser/qdeclarativejs.g +++ b/src/declarative/qml/parser/qdeclarativejs.g @@ -656,7 +656,7 @@ case $rule_number: { } else if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(2).Expression)) { QString text; for (AST::UiQualifiedId *q = qualifiedId; q; q = q->next) { - text += q->name->asString(); + text += q->name->asString(); if (q->next) text += QLatin1String("."); } node = makeAstNode(driver->nodePool(), qualifiedId); @@ -1109,6 +1109,9 @@ case $rule_number: { diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage())); return false; // ### remove me } + + loc(1).length = lexer->tokenLength(); + AST::RegExpLiteral *node = makeAstNode (driver->nodePool(), lexer->pattern, lexer->flags); node->literalToken = loc(1); sym(1).Node = node; @@ -1126,6 +1129,9 @@ case $rule_number: { diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage())); return false; } + + loc(1).length = lexer->tokenLength(); + AST::RegExpLiteral *node = makeAstNode (driver->nodePool(), lexer->pattern, lexer->flags); node->literalToken = loc(1); sym(1).Node = node; diff --git a/src/declarative/qml/parser/qdeclarativejsparser.cpp b/src/declarative/qml/parser/qdeclarativejsparser.cpp index 9205ef4..2949e88 100644 --- a/src/declarative/qml/parser/qdeclarativejsparser.cpp +++ b/src/declarative/qml/parser/qdeclarativejsparser.cpp @@ -275,7 +275,7 @@ case 20: { } else if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(2).Expression)) { QString text; for (AST::UiQualifiedId *q = qualifiedId; q; q = q->next) { - text += q->name->asString(); + text += q->name->asString(); if (q->next) text += QLatin1String("."); } node = makeAstNode(driver->nodePool(), qualifiedId); @@ -571,6 +571,9 @@ case 76: { diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage())); return false; // ### remove me } + + loc(1).length = lexer->tokenLength(); + AST::RegExpLiteral *node = makeAstNode (driver->nodePool(), lexer->pattern, lexer->flags); node->literalToken = loc(1); sym(1).Node = node; @@ -582,6 +585,9 @@ case 77: { diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage())); return false; } + + loc(1).length = lexer->tokenLength(); + AST::RegExpLiteral *node = makeAstNode (driver->nodePool(), lexer->pattern, lexer->flags); node->literalToken = loc(1); sym(1).Node = node; diff --git a/tests/auto/declarative/qdeclarativetextinput/data/validators.qml b/tests/auto/declarative/qdeclarativetextinput/data/validators.qml index efe7570..531a232 100644 --- a/tests/auto/declarative/qdeclarativetextinput/data/validators.qml +++ b/tests/auto/declarative/qdeclarativetextinput/data/validators.qml @@ -15,7 +15,7 @@ Item { validator: DoubleValidator{top: 12.12; bottom: 2.93; decimals: 2; notation: DoubleValidator.StandardNotation} } TextInput { id: strInput; - validator: RegExpValidator { regExp: RegExp(/[a-zA-z]{2,4}/) } + validator: RegExpValidator { regExp: /[a-zA-z]{2,4}/ } } } -- cgit v0.12 From ea0f3f7db1d62b2ee94addbeb991061bc2811745 Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Fri, 26 Mar 2010 14:09:47 +0200 Subject: QS60Style cannot draw transparency to UI element border areas Due to incorrect initialization of CFbsBitmap, graphic frames (9-part, or 3-part ones) are drawn with white non-transparent rect below them. Initialization corrected. Task-number: QT-3185 Reviewed-by: Janne Anttila --- src/gui/styles/qs60style_s60.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index 1138d20..97cf919 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -859,11 +859,9 @@ QPixmap QS60StyleModeSpecifics::createSkinnedGraphicsLX(QS60StylePrivate::SkinFr User::LeaveIfError(bitmapDev->CreateContext(bitmapGc)); CleanupStack::PushL(bitmapGc); -#ifndef Q_SYMBIAN_HAS_EXTENDED_BITMAP_TYPE frame->LockHeap(); memset(frame->DataAddress(), 0, frame->SizeInPixels().iWidth * frame->SizeInPixels().iHeight * 4); // 4: argb bytes frame->UnlockHeap(); -#endif const TRect outerRect(TPoint(0, 0), targetSize); const TRect innerRect = innerRectFromElement(frameElement, outerRect); -- cgit v0.12 From 0d5c68c7e4f31300ac6736203cea4f67e8b825b5 Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Fri, 26 Mar 2010 14:53:30 +0200 Subject: QInputContextFactory::languages implementation for Symbian. Task-number: QTBUG-6851 Reviewed-by: Sami Merila --- src/gui/inputmethod/inputmethod.pri | 2 +- src/gui/inputmethod/qinputcontextfactory.cpp | 47 +++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/src/gui/inputmethod/inputmethod.pri b/src/gui/inputmethod/inputmethod.pri index 6d9f748..02e3e57 100644 --- a/src/gui/inputmethod/inputmethod.pri +++ b/src/gui/inputmethod/inputmethod.pri @@ -26,6 +26,6 @@ mac:!embedded { symbian:contains(QT_CONFIG, s60) { HEADERS += inputmethod/qcoefepinputcontext_p.h SOURCES += inputmethod/qcoefepinputcontext_s60.cpp - LIBS += -lfepbase + LIBS += -lfepbase -lakninputlanguage } diff --git a/src/gui/inputmethod/qinputcontextfactory.cpp b/src/gui/inputmethod/qinputcontextfactory.cpp index 501a36e..d47e343 100644 --- a/src/gui/inputmethod/qinputcontextfactory.cpp +++ b/src/gui/inputmethod/qinputcontextfactory.cpp @@ -73,6 +73,7 @@ #endif #ifdef Q_WS_S60 #include "qcoefepinputcontext_p.h" +#include "akninputlanguageinfo.h" #endif #include "private/qfactoryloader_p.h" @@ -198,6 +199,42 @@ QStringList QInputContextFactory::keys() return result; } +#if defined(Q_WS_S60) +/*! + \internal + + This function contains pure Symbian exception handling code for + getting S60 language list. + Returned object ownership is transfered to caller. +*/ +static CAknInputLanguageList* s60LangListL() +{ + CAknInputLanguageInfo *langInfo = AknInputLanguageInfoFactory::CreateInputLanguageInfoL(); + CleanupStack::PushL(langInfo); + // In rare phone there is more than 7 languages installed -> use 7 as an array granularity + CAknInputLanguageList *langList = new (ELeave) CAknInputLanguageList(7); + CleanupStack::PushL(langList); + langInfo->AppendAvailableLanguagesL(langList); + CleanupStack::Pop(langList); + CleanupStack::PopAndDestroy(langInfo); + return langList; +} + +/*! + \internal + + This function utility function return S60 language list. + Returned object ownership is transfered to caller. +*/ +static CAknInputLanguageList* s60LangList() +{ + CAknInputLanguageList *langList = NULL; + TRAP_IGNORE(langList = s60LangListL()); + q_check_ptr(langList); + return langList; +} +#endif + /*! Returns the languages supported by the QInputContext object specified by \a key. @@ -229,7 +266,15 @@ QStringList QInputContextFactory::languages( const QString &key ) #endif #if defined(Q_WS_S60) if (key == QLatin1String("coefep")) - return QStringList(QString()); + { + CAknInputLanguageList *langList = s60LangList(); + int count = langList->Count(); + for (int i = 0; i < count; ++i) + { + result.append(QString(qt_symbianLocaleName(langList->At(i)->LanguageCode()))); + } + delete langList; + } #endif #if defined(QT_NO_LIBRARY) || defined(QT_NO_SETTINGS) Q_UNUSED(key); -- cgit v0.12 From fc6cbc103be7eb77d692fb2975397c656b6a939b Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Fri, 26 Mar 2010 14:39:23 +0100 Subject: Fix compile error on Symbian 9.1, caused in network/access. RVCT has trouble when QPointer is instantiated on classes with inlined constructors/functions. Compile fix for 43e1cffb16c2eea54392f5c56210b10abb2f044e, cc22a14f3d2159a8f760b44e3fe1636a3721ce95 and 656c02f128c56177c48b3de47f7b1e17dbbfa4d3 Reviewed-by: Peter Hartmann Reviewed-by: Prasanth --- .../access/qhttpnetworkconnectionchannel.cpp | 30 ++++++++++++++++++++++ .../access/qhttpnetworkconnectionchannel_p.h | 17 +++--------- 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index 0804498..bc7684a 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -58,6 +58,28 @@ QT_BEGIN_NAMESPACE // TODO: Put channel specific stuff here so it does not polute qhttpnetworkconnection.cpp +QHttpNetworkConnectionChannel::QHttpNetworkConnectionChannel() + : socket(0) + , state(IdleState) + , reply(0) + , written(0) + , bytesTotal(0) + , resendCurrent(false) + , lastStatus(0) + , pendingEncrypt(false) + , reconnectAttempts(2) + , authMehtod(QAuthenticatorPrivate::None) + , proxyAuthMehtod(QAuthenticatorPrivate::None) +#ifndef QT_NO_OPENSSL + , ignoreAllSslErrors(false) +#endif + , pipeliningSupported(PipeliningSupportUnknown) + , connection(0) +{ + // Inlining this function in the header leads to compiler error on + // release-armv5, on at least timebox 9.2 and 10.1. +} + void QHttpNetworkConnectionChannel::init() { #ifndef QT_NO_OPENSSL @@ -994,8 +1016,16 @@ void QHttpNetworkConnectionChannel::_q_encryptedBytesWritten(qint64 bytes) sendRequest(); // otherwise we do nothing } + #endif +void QHttpNetworkConnectionChannel::setConnection(QHttpNetworkConnection *c) +{ + // Inlining this function in the header leads to compiler error on + // release-armv5, on at least timebox 9.2 and 10.1. + connection = c; +} + QT_END_NAMESPACE #include "moc_qhttpnetworkconnectionchannel_p.cpp" diff --git a/src/network/access/qhttpnetworkconnectionchannel_p.h b/src/network/access/qhttpnetworkconnectionchannel_p.h index 4a2f8ad..51cb5e8 100644 --- a/src/network/access/qhttpnetworkconnectionchannel_p.h +++ b/src/network/access/qhttpnetworkconnectionchannel_p.h @@ -81,7 +81,6 @@ QT_BEGIN_NAMESPACE class QHttpNetworkRequest; class QHttpNetworkReply; class QByteArray; -class QHttpNetworkConnection; #ifndef HttpMessagePair typedef QPair HttpMessagePair; @@ -128,17 +127,9 @@ public: QList alreadyPipelinedRequests; - QHttpNetworkConnectionChannel() : socket(0), state(IdleState), reply(0), written(0), bytesTotal(0), resendCurrent(false), - lastStatus(0), pendingEncrypt(false), reconnectAttempts(2), - authMehtod(QAuthenticatorPrivate::None), proxyAuthMehtod(QAuthenticatorPrivate::None) -#ifndef QT_NO_OPENSSL - , ignoreAllSslErrors(false) -#endif - , pipeliningSupported(PipeliningSupportUnknown) - , connection(0) - {} - - void setConnection(QHttpNetworkConnection *c) {connection = c;} + QHttpNetworkConnectionChannel(); + + void setConnection(QHttpNetworkConnection *c); QPointer connection; void init(); @@ -188,8 +179,6 @@ public: #endif }; - - QT_END_NAMESPACE #endif // QT_NO_HTTP -- cgit v0.12 From a8af0e05b30cc4ec26f58378cd5a4e11b20cf9bd Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Fri, 26 Mar 2010 08:23:58 -0700 Subject: Fix linking error The #include "moc_qgraphicswidget.cpp" is superfluous and caused these link errors: .obj/debug-shared-emb-x86_64/moc_qgraphicswidget.o:(.data.rel.ro+0x0): multiple definition of `QGraphicsWidget::staticMetaObject' .obj/debug-shared-emb-x86_64/qgraphicswidget.o:(.data.rel.ro+0x0): first defined here .obj/debug-shared-emb-x86_64/moc_qgraphicswidget.o: In function `QGraphicsWidget::metaObject() const': Presumably this only happens when you have a stale moc file sitting around but it's a bug none-the-less. Reviewed-by: TrustMe --- src/gui/graphicsview/qgraphicswidget.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/gui/graphicsview/qgraphicswidget.cpp b/src/gui/graphicsview/qgraphicswidget.cpp index a091347..131ee87 100644 --- a/src/gui/graphicsview/qgraphicswidget.cpp +++ b/src/gui/graphicsview/qgraphicswidget.cpp @@ -342,7 +342,7 @@ void QGraphicsWidget::resize(const QSizeF &size) A side effect of calling this function is that the widget will receive a move event and a resize event. Also, if the widget has a layout assigned, the layout will activate. - + \sa geometry(), resize() */ void QGraphicsWidget::setGeometry(const QRectF &rect) @@ -574,7 +574,7 @@ void QGraphicsWidget::getWindowFrameMargins(qreal *left, qreal *top, qreal *righ void QGraphicsWidget::unsetWindowFrameMargins() { Q_D(QGraphicsWidget); - if ((d->windowFlags & Qt::Window) && (d->windowFlags & Qt::WindowType_Mask) != Qt::Popup && + if ((d->windowFlags & Qt::Window) && (d->windowFlags & Qt::WindowType_Mask) != Qt::Popup && (d->windowFlags & Qt::WindowType_Mask) != Qt::ToolTip && !(d->windowFlags & Qt::FramelessWindowHint)) { QStyleOptionTitleBar bar; d->initStyleOptionTitleBar(&bar); @@ -1151,7 +1151,7 @@ bool QGraphicsWidget::sceneEvent(QEvent *event) Returns true if \a event has been recognized and processed; otherwise, returns false. - + \sa event() */ bool QGraphicsWidget::windowFrameEvent(QEvent *event) @@ -1208,7 +1208,7 @@ Qt::WindowFrameSection QGraphicsWidget::windowFrameSectionAt(const QPointF &pos) const QRectF r = windowFrameRect(); if (!r.contains(pos)) return Qt::NoSection; - + const qreal left = r.left(); const qreal top = r.top(); const qreal right = r.right(); @@ -2335,6 +2335,4 @@ void QGraphicsWidget::dumpFocusChain() QT_END_NAMESPACE -#include "moc_qgraphicswidget.cpp" - #endif //QT_NO_GRAPHICSVIEW -- cgit v0.12 From e9538ced914739129681362dea03ebc323602126 Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Fri, 26 Mar 2010 16:27:04 +0100 Subject: Reverts using composition mode when using DeviceCoordinateMode cache. Going back to always blitting the newly painted areas to the cache (and not blending it like before). To avoid painting artifacts when the item is rotated and when it uses DeviceCoordinateMode cache mode, the entire cache is always repainted in that case. Task-number: QTBUG-7863 Reviewed-by: trustme --- src/gui/graphicsview/qgraphicsscene.cpp | 13 ++++++------- tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 18 +++++++++++------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 6934abc..6581727 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -4285,12 +4285,7 @@ static void _q_paintIntoCache(QPixmap *pix, QGraphicsItem *item, const QRegion & if (!subPix.isNull()) { // Blit the subpixmap into the main pixmap. pixmapPainter.begin(pix); - if (item->cacheMode() == QGraphicsItem::DeviceCoordinateCache - && itemToPixmap.type() > QTransform::TxTranslate) { - pixmapPainter.setCompositionMode(QPainter::CompositionMode_SourceAtop); - } else { - pixmapPainter.setCompositionMode(QPainter::CompositionMode_Source); - } + pixmapPainter.setCompositionMode(QPainter::CompositionMode_Source); pixmapPainter.setClipRegion(pixmapExposed); pixmapPainter.drawPixmap(br.topLeft(), subPix); pixmapPainter.end(); @@ -4456,6 +4451,8 @@ void QGraphicsScenePrivate::drawItemHelper(QGraphicsItem *item, QPainter *painte } // Create or reuse offscreen pixmap, possibly scroll/blit from the old one. + // If the world transform is rotated we always recreate the cache to avoid + // wrong blending. bool pixModified = false; QGraphicsItemCache::DeviceData *deviceData = &itemCache->deviceData[widget]; bool invertable = true; @@ -4463,7 +4460,9 @@ void QGraphicsScenePrivate::drawItemHelper(QGraphicsItem *item, QPainter *painte if (invertable) diff *= painter->worldTransform(); deviceData->lastTransform = painter->worldTransform(); - if (!invertable || diff.type() > QTransform::TxTranslate) { + if (!invertable + || diff.type() > QTransform::TxTranslate + || painter->worldTransform().type() > QTransform::TxScale) { pixModified = true; itemCache->allExposed = true; itemCache->exposed.clear(); diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 2b507cb..6725159 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -6825,6 +6825,9 @@ void tst_QGraphicsItem::cacheMode() QTRY_COMPARE(tester->repaints, 4); QCOMPARE(testerChild->repaints, 4); QCOMPARE(testerChild2->repaints, 3); + tester->resetTransform(); + testerChild->resetTransform(); + testerChild2->resetTransform(); // Explicit update causes a repaint. tester->update(0, 0, 5, 5); @@ -6898,23 +6901,24 @@ void tst_QGraphicsItem::cacheMode() // because the parent is rotated with a perspective. testerChild->setPos(1, 1); QTest::qWait(25); - QTRY_COMPARE(tester->repaints, 10); + QTRY_COMPARE(tester->repaints, 11); QCOMPARE(testerChild->repaints, 10); QCOMPARE(testerChild2->repaints, 5); + tester->resetTransform(); // Make a huge item tester->setGeometry(QRectF(-4000, -4000, 8000, 8000)); QTest::qWait(25); - QTRY_COMPARE(tester->repaints, 11); - QCOMPARE(testerChild->repaints, 10); + QTRY_COMPARE(tester->repaints, 12); + QCOMPARE(testerChild->repaints, 11); QCOMPARE(testerChild2->repaints, 5); // Move the large item - will cause a repaint as the // cache is clipped. tester->setPos(5, 0); QTest::qWait(25); - QTRY_COMPARE(tester->repaints, 12); - QCOMPARE(testerChild->repaints, 10); + QTRY_COMPARE(tester->repaints, 13); + QCOMPARE(testerChild->repaints, 11); QCOMPARE(testerChild2->repaints, 5); // Hiding and showing should invalidate the cache @@ -6922,8 +6926,8 @@ void tst_QGraphicsItem::cacheMode() QTest::qWait(25); tester->show(); QTest::qWait(25); - QTRY_COMPARE(tester->repaints, 13); - QCOMPARE(testerChild->repaints, 11); + QTRY_COMPARE(tester->repaints, 14); + QCOMPARE(testerChild->repaints, 12); QCOMPARE(testerChild2->repaints, 6); } -- cgit v0.12 From 96d6bff54942be11458801edc5c59e2cf646253c Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Fri, 26 Mar 2010 11:08:12 -0700 Subject: QDirectFBPixmap can handle NoOpaqueDetection. We don't need to do the conversion using QImage when NoOpaqueDetection is specified. Reviewed-by: muthu --- src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp index 4219f6f..f2fd699 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp @@ -307,7 +307,7 @@ void QDirectFBPixmapData::fromImage(const QImage &img, imageFormat = screen->pixelFormat(); } QImage image; - if (flags != Qt::AutoColor) { + if ((flags & ~Qt::NoOpaqueDetection) != Qt::AutoColor) { image = img.convertToFormat(imageFormat, flags); flags = Qt::AutoColor; } else if (img.format() == QImage::Format_RGB32) { -- cgit v0.12 From ec401f7a4c682b3ccdbc64edb4aa9881830b45cf Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Fri, 26 Mar 2010 11:17:39 -0700 Subject: Refactor QDirectFBPixmap::fromImage slightly Clean up the function a little and make sure I don't call QImage::hasAlphaChannel twice for opaque images. Reviewed-by: muthu --- .../gfxdrivers/directfb/qdirectfbpixmap.cpp | 23 +++++++++------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp index f2fd699..80366d1 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp @@ -290,27 +290,22 @@ bool QDirectFBPixmapData::fromDataBufferDescription(const DFBDataBufferDescripti void QDirectFBPixmapData::fromImage(const QImage &img, Qt::ImageConversionFlags flags) { - if (img.depth() == 1 || img.format() == QImage::Format_RGB32) { - fromImage(img.convertToFormat(screen->alphaPixmapFormat()), flags); - return; - } - - if (img.hasAlphaChannel() + if (img.depth() == 1) { + alpha = true; #ifndef QT_NO_DIRECTFB_OPAQUE_DETECTION - && (flags & Qt::NoOpaqueDetection || QDirectFBPixmapData::hasAlphaChannel(img)) -#endif - ) { + } else if (flags & Qt::NoOpaqueDetection || QDirectFBPixmapData::hasAlphaChannel(img)) { alpha = true; - imageFormat = screen->alphaPixmapFormat(); - } else { - alpha = false; - imageFormat = screen->pixelFormat(); +#else + } else if (img.hasAlphaChannel()) { + alpha = true; +#endif } + imageFormat = alpha ? screen->alphaPixmapFormat() : screen->pixelFormat(); QImage image; if ((flags & ~Qt::NoOpaqueDetection) != Qt::AutoColor) { image = img.convertToFormat(imageFormat, flags); flags = Qt::AutoColor; - } else if (img.format() == QImage::Format_RGB32) { + } else if (img.format() == QImage::Format_RGB32 || img.depth() == 1) { image = img.convertToFormat(imageFormat, flags); } else { image = img; -- cgit v0.12 From ffdd3c40413ef933506c040f40e4fb7ecd1ee062 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 29 Mar 2010 08:32:49 +1000 Subject: Installed imports are no longer searched relative to caller. (quoted URL is for that) --- tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp b/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp index adea384..16efba9 100644 --- a/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp +++ b/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp @@ -340,6 +340,7 @@ void tst_qdeclarativedom::loadImports() "Item {}"; QDeclarativeEngine engine; + engine.addImportPath(SRCDIR "/data"); QDeclarativeDomDocument document; QVERIFY(document.load(&engine, qml, QUrl::fromLocalFile(SRCDIR "/data/dummy.qml"))); -- cgit v0.12 From 6b619af035a995cf16d977439995cf7c1c0d366e Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 29 Mar 2010 08:56:09 +1000 Subject: tyop --- src/declarative/graphicsitems/qdeclarativeimagebase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/graphicsitems/qdeclarativeimagebase.cpp b/src/declarative/graphicsitems/qdeclarativeimagebase.cpp index b8d67ff..5a234b7 100644 --- a/src/declarative/graphicsitems/qdeclarativeimagebase.cpp +++ b/src/declarative/graphicsitems/qdeclarativeimagebase.cpp @@ -152,7 +152,7 @@ void QDeclarativeImageBase::load() } else { d->status = Loading; int reqwidth = d->sourcesize.width(); - int reqheight = d->sourcesize.width(); + int reqheight = d->sourcesize.height(); QSize impsize; QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(d->url, &d->pix, &impsize, d->async, reqwidth, reqheight); if (status != QDeclarativePixmapReply::Ready && status != QDeclarativePixmapReply::Error) { -- cgit v0.12 From a3868307c0e1584a1f694efc4a7b980b54c6e2b1 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 29 Mar 2010 08:57:03 +1000 Subject: Source resizing for QDeclarativeImageProvider too. (fixes test too) --- src/declarative/qml/qdeclarativeengine.cpp | 4 +-- src/declarative/qml/qdeclarativeengine_p.h | 2 +- src/declarative/qml/qdeclarativeimageprovider.cpp | 6 ++++- src/declarative/qml/qdeclarativeimageprovider.h | 2 +- src/declarative/util/qdeclarativepixmapcache.cpp | 4 ++- .../tst_qdeclarativeimageprovider.cpp | 30 ++++++++++++++-------- 6 files changed, 32 insertions(+), 16 deletions(-) diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index ad26650..dea5a40 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -580,13 +580,13 @@ void QDeclarativeEngine::removeImageProvider(const QString &providerId) delete d->imageProviders.take(providerId); } -QImage QDeclarativeEnginePrivate::getImageFromProvider(const QUrl &url) +QImage QDeclarativeEnginePrivate::getImageFromProvider(const QUrl &url, QSize *size, const QSize& req_size) { QMutexLocker locker(&mutex); QImage image; QDeclarativeImageProvider *provider = imageProviders.value(url.host()); if (provider) - image = provider->request(url.path().mid(1)); + image = provider->request(url.path().mid(1), size, req_size); return image; } diff --git a/src/declarative/qml/qdeclarativeengine_p.h b/src/declarative/qml/qdeclarativeengine_p.h index 06b5027..84bf061 100644 --- a/src/declarative/qml/qdeclarativeengine_p.h +++ b/src/declarative/qml/qdeclarativeengine_p.h @@ -225,7 +225,7 @@ public: mutable QDeclarativeNetworkAccessManagerFactory *networkAccessManagerFactory; QHash imageProviders; - QImage getImageFromProvider(const QUrl &url); + QImage getImageFromProvider(const QUrl &url, QSize *size, const QSize& req_size); mutable QMutex mutex; diff --git a/src/declarative/qml/qdeclarativeimageprovider.cpp b/src/declarative/qml/qdeclarativeimageprovider.cpp index 9ef8545..b992b9f 100644 --- a/src/declarative/qml/qdeclarativeimageprovider.cpp +++ b/src/declarative/qml/qdeclarativeimageprovider.cpp @@ -61,10 +61,14 @@ QDeclarativeImageProvider::~QDeclarativeImageProvider() } /*! - \fn QImage QDeclarativeImageProvider::request(const QString &id) + \fn QImage QDeclarativeImageProvider::request(const QString &id, QSize *size, const QSize& requested_size) Implement this method to return the image with \a id. + If \a requested_size is a valid size, resize the image to that size before returning. + + In any case, \a size must be set to the (original) size of the image. + Note: this method may be called by multiple threads, so ensure the implementation of this method is reentrant. */ diff --git a/src/declarative/qml/qdeclarativeimageprovider.h b/src/declarative/qml/qdeclarativeimageprovider.h index 6ee7bcf..50b73fe 100644 --- a/src/declarative/qml/qdeclarativeimageprovider.h +++ b/src/declarative/qml/qdeclarativeimageprovider.h @@ -54,7 +54,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativeImageProvider { public: virtual ~QDeclarativeImageProvider(); - virtual QImage request(const QString &id) = 0; + virtual QImage request(const QString &id, QSize *size, const QSize& requested_size) = 0; }; QT_END_NAMESPACE diff --git a/src/declarative/util/qdeclarativepixmapcache.cpp b/src/declarative/util/qdeclarativepixmapcache.cpp index 54dccce..1d90bf8 100644 --- a/src/declarative/util/qdeclarativepixmapcache.cpp +++ b/src/declarative/util/qdeclarativepixmapcache.cpp @@ -255,7 +255,9 @@ bool QDeclarativeImageRequestHandler::event(QEvent *event) // fetch if (url.scheme() == QLatin1String("image")) { // Use QmlImageProvider - QImage image = QDeclarativeEnginePrivate::get(engine)->getImageFromProvider(url); + QSize read_impsize; + QImage image = QDeclarativeEnginePrivate::get(engine)->getImageFromProvider(url, &read_impsize, QSize(runningJob->forcedWidth(),runningJob->forcedHeight())); + qmlOriginalSizes()->insert(url, read_impsize); QDeclarativeImageReaderEvent::ReadError errorCode = QDeclarativeImageReaderEvent::NoError; QString errorStr; if (image.isNull()) { diff --git a/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp b/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp index c5bdfc8..fe5f5a2 100644 --- a/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp +++ b/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp @@ -43,6 +43,7 @@ #include #include #include +#include // QDeclarativeImageProvider::request() is run in an idle thread where possible // Be generous in our timeout. @@ -76,28 +77,35 @@ private: class TestProvider : public QDeclarativeImageProvider { public: - QImage request(const QString &id) { - QImage image; - image.load(SRCDIR "/data/" + id); - return image; + QImage request(const QString &id, QSize *size, const QSize& requested_size) { + QImageReader io(SRCDIR "/data/" + id); + if (size) *size = io.size(); + if (requested_size.isValid()) + io.setScaledSize(requested_size); + return io.read(); } }; void tst_qdeclarativeimageprovider::imageSource_data() { QTest::addColumn("source"); + QTest::addColumn("properties"); + QTest::addColumn("size"); QTest::addColumn("error"); - QTest::newRow("exists") << "image://test/exists.png" << ""; - QTest::newRow("missing") << "image://test/no-such-file.png" + QTest::newRow("exists") << "image://test/exists.png" << "" << QSize(100,100) << ""; + QTest::newRow("scaled") << "image://test/exists.png" << "sourceSize: \"80x30\"" << QSize(80,30) << ""; + QTest::newRow("missing") << "image://test/no-such-file.png" << "" << QSize() << "\"Failed to get image from provider: image://test/no-such-file.png\" "; - QTest::newRow("unknown provider") << "image://bogus/exists.png" + QTest::newRow("unknown provider") << "image://bogus/exists.png" << "" << QSize() << "\"Failed to get image from provider: image://bogus/exists.png\" "; } void tst_qdeclarativeimageprovider::imageSource() { QFETCH(QString, source); + QFETCH(QString, properties); + QFETCH(QSize, size); QFETCH(QString, error); if (!error.isEmpty()) @@ -106,7 +114,7 @@ void tst_qdeclarativeimageprovider::imageSource() engine.addImageProvider("test", new TestProvider); QVERIFY(engine.imageProvider("test") != 0); - QString componentStr = "import Qt 4.6\nImage { source: \"" + source + "\" }"; + QString componentStr = "import Qt 4.6\nImage { source: \"" + source + "\"; " + properties + " }"; QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QDeclarativeImage *obj = qobject_cast(component.create()); @@ -118,8 +126,10 @@ void tst_qdeclarativeimageprovider::imageSource() if (error.isEmpty()) { TRY_WAIT(obj->status() == QDeclarativeImage::Ready); - QCOMPARE(obj->width(), 100.); - QCOMPARE(obj->height(), 100.); + QCOMPARE(obj->width(), 100.0); + QCOMPARE(obj->height(), 100.0); + QCOMPARE(obj->pixmap().width(), size.width()); + QCOMPARE(obj->pixmap().height(), size.height()); QCOMPARE(obj->fillMode(), QDeclarativeImage::Stretch); QCOMPARE(obj->progress(), 1.0); } else { -- cgit v0.12 From f87e175eb03a6b455f70e12bb24f75c26eacb4c2 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 29 Mar 2010 08:59:28 +1000 Subject: QTBUG-9367 has been fixed. Expect pass. --- .../declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 041fd4d..2791722c 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -1248,7 +1248,6 @@ void tst_qdeclarativeecmascript::regExpBug() QDeclarativeComponent component(&engine, TEST_FILE("regExp.qml")); MyQmlObject *object = qobject_cast(component.create()); QVERIFY(object != 0); - QEXPECT_FAIL("", "QTBUG-9367", Continue); QCOMPARE(object->regExp().pattern(), QLatin1String("[a-zA-z]")); } -- cgit v0.12 From fbd4378fa12ba8f310a3ca9f6e7c1b393f596410 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 29 Mar 2010 09:09:16 +1000 Subject: doc --- tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp index 9073750..c42a315 100644 --- a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp +++ b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp @@ -281,6 +281,9 @@ void tst_qdeclarativeimage::svg() void tst_qdeclarativeimage::big() { + // If the JPEG loader does not implement scaling efficiently, it would + // have to build a 400 MB image. That would be a bug in the JPEG loader. + QString componentStr = "import Qt 4.6\nImage { source: \"" SRCDIR "/data/big.jpeg\"; sourceSize.width: 256; sourceSize.height: 256 }"; QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); -- cgit v0.12 From 0a114cf91058e215f4b6f8bbea09aa9e9ad57069 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Mon, 29 Mar 2010 09:16:45 +1000 Subject: Fix change description: Import -> import --- src/declarative/QmlChanges.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt index 6ab77a7..847f1f5 100644 --- a/src/declarative/QmlChanges.txt +++ b/src/declarative/QmlChanges.txt @@ -62,7 +62,7 @@ MouseArea { becomes -Import “foo.js” as Foo +import “foo.js” as Foo MouseArea { onClicked: Foo.foo() } -- cgit v0.12 From 6cce231a2d8da6fb232908a8c815ba3a433cfad7 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Mon, 29 Mar 2010 09:19:07 +1000 Subject: Fix qdeclarativeimage autotest on the mac. --- .../declarative/qdeclarativeimage/data/heart-mac.png | Bin 0 -> 12621 bytes .../declarative/qdeclarativeimage/data/heart200-mac.png | Bin 0 -> 8062 bytes .../qdeclarativeimage/tst_qdeclarativeimage.cpp | 11 +++++++++-- 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 tests/auto/declarative/qdeclarativeimage/data/heart-mac.png create mode 100644 tests/auto/declarative/qdeclarativeimage/data/heart200-mac.png diff --git a/tests/auto/declarative/qdeclarativeimage/data/heart-mac.png b/tests/auto/declarative/qdeclarativeimage/data/heart-mac.png new file mode 100644 index 0000000..d7df0e4 Binary files /dev/null and b/tests/auto/declarative/qdeclarativeimage/data/heart-mac.png differ diff --git a/tests/auto/declarative/qdeclarativeimage/data/heart200-mac.png b/tests/auto/declarative/qdeclarativeimage/data/heart200-mac.png new file mode 100644 index 0000000..df22325 Binary files /dev/null and b/tests/auto/declarative/qdeclarativeimage/data/heart200-mac.png differ diff --git a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp index 9073750..bbf7421 100644 --- a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp +++ b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp @@ -155,7 +155,7 @@ void tst_qdeclarativeimage::imageSource() component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QDeclarativeImage *obj = qobject_cast(component.create()); QVERIFY(obj != 0); - + if (remote || async) TRY_WAIT(obj->status() == QDeclarativeImage::Loading); @@ -266,7 +266,11 @@ void tst_qdeclarativeimage::svg() QCOMPARE(obj->pixmap().height(), 300); QCOMPARE(obj->width(), 550.0); QCOMPARE(obj->height(), 500.0); +#if defined(Q_OS_MAC) + QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart-mac.png")); +#else QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart.png")); +#endif obj->setSourceSize(QSize(200,200)); @@ -274,8 +278,11 @@ void tst_qdeclarativeimage::svg() QCOMPARE(obj->pixmap().height(), 200); QCOMPARE(obj->width(), 550.0); QCOMPARE(obj->height(), 500.0); +#if defined(Q_OS_MAC) + QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart200-mac.png")); +#else QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart200.png")); - +#endif delete obj; } -- cgit v0.12 From 2776592d1e8dc8059f3a1c05237294b4a45543d9 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Mon, 29 Mar 2010 09:35:55 +1000 Subject: Don't set status to Ready until model has been created (currently this is set as soon as XML data is downloaded, so there is no notification when model is actually ready to be used). This also fixes data() to not crash if it is called before the model is ready. Task-number: QTBUG-7835 --- src/declarative/util/qdeclarativexmllistmodel.cpp | 147 +++++++++++++-------- src/declarative/util/qdeclarativexmllistmodel_p.h | 3 +- .../tst_qdeclarativexmllistmodel.cpp | 97 ++++++++++++-- 3 files changed, 183 insertions(+), 64 deletions(-) diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp index 3e08854..efc614b 100644 --- a/src/declarative/util/qdeclarativexmllistmodel.cpp +++ b/src/declarative/util/qdeclarativexmllistmodel.cpp @@ -57,6 +57,7 @@ #include #include #include +#include #include @@ -67,6 +68,8 @@ QT_BEGIN_NAMESPACE typedef QPair QDeclarativeXmlListRange; +#define XMLLISTMODEL_CLEAR_ID 0 + /*! \qmlclass XmlRole QDeclarativeXmlListModelRole \since 4.7 @@ -127,9 +130,10 @@ class QDeclarativeXmlQuery : public QThread Q_OBJECT public: QDeclarativeXmlQuery(QObject *parent=0) - : QThread(parent), m_quit(false), m_abortQueryId(-1), m_queryIds(0) { + : QThread(parent), m_quit(false), m_abortQueryId(-1), m_queryIds(XMLLISTMODEL_CLEAR_ID + 1) { qRegisterMetaType("QDeclarativeXmlQueryResult"); } + ~QDeclarativeXmlQuery() { m_mutex.lock(); m_quit = true; @@ -586,7 +590,8 @@ void QDeclarativeXmlListModel::setSource(const QUrl &src) Q_D(QDeclarativeXmlListModel); if (d->src != src) { d->src = src; - reload(); + if (d->xml.isEmpty()) // src is only used if d->xml is not set + reload(); emit sourceChanged(); } } @@ -663,23 +668,13 @@ void QDeclarativeXmlListModel::setNamespaceDeclarations(const QString &declarati /*! \qmlproperty enum XmlListModel::status + Specifies the model loading status, which can be one of the following: - This property holds the status of data source loading. It can be one of: \list - \o Null - no data source has been set - \o Ready - the data source has been loaded - \o Loading - the data source is currently being loaded - \o Error - an error occurred while loading the data source - \endlist - - Note that a change in the status property does not cause anything to happen - (although it reflects what has happened to the XmlListModel internally). If you wish - to react to the change in status you need to do it yourself, for example in one - of the following ways: - \list - \o Create a state, so that a state change occurs, e.g. State{name: 'loaded'; when: xmlListModel.status = XmlListModel.Ready;} - \o Do something inside the onStatusChanged signal handler, e.g. XmlListModel{id: xmlListModel; onStatusChanged: if(xmlListModel.status == XmlListModel.Ready) console.log('Loaded');} - \o Bind to the status variable somewhere, e.g. Text{text: if(xmlListModel.status!=XmlListModel.Ready){'Not Loaded';}else{'Loaded';}} + \o Null - No XML data has been set for this model. + \o Ready - The XML data has been loaded into the model. + \o Loading - The model is in the process of reading and loading XML data. + \o Error - An error occurred while the model was loading. \endlist \sa progress @@ -694,10 +689,17 @@ QDeclarativeXmlListModel::Status QDeclarativeXmlListModel::status() const /*! \qmlproperty real XmlListModel::progress - This property holds the progress of data source loading, from 0.0 (nothing loaded) - to 1.0 (finished). + This indicates the current progress of the downloading of the XML data + source. This value ranges from 0.0 (no data downloaded) to + 1.0 (all data downloaded). If the XML data is not from a remote source, + the progress becomes 1.0 as soon as the data is read. + + Note that when the progress is 1.0, the XML data has been downloaded, but + it is yet to be loaded into the model at this point. Use the status + property to find out when the XML data has been read and loaded into + the model. - \sa status + \sa status, source */ qreal QDeclarativeXmlListModel::progress() const { @@ -741,27 +743,8 @@ void QDeclarativeXmlListModel::reload() globalXmlQuery()->abort(d->queryId); d->queryId = -1; - int count = d->size; - if (count < 0) - d->size = 0; - bool hasKeys = false; - for (int i=0; iroleObjects.count(); i++) { - if (d->roleObjects[i]->isKey()) { - hasKeys = true; - break; - } - } - if (!hasKeys) { - d->data.clear(); + if (d->size < 0) d->size = 0; - if (count > 0) { - emit itemsRemoved(0, count); - emit countChanged(); - } - } - - if (d->src.isEmpty() && d->xml.isEmpty()) - return; if (d->reply) { d->reply->abort(); @@ -772,12 +755,22 @@ void QDeclarativeXmlListModel::reload() if (!d->xml.isEmpty()) { d->queryId = globalXmlQuery()->doQuery(d->query, d->namespaces, d->xml.toUtf8(), &d->roleObjects, d->keyRoleResultsCache); d->progress = 1.0; - d->status = Ready; + d->status = Loading; emit progressChanged(d->progress); emit statusChanged(d->status); return; } + if (d->src.isEmpty()) { + d->queryId = XMLLISTMODEL_CLEAR_ID; + d->progress = 1.0; + d->status = Loading; + emit progressChanged(d->progress); + emit statusChanged(d->status); + QTimer::singleShot(0, this, SLOT(dataCleared())); + return; + } + d->progress = 0.0; d->status = Loading; emit progressChanged(d->progress); @@ -813,18 +806,33 @@ void QDeclarativeXmlListModel::requestFinished() disconnect(d->reply, 0, this, 0); d->reply->deleteLater(); d->reply = 0; + + int count = this->count(); + d->data.clear(); + d->size = 0; + if (count > 0) { + emit itemsRemoved(0, count); + emit countChanged(); + } + d->status = Error; + d->queryId = -1; + emit statusChanged(d->status); } else { - d->status = Ready; QByteArray data = d->reply->readAll(); - d->queryId = globalXmlQuery()->doQuery(d->query, d->namespaces, data, &d->roleObjects, d->keyRoleResultsCache); + if (data.isEmpty()) { + d->queryId = XMLLISTMODEL_CLEAR_ID; + QTimer::singleShot(0, this, SLOT(dataCleared())); + } else { + d->queryId = globalXmlQuery()->doQuery(d->query, d->namespaces, data, &d->roleObjects, d->keyRoleResultsCache); + } disconnect(d->reply, 0, this, 0); d->reply->deleteLater(); d->reply = 0; + + d->progress = 1.0; + emit progressChanged(d->progress); } - d->progress = 1.0; - emit progressChanged(d->progress); - emit statusChanged(d->status); } void QDeclarativeXmlListModel::requestProgress(qint64 received, qint64 total) @@ -836,23 +844,58 @@ void QDeclarativeXmlListModel::requestProgress(qint64 received, qint64 total) } } +void QDeclarativeXmlListModel::dataCleared() +{ + Q_D(QDeclarativeXmlListModel); + QDeclarativeXmlQueryResult r; + r.queryId = XMLLISTMODEL_CLEAR_ID; + r.size = 0; + r.removed << qMakePair(0, count()); + r.keyRoleResultsCache = d->keyRoleResultsCache; + queryCompleted(r); +} + void QDeclarativeXmlListModel::queryCompleted(const QDeclarativeXmlQueryResult &result) { Q_D(QDeclarativeXmlListModel); if (result.queryId != d->queryId) return; + + int origCount = d->size; bool sizeChanged = result.size != d->size; + d->size = result.size; d->data = result.data; d->keyRoleResultsCache = result.keyRoleResultsCache; + d->status = Ready; + d->queryId = -1; - for (int i=0; iroleObjects.count(); i++) { + if (d->roleObjects[i]->isKey()) { + hasKeys = true; + break; + } + } + if (!hasKeys) { + if (!(origCount == 0 && d->size == 0)) { + emit itemsRemoved(0, origCount); + emit itemsInserted(0, d->size); + emit countChanged(); + } + + } else { + + for (int i=0; istatus); } QT_END_NAMESPACE diff --git a/src/declarative/util/qdeclarativexmllistmodel_p.h b/src/declarative/util/qdeclarativexmllistmodel_p.h index 7bb0f0e..7b85476 100644 --- a/src/declarative/util/qdeclarativexmllistmodel_p.h +++ b/src/declarative/util/qdeclarativexmllistmodel_p.h @@ -117,7 +117,7 @@ public: virtual void componentComplete(); Q_SIGNALS: - void statusChanged(Status); + void statusChanged(QDeclarativeXmlListModel::Status); void progressChanged(qreal progress); void countChanged(); void sourceChanged(); @@ -135,6 +135,7 @@ public Q_SLOTS: private Q_SLOTS: void requestFinished(); void requestProgress(qint64,qint64); + void dataCleared(); void queryCompleted(const QDeclarativeXmlQueryResult &); private: diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp index e3aa5cc..74da79e 100644 --- a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp +++ b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp @@ -41,6 +41,8 @@ #include #include #include +#include +#include #ifdef QTEST_XMLPATTERNS #include @@ -53,6 +55,7 @@ typedef QList QDeclarativeXmlModelData; Q_DECLARE_METATYPE(QList) Q_DECLARE_METATYPE(QDeclarativeXmlModelData) +Q_DECLARE_METATYPE(QDeclarativeXmlListModel::Status) class tst_qdeclarativexmllistmodel : public QObject @@ -62,6 +65,10 @@ public: tst_qdeclarativexmllistmodel() {} private slots: + void initTestCase() { + qRegisterMetaType("QDeclarativeXmlListModel::Status"); + } + void buildModel(); void missingFields(); void cdata(); @@ -69,7 +76,10 @@ private slots: void roles(); void roleErrors(); void uniqueRoleNames(); - void status(); + void xml(); + void xml_data(); + void source(); + void source_data(); void data(); void reload(); void useKeys(); @@ -183,7 +193,6 @@ void tst_qdeclarativexmllistmodel::attributes() QDeclarativeXmlListModel *model = qobject_cast(component.create()); QVERIFY(model != 0); QTRY_COMPARE(model->count(), 5); - QList roles; roles << Qt::UserRole; QHash data = model->data(2, roles); @@ -249,27 +258,93 @@ void tst_qdeclarativexmllistmodel::uniqueRoleNames() delete model; } -void tst_qdeclarativexmllistmodel::status() + +void tst_qdeclarativexmllistmodel::xml() { - QDeclarativeXmlListModel *model; - model = new QDeclarativeXmlListModel; - QCOMPARE(model->status(), QDeclarativeXmlListModel::Null); + QFETCH(QString, xml); + QFETCH(int, count); - model->setXml(""); + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); + QDeclarativeXmlListModel *model = qobject_cast(component.create()); + QSignalSpy spy(model, SIGNAL(statusChanged(QDeclarativeXmlListModel::Status))); + + QCOMPARE(model->progress(), qreal(0.0)); + QCOMPARE(model->status(), QDeclarativeXmlListModel::Loading); + QTRY_COMPARE(spy.count(), 1); spy.clear(); QCOMPARE(model->status(), QDeclarativeXmlListModel::Ready); + QCOMPARE(model->progress(), qreal(1.0)); + QCOMPARE(model->count(), 9); + + // if xml is empty (i.e. clearing) it won't have any effect if a source is set + if (xml.isEmpty()) + model->setSource(QUrl()); + model->setXml(xml); + QCOMPARE(model->progress(), qreal(1.0)); // immediately goes to 1.0 if using setXml() + QTRY_COMPARE(spy.count(), 1); spy.clear(); + QCOMPARE(model->status(), QDeclarativeXmlListModel::Loading); + QTRY_COMPARE(spy.count(), 1); spy.clear(); + QCOMPARE(model->status(), QDeclarativeXmlListModel::Ready); + QCOMPARE(model->count(), count); + delete model; +} + +void tst_qdeclarativexmllistmodel::xml_data() +{ + QTest::addColumn("xml"); + QTest::addColumn("count"); + + QTest::newRow("xml with no items") << "" << 0; + QTest::newRow("empty xml") << "" << 0; + QTest::newRow("one item") << "HobbesTiger7Large" << 1; +} + +void tst_qdeclarativexmllistmodel::source() +{ + QFETCH(QUrl, source); + QFETCH(int, count); + QFETCH(QDeclarativeXmlListModel::Status, status); QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); - model = qobject_cast(component.create()); - QVERIFY(model != 0); - QCOMPARE(model->status(), QDeclarativeXmlListModel::Loading); + QDeclarativeXmlListModel *model = qobject_cast(component.create()); + QSignalSpy spy(model, SIGNAL(statusChanged(QDeclarativeXmlListModel::Status))); - QTRY_COMPARE(model->count(), 9); + QCOMPARE(model->progress(), qreal(0.0)); + QCOMPARE(model->status(), QDeclarativeXmlListModel::Loading); + QTRY_COMPARE(spy.count(), 1); spy.clear(); QCOMPARE(model->status(), QDeclarativeXmlListModel::Ready); + QCOMPARE(model->progress(), qreal(1.0)); + QCOMPARE(model->count(), 9); + + model->setSource(source); + QCOMPARE(model->progress(), qreal(0.0)); + QTRY_COMPARE(spy.count(), 1); spy.clear(); + QCOMPARE(model->status(), QDeclarativeXmlListModel::Loading); + QTRY_COMPARE(spy.count(), 1); spy.clear(); + QCOMPARE(model->status(), status); + QCOMPARE(model->count(), count); + if (status == QDeclarativeXmlListModel::Ready) + QCOMPARE(model->progress(), qreal(1.0)); delete model; } +void tst_qdeclarativexmllistmodel::source_data() +{ + QTest::addColumn("source"); + QTest::addColumn("count"); + QTest::addColumn("status"); + + QTest::newRow("valid") << QUrl::fromLocalFile(SRCDIR "/data/model2.xml") << 2 << QDeclarativeXmlListModel::Ready; + QTest::newRow("invalid") << QUrl("http://blah.blah/blah.xml") << 0 << QDeclarativeXmlListModel::Error; + + // empty file + QTemporaryFile *temp = new QTemporaryFile(this); + if (temp->open()) + QTest::newRow("empty file") << QUrl::fromLocalFile(temp->fileName()) << 0 << QDeclarativeXmlListModel::Ready; + temp->close(); +} + void tst_qdeclarativexmllistmodel::data() { QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); -- cgit v0.12 From 921d6882caa4f4be78c747493295d3bdd3f1f673 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 26 Mar 2010 13:49:07 +1000 Subject: Cleanup. --- src/declarative/util/qdeclarativeanimation_p_p.h | 26 ++++-------------------- src/declarative/util/qdeclarativebehavior.cpp | 12 ++++------- 2 files changed, 8 insertions(+), 30 deletions(-) diff --git a/src/declarative/util/qdeclarativeanimation_p_p.h b/src/declarative/util/qdeclarativeanimation_p_p.h index 3908e50..2a66c8a 100644 --- a/src/declarative/util/qdeclarativeanimation_p_p.h +++ b/src/declarative/util/qdeclarativeanimation_p_p.h @@ -100,17 +100,11 @@ class QActionAnimation : public QAbstractAnimation { Q_OBJECT public: - QActionAnimation(QObject *parent = 0) : QAbstractAnimation(parent), animAction(0), policy(KeepWhenStopped), running(false) {} + QActionAnimation(QObject *parent = 0) : QAbstractAnimation(parent), animAction(0), policy(KeepWhenStopped) {} QActionAnimation(QAbstractAnimationAction *action, QObject *parent = 0) - : QAbstractAnimation(parent), animAction(action), policy(KeepWhenStopped), running(false) {} + : QAbstractAnimation(parent), animAction(action), policy(KeepWhenStopped) {} ~QActionAnimation() { if (policy == DeleteWhenStopped) { delete animAction; animAction = 0; } } virtual int duration() const { return 0; } - void clearAnimAction() - { - if (policy == DeleteWhenStopped) - delete animAction; - animAction = 0; - } void setAnimAction(QAbstractAnimationAction *action, DeletionPolicy p) { if (state() == Running) @@ -127,26 +121,18 @@ protected: { if (newState == Running) { if (animAction) { - running = true; animAction->doAction(); - running = false; if (state() == Stopped && policy == DeleteWhenStopped) { delete animAction; animAction = 0; } } - } /*else if (newState == Stopped && policy == DeleteWhenStopped) { - if (!running) { - delete animAction; - animAction = 0; - } - }*/ + } } private: QAbstractAnimationAction *animAction; DeletionPolicy policy; - bool running; }; class QDeclarativeBulkValueUpdater @@ -192,11 +178,7 @@ protected: //check for new from every loop if (fromSourced) *fromSourced = false; - } /*else if (newState == Stopped && policy == DeleteWhenStopped) { - delete animValue; - animValue = 0; - }*/ //### we get a stop each loop if we are in a group - //### top-level animation is the only reliable one for this + } } private: diff --git a/src/declarative/util/qdeclarativebehavior.cpp b/src/declarative/util/qdeclarativebehavior.cpp index 1e000df..7181777 100644 --- a/src/declarative/util/qdeclarativebehavior.cpp +++ b/src/declarative/util/qdeclarativebehavior.cpp @@ -47,15 +47,12 @@ #include #include #include - -#include +#include #include QT_BEGIN_NAMESPACE - - class QDeclarativeBehaviorPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QDeclarativeBehavior) @@ -64,7 +61,7 @@ public: QDeclarativeProperty property; QVariant currentValue; - QDeclarativeAbstractAnimation *animation; + QDeclarativeGuard animation; bool enabled; }; @@ -176,11 +173,10 @@ void QDeclarativeBehavior::write(const QVariant &value) actions << action; QList after; - if (d->animation) - d->animation->transition(actions, after, QDeclarativeAbstractAnimation::Forward); + d->animation->transition(actions, after, QDeclarativeAbstractAnimation::Forward); d->animation->qtAnimation()->start(); if (!after.contains(d->property)) - QDeclarativePropertyPrivate::write(d->property, value, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding); + QDeclarativePropertyPrivate::write(d->property, value, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding); } void QDeclarativeBehavior::setTarget(const QDeclarativeProperty &property) -- cgit v0.12 From 078ff776e37aebe5b7e88e4b4f21da1158fac3c7 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 26 Mar 2010 14:29:19 +1000 Subject: Autotest tweaks. --- .../tst_qdeclarativebehaviors.cpp | 30 ++++++++++++++++++++++ .../qdeclarativebinding/data/test-binding.qml | 2 +- .../tst_qdeclarativebinding.cpp | 8 +++++- .../qdeclarativeimage/tst_qdeclarativeimage.cpp | 3 +++ .../qdeclarativeloader/tst_qdeclarativeloader.cpp | 4 +++ 5 files changed, 45 insertions(+), 2 deletions(-) diff --git a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp index 0bf0b81..26c8231 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp +++ b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp @@ -82,6 +82,8 @@ void tst_qdeclarativebehaviors::simpleBehavior() QTest::qWait(200); qreal x = qobject_cast(rect->findChild("MyRect"))->x(); QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered + + delete rect; } void tst_qdeclarativebehaviors::scriptTriggered() @@ -95,6 +97,8 @@ void tst_qdeclarativebehaviors::scriptTriggered() QTest::qWait(200); qreal x = qobject_cast(rect->findChild("MyRect"))->x(); QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered + + delete rect; } void tst_qdeclarativebehaviors::cppTriggered() @@ -111,6 +115,8 @@ void tst_qdeclarativebehaviors::cppTriggered() QTest::qWait(200); qreal x = innerRect->x(); QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered + + delete rect; } void tst_qdeclarativebehaviors::loop() @@ -122,6 +128,8 @@ void tst_qdeclarativebehaviors::loop() //don't crash rect->setState("moved"); + + delete rect; } void tst_qdeclarativebehaviors::colorBehavior() @@ -135,6 +143,8 @@ void tst_qdeclarativebehaviors::colorBehavior() QTest::qWait(200); QColor color = qobject_cast(rect->findChild("MyRect"))->color(); QVERIFY(color != QColor("red") && color != QColor("green")); //i.e. the behavior has been triggered + + delete rect; } void tst_qdeclarativebehaviors::parentBehavior() @@ -152,6 +162,8 @@ void tst_qdeclarativebehaviors::parentBehavior() QTest::qWait(600); parent = rect->findChild("MyRect")->parentItem(); QVERIFY(parent == newParent); + + delete rect; } void tst_qdeclarativebehaviors::replaceBinding() @@ -186,6 +198,8 @@ void tst_qdeclarativebehaviors::replaceBinding() rect->setProperty("basex", 20); QTest::qWait(600); QCOMPARE(innerRect->x(), (qreal)20); + + delete rect; } void tst_qdeclarativebehaviors::group() @@ -200,6 +214,8 @@ void tst_qdeclarativebehaviors::group() QTest::qWait(200); qreal x = qobject_cast(rect->findChild("MyRect"))->x(); QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered + + delete rect; } { @@ -212,6 +228,8 @@ void tst_qdeclarativebehaviors::group() QTest::qWait(200); qreal x = qobject_cast(rect->findChild("MyRect"))->x(); QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered + + delete rect; } } @@ -225,6 +243,8 @@ void tst_qdeclarativebehaviors::emptyBehavior() rect->setState("moved"); qreal x = qobject_cast(rect->findChild("MyRect"))->x(); QCOMPARE(x, qreal(200)); //should change immediately + + delete rect; } void tst_qdeclarativebehaviors::explicitSelection() @@ -239,6 +259,8 @@ void tst_qdeclarativebehaviors::explicitSelection() QTest::qWait(200); qreal x = qobject_cast(rect->findChild("MyRect"))->x(); QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered + + delete rect; } } @@ -253,6 +275,8 @@ void tst_qdeclarativebehaviors::nonSelectingBehavior() rect->setState("moved"); qreal x = qobject_cast(rect->findChild("MyRect"))->x(); QCOMPARE(x, qreal(200)); //should change immediately + + delete rect; } } @@ -266,6 +290,8 @@ void tst_qdeclarativebehaviors::reassignedAnimation() QCOMPARE(qobject_cast( qobject_cast( rect->findChild("MyBehavior"))->animation())->duration(), 200); + + delete rect; } void tst_qdeclarativebehaviors::disabled() @@ -279,6 +305,8 @@ void tst_qdeclarativebehaviors::disabled() rect->setState("moved"); qreal x = qobject_cast(rect->findChild("MyRect"))->x(); QCOMPARE(x, qreal(200)); //should change immediately + + delete rect; } void tst_qdeclarativebehaviors::dontStart() @@ -294,6 +322,8 @@ void tst_qdeclarativebehaviors::dontStart() QDeclarativeAbstractAnimation *myAnim = rect->findChild("MyAnim"); QVERIFY(myAnim && myAnim->qtAnimation()); QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped); + + delete rect; } QTEST_MAIN(tst_qdeclarativebehaviors) diff --git a/tests/auto/declarative/qdeclarativebinding/data/test-binding.qml b/tests/auto/declarative/qdeclarativebinding/data/test-binding.qml index e9101e4..8f5b39e 100644 --- a/tests/auto/declarative/qdeclarativebinding/data/test-binding.qml +++ b/tests/auto/declarative/qdeclarativebinding/data/test-binding.qml @@ -12,5 +12,5 @@ Rectangle { Binding { target: screen; property: "text"; value: s1.text; objectName: "binding1" } Binding { target: screen; property: "color"; value: r1.color } - Binding { target: screen; property: "color"; when: screen.changeColor == true; value: r2.color } + Binding { target: screen; property: "color"; when: screen.changeColor == true; value: r2.color; objectName: "binding3" } } diff --git a/tests/auto/declarative/qdeclarativebinding/tst_qdeclarativebinding.cpp b/tests/auto/declarative/qdeclarativebinding/tst_qdeclarativebinding.cpp index 483d588..8ab7b0b 100644 --- a/tests/auto/declarative/qdeclarativebinding/tst_qdeclarativebinding.cpp +++ b/tests/auto/declarative/qdeclarativebinding/tst_qdeclarativebinding.cpp @@ -69,14 +69,20 @@ void tst_qdeclarativebinding::binding() QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-binding.qml")); QDeclarativeRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect != 0); + + QDeclarativeBind *binding3 = qobject_cast(rect->findChild("binding3")); + QVERIFY(binding3 != 0); + QCOMPARE(rect->color(), QColor("yellow")); QCOMPARE(rect->property("text").toString(), QString("Hello")); + QCOMPARE(binding3->when(), false); rect->setProperty("changeColor", true); QCOMPARE(rect->color(), QColor("red")); + QCOMPARE(binding3->when(), true); + QDeclarativeBind *binding = qobject_cast(rect->findChild("binding1")); QVERIFY(binding != 0); QCOMPARE(binding->object(), qobject_cast(rect)); diff --git a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp index bbf7421..c1bf2b8 100644 --- a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp +++ b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp @@ -156,6 +156,9 @@ void tst_qdeclarativeimage::imageSource() QDeclarativeImage *obj = qobject_cast(component.create()); QVERIFY(obj != 0); + if (async) + QVERIFY(obj->asynchronous() == true); + if (remote || async) TRY_WAIT(obj->status() == QDeclarativeImage::Loading); diff --git a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp index a745a24..05d968c 100644 --- a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp +++ b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp @@ -129,6 +129,10 @@ void tst_QDeclarativeLoader::component() QCOMPARE(loader->status(), QDeclarativeLoader::Ready); QCOMPARE(static_cast(loader)->children().count(), 1); + QDeclarativeComponent *c = qobject_cast(item->QGraphicsObject::children().at(0)); + QVERIFY(c); + QCOMPARE(loader->sourceComponent(), c); + delete loader; } -- cgit v0.12 From fbcf257f0988f1ffef442195acc9f4b4c1527870 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 26 Mar 2010 15:57:19 +1000 Subject: Syntax and other small fixes for the visual tests. --- tests/auto/declarative/visual/ListView/basic3.qml | 2 +- tests/auto/declarative/visual/ListView/basic4.qml | 2 +- .../visual/Package_Views/packageviews.qml | 4 +- .../colorAnimation/data/colorAnimation.0.png | Bin 610 -> 627 bytes .../colorAnimation/data/colorAnimation.1.png | Bin 610 -> 626 bytes .../colorAnimation/data/colorAnimation.2.png | Bin 610 -> 625 bytes .../colorAnimation/data/colorAnimation.qml | 248 ++++++++++----------- .../declarative/visual/animation/loop/loop.qml | 2 +- .../animation/parentAnimation/parentAnimation.qml | 10 + .../animation/pauseAnimation/pauseAnimation.qml | 13 +- tests/auto/declarative/visual/focusscope/test3.qml | 2 +- .../content/MyBorderImage.qml | 4 +- .../visual/qdeclarativeeasefollow/easefollow.qml | 12 +- .../visual/qdeclarativegridview/gridview2.qml | 4 +- .../visual/qdeclarativespringfollow/clock.qml | 6 +- .../visual/qdeclarativespringfollow/follow.qml | 12 +- .../qdeclarativetextinput/cursorDelegate.qml | 14 +- .../visual/webview/zooming/renderControl.qml | 2 +- .../visual/webview/zooming/resolution.qml | 15 +- .../visual/webview/zooming/zoomTextOnly.qml | 11 +- .../declarative/visual/webview/zooming/zooming.qml | 6 +- 21 files changed, 192 insertions(+), 177 deletions(-) diff --git a/tests/auto/declarative/visual/ListView/basic3.qml b/tests/auto/declarative/visual/ListView/basic3.qml index 05ac358..2d68c0a 100644 --- a/tests/auto/declarative/visual/ListView/basic3.qml +++ b/tests/auto/declarative/visual/ListView/basic3.qml @@ -5,7 +5,7 @@ Rectangle { width: 200 height: 300 id: page - Listmodel { + ListModel { id: model ListElement { name: "January" diff --git a/tests/auto/declarative/visual/ListView/basic4.qml b/tests/auto/declarative/visual/ListView/basic4.qml index 3628bd3..7c68df1 100644 --- a/tests/auto/declarative/visual/ListView/basic4.qml +++ b/tests/auto/declarative/visual/ListView/basic4.qml @@ -5,7 +5,7 @@ Rectangle { width: 200 height: 300 id: page - Listmodel { + ListModel { id: model ListElement { name: "January" diff --git a/tests/auto/declarative/visual/Package_Views/packageviews.qml b/tests/auto/declarative/visual/Package_Views/packageviews.qml index cf3f9f7..f6c033f 100644 --- a/tests/auto/declarative/visual/Package_Views/packageviews.qml +++ b/tests/auto/declarative/visual/Package_Views/packageviews.qml @@ -6,9 +6,9 @@ Rectangle { height: 200 color: "black" - VisualDatamodel { + VisualDataModel { id: model - model: Listmodel { + model: ListModel { ListElement { itemColor: "red" } ListElement { itemColor: "green" } ListElement { itemColor: "blue" } diff --git a/tests/auto/declarative/visual/animation/colorAnimation/data/colorAnimation.0.png b/tests/auto/declarative/visual/animation/colorAnimation/data/colorAnimation.0.png index f4a6cfd..e6ea16d 100644 Binary files a/tests/auto/declarative/visual/animation/colorAnimation/data/colorAnimation.0.png and b/tests/auto/declarative/visual/animation/colorAnimation/data/colorAnimation.0.png differ diff --git a/tests/auto/declarative/visual/animation/colorAnimation/data/colorAnimation.1.png b/tests/auto/declarative/visual/animation/colorAnimation/data/colorAnimation.1.png index f4a6cfd..b75ba61 100644 Binary files a/tests/auto/declarative/visual/animation/colorAnimation/data/colorAnimation.1.png and b/tests/auto/declarative/visual/animation/colorAnimation/data/colorAnimation.1.png differ diff --git a/tests/auto/declarative/visual/animation/colorAnimation/data/colorAnimation.2.png b/tests/auto/declarative/visual/animation/colorAnimation/data/colorAnimation.2.png index f4a6cfd..4320f6f 100644 Binary files a/tests/auto/declarative/visual/animation/colorAnimation/data/colorAnimation.2.png and b/tests/auto/declarative/visual/animation/colorAnimation/data/colorAnimation.2.png differ diff --git a/tests/auto/declarative/visual/animation/colorAnimation/data/colorAnimation.qml b/tests/auto/declarative/visual/animation/colorAnimation/data/colorAnimation.qml index 900bf5c..4d0959a 100644 --- a/tests/auto/declarative/visual/animation/colorAnimation/data/colorAnimation.qml +++ b/tests/auto/declarative/visual/animation/colorAnimation/data/colorAnimation.qml @@ -170,91 +170,91 @@ VisualTest { } Frame { msec: 608 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "acc736435c9f84aa82941ba561bc5dbc" } Frame { msec: 624 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "e5bda0daf98288ce18db6ce06eda3ba0" } Frame { msec: 640 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "d35008f75b8c992f80fb16ba7203649d" } Frame { msec: 656 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "14f43e0784ddf42ea8550db88c501bf1" } Frame { msec: 672 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "02276e158b5391480b1bdeaadf1fb903" } Frame { msec: 688 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "35d9513eb97a2c482b7cd197de910934" } Frame { msec: 704 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "faf0fd681e60bb2489099f5df772b6cd" } Frame { msec: 720 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "a863d3e346f94785a3a392fdc91526eb" } Frame { msec: 736 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "fdf328d3f6eb8410da59a91345e41a44" } Frame { msec: 752 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "83514a3b10d5be8f6c3b128d0f3e0b1c" } Frame { msec: 768 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "ead0eae76cd00189075964671effbaea" } Frame { msec: 784 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "24d2457fcd51490fda23071bf9929d12" } Frame { msec: 800 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "1478683446cf543dacbe31d0b76a98a6" } Frame { msec: 816 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "99f7da1f31fe920f6c02add4042ae925" } Frame { msec: 832 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "22def892006cf66667770b0f17baf6c0" } Frame { msec: 848 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "6a36d5a77099bfd58baf285478ff04e4" } Frame { msec: 864 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "6258150666b59b20ab476724c07fc20c" } Frame { msec: 880 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "f1636315bc950a6dd400d9c7ed263b88" } Frame { msec: 896 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "18447ea8dc2e8da956788e5b3cf3790a" } Frame { msec: 912 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "1d2a6e65997a73e9e670356c8e8b63b2" } Frame { msec: 928 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "bed0242c0f9ef229d1392835286d5782" } Frame { msec: 944 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "88923c190e9e5beadef8a409c06df9d6" } Frame { msec: 960 @@ -262,239 +262,239 @@ VisualTest { } Frame { msec: 976 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "85b1821cc50f2a9f3ed6944f792b7a2f" } Frame { msec: 992 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "395195716d76bc0be7b2033ed37a7a1c" } Frame { msec: 1008 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "243dbffcf416926242bbcb7348974c4c" } Frame { msec: 1024 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "a755068679616d8ac65c2aa7431f2a19" } Frame { msec: 1040 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "e8249b35a47eb492cbdf2d91cc8426f0" } Frame { msec: 1056 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "15f3da1c0e6f0779b96859d51171dd27" } Frame { msec: 1072 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "258c0c756aac3de743b43051f2aace6b" } Frame { msec: 1088 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "a58b9fdf301d72b2cc5c93934cc8927b" } Frame { msec: 1104 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "a9181d30870d472521f8904818ce520f" } Frame { msec: 1120 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "7f9e94069ccf3897c26a71bd7becd903" } Frame { msec: 1136 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "bdf305c2f46cdb86dbf57b1e0cc5a65b" } Frame { msec: 1152 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "fe5b6865d7e4fc7d1d42c1e74f8666f7" } Frame { msec: 1168 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "734f0de45a6e34c9eab7ef606196f96a" } Frame { msec: 1184 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "02a361c4534fdf7f286dc3e6dc23275c" } Frame { msec: 1200 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "e649155ad69999c14b92f6561e4d1185" } Frame { msec: 1216 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "01af177084fab755d622973f64b92018" } Frame { msec: 1232 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "097cc4a082dfab995d213a3a73883c97" } Frame { msec: 1248 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "d7b4239a3280b1eb8e885e3f422df8e9" } Frame { msec: 1264 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "59893977994e34e83f91e7ce3ad65d6d" } Frame { msec: 1280 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "b68e3fbb5cdcd6bd96df7dec558db42b" } Frame { msec: 1296 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "94ad0580648f36a1e18a9ea7e249b04d" } Frame { msec: 1312 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "750a4c01d2f5806a89a1c6cc6a9b9a68" } Frame { msec: 1328 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "4f109f50f388f1bfa4bc6b03b3e6e514" } Frame { msec: 1344 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "c6168d5cf27a533e8ee636637667be47" } Frame { msec: 1360 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "f8120547bed987aa34c00da5a01a4d1e" } Frame { msec: 1376 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "cbff526136fa2c128c8b898fbbef9e5c" } Frame { msec: 1392 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "f29e52398fab1a239a63df4c32f2fc69" } Frame { msec: 1408 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "7178bfe86fd2fd513218b33760460f8d" } Frame { msec: 1424 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "ca83285bc8ac633403896fe976896eb0" } Frame { msec: 1440 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "96ba486c09cc69d5aa38c46c00df1181" } Frame { msec: 1456 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "b88eab335842787869f4a14824c19dd8" } Frame { msec: 1472 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "065aa59012729e1e1a246a2083142690" } Frame { msec: 1488 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "dd0e98c8398861002c5f178c5f9f612d" } Frame { msec: 1504 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "04192c2b545948048eccf4d81bbde198" } Frame { msec: 1520 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "bb7502c7208281ef9fd41714ab88a1a8" } Frame { msec: 1536 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "5397195471890d08b703dca101e5bc7c" } Frame { msec: 1552 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "4c678cdbebb2ffd2cbf012ca77800cde" } Frame { msec: 1568 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "0d7a34ecd0c7f52b2c015037bf1902c6" } Frame { msec: 1584 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "fd9d5048be749ac4369fda2d018b43ae" } Frame { msec: 1600 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "93ee03795cd57ae6f7fe3a020b039ad4" } Frame { msec: 1616 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "5e1118963f219c39761ca7fbf564a9ca" } Frame { msec: 1632 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "8f40038741903150136170503649d941" } Frame { msec: 1648 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "b087b7d0aa6224821f8e18718ff5e77d" } Frame { msec: 1664 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "aa46b04a3c67dc772265ed2901955565" } Frame { msec: 1680 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "ac024bf2aeb4becdf31a09fe0a6db8f3" } Frame { msec: 1696 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "13745a174e4d06e2108a5bf125ba50cc" } Frame { msec: 1712 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "bd972f0d8e230eca0b3fea1b8c960c08" } Frame { msec: 1728 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "cbdbec802a58e7ced0cf45b3ab0bc0ba" } Frame { msec: 1744 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "5128584c50305c7d218b81b8367fa3d5" } Frame { msec: 1760 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "a71461d3593f3685620668916de870bd" } Frame { msec: 1776 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "74ebac8f32cf044b58d9883dbcd9a722" } Frame { msec: 1792 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "fedc5b638f339b90fe59b478721e65b7" } Frame { msec: 1808 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "8593a81be812edf54ec94da8ae9c1314" } Frame { msec: 1824 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "4e9b083075bc5e9287a8abc982778b56" } Frame { msec: 1840 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "1d6f02aa99afa47d77fc49ab894b365a" } Frame { msec: 1856 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "a204feec783b3b05de4c209c21745826" } Frame { msec: 1872 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "665a2a8ff00b9663157802767f504754" } Frame { msec: 1888 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "624fb09ebe60cb87d767faf8d2420b1e" } Frame { msec: 1904 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "e5af0cdc33f3275a25abb09e9165f310" } Frame { msec: 1920 @@ -502,171 +502,171 @@ VisualTest { } Frame { msec: 1936 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "e7aa6374c73832e57ceb2427a1e258aa" } Frame { msec: 1952 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "b5abd0dff1ab076faac7cc226e83f5d0" } Frame { msec: 1968 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "b759acc35bccff8efc2e6fe276ddc0f7" } Frame { msec: 1984 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "ce52e18c1f7732768779863b45314ff5" } Frame { msec: 2000 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "99d30652559dd6931e0c95543eeaa149" } Frame { msec: 2016 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "ffbd9a00e05e085b89296d19d5caec57" } Frame { msec: 2032 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "9c9d658b9c25602816b8066bf19105db" } Frame { msec: 2048 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "2b7fd058e6601e22a30bb7106b1c683b" } Frame { msec: 2064 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "f4c7e26b19ee0a3e7c9688685eb7bd05" } Frame { msec: 2080 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "0dc6d593bceff56b7f81f2a49d37fefb" } Frame { msec: 2096 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "9bfd7ad5091ccbdde43c593e133a7b10" } Frame { msec: 2112 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "2703b617937914a90ea42ebf249d79ee" } Frame { msec: 2128 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "b77e2983138254016c4cca53100f46fa" } Frame { msec: 2144 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "60c4dd24187d1281081479e586f02b37" } Frame { msec: 2160 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "62f2511abd99ef1231c9fa4b91d4abfe" } Frame { msec: 2176 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "e309b3353fd174e883d309571caddc98" } Frame { msec: 2192 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "1e2d6a134c7b12dde551b148ef4f088c" } Frame { msec: 2208 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "e5dc5450604a491cc24a0dcf5c278b58" } Frame { msec: 2224 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "c8dae97c10e1962c1e6a51ab3ab8579e" } Frame { msec: 2240 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "4e1b7e06f55fb084080689b474f1fe1d" } Frame { msec: 2256 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "b4639c907fa937bf15fac62421170cd8" } Frame { msec: 2272 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "c250208a0caeb5f6cb4d3aac3d7d350b" } Frame { msec: 2288 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "a73351eabecf0d71149efe31f197413e" } Frame { msec: 2304 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "479425f1b7aff79e4dfb7fca534af018" } Frame { msec: 2320 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "046d0f0040a52d1f26ba9f7c5de06ef4" } Frame { msec: 2336 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "655778bf13c6080903150b0eb43a7edc" } Frame { msec: 2352 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "72da0bbe81514870655fdd3354adac60" } Frame { msec: 2368 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "defe0bdf675c65fff55aaaced1e4dae7" } Frame { msec: 2384 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "c988628b6c3d3780e9a865c7694926cd" } Frame { msec: 2400 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "5ab17563655231089edd986ff13d6012" } Frame { msec: 2416 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "c1adff1d2e5800ed466d1691d3b17382" } Frame { msec: 2432 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "70129ba01fbb19592b9dc0d0a3b3e7df" } Frame { msec: 2448 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "0000829ef7ed908bf430d42904d59cc2" } Frame { msec: 2464 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "843d2927f50ab87b4a86b7a6aaeed91f" } Frame { msec: 2480 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "da86d21756025e7de8050586d5e2a1f8" } Frame { msec: 2496 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "48dd1bd6580133b0793fee327ea4f1e6" } Frame { msec: 2512 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "f0618193dcd0ba2837249515a1898b1c" } Frame { msec: 2528 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "a530184e57251065286c0cbba7301e9c" } Frame { msec: 2544 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "64a1d7203973d65dd342793007a61c58" } Frame { msec: 2560 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "5b830dfc6ba442772de87d75d5a578de" } Frame { msec: 2576 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "5563b056b0409b65f60dd16dd0dd890e" } Frame { msec: 2592 - hash: "8c0fcda4f8956394c53fc4ba18caa850" + hash: "b8bcf9ad2ca8720c11563a23d8280804" } Frame { msec: 2608 @@ -931,7 +931,7 @@ VisualTest { Key { type: 6 key: 16777249 - modifiers: 0 + modifiers: 67108864 text: "" autorep: false count: 1 diff --git a/tests/auto/declarative/visual/animation/loop/loop.qml b/tests/auto/declarative/visual/animation/loop/loop.qml index 927e103..5389b26 100644 --- a/tests/auto/declarative/visual/animation/loop/loop.qml +++ b/tests/auto/declarative/visual/animation/loop/loop.qml @@ -13,7 +13,7 @@ Rectangle { to 100, jumps to 200, animates smoothly to 400, animates smoothly back to 100, jumps to 200, and so on. */ - x: SequentialAnimation { + SequentialAnimation on x { loops: Animation.Infinite NumberAnimation { to: 100; duration: 1000 } NumberAnimation { from: 200; to: 400; duration: 1000 } diff --git a/tests/auto/declarative/visual/animation/parentAnimation/parentAnimation.qml b/tests/auto/declarative/visual/animation/parentAnimation/parentAnimation.qml index 5db2cc6..8d0b375 100644 --- a/tests/auto/declarative/visual/animation/parentAnimation/parentAnimation.qml +++ b/tests/auto/declarative/visual/animation/parentAnimation/parentAnimation.qml @@ -1,4 +1,14 @@ import Qt 4.6 + +/* +This test shows a green rectangle moving and growing from the upper-left corner +of the black rectangle to the same position as the red rectangle (it should end up +the same height as the red rect and twice as wide). There should be no odd jumps or clipping seen. + +The test shows one full transition (to the red and back), then several partial transitions, and +then a final full transition. +*/ + Rectangle { width: 800; height: 480; diff --git a/tests/auto/declarative/visual/animation/pauseAnimation/pauseAnimation.qml b/tests/auto/declarative/visual/animation/pauseAnimation/pauseAnimation.qml index 4562aa7..8830170 100644 --- a/tests/auto/declarative/visual/animation/pauseAnimation/pauseAnimation.qml +++ b/tests/auto/declarative/visual/animation/pauseAnimation/pauseAnimation.qml @@ -1,5 +1,12 @@ import Qt 4.6 +/* +This test shows a bouncing logo. +When the test starts the logo should be resting at the bottom. It should immediately move +to the top, and then fall down to bounce at the bottom. There should be a pause, and then +one repeat of the sequence. +*/ + Rectangle { id: rect width: 120 @@ -9,15 +16,15 @@ Rectangle { id: img source: "pics/qtlogo.png" x: 60-width/2 - y: 200-height - y: SequentialAnimation { + y: 100 + SequentialAnimation on y { loops: Animation.Infinite NumberAnimation { to: 0; duration: 500 easing.type: "InOutQuad" } NumberAnimation { - to: 200-img.height + to: 100 easing.type: "OutBounce" duration: 2000 } diff --git a/tests/auto/declarative/visual/focusscope/test3.qml b/tests/auto/declarative/visual/focusscope/test3.qml index 855bdc5..a8bb523 100644 --- a/tests/auto/declarative/visual/focusscope/test3.qml +++ b/tests/auto/declarative/visual/focusscope/test3.qml @@ -5,7 +5,7 @@ Rectangle { width: 800 height: 600 - Listmodel { + ListModel { id: model ListElement { name: "1" } ListElement { name: "2" } diff --git a/tests/auto/declarative/visual/qdeclarativeborderimage/content/MyBorderImage.qml b/tests/auto/declarative/visual/qdeclarativeborderimage/content/MyBorderImage.qml index c3006d5..58d03a6 100644 --- a/tests/auto/declarative/visual/qdeclarativeborderimage/content/MyBorderImage.qml +++ b/tests/auto/declarative/visual/qdeclarativeborderimage/content/MyBorderImage.qml @@ -18,13 +18,13 @@ Item { BorderImage { id: image; x: container.width / 2 - width / 2; y: container.height / 2 - height / 2 - width: SequentialAnimation { + SequentialAnimation on width { loops: Animation.Infinite NumberAnimation { from: container.minWidth; to: container.maxWidth; duration: 2000; easing.type: "InOutQuad"} NumberAnimation { from: container.maxWidth; to: container.minWidth; duration: 2000; easing.type: "InOutQuad" } } - height: SequentialAnimation { + SequentialAnimation on height { loops: Animation.Infinite NumberAnimation { from: container.minHeight; to: container.maxHeight; duration: 2000; easing.type: "InOutQuad"} NumberAnimation { from: container.maxHeight; to: container.minHeight; duration: 2000; easing.type: "InOutQuad" } diff --git a/tests/auto/declarative/visual/qdeclarativeeasefollow/easefollow.qml b/tests/auto/declarative/visual/qdeclarativeeasefollow/easefollow.qml index 99a9973..121328b 100644 --- a/tests/auto/declarative/visual/qdeclarativeeasefollow/easefollow.qml +++ b/tests/auto/declarative/visual/qdeclarativeeasefollow/easefollow.qml @@ -6,7 +6,7 @@ Rectangle { Rectangle { id: rect width: 50; height: 20; y: 30; color: "black" - x: SequentialAnimation { + SequentialAnimation on x { loops: Animation.Infinite NumberAnimation { from: 50; to: 700; duration: 2000 } NumberAnimation { from: 700; to: 50; duration: 2000 } @@ -15,26 +15,26 @@ Rectangle { Rectangle { width: 50; height: 20; y: 60; color: "red" - x: EaseFollow { source: rect.x; velocity: 400 } + EaseFollow on x { source: rect.x; velocity: 400 } } Rectangle { width: 50; height: 20; y: 90; color: "yellow" - x: EaseFollow { source: rect.x; velocity: 300; reversingMode: EaseFollow.Immediate } + EaseFollow on x { source: rect.x; velocity: 300; reversingMode: EaseFollow.Immediate } } Rectangle { width: 50; height: 20; y: 120; color: "green" - x: EaseFollow { source: rect.x; reversingMode: EaseFollow.Sync } + EaseFollow on x { source: rect.x; reversingMode: EaseFollow.Sync } } Rectangle { width: 50; height: 20; y: 150; color: "purple" - x: EaseFollow { source: rect.x; maximumEasingTime: 200 } + EaseFollow on x { source: rect.x; maximumEasingTime: 200 } } Rectangle { width: 50; height: 20; y: 180; color: "blue" - x: EaseFollow { source: rect.x; duration: 300 } + EaseFollow on x { source: rect.x; duration: 300 } } } diff --git a/tests/auto/declarative/visual/qdeclarativegridview/gridview2.qml b/tests/auto/declarative/visual/qdeclarativegridview/gridview2.qml index 81d06cf..f4fb863 100644 --- a/tests/auto/declarative/visual/qdeclarativegridview/gridview2.qml +++ b/tests/auto/declarative/visual/qdeclarativegridview/gridview2.qml @@ -49,8 +49,8 @@ Rectangle { Rectangle { color: "transparent"; border.color: "white"; border.width: 8; z: 3000 height: 100; width: 100; x: 4; y: 4 - x: EaseFollow { source: gridView.currentItem.x; velocity: 500 } - y: EaseFollow { source: gridView.currentItem.y; velocity: 500 } + EaseFollow on x { source: gridView.currentItem.x; velocity: 500 } + EaseFollow on y { source: gridView.currentItem.y; velocity: 500 } } ] } diff --git a/tests/auto/declarative/visual/qdeclarativespringfollow/clock.qml b/tests/auto/declarative/visual/qdeclarativespringfollow/clock.qml index 04bbabc..21bbc7f 100644 --- a/tests/auto/declarative/visual/qdeclarativespringfollow/clock.qml +++ b/tests/auto/declarative/visual/qdeclarativespringfollow/clock.qml @@ -23,7 +23,7 @@ Rectangle { transform: Rotation { id: hourRotation origin.x: 7.5; origin.y: 73; angle: 0 - angle: SpringFollow { + SpringFollow on angle { spring: 2; damping: 0.2; modulus: 360 source: (clock.hours * 30) + (clock.minutes * 0.5) } @@ -37,7 +37,7 @@ Rectangle { transform: Rotation { id: minuteRotation origin.x: 6.5; origin.y: 83; angle: 0 - angle: SpringFollow { + SpringFollow on angle { spring: 2; damping: 0.2; modulus: 360 source: clock.minutes * 6 } @@ -51,7 +51,7 @@ Rectangle { transform: Rotation { id: secondRotation origin.x: 2.5; origin.y: 80; angle: 0 - angle: SpringFollow { + SpringFollow on angle { spring: 5; damping: 0.25; modulus: 360 source: clock.seconds * 6 } diff --git a/tests/auto/declarative/visual/qdeclarativespringfollow/follow.qml b/tests/auto/declarative/visual/qdeclarativespringfollow/follow.qml index e9c94c7..1659bb7 100644 --- a/tests/auto/declarative/visual/qdeclarativespringfollow/follow.qml +++ b/tests/auto/declarative/visual/qdeclarativespringfollow/follow.qml @@ -7,7 +7,7 @@ Rectangle { id: rect color: "#00ff00" y: 200; width: 60; height: 20 - y: SequentialAnimation { + SequentialAnimation on y { loops: Animation.Infinite NumberAnimation { to: 20; duration: 500 @@ -26,7 +26,7 @@ Rectangle { color: "#ff0000" x: rect.width; width: rect.width; height: 20 y: 200 - y: SpringFollow { source: rect.y; velocity: 200 } + SpringFollow on y { source: rect.y; velocity: 200 } } // Spring @@ -34,13 +34,13 @@ Rectangle { color: "#ff0000" x: rect.width * 2; width: rect.width/2; height: 20 y: 200 - y: SpringFollow { source: rect.y; spring: 1.0; damping: 0.2 } + SpringFollow on y { source: rect.y; spring: 1.0; damping: 0.2 } } Rectangle { color: "#880000" x: rect.width * 2.5; width: rect.width/2; height: 20 y: 200 - y: SpringFollow { source: rect.y; spring: 1.0; damping: 0.2; mass: 3.0 } // "heavier" object + SpringFollow on y { source: rect.y; spring: 1.0; damping: 0.2; mass: 3.0 } // "heavier" object } // Follow mouse @@ -52,8 +52,8 @@ Rectangle { width: 20; height: 20 radius: 10 color: "#0000ff" - x: SpringFollow { id: f1; source: mouseRegion.mouseX-10; spring: 1.0; damping: 0.05; epsilon: 0.25 } - y: SpringFollow { id: f2; source: mouseRegion.mouseY-10; spring: 1.0; damping: 0.05; epsilon: 0.25 } + SpringFollow on x { id: f1; source: mouseRegion.mouseX-10; spring: 1.0; damping: 0.05; epsilon: 0.25 } + SpringFollow on y { id: f2; source: mouseRegion.mouseY-10; spring: 1.0; damping: 0.05; epsilon: 0.25 } states: [ State { name: "following" diff --git a/tests/auto/declarative/visual/qdeclarativetextinput/cursorDelegate.qml b/tests/auto/declarative/visual/qdeclarativetextinput/cursorDelegate.qml index 199f71f..09f16ab 100644 --- a/tests/auto/declarative/visual/qdeclarativetextinput/cursorDelegate.qml +++ b/tests/auto/declarative/visual/qdeclarativetextinput/cursorDelegate.qml @@ -3,17 +3,17 @@ import Qt 4.6 resources: [ Component { id: cursorA Item { id: cPage; - x: Behavior { NumberAnimation { } } - y: Behavior { NumberAnimation { } } - height: Behavior { NumberAnimation { duration: 200 } } + Behavior on x { NumberAnimation { } } + Behavior on y { NumberAnimation { } } + Behavior on height { NumberAnimation { duration: 200 } } Rectangle { id: cRectangle; color: "black"; y: 1; width: 1; height: parent.height-2; Rectangle { id:top; color: "black"; width: 3; height: 1; x: -1; y:0} Rectangle { id:bottom; color: "black"; width: 3; height: 1; x: -1; anchors.bottom: parent.bottom;} opacity: 1 - opacity: SequentialAnimation { running: cPage.parent.focus == true; loops: Animation.Infinite; - NumberAnimation { properties: "opacity"; to: 1; duration: 500; easing.type: "InQuad"} - NumberAnimation { properties: "opacity"; to: 0; duration: 500; easing.type: "OutQuad"} - } + SequentialAnimation on opacity { running: cPage.parent.focus == true; loops: Animation.Infinite; + NumberAnimation { properties: "opacity"; to: 1; duration: 500; easing.type: "InQuad"} + NumberAnimation { properties: "opacity"; to: 0; duration: 500; easing.type: "OutQuad"} + } } width: 1; } diff --git a/tests/auto/declarative/visual/webview/zooming/renderControl.qml b/tests/auto/declarative/visual/webview/zooming/renderControl.qml index bcbcf5c..52a569e 100644 --- a/tests/auto/declarative/visual/webview/zooming/renderControl.qml +++ b/tests/auto/declarative/visual/webview/zooming/renderControl.qml @@ -9,7 +9,7 @@ Rectangle { id: webview width: 400 url: "renderControl.html" - x: SequentialAnimation { + SequentialAnimation on x { loops: Animation.Infinite NumberAnimation { from: 100; to: 0; duration: 200 } PropertyAction { target: webview; property: "renderingEnabled"; value: false } diff --git a/tests/auto/declarative/visual/webview/zooming/resolution.qml b/tests/auto/declarative/visual/webview/zooming/resolution.qml index bce6744..d6c35d4 100644 --- a/tests/auto/declarative/visual/webview/zooming/resolution.qml +++ b/tests/auto/declarative/visual/webview/zooming/resolution.qml @@ -6,12 +6,11 @@ WebView { height: 250 * zoomFactor scale: 1/zoomFactor url: "resolution.html" - zoomFactor: - SequentialAnimation { - loops: Animation.Infinite - NumberAnimation { from: 1; to: 0.25; duration: 2000 } - NumberAnimation { from: 0.25; to: 1; duration: 2000 } - NumberAnimation { from: 1; to: 5; duration: 2000 } - NumberAnimation { from: 5; to: 1; duration: 2000 } - } + SequentialAnimation on zoomFactor { + loops: Animation.Infinite + NumberAnimation { from: 1; to: 0.25; duration: 2000 } + NumberAnimation { from: 0.25; to: 1; duration: 2000 } + NumberAnimation { from: 1; to: 5; duration: 2000 } + NumberAnimation { from: 5; to: 1; duration: 2000 } + } } diff --git a/tests/auto/declarative/visual/webview/zooming/zoomTextOnly.qml b/tests/auto/declarative/visual/webview/zooming/zoomTextOnly.qml index 6d51c8a..741450f 100644 --- a/tests/auto/declarative/visual/webview/zooming/zoomTextOnly.qml +++ b/tests/auto/declarative/visual/webview/zooming/zoomTextOnly.qml @@ -6,10 +6,9 @@ WebView { height: 250 url: "zoomTextOnly.html" settings.zoomTextOnly: true - zoomFactor: - SequentialAnimation { - loops: Animation.Infinite - NumberAnimation { from: 2; to: 0.25; duration: 1000 } - NumberAnimation { from: 0.25; to: 2; duration: 1000 } - } + SequentialAnimation on zoomFactor { + loops: Animation.Infinite + NumberAnimation { from: 2; to: 0.25; duration: 1000 } + NumberAnimation { from: 0.25; to: 2; duration: 1000 } + } } diff --git a/tests/auto/declarative/vi